wangwei 6 vuotta sitten
vanhempi
commit
b1c49505b9

+ 31 - 2
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.examwork.api.controller;
 import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -237,10 +238,24 @@ public class ExamController extends ControllerSupport {
 	 */
 	@ApiOperation(value = "按ID查询考试批次", notes = "ID查询")
 	@GetMapping("{examId}")
-	public ExamEntity getExamById(@PathVariable Long examId) {
+	public ExamDomain getExamById(@PathVariable Long examId) {
 		ExamEntity one = examRepo.findOne(examId);
 		validateRootOrgIsolation(one.getRootOrgId());
-		return one;
+
+		ExamDomain domain = new ExamDomain();
+		domain.setBeginTime(one.getBeginTime());
+		domain.setDuration(one.getDuration());
+		domain.setEnable(one.getEnable());
+		domain.setEndTime(one.getEndTime());
+		domain.setExamTimes(one.getExamTimes());
+		domain.setExamType(one.getExamType());
+		domain.setId(one.getId());
+		domain.setName(one.getName());
+		domain.setRemark(one.getRemark());
+		domain.setRootOrgId(one.getRootOrgId());
+		domain.setStarted(one.getBeginTime().before(new Date()));
+
+		return domain;
 	}
 
 	/**
@@ -312,6 +327,20 @@ public class ExamController extends ControllerSupport {
 		return saved;
 	}
 
+	@ApiOperation(value = "按ID查询考试批次", notes = "ID查询")
+	@GetMapping("{examId}")
+	public Map<String, String> getFullExamProperties(@PathVariable Long examId) {
+
+		Map<String, String> map = Maps.newHashMap();
+		List<ExamPropertyEntity> list = examPropertyRepo.findByexamId(examId);
+		for (ExamPropertyEntity cur : list) {
+			ExamProperty ep = ExamProperty.getByKeyId(cur.getKeyId());
+			map.put(ep.name(), cur.getValue());
+		}
+
+		return map;
+	}
+
 	/**
 	 * 方法注释
 	 *

+ 16 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/ExamDomain.java

@@ -55,6 +55,9 @@ public class ExamDomain implements JsonSerializable {
 	 */
 	private Integer duration;
 
+	/**
+	 * 是否可用
+	 */
 	private Boolean enable;
 
 	/**
@@ -67,6 +70,11 @@ public class ExamDomain implements JsonSerializable {
 	 */
 	private Long examTimes;
 
+	/**
+	 * 是否开考
+	 */
+	private Boolean started;
+
 	private Map<String, String> properties;
 
 	public Long getId() {
@@ -157,4 +165,12 @@ public class ExamDomain implements JsonSerializable {
 		this.properties = properties;
 	}
 
+	public Boolean getStarted() {
+		return started;
+	}
+
+	public void setStarted(Boolean started) {
+		this.started = started;
+	}
+
 }

+ 26 - 0
examcloud-core-examwork-base/src/main/java/cn/com/qmth/examcloud/core/examwork/base/enums/ExamProperty.java

@@ -1,5 +1,8 @@
 package cn.com.qmth.examcloud.core.examwork.base.enums;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 类注释
  *
@@ -9,6 +12,10 @@ package cn.com.qmth.examcloud.core.examwork.base.enums;
  */
 public enum ExamProperty {
 
+	/**
+	 * 是否显示客观题成绩
+	 */
+	IS_OBJ_SCORE_VIEW(30L, "是否显示客观题成绩"),
 	/**
 	 * IP白名单
 	 */
@@ -139,6 +146,14 @@ public enum ExamProperty {
 	 */
 	private String desc;
 
+	private static Map<Long, ExamProperty> map = new HashMap<Long, ExamProperty>();
+
+	static {
+		for (ExamProperty e : ExamProperty.values()) {
+			map.put(e.keyId, e);
+		}
+	}
+
 	/**
 	 * 构造函数
 	 *
@@ -150,6 +165,17 @@ public enum ExamProperty {
 		this.desc = desc;
 	}
 
+	/**
+	 * get ExamProperty by keyId
+	 *
+	 * @author WANGWEI
+	 * @param keyId
+	 * @return
+	 */
+	public static ExamProperty getByKeyId(Long keyId) {
+		return map.get(keyId);
+	}
+
 	public Long getKeyId() {
 		return keyId;
 	}

+ 4 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamPropertyRepo.java

@@ -1,5 +1,7 @@
 package cn.com.qmth.examcloud.core.examwork.dao;
 
+import java.util.List;
+
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
@@ -14,4 +16,6 @@ public interface ExamPropertyRepo
 
 	ExamPropertyEntity findByexamIdAndKeyId(Long examId, Long keyId);
 
+	List<ExamPropertyEntity> findByexamId(Long examId);
+
 }