创建试卷 对实训标签及数量的查询

This commit is contained in:
tiger_zhou 2022-12-30 13:24:05 +08:00
parent 4d58238cfa
commit e079307e4b
4 changed files with 69 additions and 12 deletions

View File

@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
@ -146,6 +147,12 @@ public class PaperUserController {
return this.paperUserFindPageService.findPaperUserForAccount(req); return this.paperUserFindPageService.findPaperUserForAccount(req);
}*/ }*/
@PostMapping("/question/label")
public Collection<String> paperAllLabel(@RequestBody FindCountForQuestionReqVo req){
return this.paperUserService.findAllLabel(req);
}
/** /**
* 查看组织下某个类型题的数量 * 查看组织下某个类型题的数量
* 参数 tags 目前只支持单个 * 参数 tags 目前只支持单个

View File

@ -6,6 +6,7 @@ import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -13,6 +14,9 @@ import java.util.List;
@Mapper @Mapper
@Repository @Repository
public interface PublishedTraining2DAO { public interface PublishedTraining2DAO {
@Select("<script>select label_json from rts_published_training2 where org_id = #{orgId} and type = #{type}</script>")
List<String> selectAllLabel(@Param("orgId") Long orgId,@Param("type") String type);
long countByExample(PublishedTraining2Example example); long countByExample(PublishedTraining2Example example);
int deleteByExample(PublishedTraining2Example example); int deleteByExample(PublishedTraining2Example example);

View File

@ -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.PublishedTraining2;
import club.joylink.rtss.entity.training2.PublishedTraining2Example; import club.joylink.rtss.entity.training2.PublishedTraining2Example;
import club.joylink.rtss.exception.PaperExceptionAssert; import club.joylink.rtss.exception.PaperExceptionAssert;
import club.joylink.rtss.services.training2.Training2PublishService;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.paper.PaperQType; import club.joylink.rtss.vo.paper.*;
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.convertor.PaperCompositionConvertor; import club.joylink.rtss.vo.paper.convertor.PaperCompositionConvertor;
import club.joylink.rtss.vo.paper.convertor.PaperUserConvertor; import club.joylink.rtss.vo.paper.convertor.PaperUserConvertor;
import club.joylink.rtss.vo.paper.convertor.PaperUserQuestionConvertor; import club.joylink.rtss.vo.paper.convertor.PaperUserQuestionConvertor;
@ -25,10 +23,7 @@ import org.springframework.util.CollectionUtils;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -52,6 +47,22 @@ public class PaperUserService {
private PublishedTraining2DAO trainingDAO; private PublishedTraining2DAO trainingDAO;
@Autowired @Autowired
private PagerQuestionService paperQuestionService; private PagerQuestionService paperQuestionService;
@Autowired
private Training2PublishService training2PublishService;
/**
* 获取理论或实操的搓油标签
* @param req
* @return
*/
public Collection<String> 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); BusinessConsts.TheoryType theoryType = this.getPaperQuestionType(subType);
return paperQuestionService.queryCount(orgId,theoryType,tagStr); return paperQuestionService.queryCount(orgId,theoryType,tagStr);
}else if(PaperQType.GroupType.Training.equals(groupType)){ }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; return 0L;
} }

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.services.training2; package club.joylink.rtss.services.training2;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.dao.PublishedTraining2DAO; import club.joylink.rtss.dao.PublishedTraining2DAO;
import club.joylink.rtss.entity.training2.PublishedTraining2; import club.joylink.rtss.entity.training2.PublishedTraining2;
import club.joylink.rtss.entity.training2.PublishedTraining2Example; 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.BusinessException;
import club.joylink.rtss.exception.BusinessExceptionAssert; import club.joylink.rtss.exception.BusinessExceptionAssert;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.training2.publish.*; import club.joylink.rtss.vo.training2.publish.*;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
@ -19,9 +21,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -41,6 +41,40 @@ public class Training2PublishService {
return null != find && find.size() > 0 ? find.get(0) : null; 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<String> findAllLabel(Long orgId, String type){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空");
List<String> list = this.publishedDao.selectAllLabel(orgId,type);
if(CollectionUtils.isEmpty(list)){
return Collections.emptyList();
}
return list.stream().filter(StringUtils::hasText).map(d->{
List<String> l = JsonUtils.readCollection(d,List.class,String.class);
return l;
}).flatMap(d->d.stream()).collect(Collectors.toSet());
}
/** /**
* 已发布实训分页列表 * 已发布实训分页列表
*/ */