wangwei 7 éve
szülő
commit
c75fd0202d

+ 26 - 2
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamCloudServiceProvider.java

@@ -1,5 +1,6 @@
 package cn.com.qmth.examcloud.core.examwork.api.provider;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.Exam;
 import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
 import cn.com.qmth.examcloud.core.examwork.service.impl.ExamService;
@@ -32,6 +34,9 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 	@Autowired
 	private ExamService examService;
 
+	@Autowired
+	ExamRepo examRepo;
+
 	@ApiOperation(value = "新增考试批次", notes = "新增")
 	@PostMapping
 	@Override
@@ -56,9 +61,28 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 	@PostMapping("/findExam")
 	@Override
 	public GetExamResp getExam(@RequestBody GetExamReq req) {
-		Exam exam = examService.findExamByNameAndRootOrgId(req.getName(), req.getRootOrgId());
+		Long id = req.getId();
+		Long rootOrgId = req.getRootOrgId();
+		String name = req.getName();
+		if (null == id && StringUtils.isBlank(name)) {
+			throw new StatusException("E-002002", "id,name不能都为空");
+		}
+		if (null != id && StringUtils.isNotBlank(name)) {
+			throw new StatusException("E-002003", "id,name不能都不为空");
+		}
+		Exam exam = null;
+
+		if (null != id) {
+			exam = examRepo.findOne(id);
+		} else if (StringUtils.isNotBlank(name)) {
+			if (null == rootOrgId) {
+				throw new StatusException("E-002004", "rootOrgId is null");
+			}
+			exam = examService.findExamByNameAndRootOrgId(name, rootOrgId);
+		}
+
 		if (null == exam) {
-			throw new StatusException("E-002002", "考试不存在");
+			throw new StatusException("E-002005", "考试不存在");
 		}
 		GetExamResp examResp = new GetExamResp();
 		examResp.setId(exam.getId());

+ 12 - 61
examcloud-core-examwork-api/src/main/java/cn/com/qmth/examcloud/examwork/api/request/GetExamReq.java

@@ -1,48 +1,32 @@
 package cn.com.qmth.examcloud.examwork.api.request;
 
-import java.util.Date;
-
 import cn.com.qmth.examcloud.commons.web.cloud.api.BaseRequest;
 
 /**
- * @author  	chenken
- * @date    	2018年5月2日 下午3:44:54
- * @company 	QMTH
+ * @author chenken
+ * @date 2018年5月2日 下午3:44:54
+ * @company QMTH
  * @description ExamReq.java
  */
 public class GetExamReq extends BaseRequest {
 
 	private static final long serialVersionUID = -5832266903859887508L;
+
 	/**
 	 * 机构ID
 	 */
 	private Long rootOrgId;
+
 	/**
 	 * 考试名称
 	 */
 	private String name;
+
 	/**
-	 * 考试类型
-	 */
-	private String examType;
-	/**
-	 * 考试开始时间
-	 */
-	private Date beginTime;
-	/**
-	 * 考试结束时间
-	 */
-	private Date endTime;
-	/**
-	 * 考试时长(分钟)
-	 */
-	private Integer duration;
-	/**
-	 * 备注
+	 * 考试ID
 	 */
-	private String remark;
+	private Long id;
 
-	
 	public Long getRootOrgId() {
 		return rootOrgId;
 	}
@@ -59,45 +43,12 @@ public class GetExamReq extends BaseRequest {
 		this.name = name;
 	}
 
-	public String getExamType() {
-		return examType;
-	}
-
-	public void setExamType(String examType) {
-		this.examType = examType;
+	public Long getId() {
+		return id;
 	}
 
-	public Date getBeginTime() {
-		return beginTime;
+	public void setId(Long id) {
+		this.id = id;
 	}
 
-	public void setBeginTime(Date beginTime) {
-		this.beginTime = beginTime;
-	}
-
-	public Date getEndTime() {
-		return endTime;
-	}
-
-	public void setEndTime(Date endTime) {
-		this.endTime = endTime;
-	}
-
-	public Integer getDuration() {
-		return duration;
-	}
-
-	public void setDuration(Integer duration) {
-		this.duration = duration;
-	}
-
-	public String getRemark() {
-		return remark;
-	}
-
-	public void setRemark(String remark) {
-		this.remark = remark;
-	}
-	
 }
-