chenken 7 سال پیش
والد
کامیت
fd1621f5e0

+ 1 - 1
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamProvider.java → examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamCloudServiceProvider.java

@@ -27,7 +27,7 @@ import cn.com.qmth.examcloud.service.examwork.service.ExamService;
  */
 @RestController
 @RequestMapping("${url.prefix}/exam")
-public class ExamProvider  extends ControllerSupport implements ExamCloudService{
+public class ExamCloudServiceProvider  extends ControllerSupport implements ExamCloudService{
 	
 	@Autowired
 	private ExamService examService;

+ 59 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamStudentCloudServiceProvider.java

@@ -0,0 +1,59 @@
+package cn.com.qmth.examcloud.core.examwork.api.provider;
+
+import java.util.List;
+
+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.common.support.ControllerSupport;
+import cn.com.qmth.examcloud.common.util.BeanCopierUtil;
+import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
+import cn.com.qmth.examcloud.examwork.api.request.ExamStudentReq;
+import cn.com.qmth.examcloud.service.examwork.dao.ExamStudentRepo;
+import cn.com.qmth.examcloud.service.examwork.dto.ExamStudentDTO;
+import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
+import cn.com.qmth.examcloud.service.examwork.service.ExamStudentService;
+
+/**
+ * 
+ * @author  	chenken
+ * @date    	2018年5月4日 下午2:06:14
+ * @company 	QMTH
+ * @description ExamStudentProvider.java
+ */
+@RestController
+@RequestMapping("${url.prefix}/examStudent")
+public class ExamStudentCloudServiceProvider extends  ControllerSupport implements ExamStudentCloudService{
+
+	@Autowired
+	private ExamStudentService examStudentService;
+	
+	@Autowired
+	private ExamStudentRepo examStudentRepo;
+	
+	@Override
+	public void saveExamStudent(ExamStudentReq examStudentReq) {
+		ExamStudentDTO examStudentDto = new ExamStudentDTO();
+		examStudentDto.setExamId(examStudentReq.getExamId());
+		examStudentDto.setCourseCode(examStudentReq.getCourseCode());
+		examStudentDto.setIdentityNumber(examStudentReq.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());
+        	examStudentRepo.save(examStudentOld);
+		}else{
+			ExamStudent examStudent = BeanCopierUtil.copyProperties(examStudentReq, ExamStudent.class);
+			examStudent.setFinished(false);
+			examStudentRepo.save(examStudent);
+		}
+	}
+
+}

+ 0 - 18
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamStudentProvider.java

@@ -1,18 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.api.provider;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * 
- * @author  	chenken
- * @date    	2018年5月4日 下午2:06:14
- * @company 	QMTH
- * @description ExamStudentProvider.java
- */
-@RestController
-@RequestMapping("${url.prefix}/examStudent")
-public class ExamStudentProvider {
-
-	
-}

+ 11 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamApi.java

@@ -119,6 +119,17 @@ public class ExamApi extends ControllerSupport {
 		}
 		return new ResponseEntity(examService.getAllExam(examCriteria), HttpStatus.OK);
 	}
+	
+	@ApiOperation(value = "根据名称查询考试批次(包含有效)", notes = "不分页带查询")
+	@GetMapping("/exam/name")
+	public ResponseEntity getEnableExamByName(HttpServletRequest request, @ModelAttribute Exam examCriteria) {
+		AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+		if (accessUser != null) {
+			examCriteria.setRootOrgId(accessUser.getRootOrgId());
+		}
+		examCriteria.setEnable(true);
+		return new ResponseEntity(examService.findByNameAndRootOrgId(examCriteria.getName(),examCriteria.getRootOrgId()), HttpStatus.OK);
+	}
 
 	@ApiOperation(value = "按ID查询考试批次", notes = "ID查询")
 	@GetMapping("/exam/{id}")

+ 37 - 0
examcloud-core-examwork-api/src/main/java/cn/com/qmth/examcloud/examwork/api/request/ExamStudentReq.java

@@ -5,6 +5,10 @@ import cn.com.qmth.examcloud.common.support.BaseRequest;
 public class ExamStudentReq extends BaseRequest {
 	
 	private static final long serialVersionUID = -8455805881947392754L;
+	/**
+	 * 考试ID
+	 */
+	private Long examId;
 	/**
 	 * 考试名称
 	 */
@@ -73,6 +77,23 @@ public class ExamStudentReq extends BaseRequest {
 	 * 备注
 	 */
 	private String remark;
+	
+	/**
+	 * 机构ID
+	 */
+	private Long orgId;
+	/**
+	 * 顶级机构id 
+	 */
+	private Long rootOrgId;
+	
+	public Long getExamId() {
+		return examId;
+	}
+
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
 
 	public String getExamName() {
 		return examName;
@@ -209,5 +230,21 @@ public class ExamStudentReq extends BaseRequest {
 	public void setRemark(String remark) {
 		this.remark = remark;
 	}
+
+	public Long getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
 	
 }

+ 2 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/service/examwork/dao/ExamRepo.java

@@ -18,6 +18,8 @@ public interface ExamRepo extends JpaRepository<Exam, Long>,QueryByExampleExecut
 
 	List<Exam> findByIdIn(List<Long> ids);
 
+	List<Exam> findByNameAndRootOrgId(String name,Long rootOrgId);
+	
 	Long countByName(String name);
 
 	Long countByNameAndRootOrgId(String name,Long rootOrgId);

+ 1 - 2
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/service/examwork/entity/ExamStudent.java

@@ -3,10 +3,9 @@ package cn.com.qmth.examcloud.service.examwork.entity;
 import java.io.Serializable;
 
 import javax.persistence.*;
-import javax.persistence.Id;
-import javax.persistence.Transient;
 import javax.validation.constraints.NotNull;
 
+
 /**
  * Created by songyue on 17/1/13.
  */

+ 3 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamService.java

@@ -178,4 +178,7 @@ public class ExamService {
     	exam.setRootOrgId(rootOrgId);
     	return examRepo.findOne(Example.of(exam));
     }
+    public List<Exam> findByNameAndRootOrgId(String name,Long rootOrgId) {
+        return examRepo.findByNameAndRootOrgId(name, rootOrgId);
+	}
 }