理论试题管理代码调整,支持查询分页标签检索

This commit is contained in:
tiger_zhou 2022-10-14 13:24:52 +08:00
parent 6da5f3a5ac
commit f3925f8cdb
3 changed files with 35 additions and 1 deletions

View File

@ -44,6 +44,7 @@ public class PagerQuestionBankController {
@GetMapping(path = "/org/paging")
public PageVO<PaperQuestionVO> pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) {
queryVO.setOrgId(loginInfo.getTopOrgId());
queryVO.setOrgId(173L);
return questionBankService.pagingQueryQuestions(queryVO,false);
}

View File

@ -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<String> 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);

View File

@ -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;
}