理论试题管理代码调整

This commit is contained in:
tiger_zhou 2022-09-22 17:27:05 +08:00
parent 8536894aaa
commit a6ccd7dc81
3 changed files with 44 additions and 31 deletions

View File

@ -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<String> findAllLable(@PathVariable Long companyId){
return this.questionBankService.findAllLable(companyId);
@GetMapping(path="/lable")
public Collection<String> 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<PaperQuestionVO> findByLable(@PathVariable Long companyId, @RequestBody PagerLableQueryVO queryVO){
return this.questionBankService.queryQuestionsForRaceLable(companyId,queryVO,false);
// @PostMapping(path="/{companyId}/question")
@PostMapping(path="/lable/question")
public List<PaperQuestionVO> findByLable(@RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PagerLableQueryVO queryVO){
return this.questionBankService.queryQuestionsForRaceLable(loginInfo.getProject().name(),queryVO,false);
}

View File

@ -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<PaperQuestion, Long, PaperQuestionExample>{
@Select("<script>" +
"select race_lable from paper_question where company_id = #{companyId,jdbcType=BIGINT} group by race_lable" +
"</script>")
List<String> findAllLableByCompanyId(Long companyId);
@Select("<script>" +
"select * from paper_question where company_id = #{companyId,jdbcType=BIGINT} and is_del= #{isDelete,jdbcType=INTEGER}" +
"select * from paper_question where 1 = 1 " +
"<choose>" +
"<when test=\"projectCode == 'DEFAULT'\">"+
" and project_code is null" +
"</when>"+
" <otherwise>"+
" and project_code = #{projectCode} "+
" </otherwise>" +
"</choose>" +
// "/*company_id = #{companyId,jdbcType=BIGINT}*/ " +
" and is_del= #{isDelete,jdbcType=INTEGER} " +
"<if test=\"types != null and types.size > 0\">"+
"<foreach collection=\"types\" open=\"and type in (\" close=\")\" item=\"d\" separator=\",\">"+
"#{d}"+
"<foreach collection=\"types\" open=\" and type in (\" close=\")\" item=\"d\" separator=\",\">"+
" #{d} "+
"</foreach></if>"+
" <if test=\"lable != null and lable.size > 0\"> and <foreach collection=\"lable\" open=\"(\" close=\")\" item=\"d\" separator=\"or\"> "+
"<if test=\"lable != null and lable.size > 0\"> " +
" <foreach collection=\"lable\" open=\" and (\" close=\")\" item=\"d\" separator=\" or \"> "+
" find_in_set(#{d},race_lable) > 0 "+
"</foreach></if>" +
" </foreach>" +
"</if>" +
"</script>")
List<PaperQuestion> findByCompanyIdAndRaceLable(Long companyId,int isDelete, List<String> lable,List<String> types);
List<PaperQuestion> findByCompanyIdAndRaceLable(String projectCode,int isDelete, List<String> lable,List<String> types);
}

View File

@ -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<String> findAllLable(Long companyId){
public Collection<String> 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<PaperQuestion> 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<PaperQuestionVO> queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO,boolean random) {
public List<PaperQuestionVO> queryQuestionsForRaceLable(String projectCode, PagerLableQueryVO queryVO,boolean random) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(queryVO.allNotNullOrEmpty(),"查询内容不能为空");
int isDel = BusinessConsts.DBLogicDelete.NORMAL.ordinal();
List<PaperQuestion> list = this.questionDAO.findByCompanyIdAndRaceLable(companyId,isDel,queryVO.getLables(),queryVO.getTypes());
List<PaperQuestion> list = this.questionDAO.findByCompanyIdAndRaceLable(projectCode,isDel,queryVO.getLables(),queryVO.getTypes());
List<PaperQuestionVO> questionVOS = PaperQuestionVO.convert2VOList(list);
return questionVOS;
}