From f3925f8cdbf23dfa707ea0b2dd7451c55577943f Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Fri, 14 Oct 2022 13:24:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=90=86=E8=AE=BA=E8=AF=95=E9=A2=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=9F=A5=E8=AF=A2=E5=88=86=E9=A1=B5=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=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; }