From c2dcc93b91a2d0425812d3e25ea075e01ecf2da5 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Fri, 14 Oct 2022 14:57:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E5=8A=9F=E8=83=BD=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=9B=B8=E5=85=B3=E7=AE=A1=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/permission2/SystemAbilityController.java | 8 +++++--- .../rtss/services/permission/SystemAbilityService.java | 8 +------- .../joylink/rtss/vo/permission/SystemAbilityRspVo.java | 9 +++++++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/permission2/SystemAbilityController.java b/src/main/java/club/joylink/rtss/controller/permission2/SystemAbilityController.java index bfadea763..9c7dba6ab 100644 --- a/src/main/java/club/joylink/rtss/controller/permission2/SystemAbilityController.java +++ b/src/main/java/club/joylink/rtss/controller/permission2/SystemAbilityController.java @@ -8,6 +8,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import static club.joylink.rtss.controller.advice.AuthenticateInterceptor.LOGIN_INFO_KEY; + /** * 面向权限的系统功能管理接口V2 @@ -22,14 +24,14 @@ public class SystemAbilityController { * 添加权限功能 */ @PostMapping("/basic") - public void addAbility(@RequestBody BasicSystemAbilityVo req, @RequestAttribute LoginUserInfoVO userInfoVO){ + public void addAbility(@RequestBody BasicSystemAbilityVo req, @RequestAttribute(value = LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){ this.abilityService.saveOrUpdateBasicAbility(req,userInfoVO); } /** * 修改权限功能的名称和描述 */ @PutMapping("/basic") - public void updateAbilityBasic(@RequestBody BasicSystemAbilityVo req,@RequestAttribute LoginUserInfoVO userInfoVO){ + public void updateAbilityBasic(@RequestBody BasicSystemAbilityVo req,@RequestAttribute(value = LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){ this.abilityService.saveOrUpdateBasicAbility(req,userInfoVO); } /** @@ -64,7 +66,7 @@ public class SystemAbilityController { /** * 分页查询权限功能的基本信息 */ - @PostMapping("/find/basic/page") + @PostMapping("/page") public PageVOfindByPage(FindAbilityBasicByPageReqVo req){ return this.abilityService.findByPage(req); } diff --git a/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java b/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java index 7700b8d1f..df6b7a5af 100644 --- a/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java +++ b/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java @@ -91,24 +91,18 @@ public class SystemAbilityService { * @param reqVo */ public void remove(DeleteAbilitiesReqVo reqVo){ - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(CollectionUtils.isEmpty(reqVo.getIds()),"删除数据的id不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(reqVo.getIds()),"删除数据的id不能为空"); List newIds = reqVo.getIds().stream().distinct().collect(Collectors.toList()); - PermissionSystemAbilityExample pe = new PermissionSystemAbilityExample(); pe.createCriteria().andSystemAbilityIdIn(newIds); List psaList = this.permissionSystemAbilityDAO.selectByExample(pe); Map> psaMapList = psaList.stream() .collect(Collectors.groupingBy(PermissionSystemAbility::getSystemAbilityId)); - newIds.stream().forEach(psaMapList::remove); - StringBuilder sb = new StringBuilder(); psaMapList.forEach((k,v)->{ sb.append(String.format("id=%s有绑定的权限数量=%s,不能删除",k,v.size())); }); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(psaMapList.isEmpty(),sb.toString()); - - - SystemAbilityExample example = new SystemAbilityExample(); SystemAbilityExample.Criteria criteria = example.createCriteria(); criteria.andIdIn(newIds); diff --git a/src/main/java/club/joylink/rtss/vo/permission/SystemAbilityRspVo.java b/src/main/java/club/joylink/rtss/vo/permission/SystemAbilityRspVo.java index 85cd44b7d..5eb970194 100644 --- a/src/main/java/club/joylink/rtss/vo/permission/SystemAbilityRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/permission/SystemAbilityRspVo.java @@ -6,6 +6,7 @@ import lombok.Data; import java.time.LocalDateTime; import java.util.List; +import java.util.Objects; @Data public class SystemAbilityRspVo { @@ -57,11 +58,15 @@ public class SystemAbilityRspVo { public static SystemAbilityRspVo toVO(SystemAbility sa){ SystemAbilityRspVo vo = new SystemAbilityRspVo(); vo.setId(sa.getId()); - vo.setType(SystemAbilityType.valueOf(sa.getType())); + if(Objects.nonNull(sa.getType())){ + vo.setType(SystemAbilityType.valueOf(sa.getType())); + } vo.setAbilityId(sa.getAbilityId()); vo.setName(sa.getName()); vo.setDes(sa.getDes()); - vo.setStatus(SystemAbilityStatus.valueOf(sa.getStatus())); + if(Objects.nonNull(sa.getStatus())){ + vo.setStatus(SystemAbilityStatus.valueOf(sa.getStatus())); + } vo.setCreatorId(sa.getCreatorId()); vo.setCreateTime(sa.getCreateTime()); vo.setUpdateTime(sa.getUpdateTime());