修复学生签到验证接口及业务异常处理
parent
d827f191e6
commit
e2ea71e939
|
|
@ -38,7 +38,7 @@ public class AppStudentSignController {
|
||||||
return studentSignService.add(cmd);
|
return studentSignService.add(cmd);
|
||||||
}
|
}
|
||||||
@ApiOperation("验证是否可签到")
|
@ApiOperation("验证是否可签到")
|
||||||
@GetMapping("/verify")
|
@PostMapping("/verify")
|
||||||
public SingleResponse<StudentCO> verify(@RequestBody StudentSignVerifyQry qry) {
|
public SingleResponse<StudentCO> verify(@RequestBody StudentSignVerifyQry qry) {
|
||||||
return studentSignService.verify(qry);
|
return studentSignService.verify(qry);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.zcloud.edu.command.query.resource;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.alibaba.cola.dto.PageResponse;
|
import com.alibaba.cola.dto.PageResponse;
|
||||||
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||||
import com.zcloud.edu.command.convertor.resource.ExamPaperCoConvertor;
|
import com.zcloud.edu.command.convertor.resource.ExamPaperCoConvertor;
|
||||||
import com.zcloud.edu.command.convertor.resource.QuestionCoConvertor;
|
import com.zcloud.edu.command.convertor.resource.QuestionCoConvertor;
|
||||||
|
|
@ -84,7 +85,7 @@ public class ExamPaperQueryExe {
|
||||||
public ExamPaperCO getInfoById(Long id) {
|
public ExamPaperCO getInfoById(Long id) {
|
||||||
ExamPaperDO examPaperDO =examPaperRepository.getInfoById(id);
|
ExamPaperDO examPaperDO =examPaperRepository.getInfoById(id);
|
||||||
if(examPaperDO==null){
|
if(examPaperDO==null){
|
||||||
throw new RuntimeException("试卷不存在");
|
throw new BizException("试卷不存在");
|
||||||
}
|
}
|
||||||
ExamPaperCO examPaperCO =new ExamPaperCO();
|
ExamPaperCO examPaperCO =new ExamPaperCO();
|
||||||
BeanUtil.copyProperties(examPaperDO,examPaperCO);
|
BeanUtil.copyProperties(examPaperDO,examPaperCO);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.alibaba.cola.dto.MultiResponse;
|
||||||
import com.alibaba.cola.dto.PageResponse;
|
import com.alibaba.cola.dto.PageResponse;
|
||||||
import com.alibaba.cola.dto.Response;
|
import com.alibaba.cola.dto.Response;
|
||||||
import com.alibaba.cola.dto.SingleResponse;
|
import com.alibaba.cola.dto.SingleResponse;
|
||||||
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.zcloud.edu.command.convertor.study.StudentSignCoConvertor;
|
import com.zcloud.edu.command.convertor.study.StudentSignCoConvertor;
|
||||||
import com.zcloud.edu.domain.model.study.ClassE;
|
import com.zcloud.edu.domain.model.study.ClassE;
|
||||||
import com.zcloud.edu.dto.clientobject.study.StudentCO;
|
import com.zcloud.edu.dto.clientobject.study.StudentCO;
|
||||||
|
|
@ -74,10 +75,10 @@ public class StudentSignQueryExe {
|
||||||
classE.isBegin();
|
classE.isBegin();
|
||||||
StudentDO studentDO = studentRepository.findByClassIdAndPhone(classDO.getClassId(), qry.getPhone());
|
StudentDO studentDO = studentRepository.findByClassIdAndPhone(classDO.getClassId(), qry.getPhone());
|
||||||
if (studentDO == null){
|
if (studentDO == null){
|
||||||
throw new RuntimeException("您不在此班级中");
|
throw new BizException("您不在此班级中");
|
||||||
}
|
}
|
||||||
if(studentDO.getState() == 1){
|
if(studentDO.getState() == 1){
|
||||||
throw new RuntimeException("您已经完成此班级的学习");
|
throw new BizException("您已经完成此班级的学习");
|
||||||
}
|
}
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("studentId", studentDO.getStudentId());
|
params.put("studentId", studentDO.getStudentId());
|
||||||
|
|
@ -85,12 +86,12 @@ public class StudentSignQueryExe {
|
||||||
if (qry.getType() == 1){
|
if (qry.getType() == 1){
|
||||||
List<StudentSignDO> list = studentSignRepository.listAllByStudentId(params);
|
List<StudentSignDO> list = studentSignRepository.listAllByStudentId(params);
|
||||||
if (list != null && list.size() > 0){
|
if (list != null && list.size() > 0){
|
||||||
throw new RuntimeException("您已签到");
|
throw new BizException("您已签到");
|
||||||
}
|
}
|
||||||
} else if (qry.getType() == 2){
|
} else if (qry.getType() == 2){
|
||||||
List<StudentExamRecordDO> list = studentExamRecordRepository.listAllByStudentId(studentDO.getStudentId());
|
List<StudentExamRecordDO> list = studentExamRecordRepository.listAllByStudentId(studentDO.getStudentId());
|
||||||
if (list != null && list.size() == classDO.getNumberofexams()){
|
if (list != null && list.size() == classDO.getNumberofexams()){
|
||||||
throw new RuntimeException("您已经没有考试次数");
|
throw new BizException("您已经没有考试次数");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StudentCO studentCO = new StudentCO();
|
StudentCO studentCO = new StudentCO();
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class ExamPaperRemoveExe {
|
||||||
public boolean execute(Long id) {
|
public boolean execute(Long id) {
|
||||||
ExamPaperDO examPaperDO = examPaperRepository.getById(id);
|
ExamPaperDO examPaperDO = examPaperRepository.getById(id);
|
||||||
if(examPaperDO==null){
|
if(examPaperDO==null){
|
||||||
throw new RuntimeException("试卷不存在");
|
throw new BizException("试卷不存在");
|
||||||
}
|
}
|
||||||
//企业端禁用:所属单位为股份的不能禁用
|
//企业端禁用:所属单位为股份的不能禁用
|
||||||
//股份端禁用:所属单位为各企业的不能禁用
|
//股份端禁用:所属单位为各企业的不能禁用
|
||||||
|
|
@ -70,7 +70,7 @@ public class ExamPaperRemoveExe {
|
||||||
|
|
||||||
List<ExamPaperDO> examPaperDOList =examPaperRepository.getListByIdList(examPaperRemoveCmd.getIds());
|
List<ExamPaperDO> examPaperDOList =examPaperRepository.getListByIdList(examPaperRemoveCmd.getIds());
|
||||||
if(CollUtil.isEmpty(examPaperDOList)){
|
if(CollUtil.isEmpty(examPaperDOList)){
|
||||||
throw new RuntimeException("试卷不存在");
|
throw new BizException("试卷不存在");
|
||||||
}
|
}
|
||||||
//获取试卷idlist
|
//获取试卷idlist
|
||||||
List<String> examPaperIdList = examPaperDOList.stream().map(ExamPaperDO::getExamPaperId).collect(Collectors.toList());
|
List<String> examPaperIdList = examPaperDOList.stream().map(ExamPaperDO::getExamPaperId).collect(Collectors.toList());
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class StudentSignAddExe {
|
||||||
StudentDO student = studentRepository.findFaceUrlByPhone(stu.getPhone());
|
StudentDO student = studentRepository.findFaceUrlByPhone(stu.getPhone());
|
||||||
|
|
||||||
if (student == null || ObjectUtils.isEmpty(student.getUserAvatarUrl())) {
|
if (student == null || ObjectUtils.isEmpty(student.getUserAvatarUrl())) {
|
||||||
throw new RuntimeException("您还没有录入人脸");
|
throw new BizException("您还没有录入人脸");
|
||||||
}
|
}
|
||||||
String faceUrl = null;
|
String faceUrl = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -64,35 +64,35 @@ public class QuestionE extends BaseE {
|
||||||
if (CoursewareTypeEnum.VIDEO_COURSEWARE.getCode().equals(questionE.getCoursewareType())) {
|
if (CoursewareTypeEnum.VIDEO_COURSEWARE.getCode().equals(questionE.getCoursewareType())) {
|
||||||
// 视频课件
|
// 视频课件
|
||||||
if (questionE.getVideoCoursewareId() == null) {
|
if (questionE.getVideoCoursewareId() == null) {
|
||||||
throw new RuntimeException("请选择正确的视频课件");
|
throw new BizException("请选择正确的视频课件");
|
||||||
}
|
}
|
||||||
} else if (CoursewareTypeEnum.EXAM_QUESTION.getCode().equals(questionE.getCoursewareType())) {
|
} else if (CoursewareTypeEnum.EXAM_QUESTION.getCode().equals(questionE.getCoursewareType())) {
|
||||||
// 试卷习题
|
// 试卷习题
|
||||||
if (questionE.getExamPaperId() == null) {
|
if (questionE.getExamPaperId() == null) {
|
||||||
throw new RuntimeException("请选择正确的试卷");
|
throw new BizException("请选择正确的试卷");
|
||||||
}
|
}
|
||||||
if (questionE.getScore()==null) {
|
if (questionE.getScore()==null) {
|
||||||
throw new RuntimeException("请填写正确的分值");
|
throw new BizException("请填写正确的分值");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("请选择正确的课件类型");
|
throw new BizException("请选择正确的课件类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QuestionTypeEnum.CHOICE.getCode().equals(questionE.getQuestionType())) {
|
if (QuestionTypeEnum.CHOICE.getCode().equals(questionE.getQuestionType())) {
|
||||||
// 单选题
|
// 单选题
|
||||||
if (questionE.getOptionA() == null || questionE.getOptionB() == null || questionE.getOptionC() == null || questionE.getOptionD() == null) {
|
if (questionE.getOptionA() == null || questionE.getOptionB() == null || questionE.getOptionC() == null || questionE.getOptionD() == null) {
|
||||||
throw new RuntimeException("单选题选项不能为空");
|
throw new BizException("单选题选项不能为空");
|
||||||
}
|
}
|
||||||
} else if (QuestionTypeEnum.MULTIPLE.getCode().equals(questionE.getQuestionType())) {
|
} else if (QuestionTypeEnum.MULTIPLE.getCode().equals(questionE.getQuestionType())) {
|
||||||
// 多选题
|
// 多选题
|
||||||
if (questionE.getOptionA() == null || questionE.getOptionB() == null || questionE.getOptionC() == null || questionE.getOptionD() == null) {
|
if (questionE.getOptionA() == null || questionE.getOptionB() == null || questionE.getOptionC() == null || questionE.getOptionD() == null) {
|
||||||
throw new RuntimeException("多选题选项不能为空");
|
throw new BizException("多选题选项不能为空");
|
||||||
}
|
}
|
||||||
} else if (QuestionTypeEnum.JUDGE.getCode().equals(questionE.getQuestionType())) {
|
} else if (QuestionTypeEnum.JUDGE.getCode().equals(questionE.getQuestionType())) {
|
||||||
|
|
||||||
// 判断题
|
// 判断题
|
||||||
if (questionE.getOptionA() == null || questionE.getOptionB() == null) {
|
if (questionE.getOptionA() == null || questionE.getOptionB() == null) {
|
||||||
throw new RuntimeException("判断题选项不能为空");
|
throw new BizException("判断题选项不能为空");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.zcloud.edu.domain.model.study;
|
package com.zcloud.edu.domain.model.study;
|
||||||
|
|
||||||
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.jjb.saas.framework.domain.model.BaseE;
|
import com.jjb.saas.framework.domain.model.BaseE;
|
||||||
import com.zcloud.gbscommon.utils.DateUtil;
|
import com.zcloud.gbscommon.utils.DateUtil;
|
||||||
import com.zcloud.gbscommon.utils.Tools;
|
import com.zcloud.gbscommon.utils.Tools;
|
||||||
|
|
@ -7,6 +8,7 @@ import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.zip.ZipException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web-domain
|
* web-domain
|
||||||
|
|
@ -106,9 +108,9 @@ public class ClassE extends BaseE {
|
||||||
*/
|
*/
|
||||||
public void isBegin(){
|
public void isBegin(){
|
||||||
if(DateUtil.isBeforeThan(this.startTime)){
|
if(DateUtil.isBeforeThan(this.startTime)){
|
||||||
throw new RuntimeException("班级未开班");
|
throw new BizException("班级未开班");
|
||||||
} else if(DateUtil.isAfter(this.endTime)){
|
} else if(DateUtil.isAfter(this.endTime)){
|
||||||
throw new RuntimeException("班级已结束");
|
throw new BizException("班级已结束");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue