From e079307e4bfb56dc4f17b91c9677f203611cf685 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Fri, 30 Dec 2022 13:24:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AF=95=E5=8D=B7=20?= =?UTF-8?q?=E5=AF=B9=E5=AE=9E=E8=AE=AD=E6=A0=87=E7=AD=BE=E5=8F=8A=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=9A=84=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/paper/PaperUserController.java | 7 ++++ .../rtss/dao/PublishedTraining2DAO.java | 4 ++ .../rtss/services/paper/PaperUserService.java | 30 +++++++++----- .../training2/Training2PublishService.java | 40 +++++++++++++++++-- 4 files changed, 69 insertions(+), 12 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java b/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java index 3e73fdbc3..65ad940ea 100644 --- a/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java +++ b/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.Collection; import java.util.List; /** @@ -146,6 +147,12 @@ public class PaperUserController { return this.paperUserFindPageService.findPaperUserForAccount(req); }*/ + + @PostMapping("/question/label") + public Collection paperAllLabel(@RequestBody FindCountForQuestionReqVo req){ + return this.paperUserService.findAllLabel(req); + } + /** * 查看组织下某个类型题的数量 * 参数 tags 目前只支持单个 diff --git a/src/main/java/club/joylink/rtss/dao/PublishedTraining2DAO.java b/src/main/java/club/joylink/rtss/dao/PublishedTraining2DAO.java index b281367d7..048b87755 100644 --- a/src/main/java/club/joylink/rtss/dao/PublishedTraining2DAO.java +++ b/src/main/java/club/joylink/rtss/dao/PublishedTraining2DAO.java @@ -6,6 +6,7 @@ import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; import java.util.List; @@ -13,6 +14,9 @@ import java.util.List; @Mapper @Repository public interface PublishedTraining2DAO { + + @Select("") + List selectAllLabel(@Param("orgId") Long orgId,@Param("type") String type); long countByExample(PublishedTraining2Example example); int deleteByExample(PublishedTraining2Example example); diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java index 10958e709..7edabc006 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java @@ -9,11 +9,9 @@ import club.joylink.rtss.entity.paper.question.PaperQuestionExample; import club.joylink.rtss.entity.training2.PublishedTraining2; import club.joylink.rtss.entity.training2.PublishedTraining2Example; import club.joylink.rtss.exception.PaperExceptionAssert; +import club.joylink.rtss.services.training2.Training2PublishService; import club.joylink.rtss.vo.AccountVO; -import club.joylink.rtss.vo.paper.PaperQType; -import club.joylink.rtss.vo.paper.PaperQuestionState; -import club.joylink.rtss.vo.paper.PaperSubmitRspVo; -import club.joylink.rtss.vo.paper.PaperUserWholeVo; +import club.joylink.rtss.vo.paper.*; import club.joylink.rtss.vo.paper.convertor.PaperCompositionConvertor; import club.joylink.rtss.vo.paper.convertor.PaperUserConvertor; import club.joylink.rtss.vo.paper.convertor.PaperUserQuestionConvertor; @@ -25,10 +23,7 @@ import org.springframework.util.CollectionUtils; import java.time.Duration; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -52,6 +47,22 @@ public class PaperUserService { private PublishedTraining2DAO trainingDAO; @Autowired private PagerQuestionService paperQuestionService; + @Autowired + private Training2PublishService training2PublishService; + + /** + * 获取理论或实操的搓油标签 + * @param req + * @return + */ + public Collection findAllLabel(FindCountForQuestionReqVo req){ + if(req.getGroupType() == PaperQType.GroupType.Common){ + return paperQuestionService.findAllLable(req.getOrgId(),req.getSubType().name().toLowerCase()); + }else if(PaperQType.GroupType.Training.equals(req.getGroupType())){ + return this.training2PublishService.findAllLabel(req.getOrgId(),req.getSubType().name().toUpperCase()); + } + return Collections.emptyList(); + } /** * 获取组织某个类型题的数量 */ @@ -65,7 +76,8 @@ public class PaperUserService { BusinessConsts.TheoryType theoryType = this.getPaperQuestionType(subType); return paperQuestionService.queryCount(orgId,theoryType,tagStr); }else if(PaperQType.GroupType.Training.equals(groupType)){ - PaperExceptionAssert.PdValid.assertTrue(!PaperQType.GroupType.Training.equals(groupType),"不支持查询实训题数量"); +// PaperExceptionAssert.PdValid.assertTrue(!PaperQType.GroupType.Training.equals(groupType),"不支持查询实训题数量"); + return training2PublishService.queryCountForLabel(orgId,subType.name().toUpperCase(),tags); } return 0L; } diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java index e12aab3c8..521153ea0 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java @@ -1,5 +1,6 @@ package club.joylink.rtss.services.training2; +import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.dao.PublishedTraining2DAO; import club.joylink.rtss.entity.training2.PublishedTraining2; import club.joylink.rtss.entity.training2.PublishedTraining2Example; @@ -7,6 +8,7 @@ import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs; import club.joylink.rtss.exception.BusinessException; import club.joylink.rtss.exception.BusinessExceptionAssert; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.training2.publish.*; import com.github.pagehelper.Page; @@ -19,9 +21,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -41,6 +41,40 @@ public class Training2PublishService { return null != find && find.size() > 0 ? find.get(0) : null; } + /** + * 根据组织,类型(单操作,实操),标签获取对应的数量 + + */ + public Long queryCountForLabel(Long orgId,String type,String label){ + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空"); + + PublishedTraining2Example example = new PublishedTraining2Example(); + PublishedTraining2Example.Criteria c = example.createCriteria(); + c.andOrgIdEqualTo(orgId); + c.andTypeEqualTo(type); + if(Objects.nonNull(label)){ + c.andLabelJsonLike(String.format("%%%s%%", label)); + } + return this.publishedDao.countByExample(example); + } + + /** + * 根据 组织,类型(单操作,实操) 获取标签 + */ + public Collection findAllLabel(Long orgId, String type){ + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空"); + List list = this.publishedDao.selectAllLabel(orgId,type); + if(CollectionUtils.isEmpty(list)){ + return Collections.emptyList(); + } + return list.stream().filter(StringUtils::hasText).map(d->{ + List l = JsonUtils.readCollection(d,List.class,String.class); + return l; + }).flatMap(d->d.stream()).collect(Collectors.toSet()); + } + /** * 已发布实训分页列表 */