理论试题管理代码调整

This commit is contained in:
tiger_zhou 2022-10-09 11:25:51 +08:00
parent 153fed2ef2
commit 4a450b40e7
8 changed files with 123 additions and 122 deletions

View File

@ -24,7 +24,6 @@ import java.util.List;
@RequestMapping(path = "/api/question/org")
public class PagerQuestionBankController {
@Autowired
private PagerQuestionService questionBankService;
@ -33,7 +32,7 @@ public class PagerQuestionBankController {
*/
@GetMapping(path = "/paging")
public PageVO<PaperQuestionVO> pagingQueryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) {
queryVO.setCompanyId(loginInfo.getTopOrgId());
queryVO.setOrgId(loginInfo.getTopOrgId());
return questionBankService.pagingQueryQuestions(queryVO,false);
}
@ -43,7 +42,7 @@ public class PagerQuestionBankController {
@GetMapping(path = "")
public List<PaperQuestionVO> queryQuestions(@RequestAttribute LoginUserInfoVO loginInfo, QuestionQueryVO queryVO) {
queryVO.setCompanyId(loginInfo.getTopOrgId());
queryVO.setOrgId(loginInfo.getTopOrgId());
return questionBankService.queryQuestions(queryVO,false);
}
@ -60,7 +59,7 @@ public class PagerQuestionBankController {
*/
@PostMapping(path = "")
public void addQuestion(@Validated @RequestBody PaperQuestionVO questionVO, @RequestAttribute LoginUserInfoVO loginInfo) {
questionVO.setCompanyId(loginInfo.getTopOrgId());
questionVO.setOrgId(loginInfo.getTopOrgId());
questionBankService.saveOrUpdate(questionVO, loginInfo.getAccountVO());
}
@ -107,7 +106,7 @@ public class PagerQuestionBankController {
@PutMapping(path = "/{questionId}")
public void updateQuestion(@PathVariable Long questionId, @RequestAttribute LoginUserInfoVO loginInfo, @RequestBody PaperQuestionVO questionVO, @RequestAttribute AccountVO user) {
questionVO.setId(questionId);
questionVO.setCompanyId(loginInfo.getTopOrgId());
questionVO.setOrgId(loginInfo.getTopOrgId());
questionBankService.saveOrUpdate(questionVO, user);
}

View File

@ -24,7 +24,7 @@ public interface PaperQuestionDAO {
// " and project_code = #{projectCode} "+
// " </otherwise>" +
// "</choose>" +
" and company_id = #{companyId,jdbcType=BIGINT} " +
" and org_id = #{companyId,jdbcType=BIGINT} " +
// "<if test=\"companyIdList != null and companyIdList.size > 0\">"+
// "<foreach collection=\"companyIdList\" open=\" and company_id in (\" close=\")\" item=\"d\" separator=\",\">"+
// " #{d} "+

View File

@ -31,27 +31,25 @@ public class PaperQuestion implements Serializable {
*/
private LocalDateTime createTime;
/**
* 项目code
*/
private String projectCode;
/**
* 公司组织id
*/
private Long companyId;
private Long orgId;
/**
* 标签
*/
private String raceLable;
private String tags;
/**
* 答案,号隔开
*/
private String questionAnswer;
/**
* 是否删除0=1=
*/
private Integer isDel;
private String questionAnswer;
private static final long serialVersionUID = 1L;
}

View File

@ -184,7 +184,10 @@ public class PaperQuestionExample {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andQuestionLike(String value) {
addCriterion("`question` like", value, "question");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
@ -225,10 +228,6 @@ public class PaperQuestionExample {
return (Criteria) this;
}
public Criteria andTopicLike(String value) {
addCriterion("`topic` like", value, "topic");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type");
return (Criteria) this;
@ -379,203 +378,203 @@ public class PaperQuestionExample {
return (Criteria) this;
}
public Criteria andProjectCodeIsNull() {
addCriterion("project_code is null");
public Criteria andOrgIdIsNull() {
addCriterion("org_id is null");
return (Criteria) this;
}
public Criteria andProjectCodeIsNotNull() {
addCriterion("project_code is not null");
public Criteria andOrgIdIsNotNull() {
addCriterion("org_id is not null");
return (Criteria) this;
}
public Criteria andProjectCodeEqualTo(String value) {
addCriterion("project_code =", value, "projectCode");
public Criteria andOrgIdEqualTo(Long value) {
addCriterion("org_id =", value, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeNotEqualTo(String value) {
addCriterion("project_code <>", value, "projectCode");
public Criteria andOrgIdNotEqualTo(Long value) {
addCriterion("org_id <>", value, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeGreaterThan(String value) {
addCriterion("project_code >", value, "projectCode");
public Criteria andOrgIdGreaterThan(Long value) {
addCriterion("org_id >", value, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeGreaterThanOrEqualTo(String value) {
addCriterion("project_code >=", value, "projectCode");
public Criteria andOrgIdGreaterThanOrEqualTo(Long value) {
addCriterion("org_id >=", value, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeLessThan(String value) {
addCriterion("project_code <", value, "projectCode");
public Criteria andOrgIdLessThan(Long value) {
addCriterion("org_id <", value, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeLessThanOrEqualTo(String value) {
addCriterion("project_code <=", value, "projectCode");
public Criteria andOrgIdLessThanOrEqualTo(Long value) {
addCriterion("org_id <=", value, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeLike(String value) {
addCriterion("project_code like", value, "projectCode");
public Criteria andOrgIdIn(List<Long> values) {
addCriterion("org_id in", values, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeNotLike(String value) {
addCriterion("project_code not like", value, "projectCode");
public Criteria andOrgIdNotIn(List<Long> values) {
addCriterion("org_id not in", values, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeIn(List<String> values) {
addCriterion("project_code in", values, "projectCode");
public Criteria andOrgIdBetween(Long value1, Long value2) {
addCriterion("org_id between", value1, value2, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeNotIn(List<String> values) {
addCriterion("project_code not in", values, "projectCode");
public Criteria andOrgIdNotBetween(Long value1, Long value2) {
addCriterion("org_id not between", value1, value2, "orgId");
return (Criteria) this;
}
public Criteria andProjectCodeBetween(String value1, String value2) {
addCriterion("project_code between", value1, value2, "projectCode");
public Criteria andTagsIsNull() {
addCriterion("tags is null");
return (Criteria) this;
}
public Criteria andProjectCodeNotBetween(String value1, String value2) {
addCriterion("project_code not between", value1, value2, "projectCode");
public Criteria andTagsIsNotNull() {
addCriterion("tags is not null");
return (Criteria) this;
}
public Criteria andCompanyIdIsNull() {
addCriterion("company_id is null");
public Criteria andTagsEqualTo(String value) {
addCriterion("tags =", value, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdIsNotNull() {
addCriterion("company_id is not null");
public Criteria andTagsNotEqualTo(String value) {
addCriterion("tags <>", value, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdEqualTo(Long value) {
addCriterion("company_id =", value, "companyId");
public Criteria andTagsGreaterThan(String value) {
addCriterion("tags >", value, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdNotEqualTo(Long value) {
addCriterion("company_id <>", value, "companyId");
public Criteria andTagsGreaterThanOrEqualTo(String value) {
addCriterion("tags >=", value, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdGreaterThan(Long value) {
addCriterion("company_id >", value, "companyId");
public Criteria andTagsLessThan(String value) {
addCriterion("tags <", value, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdGreaterThanOrEqualTo(Long value) {
addCriterion("company_id >=", value, "companyId");
public Criteria andTagsLessThanOrEqualTo(String value) {
addCriterion("tags <=", value, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdLessThan(Long value) {
addCriterion("company_id <", value, "companyId");
public Criteria andTagsLike(String value) {
addCriterion("tags like", value, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdLessThanOrEqualTo(Long value) {
addCriterion("company_id <=", value, "companyId");
public Criteria andTagsNotLike(String value) {
addCriterion("tags not like", value, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdIn(List<Long> values) {
addCriterion("company_id in", values, "companyId");
public Criteria andTagsIn(List<String> values) {
addCriterion("tags in", values, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdNotIn(List<Long> values) {
addCriterion("company_id not in", values, "companyId");
public Criteria andTagsNotIn(List<String> values) {
addCriterion("tags not in", values, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdBetween(Long value1, Long value2) {
addCriterion("company_id between", value1, value2, "companyId");
public Criteria andTagsBetween(String value1, String value2) {
addCriterion("tags between", value1, value2, "tags");
return (Criteria) this;
}
public Criteria andCompanyIdNotBetween(Long value1, Long value2) {
addCriterion("company_id not between", value1, value2, "companyId");
public Criteria andTagsNotBetween(String value1, String value2) {
addCriterion("tags not between", value1, value2, "tags");
return (Criteria) this;
}
public Criteria andRaceLableIsNull() {
addCriterion("race_lable is null");
public Criteria andQuestionAnswerIsNull() {
addCriterion("question_answer is null");
return (Criteria) this;
}
public Criteria andRaceLableIsNotNull() {
addCriterion("race_lable is not null");
public Criteria andQuestionAnswerIsNotNull() {
addCriterion("question_answer is not null");
return (Criteria) this;
}
public Criteria andRaceLableEqualTo(String value) {
addCriterion("race_lable =", value, "raceLable");
public Criteria andQuestionAnswerEqualTo(String value) {
addCriterion("question_answer =", value, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableNotEqualTo(String value) {
addCriterion("race_lable <>", value, "raceLable");
public Criteria andQuestionAnswerNotEqualTo(String value) {
addCriterion("question_answer <>", value, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableGreaterThan(String value) {
addCriterion("race_lable >", value, "raceLable");
public Criteria andQuestionAnswerGreaterThan(String value) {
addCriterion("question_answer >", value, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableGreaterThanOrEqualTo(String value) {
addCriterion("race_lable >=", value, "raceLable");
public Criteria andQuestionAnswerGreaterThanOrEqualTo(String value) {
addCriterion("question_answer >=", value, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableLessThan(String value) {
addCriterion("race_lable <", value, "raceLable");
public Criteria andQuestionAnswerLessThan(String value) {
addCriterion("question_answer <", value, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableLessThanOrEqualTo(String value) {
addCriterion("race_lable <=", value, "raceLable");
public Criteria andQuestionAnswerLessThanOrEqualTo(String value) {
addCriterion("question_answer <=", value, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableLike(String value) {
addCriterion("race_lable like", value, "raceLable");
public Criteria andQuestionAnswerLike(String value) {
addCriterion("question_answer like", value, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableNotLike(String value) {
addCriterion("race_lable not like", value, "raceLable");
public Criteria andQuestionAnswerNotLike(String value) {
addCriterion("question_answer not like", value, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableIn(List<String> values) {
addCriterion("race_lable in", values, "raceLable");
public Criteria andQuestionAnswerIn(List<String> values) {
addCriterion("question_answer in", values, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableNotIn(List<String> values) {
addCriterion("race_lable not in", values, "raceLable");
public Criteria andQuestionAnswerNotIn(List<String> values) {
addCriterion("question_answer not in", values, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableBetween(String value1, String value2) {
addCriterion("race_lable between", value1, value2, "raceLable");
public Criteria andQuestionAnswerBetween(String value1, String value2) {
addCriterion("question_answer between", value1, value2, "questionAnswer");
return (Criteria) this;
}
public Criteria andRaceLableNotBetween(String value1, String value2) {
addCriterion("race_lable not between", value1, value2, "raceLable");
public Criteria andQuestionAnswerNotBetween(String value1, String value2) {
addCriterion("question_answer not between", value1, value2, "questionAnswer");
return (Criteria) this;
}

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.entity.paper.question;
import java.io.Serializable;
import lombok.Data;
/**

View File

@ -36,9 +36,16 @@ public class PagerQuestionService {
@Resource
private PaperQuestionDAO questionDAO;
/**
* 查询列表
* @param queryVO
* @param isPaging
* @param companyIdCanNull 是否允许公司组织id可以为空true=管理使用false = 组织使用
* @return
*/
private Object queryQuestions(QuestionQueryVO queryVO, boolean isPaging,boolean companyIdCanNull){
if(Objects.equals(false,companyIdCanNull)){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getCompanyId()),"题目答案不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getOrgId()),"题目答案不能为空");
}
if(isPaging){
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
@ -46,14 +53,14 @@ public class PagerQuestionService {
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
if (StringUtils.hasText(queryVO.getTopic())) {
criteria.andTopicLike(String.format("%%%s%%", queryVO.getTopic()));
criteria.andQuestionLike(String.format("%%%s%%", queryVO.getTopic()));
}
if (StringUtils.hasText(queryVO.getType())) {
criteria.andTypeEqualTo(queryVO.getType());
}
if(Objects.nonNull(queryVO.getCompanyId())){
criteria.andCompanyIdEqualTo(queryVO.getCompanyId());
if(Objects.nonNull(queryVO.getOrgId())){
criteria.andOrgIdEqualTo(queryVO.getOrgId());
}
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
return questionDAO.selectByExampleWithBLOBs(example);
@ -115,7 +122,6 @@ public class PagerQuestionService {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() == 1 ,"单选,判断题答案只能有一个!");
}else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() > 2 ,"多选题答案最少需要2个");
// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() < optionList.size(),"多选题答案与标准答案数量不匹配");
}
// List<Integer> sourceOptionList = Lists.newArrayList();
// sourceOptionList.addAll(optionList);
@ -124,7 +130,7 @@ public class PagerQuestionService {
// return true;
// }
Collections.sort(answerIds);
String answerStr = Joiner.on(",").join(answerIds);
String answerStr = Joiner.on(",").skipNulls().join(answerIds);
if(Objects.equals(answerStr,vo.getQuestionAnswer())){
return true;
}
@ -147,13 +153,13 @@ public class PagerQuestionService {
List<Long> ids = this.queryFromProjectCode(projectCode);
criteria.andCompanyIdIn(ids);
}*/
criteria.andCompanyIdEqualTo(companyId);
criteria.andOrgIdEqualTo(companyId);
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
List<PaperQuestion> lableList = this.questionDAO.selectByExample(example);
if(CollectionUtils.isEmpty(lableList)){
return Collections.emptyList();
}
return lableList.stream().map(PaperQuestion::getRaceLable).filter(Objects::nonNull).flatMap(d-> Splitter.on(",").omitEmptyStrings()
return lableList.stream().map(PaperQuestion::getTags).filter(Objects::nonNull).flatMap(d-> Splitter.on(",").omitEmptyStrings()
.trimResults().splitToStream(d)).collect(Collectors.toSet());
}
@ -183,7 +189,7 @@ public class PagerQuestionService {
* @param accountVO
*/
public void saveOrUpdate(PaperQuestionVO questionVO, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(questionVO.getCompanyId()),"组织id不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(questionVO.getOrgId()),"组织id不能为空");
this.checkQuestionType(questionVO,"题库目前只支持单选,多选和判断");
if (questionVO.isSelect() || questionVO.isJudge()) {
this.checkQuestionTypeForSelectAndJudge(questionVO,"单选或判断题正确答案有且只有一个!");
@ -243,7 +249,7 @@ public class PagerQuestionService {
//默认项目导入题考虑是否有单位关联
PaperQuestionExample example = new PaperQuestionExample();
PaperQuestionExample.Criteria criteria = example.createCriteria();
criteria.andCompanyIdEqualTo(companyId);
criteria.andOrgIdEqualTo(companyId);
PaperQuestionWithBLOBs pq = new PaperQuestionWithBLOBs();
pq.setIsDel(BusinessConsts.DBLogicDelete.DELETE.ordinal());
questionDAO.updateByExampleSelective(pq,example);
@ -253,7 +259,7 @@ public class PagerQuestionService {
// questionVO.setProjectCode(projectCode);
PaperQuestionWithBLOBs question = questionVO.convert2DB();
// question.setProjectCode(null);
question.setCompanyId(companyId);
question.setOrgId(companyId);
question.setCreateUserId(accountVO.getId());
question.setCreateTime(LocalDateTime.now());
questionDAO.insert(question);

View File

@ -52,9 +52,9 @@ public class PaperQuestionVO implements Cloneable {
private String createUserName;
private String projectCode;
private Long companyId;
private String raceLable;
// private String projectCode;
private Long orgId;
private String tags;
private String questionAnswer;
private String answer;
@ -68,9 +68,9 @@ public class PaperQuestionVO implements Cloneable {
this.id = question.getId();
this.type = question.getType();
this.question = question.getQuestion();
this.projectCode = question.getProjectCode();
this.companyId = question.getCompanyId();
this.raceLable = question.getRaceLable();
// this.projectCode = question.getProjectCode();
this.orgId = question.getOrgId();
this.tags = question.getTags();
this.optionList = JsonUtils.readCollection(question.getQuestionOption(),ArrayList.class, PaperQuestionOptionVO2.class);
String dd = Objects.isNull(question.getQuestionAnswer()) ? "" : question.getQuestionAnswer();
this.answer = dd;
@ -88,8 +88,8 @@ public class PaperQuestionVO implements Cloneable {
question.setId(this.id);
question.setType(type);
question.setQuestion(this.question);
question.setProjectCode(Project.isDefault(Project.valueOf(projectCode)) ? null : projectCode);
question.setCompanyId(companyId);
// question.setProjectCode(Project.isDefault(Project.valueOf(projectCode)) ? null : projectCode);
question.setOrgId(this.orgId);
this.setOptionId(question);
String dd = JsonUtils.writeValueAsString(this.optionList);
@ -98,7 +98,7 @@ public class PaperQuestionVO implements Cloneable {
listMap.forEach(d->d.remove("correct"));
question.setQuestionOption(JsonUtils.writeValueAsString(listMap));
question.setRaceLable(this.raceLable);
question.setTags(this.tags);
question.setIsDel(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
// question.setQuestionAnswer(this.answer);
return question;

View File

@ -13,6 +13,6 @@ public class QuestionQueryVO extends PageQueryVO {
private String type;
// private String projectCode;
private Long companyId;
private Long orgId;
}