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/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); } 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; }