|
@@ -2,12 +2,18 @@ package cn.com.qmth.examcloud.core.examwork.api.provider;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.BeanCopierUtil;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentDTO;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
|
|
@@ -29,31 +35,54 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
|
|
|
ExamStudentCloudService {
|
|
|
|
|
|
@Autowired
|
|
|
- private ExamStudentService examStudentService;
|
|
|
+ ExamStudentService examStudentService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ExamStudentRepo examStudentRepo;
|
|
|
+ ExamStudentRepo examStudentRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrgCloudService orgCloudService;
|
|
|
|
|
|
@Override
|
|
|
- public void saveExamStudent(SaveExamStudentReq examStudentReq) {
|
|
|
+ public void saveExamStudent(SaveExamStudentReq req) {
|
|
|
+
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ GetOrgReq getOrgReq = new GetOrgReq();
|
|
|
+ getOrgReq.setOrgId(rootOrgId);
|
|
|
+ GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
|
|
|
+ OrgBean rootOrg = getOrgResp.getOrg();
|
|
|
+ if (!rootOrg.getParentId().equals(0L)) {
|
|
|
+ throw new StatusException("E-100001", "rootOrgId is wrong");
|
|
|
+ }
|
|
|
+
|
|
|
+ String studentCode = req.getStudentCode();
|
|
|
+ String identityNumber = req.getIdentityNumber();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(studentCode)) {
|
|
|
+ throw new StatusException("E-100002", "studentCode is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(identityNumber)) {
|
|
|
+ throw new StatusException("E-100003", "identityNumber is null");
|
|
|
+ }
|
|
|
+
|
|
|
ExamStudentDTO examStudentDto = new ExamStudentDTO();
|
|
|
- examStudentDto.setExamId(examStudentReq.getExamId());
|
|
|
- examStudentDto.setCourseCode(examStudentReq.getCourseCode());
|
|
|
- examStudentDto.setIdentityNumber(examStudentReq.getIdentityNumber());
|
|
|
+ examStudentDto.setExamId(req.getExamId());
|
|
|
+ examStudentDto.setCourseCode(req.getCourseCode());
|
|
|
+ examStudentDto.setIdentityNumber(req.getIdentityNumber());
|
|
|
List<ExamStudent> examStudents = examStudentService.getAllExamStudent(examStudentDto);
|
|
|
if (examStudents != null && examStudents.size() > 0) {
|
|
|
ExamStudent examStudentOld = examStudents.get(0);
|
|
|
// 更新相关的姓名、学习中心、专业
|
|
|
- examStudentOld.setName(examStudentReq.getStudentName());
|
|
|
- examStudentOld.setOrgId(examStudentReq.getOrgId());
|
|
|
- examStudentOld.setOrgCode(examStudentReq.getOrgCode());
|
|
|
- examStudentOld.setOrgName(examStudentReq.getOrgName());
|
|
|
- examStudentOld.setRootOrgId(examStudentReq.getRootOrgId());
|
|
|
- examStudentOld.setSpecialtyName(examStudentReq.getSpecialtyName());
|
|
|
+ // examStudentOld.setName(examStudentReq.getStudentName());
|
|
|
+ // examStudentOld.setOrgId(examStudentReq.getOrgId());
|
|
|
+ // examStudentOld.setOrgCode(examStudentReq.getOrgCode());
|
|
|
+ // examStudentOld.setOrgName(examStudentReq.getOrgName());
|
|
|
+ // examStudentOld.setRootOrgId(examStudentReq.getRootOrgId());
|
|
|
+ // examStudentOld.setSpecialtyName(examStudentReq.getSpecialtyName());
|
|
|
examStudentRepo.save(examStudentOld);
|
|
|
} else {
|
|
|
- ExamStudent examStudent = BeanCopierUtil.copyProperties(examStudentReq,
|
|
|
- ExamStudent.class);
|
|
|
+ ExamStudent examStudent = BeanCopierUtil.copyProperties(req, ExamStudent.class);
|
|
|
examStudent.setFinished(false);
|
|
|
examStudentRepo.save(examStudent);
|
|
|
}
|