wangwei 6 年 前
コミット
91b2288415

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

@@ -45,6 +45,7 @@ import cn.com.qmth.examcloud.commons.web.security.bean.User;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.examwork.api.controller.bean.CourseGroupDomain;
 import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamDomain;
+import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamOrgDomain;
 import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
 import cn.com.qmth.examcloud.core.examwork.dao.CourseGroupRelationRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.CourseGroupRepo;
@@ -566,19 +567,36 @@ public class ExamController extends ControllerSupport {
 	 * 方法注释
 	 *
 	 * @author WANGWEI
-	 * @param examId
 	 * @param curPage
 	 * @param pageSize
+	 * @param examOrgDomain
 	 * @return
 	 */
 	@ApiOperation(value = "查询考试相关的学习中心设置", notes = "")
-	@GetMapping("getExamOrgList/{examId}/{curPage}/{pageSize}")
-	public List<?> getExamOrgList(@PathVariable Long examId, @PathVariable Integer curPage,
-			@PathVariable Integer pageSize) {
+	@GetMapping("getExamOrgList/{curPage}/{pageSize}")
+	public Page<ExamOrgEntity> getExamOrgList(@PathVariable Integer curPage,
+			@PathVariable Integer pageSize, @ModelAttribute ExamOrgDomain examOrgDomain) {
+
+		if (null == examOrgDomain.getExamId()) {
+			throw new StatusException("E-001210", "examId is null");
+		}
+
+		Specification<ExamOrgEntity> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+
+			predicates.add(cb.equal(root.get("examId"), examOrgDomain.getExamId()));
+
+			if (null != examOrgDomain.getOrgId()) {
+				predicates.add(cb.equal(root.get("orgId"), examOrgDomain.getOrgId()));
+			}
+
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+
 		Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC,
 				"updateTime");
-		List<ExamOrgEntity> allByExamId = examOrgRepo.findAllByExamId(examId, pageable);
-		return allByExamId;
+		Page<ExamOrgEntity> page = examOrgRepo.findAll(specification, pageable);
+		return page;
 	}
 
 	/**

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

@@ -0,0 +1,106 @@
+package cn.com.qmth.examcloud.core.examwork.api.controller.bean;
+
+import java.util.Date;
+
+import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
+
+/**
+ * 考试机构设置
+ *
+ * @author WANGWEI
+ * @date 2018年5月16日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public class ExamOrgDomain implements JsonSerializable {
+
+	private static final long serialVersionUID = -3335725218626631530L;
+
+	private Long id;
+
+	/**
+	 * 考试ID
+	 */
+	private Long examId;
+
+	/**
+	 * 顶级机构ID
+	 */
+	private Long rootOrgId;
+
+	/**
+	 * 机构ID
+	 */
+	private Long orgId;
+
+	/**
+	 * 考试批次开始时间
+	 */
+	private Date beginTime;
+
+	/**
+	 * 考试批次结束时间
+	 */
+	private Date endTime;
+
+	/**
+	 * 是否允许上传附件(离线考试)
+	 */
+	private Boolean canUploadAttachment;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getExamId() {
+		return examId;
+	}
+
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public Long getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
+
+	public Date getBeginTime() {
+		return beginTime;
+	}
+
+	public void setBeginTime(Date beginTime) {
+		this.beginTime = beginTime;
+	}
+
+	public Date getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(Date endTime) {
+		this.endTime = endTime;
+	}
+
+	public Boolean getCanUploadAttachment() {
+		return canUploadAttachment;
+	}
+
+	public void setCanUploadAttachment(Boolean canUploadAttachment) {
+		this.canUploadAttachment = canUploadAttachment;
+	}
+
+}

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
@@ -14,7 +15,8 @@ import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgEntity;
 public interface ExamOrgRepo
 		extends
 			JpaRepository<ExamOrgEntity, Long>,
-			QueryByExampleExecutor<ExamOrgEntity> {
+			QueryByExampleExecutor<ExamOrgEntity>,
+			JpaSpecificationExecutor<ExamOrgEntity> {
 
 	@Transactional
 	@Modifying
@@ -26,8 +28,6 @@ public interface ExamOrgRepo
 	@Query("delete from ExamOrgEntity where examId = ?1 and orgId = ?2")
 	void deleteByExamIdAndOrgId(Long examId, Long orgId);
 
-	List<ExamOrgEntity> findAllByExamId(Long examId, Pageable pageable);
-
 	List<ExamOrgEntity> findAllByExamIdAndOrgId(Long examId, Long orgId, Pageable pageable);
 
 }