From a6ccd7dc81d683d65dfadf711f5a58f3f014963d Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Thu, 22 Sep 2022 17:27:05 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/PagerQuestionBankController.java | 19 ++++++----- .../joylink/rtss/dao/PagerQuestionDAO.java | 33 +++++++++++-------- .../question/PagerQuestionService.java | 23 ++++++++----- 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java b/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java index 00c607d51..810a9961f 100644 --- a/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java +++ b/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*; import java.util.Collection; import java.util.List; -import java.util.Map; + /** @@ -75,23 +75,24 @@ public class PagerQuestionBankController { /** * 根据companyId 查询所有的标签 - * @param companyId + * * @return */ - @GetMapping(path="/lable/{companyId}") - public Collection findAllLable(@PathVariable Long companyId){ - return this.questionBankService.findAllLable(companyId); + @GetMapping(path="/lable") + public Collection findAllLable(@RequestAttribute LoginUserInfoVO loginInfo /*@PathVariable Long companyId*/){ + return this.questionBankService.findAllLable(loginInfo.getProject().name()); } /** * 根据标签查询所有的题型 - * @param companyId + * @param queryVO * @return */ - @PostMapping(path="/{companyId}/question") - public List findByLable(@PathVariable Long companyId, @RequestBody PagerLableQueryVO queryVO){ - return this.questionBankService.queryQuestionsForRaceLable(companyId,queryVO,false); +// @PostMapping(path="/{companyId}/question") + @PostMapping(path="/lable/question") + public List findByLable(@RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PagerLableQueryVO queryVO){ + return this.questionBankService.queryQuestionsForRaceLable(loginInfo.getProject().name(),queryVO,false); } diff --git a/src/main/java/club/joylink/rtss/dao/PagerQuestionDAO.java b/src/main/java/club/joylink/rtss/dao/PagerQuestionDAO.java index a175b34e2..b8e116d4b 100644 --- a/src/main/java/club/joylink/rtss/dao/PagerQuestionDAO.java +++ b/src/main/java/club/joylink/rtss/dao/PagerQuestionDAO.java @@ -1,11 +1,9 @@ package club.joylink.rtss.dao; -import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.entity.question.PaperQuestion; import club.joylink.rtss.entity.question.PaperQuestionExample; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.type.JdbcType; import org.springframework.stereotype.Repository; import java.util.List; @@ -14,20 +12,27 @@ import java.util.List; @Repository public interface PagerQuestionDAO extends MyBatisBaseDao{ @Select("") - List findAllLableByCompanyId(Long companyId); - - @Select("") - List findByCompanyIdAndRaceLable(Long companyId,int isDelete, List lable,List types); + List findByCompanyIdAndRaceLable(String projectCode,int isDelete, List lable,List types); } diff --git a/src/main/java/club/joylink/rtss/services/completition/question/PagerQuestionService.java b/src/main/java/club/joylink/rtss/services/completition/question/PagerQuestionService.java index beb2a3bb6..135bd9c91 100644 --- a/src/main/java/club/joylink/rtss/services/completition/question/PagerQuestionService.java +++ b/src/main/java/club/joylink/rtss/services/completition/question/PagerQuestionService.java @@ -49,9 +49,9 @@ public class PagerQuestionService { criteria.andProjectCodeIsNull(); if (Objects.nonNull(queryVO.getCompanyId())) { criteria.andCompanyIdEqualTo(queryVO.getCompanyId()); - } else { + } /*else { criteria.andCompanyIdIsNull(); - } + }*/ } else { criteria.andProjectCodeEqualTo(queryVO.getProjectCode()); } @@ -97,12 +97,18 @@ public class PagerQuestionService { /** * 获取所有公司组织下的标签 - * @param companyId + * */ - public Collection findAllLable(Long companyId){ + public Collection findAllLable(String projectCode){ PaperQuestionExample example = new PaperQuestionExample(); PaperQuestionExample.Criteria criteria = example.createCriteria(); - criteria.andCompanyIdEqualTo(companyId); + boolean isDefault = Project.isDefault(Project.valueOf(projectCode)); +// criteria.andCompanyIdEqualTo(companyId); + if(isDefault){ + criteria.andProjectCodeIsNull(); + }else{ + criteria.andProjectCodeEqualTo(projectCode); + } criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); List lableList = this.questionDAO.selectByExample(example); if(CollectionUtils.isEmpty(lableList)){ @@ -115,15 +121,16 @@ public class PagerQuestionService { /** * 根据公司id和标签或类型查询 - * @param companyId + * * @param queryVO * @param random * @return */ - public List queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO,boolean random) { + public List queryQuestionsForRaceLable(String projectCode, PagerLableQueryVO queryVO,boolean random) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(queryVO.allNotNullOrEmpty(),"查询内容不能为空"); int isDel = BusinessConsts.DBLogicDelete.NORMAL.ordinal(); - List list = this.questionDAO.findByCompanyIdAndRaceLable(companyId,isDel,queryVO.getLables(),queryVO.getTypes()); + + List list = this.questionDAO.findByCompanyIdAndRaceLable(projectCode,isDel,queryVO.getLables(),queryVO.getTypes()); List questionVOS = PaperQuestionVO.convert2VOList(list); return questionVOS; }