| package com.xzx.gc.role.service;  | 
|   | 
| import com.github.pagehelper.PageHelper;  | 
| import com.github.pagehelper.PageInfo;  | 
| import com.xzx.gc.entity.CoreRole;  | 
| import com.xzx.gc.model.query.RoleQuery;  | 
| import com.xzx.gc.role.mapper.RoleConsoleMapper;  | 
| import com.xzx.gc.role.rbac.tree.OrgItem;  | 
| import com.xzx.gc.util.enums.RoleTypeEnum;  | 
| import org.springframework.beans.factory.annotation.Autowired;  | 
| import org.springframework.stereotype.Service;  | 
| import org.springframework.transaction.annotation.Transactional;  | 
|   | 
| import java.util.ArrayList;  | 
| import java.util.List;  | 
|   | 
| @Service  | 
| @Transactional  | 
| public class RoleConsoleService {  | 
|   | 
|     @Autowired  | 
|     private RoleConsoleMapper roleDao;  | 
|   | 
|     @Autowired  | 
|     private CorePlatformService platformService;  | 
|     @Autowired  | 
|     private CoreDictService dictService;  | 
|     /**  | 
|      * 根据条件查询  | 
|      *  | 
|      * @param query  | 
|      */  | 
|     public PageInfo<CoreRole> queryByCondtion(RoleQuery query) {  | 
|   | 
|         PageHelper.startPage(query.getPage(),query.getLimit());  | 
|         List<CoreRole> list=roleDao.queryByCondtion(query);  | 
|         for (CoreRole role:list) {  | 
|             String dict = dictService.findNameByType(role.getType());  | 
|             role.setTypeText(dict);  | 
|         }  | 
|         PageInfo<CoreRole> pageInfo=new PageInfo(list);  | 
|         //super.queryListAfter(list);  | 
|         return pageInfo;  | 
|     }  | 
|   | 
|   | 
|     /**  | 
|      * 获取机构下面的所以机构  | 
|      *  | 
|      * @param orgId 机构id  | 
|      */  | 
|     public List<Long> getAllChildIdsByOrgId(Long orgId) {  | 
|         if (orgId == null) {  | 
|             return null;  | 
|         }  | 
|         OrgItem orgItem = platformService.buildOrg().findChild(orgId);  | 
|         if (orgItem == null) {  | 
|             return null;  | 
|         }  | 
|         List<Long> ids = orgItem.findAllChildrenId();  | 
|         if (ids == null) {  | 
|             ids = new ArrayList<>();  | 
|         }  | 
|         ids.add(orgId);  | 
|   | 
|         return ids;  | 
|     }  | 
|   | 
|     public CoreRole queryByCode(String code) {  | 
|         CoreRole queryRole = new CoreRole();  | 
|         queryRole.setCode(code);  | 
|         CoreRole role = roleDao.selectOne(queryRole);  | 
|         return role;  | 
|     }  | 
|   | 
|     public void save(CoreRole role) {  | 
|         roleDao.insertSelective(role);  | 
|     }  | 
|   | 
|     public boolean update(CoreRole role) {  | 
|         return roleDao.updateByPrimaryKeySelective(role)>0;  | 
|     }  | 
|   | 
|     public CoreRole queryById(Long id) {  | 
|         return roleDao.selectByPrimaryKey(id);  | 
|     }  | 
|   | 
|     public List<CoreRole> queryAllPermissionList() {  | 
|        CoreRole template = new CoreRole();  | 
|         template.setType(RoleTypeEnum.ACCESS.getValue());  | 
|         template.setDelFlag("0");  | 
|         return roleDao.select(template);  | 
|     }  | 
| }  | 
|   |