| | |
| | | import com.dy.pipIrrGlobal.daoBa.BaRoleMapper; |
| | | import com.dy.pipIrrGlobal.daoBa.BaRolePrivilegeMapper; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaRole; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaRolePrivilege; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | * 得到所有角色 |
| | | * @return 所有角色集合 |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public QueryResultVo<List<BaRole>> selectAll(QueryVo vo){ |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ; |
| | | public QueryResultVo<List<BaRole>> selectAll(){ |
| | | QueryResultVo<List<BaRole>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.obj = this.dao.selectAll(params) ; |
| | | rsVo.obj = this.dao.selectAll() ; |
| | | return rsVo ; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Transactional |
| | | public int save(BaRole po){ |
| | | return this.dao.insert(po) ; |
| | | return this.dao.putin(po) ; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 设置角色权限 |
| | | * @param roleId 角色id |
| | | * @param priviIds 选择的权限id集合 |
| | | * @return 插入角色与权限关联记录数量 |
| | | */ |
| | | public int setRoles(Long roleId, Long[] priviIds){ |
| | | this.rolePrivDao.deleteByRoleId(roleId) ; |
| | | int count = 0 ; |
| | | if(priviIds != null && priviIds.length > 0){ |
| | | for(Long privId : priviIds){ |
| | | count += this.rolePrivDao.insertSelective(new BaRolePrivilege(roleId, privId)) ; |
| | | } |
| | | } |
| | | return count ; |
| | | } |
| | | |
| | | /** |
| | | * 保存修改实体 |
| | | * @param id 实体ID |
| | | * @return 影响记录数量 |
| | | */ |
| | | @Transactional |
| | | public int delete(Long id){ |
| | | int count = this.dao.deleteLogicById(id) ; |
| | | if(count > 0){ |
| | | this.rolePrivDao.deleteByRoleId(id) ; |
| | | } |
| | | return count ; |
| | | //int count = this.dao.deleteLogicById(id) ; |
| | | //逻辑删除,所以不实际删除其关联的权限 |
| | | //if(count > 0){ |
| | | // this.rolePrivDao.deleteByRoleId(id) ; |
| | | //} |
| | | //return count ; |
| | | return this.dao.deleteLogicById(id) ; |
| | | } |
| | | |
| | | |