wangwei 6 lat temu
rodzic
commit
bfee5e8416

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

@@ -256,6 +256,9 @@ public class ExamController extends ControllerSupport {
 	@GetMapping("{examId}")
 	public ExamDomain getExamById(@PathVariable Long examId) {
 		ExamEntity one = examRepo.findOne(examId);
+		if (null == one) {
+			throw new StatusException("E-001250", "examId is wrong");
+		}
 		validateRootOrgIsolation(one.getRootOrgId());
 
 		ExamDomain domain = new ExamDomain();
@@ -345,6 +348,12 @@ public class ExamController extends ControllerSupport {
 	@GetMapping("allProperties/{examId}")
 	public Map<String, String> getAllExamProperties(@PathVariable Long examId) {
 
+		ExamEntity examEntity = examRepo.findOne(examId);
+		if (null == examEntity) {
+			throw new StatusException("E-001250", "examId is wrong");
+		}
+		validateRootOrgIsolation(examEntity.getRootOrgId());
+
 		Map<String, String> map = Maps.newHashMap();
 		List<ExamPropertyEntity> list = examPropertyRepo.findByexamId(examId);
 		for (ExamPropertyEntity cur : list) {
@@ -362,9 +371,15 @@ public class ExamController extends ControllerSupport {
 	 * @param examId
 	 * @return
 	 */
-	@ApiOperation(value = "考试批次所有属性")
+	@ApiOperation(value = "查询考试批次单个属性")
 	@GetMapping("property/{examId}/{key}")
 	public String getExamProperty(@PathVariable Long examId, @PathVariable String key) {
+		ExamEntity examEntity = examRepo.findOne(examId);
+		if (null == examEntity) {
+			throw new StatusException("E-001250", "examId is wrong");
+		}
+		validateRootOrgIsolation(examEntity.getRootOrgId());
+
 		ExamProperty ep = ExamProperty.valueOf(key);
 		ExamPropertyEntity one = examPropertyRepo.findByexamIdAndKeyId(examId, ep.getKeyId());
 		if (null == one) {
@@ -373,6 +388,25 @@ public class ExamController extends ControllerSupport {
 		return one.getValue();
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param examId
+	 * @return
+	 */
+	@ApiOperation(value = "查询考生考试批次单个属性")
+	@GetMapping("studentOrgProperty/{examId}/{key}")
+	public String getStudentOrgProperty(@PathVariable Long examId, @PathVariable String key) {
+		User accessUser = getAccessUser();
+		ExamEntity examEntity = examRepo.findOne(examId);
+		if (null == examEntity) {
+			throw new StatusException("E-001250", "examId is wrong");
+		}
+		validateRootOrgIsolation(examEntity.getRootOrgId());
+		return examService.getOrgProperty(examId, accessUser.getOrgId(), key);
+	}
+
 	/**
 	 * 方法注释
 	 *

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

@@ -32,4 +32,15 @@ public interface ExamService {
 	 */
 	ExamOrgEntity saveExamOrg(ExamOrgInfo examOrgInfo);
 
+	/**
+	 * 查询机构属性
+	 *
+	 * @author WANGWEI
+	 * @param examId
+	 * @param orgId
+	 * @param key
+	 * @return
+	 */
+	String getOrgProperty(Long examId, Long orgId, String key);
+
 }

+ 19 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamServiceImpl.java

@@ -241,4 +241,23 @@ public class ExamServiceImpl implements ExamService {
 
 		return saved;
 	}
+
+	@Override
+	public String getOrgProperty(Long examId, Long orgId, String key) {
+		ExamProperty ep = ExamProperty.valueOf(key);
+
+		ExamOrgPropertyEntity examOrgPropertyEntity = examOrgPropertyRepo
+				.findByexamIdAndOrgIdAndKeyId(examId, orgId, ep.getKeyId());
+		if (null != examOrgPropertyEntity) {
+			return examOrgPropertyEntity.getValue();
+		}
+
+		ExamPropertyEntity examPropertyEntity = examPropertyRepo.findByexamIdAndKeyId(examId,
+				ep.getKeyId());
+		if (null == examPropertyEntity) {
+			return null;
+		}
+
+		return examPropertyEntity.getValue();
+	}
 }