Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin
This commit is contained in:
commit
153fed2ef2
@ -0,0 +1,38 @@
|
|||||||
|
package club.joylink.rtss.exception;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum PaperExceptionAssert implements BusinessExceptionAssert {
|
||||||
|
PcExisted(60000,"试卷定义已经存在"),
|
||||||
|
PcNotExisted(60001,"试卷定义不存在"),
|
||||||
|
PcCanModify(60002,"试卷定义可以编辑修改"),
|
||||||
|
PcStoreSuccess(60003,"试卷定义存储成功"),
|
||||||
|
PrExisted(60004,"试卷规则存在"),
|
||||||
|
PrNotExisted(60005,"试卷规则不存在"),
|
||||||
|
PuExisted(60006,"用户试卷已经存在"),
|
||||||
|
PuNotExisted(60007,"用户试卷不存在"),
|
||||||
|
PcCanCreatePu(60008,"试卷定义可以生成用户试卷"),
|
||||||
|
PcCantCreatePu(60008,"试卷定义不可以生成用户试卷"),
|
||||||
|
PcNotHavePr(60009,"试卷定义没有试卷规则"),
|
||||||
|
PcHavePr(60010,"试卷定义有试卷规则"),
|
||||||
|
PqNotEnough(60011,"没有充足的符合试卷定义的试题"),
|
||||||
|
PqEnough(60012,"有充足的符合试卷定义的试题"),
|
||||||
|
PuNotStart(60013,"用户未开始答题"),
|
||||||
|
PuStart(60014,"用户开始答题"),
|
||||||
|
PuSubmit(60015,"用户已经交卷"),
|
||||||
|
PuNotSubmit(60016,"用户未交卷"),
|
||||||
|
PqExisted(60017,"试卷试题存在"),
|
||||||
|
PuqHaveTime(60018,"用户答题截止时间未到"),
|
||||||
|
PuqCanSubmit(60019,"用户可以提交试题答案")
|
||||||
|
;
|
||||||
|
|
||||||
|
int code;
|
||||||
|
|
||||||
|
String message;
|
||||||
|
|
||||||
|
private PaperExceptionAssert(int code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ import club.joylink.rtss.entity.paper.PaperComposition;
|
|||||||
import club.joylink.rtss.entity.paper.PaperCompositionExample;
|
import club.joylink.rtss.entity.paper.PaperCompositionExample;
|
||||||
import club.joylink.rtss.entity.paper.PaperRule;
|
import club.joylink.rtss.entity.paper.PaperRule;
|
||||||
import club.joylink.rtss.entity.paper.PaperRuleExample;
|
import club.joylink.rtss.entity.paper.PaperRuleExample;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.PaperExceptionAssert;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
import club.joylink.rtss.vo.paper.*;
|
import club.joylink.rtss.vo.paper.*;
|
||||||
@ -38,7 +38,7 @@ public class PaperCompositionService {
|
|||||||
public CreatePaperCompositionRspVo createPaperComposition(CreatePaperCompositionReqVo req, AccountVO user) {
|
public CreatePaperCompositionRspVo createPaperComposition(CreatePaperCompositionReqVo req, AccountVO user) {
|
||||||
//根据项目和名称来查,如果存在则结束
|
//根据项目和名称来查,如果存在则结束
|
||||||
List<PaperComposition> pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName());
|
List<PaperComposition> pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName());
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(pcList), "试卷定义已经存在:companyId=" + req.getCompanyId() + " name=" + req.getName());
|
PaperExceptionAssert.PcNotExisted.assertTrue(CollectionUtils.isEmpty(pcList), "试卷定义已经存在:companyId=" + req.getCompanyId() + " name=" + req.getName());
|
||||||
//
|
//
|
||||||
PaperComposition newPc = new PaperComposition();
|
PaperComposition newPc = new PaperComposition();
|
||||||
newPc.setName(req.getName());
|
newPc.setName(req.getName());
|
||||||
@ -49,7 +49,7 @@ public class PaperCompositionService {
|
|||||||
newPc.setCreatorId(user.getId());
|
newPc.setCreatorId(user.getId());
|
||||||
newPc.setState(PaperCompositionState.Editing.getValue());
|
newPc.setState(PaperCompositionState.Editing.getValue());
|
||||||
int newRt = compositionDAO.insertSelective(newPc);
|
int newRt = compositionDAO.insertSelective(newPc);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(newRt > 0, "存储试卷定义失败");
|
PaperExceptionAssert.PcStoreSuccess.assertTrue(newRt > 0, "存储试卷定义失败");
|
||||||
//
|
//
|
||||||
pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName());
|
pcList = this.findCompositionByCompanyIdAndName(req.getCompanyId(), req.getName());
|
||||||
newPc = pcList.get(0);
|
newPc = pcList.get(0);
|
||||||
@ -75,7 +75,7 @@ public class PaperCompositionService {
|
|||||||
boolean exist = pcList.stream().anyMatch(c -> {
|
boolean exist = pcList.stream().anyMatch(c -> {
|
||||||
return c.getId().compareTo(curPc.getId()) != 0;
|
return c.getId().compareTo(curPc.getId()) != 0;
|
||||||
});
|
});
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(exist, "试卷定义已经存在:companyId=" + req.getCompanyId() + " name=" + req.getName());
|
PaperExceptionAssert.PcExisted.assertNotTrue(exist, "试卷定义已经存在:companyId=" + req.getCompanyId() + " name=" + req.getName());
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
curPc.setName(req.getName());
|
curPc.setName(req.getName());
|
||||||
@ -110,7 +110,7 @@ public class PaperCompositionService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void lockPaperComposition(Long pcId, AccountVO user) {
|
public void lockPaperComposition(Long pcId, AccountVO user) {
|
||||||
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != curPc && PaperCompositionState.Editing.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义存在或非编辑中");
|
PaperExceptionAssert.PcCanModify.assertTrue(null != curPc && PaperCompositionState.Editing.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或非编辑中");
|
||||||
//
|
//
|
||||||
PaperComposition nPc = new PaperComposition();
|
PaperComposition nPc = new PaperComposition();
|
||||||
nPc.setId(curPc.getId());
|
nPc.setId(curPc.getId());
|
||||||
@ -124,26 +124,28 @@ public class PaperCompositionService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void unlockPaperComposition(Long pcId, AccountVO user) {
|
public void unlockPaperComposition(Long pcId, AccountVO user) {
|
||||||
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != curPc && PaperCompositionState.Locked.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义存在或非封存中");
|
PaperExceptionAssert.PcCanModify.assertTrue(null != curPc && PaperCompositionState.Locked.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或非封存中");
|
||||||
//
|
//
|
||||||
PaperComposition nPc = new PaperComposition();
|
PaperComposition nPc = new PaperComposition();
|
||||||
nPc.setId(curPc.getId());
|
nPc.setId(curPc.getId());
|
||||||
nPc.setState(PaperCompositionState.Editing.getValue());
|
nPc.setState(PaperCompositionState.Editing.getValue());
|
||||||
compositionDAO.updateByPrimaryKeySelective(nPc);
|
compositionDAO.updateByPrimaryKeySelective(nPc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标记已封存的试卷已使用
|
* 标记已封存的试卷已使用
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void usePaperComposition(Long pcId) {
|
public void usePaperComposition(Long pcId) {
|
||||||
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
||||||
if(PaperCompositionState.Locked.equals(PaperCompositionState.getItem(curPc.getState()))){
|
if (PaperCompositionState.Locked.equals(PaperCompositionState.getItem(curPc.getState()))) {
|
||||||
PaperComposition nPc = new PaperComposition();
|
PaperComposition nPc = new PaperComposition();
|
||||||
nPc.setId(curPc.getId());
|
nPc.setId(curPc.getId());
|
||||||
nPc.setState(PaperCompositionState.Used.getValue());
|
nPc.setState(PaperCompositionState.Used.getValue());
|
||||||
compositionDAO.updateByPrimaryKeySelective(nPc);
|
compositionDAO.updateByPrimaryKeySelective(nPc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除试卷蓝图(只能删除处于编辑状态的)
|
* 删除试卷蓝图(只能删除处于编辑状态的)
|
||||||
*
|
*
|
||||||
@ -176,7 +178,7 @@ public class PaperCompositionService {
|
|||||||
* 断言试卷蓝图可以修改
|
* 断言试卷蓝图可以修改
|
||||||
*/
|
*/
|
||||||
public void assertPaperCompositionCanModify(PaperComposition curPc) {
|
public void assertPaperCompositionCanModify(PaperComposition curPc) {
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != curPc && PaperCompositionState.Editing.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或状态非编辑中,不能修改,pcId = " + curPc.getId());
|
PaperExceptionAssert.PcCanModify.assertTrue(null != curPc && PaperCompositionState.Editing.equals(PaperCompositionState.getItem(curPc.getState())), "试卷定义不存在或状态非编辑中,不能修改,pcId = " + curPc.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,14 +190,14 @@ public class PaperCompositionService {
|
|||||||
PaperCompositionExample.Criteria pcExCriteria = pcEx.createCriteria();
|
PaperCompositionExample.Criteria pcExCriteria = pcEx.createCriteria();
|
||||||
if (null != req.getName()) {
|
if (null != req.getName()) {
|
||||||
if (req.getNameLike()) {
|
if (req.getNameLike()) {
|
||||||
pcExCriteria.andNameLike(String.format("%%%s%%",req.getName()));
|
pcExCriteria.andNameLike(String.format("%%%s%%", req.getName()));
|
||||||
} else {
|
} else {
|
||||||
pcExCriteria.andNameEqualTo(req.getName());
|
pcExCriteria.andNameEqualTo(req.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != req.getProfile()) {
|
if (null != req.getProfile()) {
|
||||||
if (req.getProfileLike()) {
|
if (req.getProfileLike()) {
|
||||||
pcExCriteria.andProfileLike(String.format("%%%s%%",req.getProfile()));
|
pcExCriteria.andProfileLike(String.format("%%%s%%", req.getProfile()));
|
||||||
} else {
|
} else {
|
||||||
pcExCriteria.andProfileEqualTo(req.getProfile());
|
pcExCriteria.andProfileEqualTo(req.getProfile());
|
||||||
}
|
}
|
||||||
@ -254,7 +256,7 @@ public class PaperCompositionService {
|
|||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public PaperCompositionVo findPaperComposition(Long pcId, AccountVO user) {
|
public PaperCompositionVo findPaperComposition(Long pcId, AccountVO user) {
|
||||||
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(curPc, "试卷定义不存在:id=" + pcId);
|
PaperExceptionAssert.PcExisted.assertTrue(null != curPc, "试卷定义不存在:id=" + pcId);
|
||||||
List<PaperRule> paperRuleList = this.findRuleByPcId(pcId);
|
List<PaperRule> paperRuleList = this.findRuleByPcId(pcId);
|
||||||
//
|
//
|
||||||
PaperCompositionVo rt = PaperCompositionConvertor.convert(curPc, paperRuleList);
|
PaperCompositionVo rt = PaperCompositionConvertor.convert(curPc, paperRuleList);
|
||||||
|
@ -5,7 +5,7 @@ import club.joylink.rtss.dao.paper.PaperRuleDAO;
|
|||||||
import club.joylink.rtss.entity.paper.PaperComposition;
|
import club.joylink.rtss.entity.paper.PaperComposition;
|
||||||
import club.joylink.rtss.entity.paper.PaperRule;
|
import club.joylink.rtss.entity.paper.PaperRule;
|
||||||
import club.joylink.rtss.entity.paper.PaperRuleExample;
|
import club.joylink.rtss.entity.paper.PaperRuleExample;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.PaperExceptionAssert;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.paper.CreatePaperRuleReqVo;
|
import club.joylink.rtss.vo.paper.CreatePaperRuleReqVo;
|
||||||
import club.joylink.rtss.vo.paper.PaperQType;
|
import club.joylink.rtss.vo.paper.PaperQType;
|
||||||
@ -35,7 +35,7 @@ public class PaperRuleService {
|
|||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
private void assertPaperCompositionRuleCanModify(Long ruleId) {
|
private void assertPaperCompositionRuleCanModify(Long ruleId) {
|
||||||
PaperRule rule = ruleDAO.selectByPrimaryKey(ruleId);
|
PaperRule rule = ruleDAO.selectByPrimaryKey(ruleId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(rule);
|
PaperExceptionAssert.PrExisted.assertNotNull(rule);
|
||||||
//
|
//
|
||||||
compositionService.assertPaperCompositionCanModify(rule.getPcId());
|
compositionService.assertPaperCompositionCanModify(rule.getPcId());
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class PaperRuleService {
|
|||||||
PaperRuleExample example = new PaperRuleExample();
|
PaperRuleExample example = new PaperRuleExample();
|
||||||
example.createCriteria().andPcIdEqualTo(pcId).andSubtypeEqualTo(ruleType.getValue());
|
example.createCriteria().andPcIdEqualTo(pcId).andSubtypeEqualTo(ruleType.getValue());
|
||||||
List<PaperRule> list = ruleDAO.selectByExample(example);
|
List<PaperRule> list = ruleDAO.selectByExample(example);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(list),String.format("试卷定义(pcId=%s)的规则(%s)已经存在",pcId,ruleType.name()));
|
PaperExceptionAssert.PrNotExisted.assertTrue(CollectionUtils.isEmpty(list),String.format("试卷定义(pcId=%s)的规则(%s)已经存在",pcId,ruleType.name()));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 更新(保存)试卷蓝图的规则
|
* 更新(保存)试卷蓝图的规则
|
||||||
@ -76,7 +76,7 @@ public class PaperRuleService {
|
|||||||
assertPaperCompositionRuleCanModify(req.getId());
|
assertPaperCompositionRuleCanModify(req.getId());
|
||||||
//
|
//
|
||||||
PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getPcId());
|
PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getPcId());
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(curPc, "试卷定义不存在:id=" + req.getPcId());
|
PaperExceptionAssert.PcExisted.assertNotNull(curPc, "试卷定义不存在:id=" + req.getPcId());
|
||||||
//
|
//
|
||||||
PaperRule updateRule = ruleDAO.selectByPrimaryKey(req.getId());//需要更新的规则
|
PaperRule updateRule = ruleDAO.selectByPrimaryKey(req.getId());//需要更新的规则
|
||||||
PaperRuleExample findRuleEx = new PaperRuleExample();
|
PaperRuleExample findRuleEx = new PaperRuleExample();
|
||||||
@ -87,7 +87,7 @@ public class PaperRuleService {
|
|||||||
ruleDAO.updateByPrimaryKeySelective(rule);
|
ruleDAO.updateByPrimaryKeySelective(rule);
|
||||||
}else{//类型不变,更新
|
}else{//类型不变,更新
|
||||||
PaperRule findRule = findRuleList.get(0);
|
PaperRule findRule = findRuleList.get(0);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(updateRule.getId().compareTo(findRule.getId())==0,String.format("试卷定义规则已经存在,pcId=%s type=%s subType=%s",req.getPcId(),req.getType().name(),req.getSubtype().name()));
|
PaperExceptionAssert.PrNotExisted.assertTrue(updateRule.getId().compareTo(findRule.getId())==0,String.format("试卷定义规则已经存在,pcId=%s type=%s subType=%s",req.getPcId(),req.getType().name(),req.getSubtype().name()));
|
||||||
ruleDAO.updateByPrimaryKeySelective(rule);
|
ruleDAO.updateByPrimaryKeySelective(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import club.joylink.rtss.entity.paper.question.PaperQuestion;
|
|||||||
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
|
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.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.PaperExceptionAssert;
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.paper.CreatePaperRspVo;
|
import club.joylink.rtss.vo.paper.CreatePaperRspVo;
|
||||||
@ -21,7 +21,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -59,16 +58,16 @@ public class PaperUserCreateService {
|
|||||||
public CreatePaperRspVo createPaper(Long pcId, AccountVO user) {
|
public CreatePaperRspVo createPaper(Long pcId, AccountVO user) {
|
||||||
// 检测是否创建过试卷
|
// 检测是否创建过试卷
|
||||||
PaperUser oldPu = paperUserService.findByUserIdAndPcId(user.getId(), pcId);
|
PaperUser oldPu = paperUserService.findByUserIdAndPcId(user.getId(), pcId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null == oldPu, "该用户的试卷已经存在,pcId = " + pcId);
|
PaperExceptionAssert.PcNotExisted.assertTrue(null == oldPu, "该用户的试卷已经存在,pcId = " + pcId);
|
||||||
// 校验试卷蓝图
|
// 校验试卷蓝图
|
||||||
PaperComposition composition = compositionDAO.selectByPrimaryKey(pcId);
|
PaperComposition composition = compositionDAO.selectByPrimaryKey(pcId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(composition, "创建试卷的试卷定义不存在,pcId = " + pcId);
|
PaperExceptionAssert.PcExisted.assertNotNull(composition, "创建试卷的试卷定义不存在,pcId = " + pcId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(!PaperCompositionState.Editing.equals(PaperCompositionState.getItem(composition.getState())), "编辑中的试卷定义无法用于生成用户试卷,pcId = " + pcId);
|
PaperExceptionAssert.PcCanCreatePu.assertTrue(!PaperCompositionState.Editing.equals(PaperCompositionState.getItem(composition.getState())), "编辑中的试卷定义无法用于生成用户试卷,pcId = " + pcId);
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(now.isAfter(composition.getStartTime()) && now.isBefore(composition.getEndTime()), "当前时间未在试卷启用时间内,不能创建试卷");
|
PaperExceptionAssert.PcCanCreatePu.assertTrue(now.isAfter(composition.getStartTime()) && now.isBefore(composition.getEndTime()), "当前时间未在试卷启用时间内,不能创建试卷");
|
||||||
// 试卷蓝图规则
|
// 试卷蓝图规则
|
||||||
List<PaperRule> ruleList = compositionService.findRuleByPcId(pcId);
|
List<PaperRule> ruleList = compositionService.findRuleByPcId(pcId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(ruleList, "试卷定义没有规则定义,无法生成用户试卷,pcId = " + pcId);
|
PaperExceptionAssert.PcHavePr.assertCollectionNotEmpty(ruleList, "试卷定义没有规则定义,无法生成用户试卷,pcId = " + pcId);
|
||||||
//
|
//
|
||||||
String companyId = composition.getCompanyId();
|
String companyId = composition.getCompanyId();
|
||||||
// 标记封存的试卷蓝图已使用
|
// 标记封存的试卷蓝图已使用
|
||||||
@ -118,12 +117,12 @@ public class PaperUserCreateService {
|
|||||||
//符合条件的题目数目
|
//符合条件的题目数目
|
||||||
long count = questionDAO.countByExample(questionExample);
|
long count = questionDAO.countByExample(questionExample);
|
||||||
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
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);
|
PaperExceptionAssert.PqEnough.assertTrue(count >= qSum, "符合条件的理论题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum);
|
||||||
final String orderBy = "rand()";
|
final String orderBy = "rand()";
|
||||||
questionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, 0, qSum));
|
questionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, 0, qSum));
|
||||||
List<PaperQuestion> findRand = questionDAO.selectByExample(questionExample);
|
List<PaperQuestion> findRand = questionDAO.selectByExample(questionExample);
|
||||||
//校验最终查询到的题目数目
|
//校验最终查询到的题目数目
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(findRand.size() == qSum, "没有足够的符合条件的理论题目");
|
PaperExceptionAssert.PqEnough.assertTrue(findRand.size() == qSum, "没有足够的符合条件的理论题目");
|
||||||
//将题目与试卷关联
|
//将题目与试卷关联
|
||||||
findRand.forEach(q -> {
|
findRand.forEach(q -> {
|
||||||
PaperUserQuestion puq = new PaperUserQuestion();
|
PaperUserQuestion puq = new PaperUserQuestion();
|
||||||
@ -147,12 +146,12 @@ public class PaperUserCreateService {
|
|||||||
//符合条件的题目数目
|
//符合条件的题目数目
|
||||||
long count = trainingDAO.countByExample(questionExample);
|
long count = trainingDAO.countByExample(questionExample);
|
||||||
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
|
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);
|
PaperExceptionAssert.PqEnough.assertTrue(count >= qSum, "符合条件的实训题数目过少:pcId = " + pc.getId() + " pcName = " + pc.getName() + " companyId = " + pc.getCompanyId() + " ruleType = " + subType.name() + " ruleSum = " + qSum);
|
||||||
final String orderBy = "rand()";
|
final String orderBy = "rand()";
|
||||||
questionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, 0, qSum));
|
questionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, 0, qSum));
|
||||||
List<PublishedTraining2> findRand = trainingDAO.selectByExample(questionExample);
|
List<PublishedTraining2> findRand = trainingDAO.selectByExample(questionExample);
|
||||||
//校验最终查询到的题目数目
|
//校验最终查询到的题目数目
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(findRand.size() == qSum, "没有足够的符合条件的实训题目");
|
PaperExceptionAssert.PqEnough.assertTrue(findRand.size() == qSum, "没有足够的符合条件的实训题目");
|
||||||
//将题目与试卷关联
|
//将题目与试卷关联
|
||||||
findRand.forEach(q -> {
|
findRand.forEach(q -> {
|
||||||
PaperUserQuestion puq = new PaperUserQuestion();
|
PaperUserQuestion puq = new PaperUserQuestion();
|
||||||
|
@ -5,7 +5,7 @@ import club.joylink.rtss.dao.paper.PaperUserDAO;
|
|||||||
import club.joylink.rtss.entity.paper.PaperComposition;
|
import club.joylink.rtss.entity.paper.PaperComposition;
|
||||||
import club.joylink.rtss.entity.paper.PaperUser;
|
import club.joylink.rtss.entity.paper.PaperUser;
|
||||||
import club.joylink.rtss.entity.paper.PaperUserExample;
|
import club.joylink.rtss.entity.paper.PaperUserExample;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.PaperExceptionAssert;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
import club.joylink.rtss.vo.paper.FindPaperUserForCompositionReqVo;
|
import club.joylink.rtss.vo.paper.FindPaperUserForCompositionReqVo;
|
||||||
@ -34,7 +34,7 @@ public class PaperUserFindPageService {
|
|||||||
PageVO<PaperUserInfoVo> page = new PageVO<>();
|
PageVO<PaperUserInfoVo> page = new PageVO<>();
|
||||||
//
|
//
|
||||||
PaperComposition pc = paperCompositionDAO.selectByPrimaryKey(req.getPcId());
|
PaperComposition pc = paperCompositionDAO.selectByPrimaryKey(req.getPcId());
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(pc);
|
PaperExceptionAssert.PcExisted.assertNotNull(pc,"试卷定义不存在");
|
||||||
PaperUserExample example = new PaperUserExample();
|
PaperUserExample example = new PaperUserExample();
|
||||||
PaperUserExample.Criteria c = example.createCriteria().andPcIdEqualTo(req.getPcId());
|
PaperUserExample.Criteria c = example.createCriteria().andPcIdEqualTo(req.getPcId());
|
||||||
switch (req.getFindType()){
|
switch (req.getFindType()){
|
||||||
|
@ -7,7 +7,7 @@ import club.joylink.rtss.entity.paper.question.PaperQuestion;
|
|||||||
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
|
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.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.PaperExceptionAssert;
|
||||||
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.PaperQType;
|
||||||
import club.joylink.rtss.vo.paper.PaperQuestionState;
|
import club.joylink.rtss.vo.paper.PaperQuestionState;
|
||||||
@ -20,9 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -60,7 +57,7 @@ public class PaperUserService {
|
|||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public PaperUserWholeVo findPaperUser(Long puId, AccountVO user) {
|
public PaperUserWholeVo findPaperUser(Long puId, AccountVO user) {
|
||||||
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(paper, "用户试卷不存在");
|
PaperExceptionAssert.PuExisted.assertNotNull(paper, "用户试卷不存在");
|
||||||
//
|
//
|
||||||
PaperComposition composition = compositionDAO.selectByPrimaryKey(paper.getPcId());
|
PaperComposition composition = compositionDAO.selectByPrimaryKey(paper.getPcId());
|
||||||
List<PaperRule> ruleList = compositionService.findRuleByPcId(composition.getId());
|
List<PaperRule> ruleList = compositionService.findRuleByPcId(composition.getId());
|
||||||
@ -98,8 +95,8 @@ public class PaperUserService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void paperStart(Long puId, AccountVO user) {
|
public void paperStart(Long puId, AccountVO user) {
|
||||||
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(paper, "该用户的试卷不存在,puId = " + puId);
|
PaperExceptionAssert.PuExisted.assertNotNull(paper, "该用户的试卷不存在,puId = " + puId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNull(paper.getStartTime(), "用户已经开始答题");
|
PaperExceptionAssert.PuNotStart.assertNull(paper.getStartTime(), "用户已经开始答题");
|
||||||
PaperUser startPaper = new PaperUser();
|
PaperUser startPaper = new PaperUser();
|
||||||
startPaper.setId(puId);
|
startPaper.setId(puId);
|
||||||
startPaper.setStartTime(LocalDateTime.now());
|
startPaper.setStartTime(LocalDateTime.now());
|
||||||
@ -114,9 +111,9 @@ public class PaperUserService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public PaperSubmitRspVo paperSubmit(Long puId, AccountVO user) {
|
public PaperSubmitRspVo paperSubmit(Long puId, AccountVO user) {
|
||||||
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(paper, "该用户的试卷不存在,puId = " + puId);
|
PaperExceptionAssert.PuExisted.assertNotNull(paper, "该用户的试卷不存在,puId = " + puId);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(paper.getStartTime(), "用户未开始答题");
|
PaperExceptionAssert.PuStart.assertNotNull(paper.getStartTime(), "用户未开始答题");
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNull(paper.getEndTime(), "用户已经交卷");
|
PaperExceptionAssert.PuNotSubmit.assertNull(paper.getEndTime(), "用户已经交卷");
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
//记录交卷时间
|
//记录交卷时间
|
||||||
PaperUser endPaper = new PaperUser();
|
PaperUser endPaper = new PaperUser();
|
||||||
|
@ -10,7 +10,7 @@ import club.joylink.rtss.entity.paper.PaperUserQuestion;
|
|||||||
import club.joylink.rtss.entity.paper.PaperUserQuestionExample;
|
import club.joylink.rtss.entity.paper.PaperUserQuestionExample;
|
||||||
import club.joylink.rtss.entity.paper.question.PaperQuestion;
|
import club.joylink.rtss.entity.paper.question.PaperQuestion;
|
||||||
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
|
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.PaperExceptionAssert;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.paper.PaperQuestionState;
|
import club.joylink.rtss.vo.paper.PaperQuestionState;
|
||||||
import club.joylink.rtss.vo.paper.PaperSubmitAnswerReqVo;
|
import club.joylink.rtss.vo.paper.PaperSubmitAnswerReqVo;
|
||||||
@ -47,7 +47,7 @@ public class PaperUserSubmitAnswerService {
|
|||||||
puqExample.createCriteria().andPuIdEqualTo(req.getPuId()).andQuestionIdEqualTo(req.getPqId());
|
puqExample.createCriteria().andPuIdEqualTo(req.getPuId()).andQuestionIdEqualTo(req.getPqId());
|
||||||
final List<PaperUserQuestion> paperUserQuestionList = paperUserQuestionDAO.selectByExample(puqExample);
|
final List<PaperUserQuestion> paperUserQuestionList = paperUserQuestionDAO.selectByExample(puqExample);
|
||||||
final String pqNotExistMsg = String.format("用户试卷题目不存在,题目类型:%s 题目子类型:%s 题目id:%s 试卷id:%s",req.getType().name(),req.getSubType().name(),req.getPqId(),req.getPuId());
|
final String pqNotExistMsg = String.format("用户试卷题目不存在,题目类型:%s 题目子类型:%s 题目id:%s 试卷id:%s",req.getType().name(),req.getSubType().name(),req.getPqId(),req.getPuId());
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(paperUserQuestionList,pqNotExistMsg);
|
PaperExceptionAssert.PqExisted.assertCollectionNotEmpty(paperUserQuestionList,pqNotExistMsg);
|
||||||
//
|
//
|
||||||
final PaperUserQuestion puq = paperUserQuestionList.get(0);
|
final PaperUserQuestion puq = paperUserQuestionList.get(0);
|
||||||
//用户试卷
|
//用户试卷
|
||||||
@ -88,9 +88,9 @@ public class PaperUserSubmitAnswerService {
|
|||||||
final LocalDateTime start = pu.getStartTime();
|
final LocalDateTime start = pu.getStartTime();
|
||||||
final LocalDateTime dead = start.plusMinutes(pc.getValidDuration());
|
final LocalDateTime dead = start.plusMinutes(pc.getValidDuration());
|
||||||
//校验时间
|
//校验时间
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(now.isAfter(dead), "剩余答题时间为0");
|
PaperExceptionAssert.PuqHaveTime.assertTrue(now.isBefore(dead), "剩余答题时间为0");
|
||||||
//校验重复做题
|
//校验重复做题
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(PaperQuestionState.Undo.equals(PaperQuestionState.getItem(puq.getState())), "只有未做的题才能提交答案");
|
PaperExceptionAssert.PuqCanSubmit.assertTrue(PaperQuestionState.Undo.equals(PaperQuestionState.getItem(puq.getState())), "只有未做的题才能提交答案");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user