From f3925f8cdbf23dfa707ea0b2dd7451c55577943f Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Fri, 14 Oct 2022 13:24:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=90=86=E8=AE=BA=E8=AF=95=E9=A2=98?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9F=A5=E8=AF=A2=E5=88=86=E9=A1=B5=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paper/PagerQuestionBankController.java | 1 + .../services/paper/PagerQuestionService.java | 31 +++++++++++++++++++ .../pager/question/QuestionQueryVO.java | 4 ++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java b/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java index 94f792db8..310033d51 100644 --- a/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java +++ b/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java @@ -44,6 +44,7 @@ public class PagerQuestionBankController { @GetMapping(path = "/org/paging") public PageVO pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) { queryVO.setOrgId(loginInfo.getTopOrgId()); + queryVO.setOrgId(173L); return questionBankService.pagingQueryQuestions(queryVO,false); } diff --git a/src/main/java/club/joylink/rtss/services/paper/PagerQuestionService.java b/src/main/java/club/joylink/rtss/services/paper/PagerQuestionService.java index df5969421..8925edd00 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PagerQuestionService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PagerQuestionService.java @@ -23,6 +23,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import javax.annotation.Resource; +import java.lang.reflect.Method; import java.time.LocalDateTime; import java.util.Collection; import java.util.Collections; @@ -61,6 +62,36 @@ public class PagerQuestionService { if(Objects.nonNull(queryVO.getOrgId())){ criteria.andOrgIdEqualTo(queryVO.getOrgId()); + + } + + if(Objects.nonNull(queryVO.getLabels())){ + +// PaperQuestionExample.Criteria criteria2 = example.createCriteria(); +// example.getOredCriteria().add(criteria2); + List tmpLableList = Splitter.on(",").omitEmptyStrings().splitToList(queryVO.getLabels()); + if(Objects.equals(false,CollectionUtils.isEmpty(tmpLableList))){ + StringBuilder sqlBuilder = new StringBuilder("("); + for(var i = 0 ; i < tmpLableList.size();i++){ + String data = tmpLableList.get(i); + if(i != 0){ + sqlBuilder.append(" or "); + } + sqlBuilder.append(String.format(" find_in_set('%s',tags) > 0 ",data)); + } + sqlBuilder.append(")"); + Class criteriaCls = PaperQuestionExample.Criteria.class; + Class generatedCriteriaCls = criteriaCls.getSuperclass(); + try{ + Method addCriterion = generatedCriteriaCls.getDeclaredMethod("addCriterion", String.class); + addCriterion.setAccessible(true); + addCriterion.invoke(criteria, sqlBuilder.toString()); + }catch (Exception e){ + + } + } + + } criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); return questionDAO.selectByExampleWithBLOBs(example); diff --git a/src/main/java/club/joylink/rtss/vo/client/pager/question/QuestionQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/pager/question/QuestionQueryVO.java index 7c435724a..02dba78cf 100644 --- a/src/main/java/club/joylink/rtss/vo/client/pager/question/QuestionQueryVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/pager/question/QuestionQueryVO.java @@ -4,6 +4,8 @@ import club.joylink.rtss.vo.client.PageQueryVO; import lombok.Getter; import lombok.Setter; +import java.util.List; + @Getter @Setter public class QuestionQueryVO extends PageQueryVO { @@ -14,5 +16,5 @@ public class QuestionQueryVO extends PageQueryVO { // private String projectCode; private Long orgId; - + private String labels; } From 685b3ec4fa77a51740afeaefee8150020d34dc2e Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Fri, 14 Oct 2022 13:25:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=90=86=E8=AE=BA=E8=AF=95=E9=A2=98?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9F=A5=E8=AF=A2=E5=88=86=E9=A1=B5=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/controller/paper/PagerQuestionBankController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java b/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java index 310033d51..94f792db8 100644 --- a/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java +++ b/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java @@ -44,7 +44,6 @@ public class PagerQuestionBankController { @GetMapping(path = "/org/paging") public PageVO pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) { queryVO.setOrgId(loginInfo.getTopOrgId()); - queryVO.setOrgId(173L); return questionBankService.pagingQueryQuestions(queryVO,false); } From 5a607002466a52de5733622a538c38d36afa2980 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Fri, 14 Oct 2022 13:26:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=9C=A8=E5=88=A0=E9=99=A4=E7=9A=84=E6=97=B6=E5=80=99=E6=A3=80?= =?UTF-8?q?=E6=B5=8Brts=5Fpermission=5Fsystem=5Fability=20=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=E6=98=AF=E5=90=A6=E6=9C=89=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=B0=B1?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../permission/SystemAbilityService.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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 6a057859a..7700b8d1f 100644 --- a/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java +++ b/src/main/java/club/joylink/rtss/services/permission/SystemAbilityService.java @@ -1,6 +1,9 @@ package club.joylink.rtss.services.permission; +import club.joylink.rtss.dao.permission.PermissionSystemAbilityDAO; import club.joylink.rtss.dao.permission.SystemAbilityDAO; +import club.joylink.rtss.entity.permission.PermissionSystemAbility; +import club.joylink.rtss.entity.permission.PermissionSystemAbilityExample; import club.joylink.rtss.entity.permission.SystemAbility; import club.joylink.rtss.entity.permission.SystemAbilityExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; @@ -16,7 +19,9 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.List; +import java.util.Map; import java.util.Objects; +import java.util.stream.Collectors; import static club.joylink.rtss.vo.permission.SystemAbilityStatus.Editing; @@ -25,6 +30,9 @@ import static club.joylink.rtss.vo.permission.SystemAbilityStatus.Editing; public class SystemAbilityService { @Resource private SystemAbilityDAO systemAbilityDAO; + @Resource + private PermissionSystemAbilityDAO permissionSystemAbilityDAO; + public SystemAbility findById(Long id){ SystemAbility dbSa = this.systemAbilityDAO.selectByPrimaryKey(id); @@ -84,9 +92,26 @@ public class SystemAbilityService { */ public void remove(DeleteAbilitiesReqVo reqVo){ 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(reqVo.getIds()); + criteria.andIdIn(newIds); this.systemAbilityDAO.deleteByExample(example); }