| | |
| | | package com.dy.pipIrrBase.role; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoBa.BaRoleMapper; |
| | | import com.dy.pipIrrGlobal.daoBa.BaRolePermissionsMapper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | |
| | | public QueryResultVo<List<VoRole>> getRoles(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | Long itemTotal = baRoleMapper.getRecordCount(params); |
| | | Long itemTotal = baRolePermissionsMapper.getRecordCount(params); |
| | | |
| | | QueryResultVo<List<VoRole>> rsVo = new QueryResultVo<>() ; |
| | | |
| | | Integer pageCurr = 0; |
| | | Integer pageSize = 10000; |
| | | rsVo.pageCurr = 1; |
| | |
| | | params.put("pageSize", pageSize); |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = baRoleMapper.getRoles(params); |
| | | //rsVo.obj = baRoleMapper.getRoles(params); |
| | | |
| | | /** |
| | | * 获取角色列表,把汗角色权限ID |
| | | * 遍历角色列表并取出角色对象中的perId |
| | | * 根据perId获取权限对象,并将对象添加到角色对象中 |
| | | */ |
| | | List<VoRole> list_Roles = Optional.ofNullable(baRolePermissionsMapper.getRoles(params)).orElse(new ArrayList<>()); |
| | | if(list_Roles.size() > 0) { |
| | | for(int i = 0; i < list_Roles.size(); i++) { |
| | | VoRole voRole = list_Roles.get(i); |
| | | Long perId = voRole.getPerId(); |
| | | BaRolePermissions baRolePermissions = baRolePermissionsMapper.selectByPrimaryKey(perId); |
| | | JSONArray array_permission = JSONArray.parseArray("[]"); |
| | | if(baRolePermissions != null) { |
| | | array_permission = baRolePermissions.getPermissions(); |
| | | } |
| | | voRole.setPermissions(array_permission); |
| | | } |
| | | } |
| | | rsVo.obj = list_Roles; |
| | | return rsVo ; |
| | | } |
| | | |
| | | public BaRolePermissions getRolePermissionsById(Long id) { |
| | | return baRolePermissionsMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | /** |
| | | * 得到所有角色 |
| | | * @return 所有角色集合 |