From f2f6f50aa0a9a8ec25acefdd590c732920a57831 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期一, 15 一月 2024 17:13:53 +0800 Subject: [PATCH] 2024-01-15 朱宝民 角色添加接口、授权接口、控制code改为rtuAddr --- pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleSv.java | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 45 insertions(+), 9 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleSv.java index af117e5..0947d23 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleSv.java @@ -1,5 +1,6 @@ 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; @@ -11,8 +12,10 @@ 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 @@ -52,9 +55,10 @@ 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; @@ -69,8 +73,32 @@ params.put("pageSize", pageSize); rsVo.calculateAndSet(itemTotal, params); - rsVo.obj = baRoleMapper.getRoles(params); + //rsVo.obj = baRoleMapper.getRoles(params); + + /** + * 鑾峰彇瑙掕壊鍒楄〃锛屾妸姹楄鑹叉潈闄怚D + * 閬嶅巻瑙掕壊鍒楄〃骞跺彇鍑鸿鑹插璞′腑鐨刾erId + * 鏍规嵁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); } /** @@ -133,14 +161,22 @@ } /** - * 淇濆瓨淇敼瀹炰綋 - * @param po 瀹炰綋 - * @return 褰卞搷璁板綍鏁伴噺 + * 淇敼瑙掕壊 + * @param record + * @return */ - //@Transactional - //public int update(BaRole po){ - // return this.dao.updateByPrimaryKeySelective(po) ; - //} + public int updateRole(BaRole record) { + return baRoleMapper.updateByPrimaryKeySelective(record); + } + + /** + * 鏍规嵁roleId閫昏緫鍒犻櫎瑙掕壊瀵硅薄 + * @param roleId 瑙掕壊缂栧彿 + * @return + */ + public Integer deleteRoleById(Long roleId) { + return baRoleMapper.deleteRoleById(roleId); + } /** * 璁剧疆瑙掕壊鏉冮檺 -- Gitblit v1.8.0