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 2ba9d7537..2047f7cb9 100644 --- a/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java +++ b/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java @@ -1,7 +1,9 @@ package club.joylink.rtss.controller.paper; import club.joylink.rtss.services.paper.PaperUserCreateService; +import club.joylink.rtss.services.paper.PaperUserLoadQuestionService; import club.joylink.rtss.services.paper.PaperUserService; +import club.joylink.rtss.services.paper.PaperUserSubmitAnswerService; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.paper.*; @@ -20,6 +22,10 @@ public class PaperUserController { private PaperUserService paperUserService; @Autowired private PaperUserCreateService paperUserCreateService; + @Autowired + private PaperUserLoadQuestionService paperUserLoadQuestionService; + @Autowired + private PaperUserSubmitAnswerService paperUserSubmitAnswerService; /** * 根据试卷蓝图生成用户的试卷 @@ -71,7 +77,7 @@ public class PaperUserController { public PaperQuestionLoadRspVo loadQuestion(@PathVariable("groupType") Integer groupType, @PathVariable("qId") Long qId, @RequestAttribute AccountVO user) { PaperQType.GroupType pgType = PaperQType.GroupType.getItem(groupType); - return null; + return this.paperUserLoadQuestionService.loadQuestion(pgType, qId, user); } /** @@ -79,8 +85,7 @@ public class PaperUserController { */ @PostMapping("/user/question/answer") public PaperSubmitAnswerRspVo submitAnswer(@RequestBody PaperSubmitAnswerReqVo req, @RequestAttribute AccountVO user) { - - return null; + return this.paperUserSubmitAnswerService.submitAnswer(req, user); } /** diff --git a/src/main/java/club/joylink/rtss/dao/paper/PaperCompositionDAO.java b/src/main/java/club/joylink/rtss/dao/paper/PaperCompositionDAO.java index 67d262d82..61ff7e9cb 100644 --- a/src/main/java/club/joylink/rtss/dao/paper/PaperCompositionDAO.java +++ b/src/main/java/club/joylink/rtss/dao/paper/PaperCompositionDAO.java @@ -31,4 +31,4 @@ public interface PaperCompositionDAO { int updateByPrimaryKeySelective(PaperComposition record); int updateByPrimaryKey(PaperComposition record); -} +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperComposition.java b/src/main/java/club/joylink/rtss/entity/paper/PaperComposition.java index e2cf37f90..7a5fc9fb1 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperComposition.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperComposition.java @@ -5,8 +5,8 @@ import java.time.LocalDateTime; import lombok.Data; /** - * @author - * + * @author + * */ @Data public class PaperComposition implements Serializable { @@ -26,9 +26,9 @@ public class PaperComposition implements Serializable { private String profile; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 启用起始时间 @@ -66,9 +66,9 @@ public class PaperComposition implements Serializable { private LocalDateTime updateTime; /** - * 试卷蓝图状态:1-正在编辑,2-封存(不能修改),3-已经被使用(不能修改删除) + * 试卷蓝图状态:1-正在编辑,2-封存(不能修改),3-已经被使用(不能修改删除);定于见PaperCompositionState */ private Integer state; private static final long serialVersionUID = 1L; -} +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperCompositionExample.java b/src/main/java/club/joylink/rtss/entity/paper/PaperCompositionExample.java index e364da0a2..399256f4b 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperCompositionExample.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperCompositionExample.java @@ -325,73 +325,73 @@ public class PaperCompositionExample { return (Criteria) this; } - public Criteria andProjectCodeIsNull() { - addCriterion("project_code is null"); + public Criteria andCompanyIdIsNull() { + addCriterion("company_id is null"); return (Criteria) this; } - public Criteria andProjectCodeIsNotNull() { - addCriterion("project_code is not null"); + public Criteria andCompanyIdIsNotNull() { + addCriterion("company_id is not null"); return (Criteria) this; } - public Criteria andProjectCodeEqualTo(String value) { - addCriterion("project_code =", value, "projectCode"); + public Criteria andCompanyIdEqualTo(String value) { + addCriterion("company_id =", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotEqualTo(String value) { - addCriterion("project_code <>", value, "projectCode"); + public Criteria andCompanyIdNotEqualTo(String value) { + addCriterion("company_id <>", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThan(String value) { - addCriterion("project_code >", value, "projectCode"); + public Criteria andCompanyIdGreaterThan(String value) { + addCriterion("company_id >", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThanOrEqualTo(String value) { - addCriterion("project_code >=", value, "projectCode"); + public Criteria andCompanyIdGreaterThanOrEqualTo(String value) { + addCriterion("company_id >=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThan(String value) { - addCriterion("project_code <", value, "projectCode"); + public Criteria andCompanyIdLessThan(String value) { + addCriterion("company_id <", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThanOrEqualTo(String value) { - addCriterion("project_code <=", value, "projectCode"); + public Criteria andCompanyIdLessThanOrEqualTo(String value) { + addCriterion("company_id <=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLike(String value) { - addCriterion("project_code like", value, "projectCode"); + public Criteria andCompanyIdLike(String value) { + addCriterion("company_id like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotLike(String value) { - addCriterion("project_code not like", value, "projectCode"); + public Criteria andCompanyIdNotLike(String value) { + addCriterion("company_id not like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeIn(List values) { - addCriterion("project_code in", values, "projectCode"); + public Criteria andCompanyIdIn(List values) { + addCriterion("company_id in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotIn(List values) { - addCriterion("project_code not in", values, "projectCode"); + public Criteria andCompanyIdNotIn(List values) { + addCriterion("company_id not in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeBetween(String value1, String value2) { - addCriterion("project_code between", value1, value2, "projectCode"); + public Criteria andCompanyIdBetween(String value1, String value2) { + addCriterion("company_id between", value1, value2, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotBetween(String value1, String value2) { - addCriterion("project_code not between", value1, value2, "projectCode"); + public Criteria andCompanyIdNotBetween(String value1, String value2) { + addCriterion("company_id not between", value1, value2, "companyId"); return (Criteria) this; } @@ -970,4 +970,4 @@ public class PaperCompositionExample { this(condition, value, secondValue, null); } } -} +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperRule.java b/src/main/java/club/joylink/rtss/entity/paper/PaperRule.java index 350678982..bb793ae03 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperRule.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperRule.java @@ -30,7 +30,7 @@ public class PaperRule implements Serializable { private Integer subtype; /** - * 筛选题目的标签,即根据标签来筛选题目 + * 筛选题目的标签,即根据标签来筛选题目;List的json */ private String tags; diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperUser.java b/src/main/java/club/joylink/rtss/entity/paper/PaperUser.java index 764838744..246a6623f 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperUser.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperUser.java @@ -26,9 +26,9 @@ public class PaperUser implements Serializable { private Long pcId; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 用户最终得分 diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperUserExample.java b/src/main/java/club/joylink/rtss/entity/paper/PaperUserExample.java index 9416d1ec7..519ecb62c 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperUserExample.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperUserExample.java @@ -305,73 +305,73 @@ public class PaperUserExample { return (Criteria) this; } - public Criteria andProjectCodeIsNull() { - addCriterion("project_code is null"); + public Criteria andCompanyIdIsNull() { + addCriterion("company_id is null"); return (Criteria) this; } - public Criteria andProjectCodeIsNotNull() { - addCriterion("project_code is not null"); + public Criteria andCompanyIdIsNotNull() { + addCriterion("company_id is not null"); return (Criteria) this; } - public Criteria andProjectCodeEqualTo(String value) { - addCriterion("project_code =", value, "projectCode"); + public Criteria andCompanyIdEqualTo(String value) { + addCriterion("company_id =", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotEqualTo(String value) { - addCriterion("project_code <>", value, "projectCode"); + public Criteria andCompanyIdNotEqualTo(String value) { + addCriterion("company_id <>", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThan(String value) { - addCriterion("project_code >", value, "projectCode"); + public Criteria andCompanyIdGreaterThan(String value) { + addCriterion("company_id >", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThanOrEqualTo(String value) { - addCriterion("project_code >=", value, "projectCode"); + public Criteria andCompanyIdGreaterThanOrEqualTo(String value) { + addCriterion("company_id >=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThan(String value) { - addCriterion("project_code <", value, "projectCode"); + public Criteria andCompanyIdLessThan(String value) { + addCriterion("company_id <", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThanOrEqualTo(String value) { - addCriterion("project_code <=", value, "projectCode"); + public Criteria andCompanyIdLessThanOrEqualTo(String value) { + addCriterion("company_id <=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLike(String value) { - addCriterion("project_code like", value, "projectCode"); + public Criteria andCompanyIdLike(String value) { + addCriterion("company_id like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotLike(String value) { - addCriterion("project_code not like", value, "projectCode"); + public Criteria andCompanyIdNotLike(String value) { + addCriterion("company_id not like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeIn(List values) { - addCriterion("project_code in", values, "projectCode"); + public Criteria andCompanyIdIn(List values) { + addCriterion("company_id in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotIn(List values) { - addCriterion("project_code not in", values, "projectCode"); + public Criteria andCompanyIdNotIn(List values) { + addCriterion("company_id not in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeBetween(String value1, String value2) { - addCriterion("project_code between", value1, value2, "projectCode"); + public Criteria andCompanyIdBetween(String value1, String value2) { + addCriterion("company_id between", value1, value2, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotBetween(String value1, String value2) { - addCriterion("project_code not between", value1, value2, "projectCode"); + public Criteria andCompanyIdNotBetween(String value1, String value2) { + addCriterion("company_id not between", value1, value2, "companyId"); return (Criteria) this; } diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestion.java b/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestion.java index d966f7ecf..26715d391 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestion.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestion.java @@ -20,9 +20,9 @@ public class PaperUserQuestion implements Serializable { private Long puId; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 试题类型:1-理论题,2-实训题 diff --git a/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestionExample.java b/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestionExample.java index 984c9e4d3..4b4e3a415 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestionExample.java +++ b/src/main/java/club/joylink/rtss/entity/paper/PaperUserQuestionExample.java @@ -244,73 +244,73 @@ public class PaperUserQuestionExample { return (Criteria) this; } - public Criteria andProjectCodeIsNull() { - addCriterion("project_code is null"); + public Criteria andCompanyIdIsNull() { + addCriterion("company_id is null"); return (Criteria) this; } - public Criteria andProjectCodeIsNotNull() { - addCriterion("project_code is not null"); + public Criteria andCompanyIdIsNotNull() { + addCriterion("company_id is not null"); return (Criteria) this; } - public Criteria andProjectCodeEqualTo(String value) { - addCriterion("project_code =", value, "projectCode"); + public Criteria andCompanyIdEqualTo(String value) { + addCriterion("company_id =", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotEqualTo(String value) { - addCriterion("project_code <>", value, "projectCode"); + public Criteria andCompanyIdNotEqualTo(String value) { + addCriterion("company_id <>", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThan(String value) { - addCriterion("project_code >", value, "projectCode"); + public Criteria andCompanyIdGreaterThan(String value) { + addCriterion("company_id >", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeGreaterThanOrEqualTo(String value) { - addCriterion("project_code >=", value, "projectCode"); + public Criteria andCompanyIdGreaterThanOrEqualTo(String value) { + addCriterion("company_id >=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThan(String value) { - addCriterion("project_code <", value, "projectCode"); + public Criteria andCompanyIdLessThan(String value) { + addCriterion("company_id <", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLessThanOrEqualTo(String value) { - addCriterion("project_code <=", value, "projectCode"); + public Criteria andCompanyIdLessThanOrEqualTo(String value) { + addCriterion("company_id <=", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeLike(String value) { - addCriterion("project_code like", value, "projectCode"); + public Criteria andCompanyIdLike(String value) { + addCriterion("company_id like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotLike(String value) { - addCriterion("project_code not like", value, "projectCode"); + public Criteria andCompanyIdNotLike(String value) { + addCriterion("company_id not like", value, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeIn(List values) { - addCriterion("project_code in", values, "projectCode"); + public Criteria andCompanyIdIn(List values) { + addCriterion("company_id in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotIn(List values) { - addCriterion("project_code not in", values, "projectCode"); + public Criteria andCompanyIdNotIn(List values) { + addCriterion("company_id not in", values, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeBetween(String value1, String value2) { - addCriterion("project_code between", value1, value2, "projectCode"); + public Criteria andCompanyIdBetween(String value1, String value2) { + addCriterion("company_id between", value1, value2, "companyId"); return (Criteria) this; } - public Criteria andProjectCodeNotBetween(String value1, String value2) { - addCriterion("project_code not between", value1, value2, "projectCode"); + public Criteria andCompanyIdNotBetween(String value1, String value2) { + addCriterion("company_id not between", value1, value2, "companyId"); return (Criteria) this; } diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperCompositionService.java b/src/main/java/club/joylink/rtss/services/paper/PaperCompositionService.java index 0e070c1f6..00d824a3a 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperCompositionService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperCompositionService.java @@ -37,12 +37,12 @@ public class PaperCompositionService { @Transactional(rollbackFor = Exception.class) public CreatePaperCompositionRspVo createPaperComposition(CreatePaperCompositionReqVo req, AccountVO user) { //根据项目和名称来查,如果存在则结束 - List pcList = this.findCompositionByProjectAndName(req.getProjectCode(), req.getName()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(pcList), "试卷定义已经存在:projectCode=" + req.getProjectCode() + " name=" + req.getName()); + List pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(pcList), "试卷定义已经存在:companyId=" + req.getCompanyId() + " name=" + req.getName()); // PaperComposition newPc = new PaperComposition(); newPc.setName(req.getName()); - newPc.setProjectCode(req.getProjectCode()); + newPc.setCompanyId(req.getCompanyId()); newPc.setProfile(req.getProfile()); newPc.setCreateTime(LocalDateTime.now()); newPc.setUpdateTime(LocalDateTime.now()); @@ -51,14 +51,14 @@ public class PaperCompositionService { int newRt = compositionDAO.insertSelective(newPc); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(newRt > 0, "存储试卷定义失败"); // - pcList = this.findCompositionByProjectAndName(req.getProjectCode(), req.getName()); + pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName()); newPc = pcList.get(0); // CreatePaperCompositionRspVo rsp = new CreatePaperCompositionRspVo(); rsp.setId(newPc.getId()); rsp.setName(newPc.getName()); rsp.setProfile(newPc.getProfile()); - rsp.setProjectCode(newPc.getProjectCode()); + rsp.setCompanyId(newPc.getCompanyId()); return rsp; } @@ -70,17 +70,17 @@ public class PaperCompositionService { PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getId()); assertPaperCompositionCanModify(curPc); // - List pcList = this.findCompositionByProjectAndName(req.getProjectCode(), req.getName()); + List pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName()); if (!CollectionUtils.isEmpty(pcList)) { boolean exist = pcList.stream().anyMatch(c -> { return c.getId().compareTo(curPc.getId()) != 0; }); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(exist, "试卷定义已经存在:projectCode=" + req.getProjectCode() + " name=" + req.getName()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(exist, "试卷定义已经存在:companyId=" + req.getCompanyId() + " name=" + req.getName()); } // curPc.setName(req.getName()); curPc.setProfile(req.getProfile()); - curPc.setProjectCode(req.getProjectCode()); + curPc.setCompanyId(req.getCompanyId()); curPc.setUpdateTime(LocalDateTime.now()); compositionDAO.updateByPrimaryKeySelective(curPc); } @@ -193,11 +193,11 @@ public class PaperCompositionService { pcExCriteria.andNameEqualTo(req.getName()); } } - if (null != req.getProjectCode()) { + if (null != req.getCompanyId()) { if (req.getProjectCodeLike()) { - pcExCriteria.andProjectCodeLike(req.getProjectCode()); + pcExCriteria.andCompanyIdLike(String.format("%%%s%%",req.getCompanyId())); } else { - pcExCriteria.andProjectCodeEqualTo(req.getProjectCode()); + pcExCriteria.andCompanyIdEqualTo(req.getCompanyId()); } } if (null != req.getProfile()) { @@ -272,9 +272,9 @@ public class PaperCompositionService { * 根据试卷蓝图的项目和名称查找项目 */ @Transactional(readOnly = true) - public List findCompositionByProjectAndName(String projectCode, String name) { + public List findCompositionByCompanyIdAndName(String companyId, String name) { PaperCompositionExample example = new PaperCompositionExample(); - example.createCriteria().andProjectCodeEqualTo(projectCode).andNameEqualTo(name); + example.createCriteria().andCompanyIdEqualTo(companyId).andNameEqualTo(name); List list = compositionDAO.selectByExample(example); return list; } diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserCreateService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserCreateService.java index a00dcd501..f24d55af6 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserCreateService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserCreateService.java @@ -5,17 +5,25 @@ import club.joylink.rtss.dao.paper.*; import club.joylink.rtss.entity.paper.PaperComposition; import club.joylink.rtss.entity.paper.PaperRule; import club.joylink.rtss.entity.paper.PaperUser; +import club.joylink.rtss.entity.paper.PaperUserQuestion; +import club.joylink.rtss.entity.paper.question.PaperQuestion; 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.BusinessExceptionAssertEnum; +import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.paper.CreatePaperRspVo; import club.joylink.rtss.vo.paper.PaperCompositionState; import club.joylink.rtss.vo.paper.PaperQType; +import club.joylink.rtss.vo.paper.PaperQuestionState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; /** @@ -36,7 +44,7 @@ public class PaperUserCreateService { @Autowired private PaperCompositionService compositionService; @Autowired - private PaperQuestionDAO pagerQuestionDAO; + private PaperQuestionDAO questionDAO; @Autowired private PublishedTraining2DAO trainingDAO; @@ -60,14 +68,14 @@ public class PaperUserCreateService { List ruleList = compositionService.findRuleByPcId(pcId); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(ruleList, "试卷定义没有规则定义,无法生成用户试卷,pcId = " + pcId); // - String projectCode = composition.getProjectCode(); + String companyId = composition.getCompanyId(); // 标记封存的试卷蓝图已使用 compositionService.usePaperComposition(pcId); // 创建用户试卷 PaperUser paper = new PaperUser(); paper.setUserId(user.getId()); paper.setPcId(pcId); - paper.setProjectCode(projectCode); + paper.setCompanyId(companyId); paper.setCreateTime(LocalDateTime.now()); paperUserDAO.insertSelective(paper); paper = paperUserService.findByUserIdAndPcId(user.getId(), pcId); @@ -76,7 +84,7 @@ public class PaperUserCreateService { // CreatePaperRspVo rsp = new CreatePaperRspVo(); rsp.setPaperName(composition.getName()); - rsp.setProjectCode(projectCode); + rsp.setCompanyId(companyId); rsp.setId(paper.getId()); return rsp; } @@ -92,35 +100,188 @@ public class PaperUserCreateService { this.dispatcherCommonQuestion(pu, pc, rule); break; case Training: + this.dispatcherTrainingQuestion(pu, pc, rule); + break; } }); } + /** + * 随机选择理论题目 + */ private void dispatcherCommonQuestion(PaperUser pu, PaperComposition pc, PaperRule rule) { - String tags = rule.getTags();//规则标签,逗号分隔 - String[] tagArray = null != tags && tags.length() > 0 ? tags.split(",") : null; + final int qSum = rule.getSum();//该类型问题个数 + // + PaperQuestionExample questionExample = this.commonQuestionExample(pu, pc, rule, null, null); + //符合条件的题目数目 + long count = questionDAO.countByExample(questionExample); + PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的理论题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum); + //引入随机数 + //每页记录数 + final int pageSize = 5; + //页数 + final long pageSum = count / pageSize + count % pageSize > 0 ? 1 : 0; + //随机生成页码 + int pageNum = (int) (Math.random() * pageSum) + 1; + //在页内随机选择一条,在该条前后连续取够qSum个问题 + long startIndex = (pageNum - 1) * pageSize; + final String orderBy = "id"; + questionExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, pageSize)); + List page = questionDAO.selectByExample(questionExample); + final int randomIndex = (int) (Math.random() * page.size()); + //选择该题目后边连续qSum个 + PaperQuestion randomQuestion = page.get(randomIndex); + final List questionList = new ArrayList<>(qSum); + questionList.add(randomQuestion); + final int questionSum = qSum - 1; + PaperQuestionExample greaterExample = this.commonQuestionExample(pu, pc, rule, true, randomQuestion.getId()); + greaterExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, 0, questionSum)); + List greaterList = questionDAO.selectByExample(greaterExample); + if (!CollectionUtils.isEmpty(greaterList)) { + questionList.addAll(greaterList); + } + final int lessSum = questionSum - questionList.size(); + if (lessSum > 0) { + PaperQuestionExample lessExample = this.commonQuestionExample(pu, pc, rule, false, randomQuestion.getId()); + lessExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, 0, lessSum)); + List lessList = questionDAO.selectByExample(lessExample); + questionList.addAll(lessList); + } + //校验最终查询到的题目数目 + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(questionList.size() == qSum, "没有足够的符合条件的理论题目"); + //将题目与试卷关联 + questionList.forEach(q -> { + PaperUserQuestion puq = new PaperUserQuestion(); + puq.setState(PaperQuestionState.Undo.getValue()); + puq.setPuId(pu.getId()); + puq.setCompanyId(pc.getCompanyId()); + puq.setType(PaperQType.GroupType.getItem(rule.getType()).getValue()); + puq.setQuestionId(q.getId()); + paperUserQuestionDAO.insertSelective(puq); + }); + } + + /** + * 随机选择实训题目 + */ + private void dispatcherTrainingQuestion(PaperUser pu, PaperComposition pc, PaperRule rule) { + final int qSum = rule.getSum();//该类型问题个数 + // + PublishedTraining2Example questionExample = this.trainingQuestionExample(pu, pc, rule, null, null); + //符合条件的题目数目 + long count = trainingDAO.countByExample(questionExample); + PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的实训题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum); + //引入随机数 + //每页记录数 + final int pageSize = 5; + //页数 + final long pageSum = count / pageSize + count % pageSize > 0 ? 1 : 0; + //随机生成页码 + int pageNum = (int) (Math.random() * pageSum) + 1; + //在页内随机选择一条,在该条前后连续取够qSum个问题 + long startIndex = (pageNum - 1) * pageSize; + final String orderBy = "id"; + questionExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, pageSize)); + List page = trainingDAO.selectByExample(questionExample); + final int randomIndex = (int) (Math.random() * page.size()); + //选择该题目后边连续qSum个 + PublishedTraining2 randomQuestion = page.get(randomIndex); + final List questionList = new ArrayList<>(qSum); + questionList.add(randomQuestion); + final int questionSum = qSum - 1; + PublishedTraining2Example greaterExample = this.trainingQuestionExample(pu, pc, rule, true, randomQuestion.getId()); + greaterExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, 0, questionSum)); + List greaterList = trainingDAO.selectByExample(greaterExample); + if (!CollectionUtils.isEmpty(greaterList)) { + questionList.addAll(greaterList); + } + final int lessSum = questionSum - questionList.size(); + if (lessSum > 0) { + PublishedTraining2Example lessExample = this.trainingQuestionExample(pu, pc, rule, false, randomQuestion.getId()); + lessExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, 0, lessSum)); + List lessList = trainingDAO.selectByExample(lessExample); + questionList.addAll(lessList); + } + //校验最终查询到的题目数目 + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(questionList.size() == qSum, "没有足够的符合条件的实训题目"); + //将题目与试卷关联 + questionList.forEach(q -> { + PaperUserQuestion puq = new PaperUserQuestion(); + puq.setState(PaperQuestionState.Undo.getValue()); + puq.setPuId(pu.getId()); + puq.setCompanyId(pc.getCompanyId()); + puq.setType(PaperQType.GroupType.getItem(rule.getType()).getValue()); + puq.setQuestionId(q.getId()); + paperUserQuestionDAO.insertSelective(puq); + }); + } + + /** + * 生成根据tag查询的条件 + */ + private PublishedTraining2Example trainingQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule, Boolean isGreaterThan, Long id) { + String tags = rule.getTags();//规则标签,list json + List tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null; + PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype()); + // + PublishedTraining2Example questionExample = new PublishedTraining2Example(); + if (null == tagArray) { + PublishedTraining2Example.Criteria c = questionExample.createCriteria().andTypeEqualTo(this.paperUserService.getTrainingType(subType)).andStateEqualTo(1);//1-上架 + if (null != isGreaterThan && null != id) { + if (isGreaterThan) { + c.andIdGreaterThan(id); + } else { + c.andIdLessThan(id); + } + } + } else { + for (String tag : tagArray) { + PublishedTraining2Example.Criteria c = questionExample.or().andTypeEqualTo(this.paperUserService.getTrainingType(subType)).andStateEqualTo(1).andLabelJsonLike(String.format("%%%s%%", tag)); + if (null != isGreaterThan && null != id) { + if (isGreaterThan) { + c.andIdGreaterThan(id); + } else { + c.andIdLessThan(id); + } + } + } + } + return questionExample; + } + + /** + * 生成根据tag查询的条件 + */ + private PaperQuestionExample commonQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule, Boolean isGreaterThan, Long id) { + String tags = rule.getTags();//规则标签,list json + List tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null; PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype()); - int qSum = rule.getSum();//该类型问题个数 // PaperQuestionExample questionExample = new PaperQuestionExample(); if (null == tagArray) { - questionExample.createCriteria().andProjectCodeEqualTo(pc.getProjectCode()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0); + PaperQuestionExample.Criteria c = questionExample.createCriteria().andProjectCodeEqualTo(pc.getCompanyId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0); + if (null != isGreaterThan && null != id) { + if (isGreaterThan) { + c.andIdGreaterThan(id); + } else { + c.andIdLessThan(id); + } + } } else { for (String tag : tagArray) { - questionExample.or().andProjectCodeEqualTo(pc.getProjectCode()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0).andRaceLableLike(tag); + PaperQuestionExample.Criteria c = questionExample.or().andProjectCodeEqualTo(pc.getCompanyId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0).andRaceLableLike(String.format("%%%s%%", tag)); + if (null != isGreaterThan && null != id) { + if (isGreaterThan) { + c.andIdGreaterThan(id); + } else { + c.andIdLessThan(id); + } + } } } - //符合条件的题目数目 - long count = pagerQuestionDAO.countByExample(questionExample); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(count >= qSum, "符合条件的理论题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " projectCode = " + pc.getProjectCode() + " ruleType = " + subType.name() + " ruleSum = " + qSum); - //引入随机数 - //每页10条一共页数 - long pageSum = count/10+count%10>0?1:0; - //随机生成页码 - int pageNum = (int) (Math.random()*pageSum); - //在页内随机选择一条,在该条前后连续取够qSum个问题 - + return questionExample; } - } diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserLoadQuestionService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserLoadQuestionService.java new file mode 100644 index 000000000..44bd946e2 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserLoadQuestionService.java @@ -0,0 +1,76 @@ +package club.joylink.rtss.services.paper; + +import club.joylink.rtss.dao.PublishedTraining2DAO; +import club.joylink.rtss.dao.paper.PaperQuestionDAO; +import club.joylink.rtss.entity.paper.question.PaperQuestionWithBLOBs; +import club.joylink.rtss.entity.training2.PublishedTraining2; +import club.joylink.rtss.entity.training2.PublishedTraining2Example; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.AccountVO; +import club.joylink.rtss.vo.paper.PaperCommonQuestionVo; +import club.joylink.rtss.vo.paper.PaperQType; +import club.joylink.rtss.vo.paper.PaperQuestionLoadRspVo; +import club.joylink.rtss.vo.paper.PaperTrainingQuestionVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; + +@Service +public class PaperUserLoadQuestionService { + @Autowired + private PaperUserService paperUserService; + @Autowired + private PaperQuestionDAO questionDAO; + @Autowired + private PublishedTraining2DAO trainingDAO; + + /** + * 加载用户试卷试题 + * + * @param groupType 试卷试题大类型:1-理论题,2-实训题 + * @param qId 试题id + */ + @Transactional(readOnly = true) + public PaperQuestionLoadRspVo loadQuestion(PaperQType.GroupType groupType, Long qId, AccountVO user) { + PaperQuestionLoadRspVo rsp = new PaperQuestionLoadRspVo(); + rsp.setId(qId); + rsp.setType(groupType); + switch (groupType) { + case Training: + rsp.setTraining(loadTrainingQuestion(qId, user)); + break; + case Common: + rsp.setCommon(loadCommonQuestion(qId, user)); + break; + } + return rsp; + } + + private PaperTrainingQuestionVo loadTrainingQuestion(Long qId, AccountVO user) { + PublishedTraining2Example example = new PublishedTraining2Example(); + example.createCriteria().andIdEqualTo(qId); + PublishedTraining2 training = trainingDAO.selectByExample(example).get(0); + PaperTrainingQuestionVo rt = new PaperTrainingQuestionVo(); + rt.setId(training.getId()); + rt.setType(paperUserService.getTrainingType(training)); + rt.setName(training.getName()); + rt.setDescription(training.getDescription()); + return rt; + } + + private PaperCommonQuestionVo loadCommonQuestion(Long qId, AccountVO user) { + PaperCommonQuestionVo q = new PaperCommonQuestionVo(); + PaperQuestionWithBLOBs question = questionDAO.selectByPrimaryKey(qId); + q.setId(question.getId()); + q.setType(paperUserService.getPaperQuestionType(question)); + q.setCreateUserId(question.getCreateUserId()); + q.setCreateTime(question.getCreateTime()); + q.setProjectCode(question.getProjectCode()); + q.setCompanyId(question.getCompanyId()); + q.setRaceLable(question.getRaceLable()); + q.setQuestion(question.getQuestion()); + q.setOptionList(JsonUtils.readCollection(question.getQuestionOption(), ArrayList.class, PaperCommonQuestionVo.OptionVo.class)); + return q; + } +} 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 3543db2a3..441017813 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java @@ -17,6 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestBody; import java.time.Duration; import java.time.LocalDateTime; @@ -46,10 +49,6 @@ public class PaperUserService { @Autowired private PublishedTraining2DAO trainingDAO; - - - - /** * 获取用户试卷完整信息 * @@ -73,19 +72,6 @@ public class PaperUserService { return rsp; } - /** - * 加载用户试卷试题 - * - * @param groupType 试卷试题大类型:1-理论题,2-实训题 - * @param qId 试题id - */ - @Transactional(readOnly = true) - public PaperQuestionLoadRspVo loadQuestion(PaperQType.GroupType groupType, Long qId, AccountVO user) { - - - return null; - } - /** * 开始答题 * @@ -142,7 +128,7 @@ public class PaperUserService { PaperSubmitRspVo rsp = new PaperSubmitRspVo(); rsp.setPuId(puId); rsp.setName(composition.getName()); - rsp.setProjectCode(composition.getProjectCode()); + rsp.setCompanyId(composition.getCompanyId()); rsp.setDuration(paperTime); rsp.setScore(scoreCommon + scoreTraining); rsp.setCommonScore(scoreCommon); @@ -159,14 +145,13 @@ public class PaperUserService { example.createCriteria().andIdEqualTo(puq.getQuestionId()); PaperQuestion question = pagerQuestionDAO.selectByExample(example).get(0); if (PaperQuestionState.Right.equals(PaperQuestionState.getItem(puq.getState()))) {//题答对时 - PaperRule rule = ruleMap.get(this.getPaperQuestionType(question)); - return rule.getScore(); + PaperRule rule = ruleMap.get(this.getPaperQuestionType(question)); + return rule.getScore(); } return 0; } - /** * 获取题的最终得分 */ @@ -231,36 +216,50 @@ public class PaperUserService { return list.get(0); } } + public PaperQType.SubType getPaperQuestionType(PaperQuestion question) { switch (question.getType()) { - case "select": return PaperQType.SubType.Select; - case "judge":return PaperQType.SubType.Judge; - case "multi":return PaperQType.SubType.Multi; + case "select": + return PaperQType.SubType.Select; + case "judge": + return PaperQType.SubType.Judge; + case "multi": + return PaperQType.SubType.Multi; } return null; } - public String getPaperQuestionType(PaperQType.SubType qt){ - switch (qt){ - case Judge:return "judge"; - case Select:return "select"; - case Multi:return "multi"; + + public String getPaperQuestionType(PaperQType.SubType qt) { + switch (qt) { + case Judge: + return "judge"; + case Select: + return "select"; + case Multi: + return "multi"; } return null; } + /** * 实训类型(单操 single;场景scene) */ - public PaperQType.SubType getTrainingType(PublishedTraining2 training){ - switch (training.getType()){ - case "single":return PaperQType.SubType.Single; - case "scene":return PaperQType.SubType.Scene; + public PaperQType.SubType getTrainingType(PublishedTraining2 training) { + switch (training.getType()) { + case "single": + return PaperQType.SubType.Single; + case "scene": + return PaperQType.SubType.Scene; } return null; } - public String getTrainingType(PaperQType.SubType training){ - switch(training){ - case Single:return "single"; - case Scene:return "scene"; + + public String getTrainingType(PaperQType.SubType training) { + switch (training) { + case Single: + return "single"; + case Scene: + return "scene"; } return null; } diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java new file mode 100644 index 000000000..e93586a10 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java @@ -0,0 +1,34 @@ +package club.joylink.rtss.services.paper; + +import club.joylink.rtss.dao.paper.PaperUserQuestionDAO; +import club.joylink.rtss.entity.paper.PaperUserQuestionExample; +import club.joylink.rtss.vo.AccountVO; +import club.joylink.rtss.vo.paper.PaperSubmitAnswerReqVo; +import club.joylink.rtss.vo.paper.PaperSubmitAnswerRspVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * 用户提交答案业务处理 + */ +@Service +public class PaperUserSubmitAnswerService { + @Autowired + private PaperUserQuestionDAO paperUserQuestionDAO; + + /** + * 用户提交答案 + */ + @Transactional(rollbackFor = Exception.class) + public PaperSubmitAnswerRspVo submitAnswer(PaperSubmitAnswerReqVo req, AccountVO user) { + PaperUserQuestionExample example = new PaperUserQuestionExample(); + example.createCriteria().andPuIdEqualTo(req.getPuId()).andQuestionIdEqualTo(req.getPqId()); + PaperSubmitAnswerRspVo rsp = new PaperSubmitAnswerRspVo(); + + return null; + } + private void submitCommonAnswer(PaperSubmitAnswerReqVo req){ + + } +} diff --git a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionReqVo.java index 0f1f2ca10..43975f765 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionReqVo.java @@ -18,8 +18,8 @@ public class CreatePaperCompositionReqVo { private String profile; /** - * 项目code + * 组织id */ @NotNull - private String projectCode; + private String companyId; } diff --git a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionRspVo.java b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionRspVo.java index 0e1589735..8bcec04fe 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperCompositionRspVo.java @@ -22,7 +22,7 @@ public class CreatePaperCompositionRspVo { private String profile; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; } diff --git a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRspVo.java b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRspVo.java index 22872a9d4..bbd99e4e0 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRspVo.java @@ -18,9 +18,9 @@ public class CreatePaperRspVo { @JsonSerialize(using = ToStringSerializer.class) private Long id; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 试卷名称 */ diff --git a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRuleReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRuleReqVo.java index 21ce929cc..03d33bb7a 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRuleReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/CreatePaperRuleReqVo.java @@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; @Data public class CreatePaperRuleReqVo { @@ -28,7 +30,7 @@ public class CreatePaperRuleReqVo { /** * 筛选题目的标签,即根据标签来筛选题目 */ - private String tags; + private List tags; /** * 该类型题目数量 diff --git a/src/main/java/club/joylink/rtss/vo/paper/FindPaperCompositionPageReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/FindPaperCompositionPageReqVo.java index adf39ba4f..99c059fa1 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/FindPaperCompositionPageReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/FindPaperCompositionPageReqVo.java @@ -32,10 +32,10 @@ public class FindPaperCompositionPageReqVo extends PageQueryVO { */ private Boolean nameLike = true; /** - * 项目code
+ * 组织id
* 选填
*/ - private String projectCode; + private String companyId; /** * 项目code--是否模糊查询,默认false
* 选填
diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperCommonQuestionVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperCommonQuestionVo.java new file mode 100644 index 000000000..f0cf15055 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperCommonQuestionVo.java @@ -0,0 +1,71 @@ +package club.joylink.rtss.vo.paper; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.List; + +@Data +public class PaperCommonQuestionVo { + /** + * 理论题id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 类型 选择题=select,判断题=judge,多选题=multi + */ + private PaperQType.SubType type; + + /** + * 创建者id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long createUserId; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 项目code + */ + private String projectCode; + + /** + * 公司组织id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long companyId; + + /** + * 标签 + */ + private String raceLable; + /** + *题目 + */ + private String question; + /** + *选项列表 + */ + private List optionList; + /** + * 题目选项 + */ + @Data + public static class OptionVo{ + /** + * 选项编号 + */ + private int id; + /** + * 选项内容 + */ + private String content; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionBasicVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionBasicVo.java index 89a8f66da..44d9828e5 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionBasicVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionBasicVo.java @@ -25,7 +25,7 @@ public class PaperCompositionBasicVo { private String profile; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; } diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperQuestionLoadRspVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperQuestionLoadRspVo.java index 941eca87e..1f41e2d5c 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperQuestionLoadRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperQuestionLoadRspVo.java @@ -21,6 +21,14 @@ public class PaperQuestionLoadRspVo { * 试题类型:1-理论题,2-实训题 */ private PaperQType.GroupType type; + /** + * 加载到的实训试题 + */ + private PaperTrainingQuestionVo training; + /** + * 加载到的理论试题 + */ + private PaperCommonQuestionVo common; } diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperRuleVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperRuleVo.java index b70098dbb..6073e8892 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperRuleVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperRuleVo.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; import javax.validation.constraints.NotNull; +import java.util.List; @Data public class PaperRuleVo { @@ -35,7 +36,7 @@ public class PaperRuleVo { /** * 筛选题目的标签,即根据标签来筛选题目 */ - private String tags; + private List tags; /** * 该类型题目数量 diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitAnswerReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitAnswerReqVo.java index 6105e56e1..bcc8595a5 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitAnswerReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitAnswerReqVo.java @@ -8,12 +8,18 @@ import javax.validation.constraints.NotNull; @Data public class PaperSubmitAnswerReqVo { + /** + * 用户试卷id + */ + @NotNull + @JsonSerialize(using = ToStringSerializer.class) + private Long puId; /** * 用户试卷试题id */ @NotNull @JsonSerialize(using = ToStringSerializer.class) - private Long id; + private Long pqId; /** * 试题类型:1-理论题,2-实训题 */ diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitAnswerRspVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitAnswerRspVo.java index 1c11fc55b..f76cefdf1 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitAnswerRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitAnswerRspVo.java @@ -8,12 +8,18 @@ import javax.validation.constraints.NotNull; @Data public class PaperSubmitAnswerRspVo { + /** + * 用户试卷id + */ + @NotNull + @JsonSerialize(using = ToStringSerializer.class) + private Long puId; /** * 用户试卷试题id */ @NotNull @JsonSerialize(using = ToStringSerializer.class) - private Long id; + private Long pqId; /** * 试题类型:1-理论题,2-实训题 */ diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitRspVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitRspVo.java index 4627dad98..5b1d3a5cb 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperSubmitRspVo.java @@ -23,9 +23,9 @@ public class PaperSubmitRspVo { */ private String name; /** - * 项目code + * 组织id */ - private String projectCode; + private String companyId; /** * 及格分 */ diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperTrainingQuestionVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperTrainingQuestionVo.java new file mode 100644 index 000000000..fd1c1a9ae --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperTrainingQuestionVo.java @@ -0,0 +1,26 @@ +package club.joylink.rtss.vo.paper; + +import lombok.Data; + +/** + * 响应实训试题 + */ +@Data +public class PaperTrainingQuestionVo { + /** + * 已发布的实训的id + */ + private Long id; + /** + * 实训名称 + */ + private String name; + /** + * 实训类型(单操 single;场景scene) + */ + private PaperQType.SubType type; + /** + * 实训描述 + */ + private String description; +} diff --git a/src/main/java/club/joylink/rtss/vo/paper/convertor/PaperRuleConvertor.java b/src/main/java/club/joylink/rtss/vo/paper/convertor/PaperRuleConvertor.java index c06d10bd8..da2daa72d 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/convertor/PaperRuleConvertor.java +++ b/src/main/java/club/joylink/rtss/vo/paper/convertor/PaperRuleConvertor.java @@ -1,40 +1,54 @@ package club.joylink.rtss.vo.paper.convertor; import club.joylink.rtss.entity.paper.PaperRule; +import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.paper.CreatePaperRuleReqVo; import club.joylink.rtss.vo.paper.PaperQType; import club.joylink.rtss.vo.paper.PaperRuleVo; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; public class PaperRuleConvertor { - public static PaperRuleVo convert(PaperRule from){ + public static PaperRuleVo convert(PaperRule from) { PaperRuleVo to = new PaperRuleVo(); to.setId(from.getId()); to.setPcId(from.getPcId()); to.setType(PaperQType.GroupType.getItem(from.getType())); to.setSubtype(PaperQType.SubType.getItem(from.getSubtype())); - to.setTags(from.getTags()); + to.setTags(JsonUtils.readCollection(from.getTags(),ArrayList.class,String.class)); to.setScore(from.getScore()); to.setSum(from.getSum()); return to; } - public static PaperRule convert(PaperRuleVo from){ + + public static PaperRule convert(PaperRuleVo from) { PaperRule to = new PaperRule(); to.setId(from.getId()); to.setPcId(from.getPcId()); to.setType(from.getType().getValue()); to.setSubtype(from.getSubtype().getValue()); - to.setTags(from.getTags()); + if (!CollectionUtils.isEmpty(from.getTags())) { + to.setTags(JsonUtils.writeValueAsString(from.getTags())); + } else { + to.setTags(JsonUtils.writeValueAsString(new ArrayList())); + } to.setScore(from.getScore()); to.setSum(from.getSum()); return to; } - public static PaperRule convert(CreatePaperRuleReqVo from){ + + public static PaperRule convert(CreatePaperRuleReqVo from) { PaperRule to = new PaperRule(); to.setPcId(from.getPcId()); to.setType(from.getType().getValue()); to.setSubtype(from.getSubtype().getValue()); - to.setTags(from.getTags()); + if (!CollectionUtils.isEmpty(from.getTags())) { + to.setTags(JsonUtils.writeValueAsString(from.getTags())); + } else { + to.setTags(JsonUtils.writeValueAsString(new ArrayList())); + } to.setScore(from.getScore()); to.setSum(from.getSum()); return to; diff --git a/src/main/resources/mybatis/mapper/PaperCompositionDAO.xml b/src/main/resources/mybatis/mapper/PaperCompositionDAO.xml index 04be99f98..66d2134da 100644 --- a/src/main/resources/mybatis/mapper/PaperCompositionDAO.xml +++ b/src/main/resources/mybatis/mapper/PaperCompositionDAO.xml @@ -5,7 +5,7 @@ - + @@ -74,7 +74,7 @@ - id, `name`, profile, project_code, start_time, end_time, valid_duration, pass_score, + id, `name`, profile, company_id, start_time, end_time, valid_duration, pass_score, creator_id, create_time, update_time, `state` select @@ -113,11 +113,11 @@ insert into paper_user (id, user_id, pc_id, - project_code, score, start_time, + company_id, score, start_time, end_time, cause, create_time ) values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{pcId,jdbcType=BIGINT}, - #{projectCode,jdbcType=VARCHAR}, #{score,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, + #{companyId,jdbcType=VARCHAR}, #{score,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{cause,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP} ) @@ -133,8 +133,8 @@ pc_id, - - project_code, + + company_id, score, @@ -162,8 +162,8 @@ #{pcId,jdbcType=BIGINT}, - - #{projectCode,jdbcType=VARCHAR}, + + #{companyId,jdbcType=VARCHAR}, #{score,jdbcType=INTEGER}, @@ -200,8 +200,8 @@ pc_id = #{record.pcId,jdbcType=BIGINT}, - - project_code = #{record.projectCode,jdbcType=VARCHAR}, + + company_id = #{record.companyId,jdbcType=VARCHAR}, score = #{record.score,jdbcType=INTEGER}, @@ -228,7 +228,7 @@ set id = #{record.id,jdbcType=BIGINT}, user_id = #{record.userId,jdbcType=BIGINT}, pc_id = #{record.pcId,jdbcType=BIGINT}, - project_code = #{record.projectCode,jdbcType=VARCHAR}, + company_id = #{record.companyId,jdbcType=VARCHAR}, score = #{record.score,jdbcType=INTEGER}, start_time = #{record.startTime,jdbcType=TIMESTAMP}, end_time = #{record.endTime,jdbcType=TIMESTAMP}, @@ -247,8 +247,8 @@ pc_id = #{pcId,jdbcType=BIGINT}, - - project_code = #{projectCode,jdbcType=VARCHAR}, + + company_id = #{companyId,jdbcType=VARCHAR}, score = #{score,jdbcType=INTEGER}, @@ -272,7 +272,7 @@ update paper_user set user_id = #{userId,jdbcType=BIGINT}, pc_id = #{pcId,jdbcType=BIGINT}, - project_code = #{projectCode,jdbcType=VARCHAR}, + company_id = #{companyId,jdbcType=VARCHAR}, score = #{score,jdbcType=INTEGER}, start_time = #{startTime,jdbcType=TIMESTAMP}, end_time = #{endTime,jdbcType=TIMESTAMP}, diff --git a/src/main/resources/mybatis/mapper/PaperUserQuestionDAO.xml b/src/main/resources/mybatis/mapper/PaperUserQuestionDAO.xml index 118f0341b..6132aa104 100644 --- a/src/main/resources/mybatis/mapper/PaperUserQuestionDAO.xml +++ b/src/main/resources/mybatis/mapper/PaperUserQuestionDAO.xml @@ -4,7 +4,7 @@ - + @@ -68,7 +68,7 @@ - id, pu_id, project_code, `type`, question_id, `state` + id, pu_id, company_id, `type`, question_id, `state`