wangwei před 6 roky
rodič
revize
c4d127ed4d

+ 7 - 7
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamStudentController.java

@@ -51,7 +51,7 @@ import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamStudentDomain
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.Exam;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
 import io.swagger.annotations.ApiOperation;
@@ -91,7 +91,7 @@ public class ExamStudentController extends ControllerSupport {
 	 */
 	@ApiOperation(value = "查询学生的所有考试")
 	@GetMapping("/byStudentId/{studentId}")
-	public List<ExamStudent> getExamStudentListByStudentId(@PathVariable Long studentId) {
+	public List<ExamStudentEntity> getExamStudentListByStudentId(@PathVariable Long studentId) {
 
 		return examStudentRepo.findByStudentId(studentId);
 	}
@@ -110,7 +110,7 @@ public class ExamStudentController extends ControllerSupport {
 	public PageInfo<ExamStudentDomain> getExamStudentList(
 			@ModelAttribute ExamStudentDomain examCriteria, @PathVariable Integer curPage,
 			@PathVariable Integer pageSize) {
-		Specification<ExamStudent> specification = (root, query, cb) -> {
+		Specification<ExamStudentEntity> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();
 			predicates.add(cb.equal(root.get("rootOrgId"), getRootOrgId()));
 
@@ -162,11 +162,11 @@ public class ExamStudentController extends ControllerSupport {
 		PageRequest pageRequest = new PageRequest(curPage, pageSize,
 				new Sort(Direction.DESC, "updateTime"));
 
-		Page<ExamStudent> examStudents = examStudentRepo.findAll(specification, pageRequest);
+		Page<ExamStudentEntity> examStudents = examStudentRepo.findAll(specification, pageRequest);
 
 		List<ExamStudentDomain> ret = Lists.newArrayList();
 
-		for (ExamStudent cur : examStudents) {
+		for (ExamStudentEntity cur : examStudents) {
 			Exam exam = examRepo.findOne(cur.getExamId());
 			GetCourseReq req = new GetCourseReq();
 			req.setId(cur.getCourseId());
@@ -216,8 +216,8 @@ public class ExamStudentController extends ControllerSupport {
 	 */
 	@ApiOperation(value = "按ID查询考试学生", notes = "ID查询")
 	@GetMapping("{id}")
-	public ExamStudent getExamStudentById(@PathVariable Long id) {
-		ExamStudent es = examStudentRepo.findOne(id);
+	public ExamStudentEntity getExamStudentById(@PathVariable Long id) {
+		ExamStudentEntity es = examStudentRepo.findOne(id);
 		if (null == es) {
 			throw new StatusException("E-520001", "考生不存在");
 		}

+ 9 - 8
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamStudentRepo.java

@@ -8,21 +8,22 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 
 public interface ExamStudentRepo
 		extends
-			JpaRepository<ExamStudent, Long>,
-			QueryByExampleExecutor<ExamStudent>,
-			JpaSpecificationExecutor<ExamStudent> {
+			JpaRepository<ExamStudentEntity, Long>,
+			QueryByExampleExecutor<ExamStudentEntity>,
+			JpaSpecificationExecutor<ExamStudentEntity> {
 
-	List<ExamStudent> findByStudentId(Long examId);
+	List<ExamStudentEntity> findByStudentId(Long examId);
 
-	List<ExamStudent> findByIdIn(List<Long> ids);
+	List<ExamStudentEntity> findByIdIn(List<Long> ids);
 
 	@Modifying
-	@Query("delete from ExamStudent s where s.exam.id = ?1")
+	@Query("delete from ExamStudentEntity s where s.examId = ?1")
 	void deleteByExamId(Long examId);
 
-	ExamStudent findByExamIdAndStudentIdAndCourseId(Long examId, Long studentId, Long courseId);
+	ExamStudentEntity findByExamIdAndStudentIdAndCourseId(Long examId, Long studentId,
+			Long courseId);
 }

+ 3 - 3
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamScore.java

@@ -19,7 +19,7 @@ public class ExamScore implements Serializable {
 
 	@OneToOne
 	@JoinColumn(name = "examStudentId")
-	private ExamStudent examStudent;
+	private ExamStudentEntity examStudent;
 
 	private Double score;
 
@@ -35,11 +35,11 @@ public class ExamScore implements Serializable {
 		return serialVersionUID;
 	}
 
-	public ExamStudent getExamStudent() {
+	public ExamStudentEntity getExamStudent() {
 		return examStudent;
 	}
 
-	public void setExamStudent(ExamStudent examStudent) {
+	public void setExamStudent(ExamStudentEntity examStudent) {
 		this.examStudent = examStudent;
 	}
 

+ 4 - 5
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamStudent.java → examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamStudentEntity.java

@@ -3,16 +3,15 @@ package cn.com.qmth.examcloud.core.examwork.dao.entity;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
+import javax.persistence.Index;
 import javax.persistence.Table;
 
 import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
-/**
- * Created by songyue on 17/1/13.
- */
 @Entity
-@Table(name = "EC_E_EXAM_STUDENT")
-public class ExamStudent extends JpaEntity {
+@Table(name = "EC_E_EXAM_STUDENT", indexes = {
+		@Index(name = "IDX_E_E_S_001001", columnList = "studentId,examId,courseId", unique = true)})
+public class ExamStudentEntity extends JpaEntity {
 
 	private static final long serialVersionUID = 757531976286006550L;
 

+ 6 - 6
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentServiceImpl.java

@@ -27,7 +27,7 @@ import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.Exam;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
 import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
 
@@ -68,8 +68,8 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	 */
 	@Override
 	public void deleteExamStudentsByStudentIds(List<Long> ids) {
-		List<ExamStudent> examStudents = examStudentRepo.findByIdIn(ids);
-		for (ExamStudent examStudent : examStudents) {
+		List<ExamStudentEntity> examStudents = examStudentRepo.findByIdIn(ids);
+		for (ExamStudentEntity examStudent : examStudents) {
 			// 网考判断
 			if (System.currentTimeMillis() > 0) {
 				throw new StatusException("E-150112", examStudent.getName() + "已开始考试,不能删除");
@@ -168,11 +168,11 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 		SaveCourseResp saveCourseResp = courseCloudService.saveCourse(saveCourseReq);
 		CourseBean courseBean = saveCourseResp.getCourseBean();
 
-		ExamStudent examStudent = examStudentRepo.findByExamIdAndStudentIdAndCourseId(exam.getId(),
+		ExamStudentEntity examStudent = examStudentRepo.findByExamIdAndStudentIdAndCourseId(exam.getId(),
 				studentInfo.getId(), courseBean.getId());
 
 		if (null == examStudent) {
-			examStudent = new ExamStudent();
+			examStudent = new ExamStudentEntity();
 		}
 
 		examStudent.setInfoCollector(examStudentInfo.getInfoCollector());
@@ -193,7 +193,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 		examStudent.setExamSite(examStudentInfo.getExamSite());
 		examStudent.setRemark(examStudentInfo.getRemark());
 
-		ExamStudent saved = examStudentRepo.saveAndFlush(examStudent);
+		ExamStudentEntity saved = examStudentRepo.saveAndFlush(examStudent);
 
 		ExamStudentInfo ret = new ExamStudentInfo();
 		ret.setId(saved.getId());