Browse Source

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-2/examcloud-core-examwork.git

wangwei 6 năm trước cách đây
mục cha
commit
a7dde6e88e
30 tập tin đã thay đổi với 698 bổ sung1072 xóa
  1. 227 61
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java
  2. 0 43
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamCourseController.java
  3. 0 76
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamOrgTimeController.java
  4. 0 63
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamScoreController.java
  5. 1 1
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/CourseGroupDomain.java
  6. 104 0
      examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/ExamOrgDomain.java
  7. 4 0
      examcloud-core-examwork-base/src/main/java/cn/com/qmth/examcloud/core/examwork/base/enums/ExamProperty.java
  8. 5 5
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/CourseGroupRelationRepo.java
  9. 28 0
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamOrgPropertyRepo.java
  10. 15 2
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamOrgRepo.java
  11. 0 30
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamOrgTimeRepo.java
  12. 0 9
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamScoreRepo.java
  13. 0 43
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/bean/BasePageable.java
  14. 0 78
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/bean/ExamCourseCriteria.java
  15. 0 64
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/bean/ExamCourseDTO.java
  16. 0 81
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/bean/OrgExamInfoDTO.java
  17. 1 1
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/CourseGroupEntity.java
  18. 3 3
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/CourseGroupRelationEntity.java
  19. 35 5
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgEntity.java
  20. 0 45
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgPK.java
  21. 79 0
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgPropertyEntity.java
  22. 0 130
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgTime.java
  23. 0 54
      examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamScore.java
  24. 11 0
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/ExamService.java
  25. 104 0
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/ExamOrgInfo.java
  26. 0 113
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamCourseService.java
  27. 0 61
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamOrgTimeService.java
  28. 0 85
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamScoreService.java
  29. 79 17
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamServiceImpl.java
  30. 2 2
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentServiceImpl.java

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

@@ -4,6 +4,7 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -40,25 +41,34 @@ import com.google.common.collect.Maps;
 
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.base.util.JsonUtil;
+import cn.com.qmth.examcloud.commons.web.helpers.page.PageInfo;
 import cn.com.qmth.examcloud.commons.web.redis.RedisClient;
 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.CourseGroupBean;
+import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
+import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
+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;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgPropertyRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupEntity;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupRelation;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupRelationEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgPropertyEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.ExamOrgInfo;
 import cn.com.qmth.examcloud.core.examwork.service.impl.ExamServiceImpl;
 import cn.com.qmth.examcloud.core.examwork.service.impl.ExamStudentServiceImpl;
 import io.swagger.annotations.ApiOperation;
@@ -102,6 +112,12 @@ public class ExamController extends ControllerSupport {
 	@Autowired
 	CourseGroupRelationRepo courseGroupRelationRepo;
 
+	@Autowired
+	OrgCloudService orgCloudService;
+
+	@Autowired
+	ExamOrgPropertyRepo examOrgPropertyRepo;
+
 	/**
 	 * 方法注释
 	 *
@@ -254,7 +270,6 @@ public class ExamController extends ControllerSupport {
 		domain.setRemark(one.getRemark());
 		domain.setRootOrgId(one.getRootOrgId());
 		domain.setStarted(one.getBeginTime().before(new Date()));
-
 		return domain;
 	}
 
@@ -268,29 +283,7 @@ public class ExamController extends ControllerSupport {
 	@ApiOperation(value = "新增考试批次", notes = "新增")
 	@PostMapping()
 	public ExamEntity addExam(@RequestBody ExamDomain domain) {
-		trim(domain, true);
-
-		User accessUser = getAccessUser();
-
-		ExamInfo examInfo = new ExamInfo();
-
-		examInfo.setBeginTime(domain.getBeginTime());
-		examInfo.setDuration(domain.getDuration());
-		examInfo.setEnable(true);
-		examInfo.setEndTime(domain.getEndTime());
-		examInfo.setExamTimes(domain.getExamTimes());
-		examInfo.setExamType(domain.getExamType());
-		examInfo.setId(domain.getId());
-		examInfo.setName(domain.getName());
-		examInfo.setRemark(domain.getRemark());
-		examInfo.setRootOrgId(accessUser.getRootOrgId());
-
-		Map<String, String> properties = domain.getProperties();
-		examInfo.setProperties(properties);
-
-		ExamEntity saved = examService.saveExam(examInfo);
-
-		return saved;
+		return saveExam(domain);
 	}
 
 	/**
@@ -303,6 +296,17 @@ public class ExamController extends ControllerSupport {
 	@ApiOperation(value = "更新考试批次", notes = "更新")
 	@PutMapping()
 	public ExamEntity updateExam(@RequestBody ExamDomain domain) {
+		return saveExam(domain);
+	}
+
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param domain
+	 * @return
+	 */
+	private ExamEntity saveExam(ExamDomain domain) {
 		trim(domain, true);
 
 		User accessUser = getAccessUser();
@@ -310,7 +314,7 @@ public class ExamController extends ControllerSupport {
 		ExamInfo examInfo = new ExamInfo();
 		examInfo.setBeginTime(domain.getBeginTime());
 		examInfo.setDuration(domain.getDuration());
-		examInfo.setEnable(true);
+		examInfo.setEnable(domain.getEnable());
 		examInfo.setEndTime(domain.getEndTime());
 		examInfo.setExamTimes(domain.getExamTimes());
 		examInfo.setExamType(domain.getExamType());
@@ -320,6 +324,9 @@ public class ExamController extends ControllerSupport {
 		examInfo.setRootOrgId(accessUser.getRootOrgId());
 
 		Map<String, String> properties = domain.getProperties();
+		if (null == properties) {
+			properties = Maps.newHashMap();
+		}
 		examInfo.setProperties(properties);
 
 		ExamEntity saved = examService.saveExam(examInfo);
@@ -406,19 +413,28 @@ public class ExamController extends ControllerSupport {
 		}
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param examId
+	 * @param curPage
+	 * @param pageSize
+	 * @return
+	 */
 	@ApiOperation(value = "查询课程组集合", notes = "")
-	@GetMapping("queryCourseGroupList/{examId}/{curPage}/{pageSize}")
-	public List<CourseGroupBean> queryCourseGroupList(@PathVariable Long examId,
+	@GetMapping("getCourseGroupListByExamId/{examId}/{curPage}/{pageSize}")
+	public List<CourseGroupDomain> getCourseGroupListByExamId(@PathVariable Long examId,
 			@PathVariable Integer curPage, @PathVariable Integer pageSize) {
 
 		Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC,
 				"updateTime");
 		List<CourseGroupEntity> groupList = courseGroupRepo.findAllByExamId(examId, pageable);
 
-		List<CourseGroupBean> ret = Lists.newArrayList();
+		List<CourseGroupDomain> ret = Lists.newArrayList();
 
 		for (CourseGroupEntity curCourseGroup : groupList) {
-			CourseGroupBean bean = new CourseGroupBean();
+			CourseGroupDomain bean = new CourseGroupDomain();
 			bean.setBeginTime(curCourseGroup.getBeginTime());
 			bean.setCreationTime(curCourseGroup.getCreationTime());
 			bean.setDescription(curCourseGroup.getDescription());
@@ -431,10 +447,10 @@ public class ExamController extends ControllerSupport {
 			List<Long> courseIdList = Lists.newArrayList();
 			bean.setCourseIdList(courseIdList);
 
-			List<CourseGroupRelation> relationList = courseGroupRelationRepo
+			List<CourseGroupRelationEntity> relationList = courseGroupRelationRepo
 					.findAllByGroupId(bean.getId());
 
-			for (CourseGroupRelation cur : relationList) {
+			for (CourseGroupRelationEntity cur : relationList) {
 				courseIdList.add(cur.getCourseId());
 			}
 
@@ -444,16 +460,24 @@ public class ExamController extends ControllerSupport {
 		return ret;
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param examId
+	 * @param courseId
+	 * @return
+	 */
 	@ApiOperation(value = "通过课程ID查询课程组集合", notes = "")
-	@GetMapping("queryCourseGroupList/{examId}/{courseId}")
-	public List<CourseGroupBean> queryCourseGroupList(@PathVariable Long examId,
+	@GetMapping("getCourseGroupListByExamIdAndCourseId/{examId}/{courseId}")
+	public List<CourseGroupDomain> getCourseGroupListByExamIdAndCourseId(@PathVariable Long examId,
 			@PathVariable Long courseId) {
 
-		List<CourseGroupRelation> relationList = courseGroupRelationRepo
+		List<CourseGroupRelationEntity> relationList = courseGroupRelationRepo
 				.findAllByCourseIdAndExamId(courseId, examId);
 
 		List<Long> groupIdList = Lists.newArrayList();
-		for (CourseGroupRelation cur : relationList) {
+		for (CourseGroupRelationEntity cur : relationList) {
 			Long groupId = cur.getGroupId();
 			groupIdList.add(groupId);
 		}
@@ -461,10 +485,10 @@ public class ExamController extends ControllerSupport {
 		List<CourseGroupEntity> groupList = courseGroupRepo
 				.findAllByIdInOrderByUpdateTimeDesc(groupIdList);
 
-		List<CourseGroupBean> ret = Lists.newArrayList();
+		List<CourseGroupDomain> ret = Lists.newArrayList();
 
 		for (CourseGroupEntity curCourseGroup : groupList) {
-			CourseGroupBean bean = new CourseGroupBean();
+			CourseGroupDomain bean = new CourseGroupDomain();
 			bean.setBeginTime(curCourseGroup.getBeginTime());
 			bean.setCreationTime(curCourseGroup.getCreationTime());
 			bean.setDescription(curCourseGroup.getDescription());
@@ -477,10 +501,10 @@ public class ExamController extends ControllerSupport {
 			List<Long> courseIdList = Lists.newArrayList();
 			bean.setCourseIdList(courseIdList);
 
-			List<CourseGroupRelation> curRelationList = courseGroupRelationRepo
+			List<CourseGroupRelationEntity> curRelationList = courseGroupRelationRepo
 					.findAllByGroupId(bean.getId());
 
-			for (CourseGroupRelation cur : curRelationList) {
+			for (CourseGroupRelationEntity cur : curRelationList) {
 				courseIdList.add(cur.getCourseId());
 			}
 		}
@@ -488,9 +512,16 @@ public class ExamController extends ControllerSupport {
 		return ret;
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param courseGroupBean
+	 * @param request
+	 */
 	@ApiOperation(value = "更新课程组", notes = "")
 	@PutMapping("courseGroup")
-	public void updateCourseGroup(@RequestBody CourseGroupBean courseGroupBean,
+	public void updateCourseGroup(@RequestBody CourseGroupDomain courseGroupBean,
 			HttpServletRequest request) {
 
 		CourseGroupEntity courseGroup = new CourseGroupEntity();
@@ -506,12 +537,12 @@ public class ExamController extends ControllerSupport {
 		courseGroupRepo.save(courseGroup);
 		List<Long> courseIdList = courseGroupBean.getCourseIdList();
 
-		List<CourseGroupRelation> relationList = Lists.newArrayList();
+		List<CourseGroupRelationEntity> relationList = Lists.newArrayList();
 
 		courseGroupRelationRepo.deleteByGroupId(courseGroup.getId());
 
 		for (Long cur : courseIdList) {
-			CourseGroupRelation relation = new CourseGroupRelation();
+			CourseGroupRelationEntity relation = new CourseGroupRelationEntity();
 			relation.setCourseId(cur);
 			relation.setExamId(courseGroupBean.getExamId());
 			relation.setGroupId(courseGroup.getId());
@@ -520,46 +551,181 @@ public class ExamController extends ControllerSupport {
 		courseGroupRelationRepo.save(relationList);
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param id
+	 */
 	@ApiOperation(value = "删除课程组", notes = "")
 	@DeleteMapping("courseGroup/{id}")
-	public void deleteSpecificExam(@PathVariable Long id, HttpServletRequest request) {
+	public void deleteCourseGroup(@PathVariable Long id) {
 		courseGroupRepo.delete(id);
 		courseGroupRelationRepo.deleteByGroupId(id);
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @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) {
-		Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC,
-				"updateTime");
-		List<ExamOrgEntity> allByExamId = examOrgRepo.findAllByExamId(examId, pageable);
-		return allByExamId;
+	@GetMapping("getExamOrgList/{curPage}/{pageSize}")
+	public PageInfo<ExamOrgDomain> getExamOrgList(@PathVariable Integer curPage,
+			@PathVariable Integer pageSize, @ModelAttribute ExamOrgDomain examOrgDomain) {
+
+		Long examId = examOrgDomain.getExamId();
+		if (null == examOrgDomain.getExamId()) {
+			throw new StatusException("E-001210", "examId is null");
+		}
+		ExamEntity examEntity = examRepo.findOne(examId);
+		if (null == examEntity) {
+			throw new StatusException("E-001250", "examId is wrong");
+		}
+		validateRootOrgIsolation(examEntity.getRootOrgId());
+
+		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, pageSize, Sort.Direction.DESC, "updateTime");
+		Page<ExamOrgEntity> page = examOrgRepo.findAll(specification, pageable);
+
+		Iterator<ExamOrgEntity> iterator = page.iterator();
+		List<ExamOrgDomain> domainList = Lists.newArrayList();
+
+		while (iterator.hasNext()) {
+			ExamOrgEntity next = iterator.next();
+			ExamOrgDomain bean = new ExamOrgDomain();
+			domainList.add(bean);
+
+			bean.setBeginTime(next.getBeginTime());
+			bean.setEndTime(next.getEndTime());
+			bean.setExamId(next.getExamId());
+			bean.setId(next.getId());
+			bean.setOrgId(next.getOrgId());
+			bean.setRootOrgId(next.getRootOrgId());
+
+			List<ExamOrgPropertyEntity> propList = examOrgPropertyRepo
+					.findByexamIdAndOrgId(next.getExamId(), next.getOrgId());
+
+			Map<String, String> map = Maps.newHashMap();
+			for (ExamOrgPropertyEntity cur : propList) {
+				ExamProperty ep = ExamProperty.getByKeyId(cur.getKeyId());
+				map.put(ep.name(), cur.getValue());
+			}
+
+			bean.setProperties(map);
+		}
+
+		PageInfo<ExamOrgDomain> ret = new PageInfo<ExamOrgDomain>();
+		ret.setList(domainList);
+		ret.setTotal(page.getTotalElements());
+		return ret;
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param examOrg
+	 * @return
+	 */
 	@ApiOperation(value = "新增考试相关的学习中心设置", notes = "")
 	@PostMapping("examOrg")
-	public ExamOrgEntity addExamOrg(@RequestBody ExamOrgEntity examOrg) {
-		ExamOrgEntity ret = examOrgRepo.save(examOrg);
-		return ret;
+	public ExamOrgEntity addExamOrg(@RequestBody ExamOrgDomain domain) {
+		return saveExamOrg(domain);
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param examOrg
+	 * @return
+	 */
 	@ApiOperation(value = "更新考试相关的学习中心设置", notes = "")
 	@PutMapping("examOrg")
-	public ExamOrgEntity updateExamOrg(@RequestBody ExamOrgEntity examOrg) {
-		ExamOrgEntity ret = examOrgRepo.save(examOrg);
+	public ExamOrgEntity updateExamOrg(@RequestBody ExamOrgDomain domain) {
+		return saveExamOrg(domain);
+	}
+
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param domain
+	 * @return
+	 */
+	private ExamOrgEntity saveExamOrg(ExamOrgDomain domain) {
+		Long examId = domain.getExamId();
+
+		ExamEntity examEntity = examRepo.findOne(examId);
+		if (null == examEntity) { 
+			throw new StatusException("E-001250", "examId is wrong");
+		}
+		validateRootOrgIsolation(examEntity.getRootOrgId());
+
+		Long orgId = domain.getOrgId();
+
+		GetOrgReq getOrgReq = new GetOrgReq();
+		getOrgReq.setOrgId(orgId);
+		GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
+		OrgBean org = getOrgResp.getOrg();
+		org.getRootId();
+		validateRootOrgIsolation(org.getRootId());
+
+		User accessUser = getAccessUser();
+		ExamOrgInfo info = new ExamOrgInfo();
+		info.setBeginTime(domain.getBeginTime());
+		info.setEndTime(domain.getEndTime());
+		info.setExamId(domain.getExamId());
+		info.setOrgId(domain.getOrgId());
+		info.setRootOrgId(accessUser.getRootOrgId());
+
+		Map<String, String> properties = domain.getProperties();
+		if (null == properties) {
+			properties = Maps.newHashMap();
+		}
+		info.setProperties(domain.getProperties());
+
+		ExamOrgEntity ret = examService.saveExamOrg(info);
 		return ret;
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param examId
+	 * @param orgId
+	 */
 	@ApiOperation(value = "删除考试相关的学习中心设置", notes = "")
 	@DeleteMapping("examOrg/{examId}/{orgId}")
 	public void deleteExamOrg(@PathVariable Long examId, @PathVariable Long orgId) {
-		ExamOrgEntity examOrg = new ExamOrgEntity();
-		examOrg.setExamId(examId);
-		examOrg.setOrgId(orgId);
-		examOrgRepo.delete(examOrg);
+		examOrgRepo.deleteByExamIdAndOrgId(examId, orgId);
 	}
 
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param request
+	 * @param examId
+	 * @return
+	 */
 	@ApiOperation(value = "考试IP限制", notes = "")
 	@GetMapping("ipLimit/{examId}")
 	public Map<String, Object> ipLimit(HttpServletRequest request, @PathVariable Long examId) {

+ 0 - 43
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamCourseController.java

@@ -1,43 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.api.controller;
-
-import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamCourseCriteria;
-import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamCourseDTO;
-import cn.com.qmth.examcloud.core.examwork.service.impl.ExamCourseService;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * Created by yuanpan on 2017/4/12.
- */
-@Transactional
-@RestController
-@RequestMapping("${$rmp.ctr.examwork}/exam_course")
-public class ExamCourseController {
-
-    @Autowired
-    private ExamCourseService examCourseService;
-
-
-    @GetMapping
-    public Page<ExamCourseDTO> findAllPage(@RequestParam("exam_id") Long examId,
-                                           @RequestParam(value = "course_code",required = false) String courseCode,
-                                           @RequestParam(value = "course_level",required = false) String courseLevel,
-                                           @RequestParam("cur_page") Integer curPage,
-                                           @RequestParam("page_size") Integer pageSize) {
-        ExamCourseCriteria courseCriteria = new ExamCourseCriteria(examId,courseCode,courseLevel,curPage,pageSize);
-        Page<ExamCourseDTO> examCourseDTOs = examCourseService.findAllPage(courseCriteria);
-        return examCourseDTOs;
-    }
-
-    @GetMapping("/marking")
-    public List<ExamCourseDTO> findAll(@RequestParam("exam_id") Long examId) {
-        ExamCourseCriteria courseCriteria = new ExamCourseCriteria(examId);
-        List<ExamCourseDTO> examCourseDTOs = examCourseService.findAll(courseCriteria);
-        return examCourseDTOs;
-    }
-}

+ 0 - 76
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamOrgTimeController.java

@@ -1,76 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.api.controller;
-
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
-import cn.com.qmth.examcloud.core.examwork.service.impl.ExamOrgTimeService;
-import io.swagger.annotations.ApiOperation;
-
-/**
- * 考试服务API Created by songyue on 17/1/13.
- */
-@Transactional
-@RestController
-@RequestMapping("${$rmp.ctr.examwork}/examOrgTime")
-public class ExamOrgTimeController {
-
-	@Autowired
-	ExamOrgTimeRepo examOrgTimeRepo;
-
-	@Autowired
-	ExamOrgTimeService examOrgTimeService;
-
-	@ApiOperation(value = "查询学习中心考试时间", notes = "分页")
-	@GetMapping("{curPage}/{pageSize}")
-	public ResponseEntity findByExamId(@ModelAttribute ExamOrgTime examOrgTime,
-			@PathVariable Integer curPage, @PathVariable Integer pageSize) {
-		PageRequest pageRequest = new PageRequest(curPage, pageSize);
-		Page<ExamOrgTime> orgTimePage = examOrgTimeService.getAllOrgTime(examOrgTime, pageRequest);
-		return new ResponseEntity(orgTimePage, HttpStatus.OK);
-	}
-
-	@ApiOperation(value = "查询学习中心考试时间", notes = "不分页")
-	@GetMapping("{examId}")
-	public ResponseEntity findByExamId(@PathVariable Long examId) {
-		List<ExamOrgTime> orgTimePage = examOrgTimeRepo.findByExamId(examId);
-		return new ResponseEntity(orgTimePage, HttpStatus.OK);
-	}
-
-	@ApiOperation(value = "按ID查询学习中心考试时间", notes = "ID查询")
-	@GetMapping("{id}")
-	public ResponseEntity findById(@PathVariable Long id) {
-		return new ResponseEntity(examOrgTimeRepo.findOne(id), HttpStatus.OK);
-	}
-
-	@ApiOperation(value = "新增学习中心考试时间", notes = "新增")
-	@PostMapping()
-	public ExamOrgTime add(@RequestBody ExamOrgTime examOrgTime) {
-		ExamOrgTime saved = examOrgTimeRepo.save(examOrgTime);
-
-		return saved;
-	}
-
-	@ApiOperation(value = "更新学习中心考试时间", notes = "更新")
-	@PutMapping()
-	public ExamOrgTime update(@RequestBody ExamOrgTime examOrgTime) {
-
-		ExamOrgTime saved = examOrgTimeRepo.save(examOrgTime);
-		return saved;
-	}
-}

+ 0 - 63
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamScoreController.java

@@ -1,63 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.api.controller;
-
-import cn.com.qmth.examcloud.core.examwork.dao.ExamScoreRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamScore;
-import cn.com.qmth.examcloud.core.examwork.service.impl.ExamScoreService;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.http.ResponseEntity;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * 考试分数服务API
- * Created by songyue on 17/1/13.
- */
-@Transactional
-@RestController
-@RequestMapping("${$rmp.ctr.examwork}")
-public class ExamScoreController {
-
-    @Autowired
-    ExamScoreRepo examScoreRepo;
-
-    @Autowired
-    ExamScoreService examScoreService;
-
-    @ApiOperation(value="查询所有考试分数",notes = "分页")
-    @GetMapping("/exam_score/all/{curPage}/{pageSize}")
-    public ResponseEntity getAllExamScore(@ModelAttribute ExamScore examCriteria, @PathVariable Integer curPage, @PathVariable Integer pageSize){
-        return examScoreService.getAllExamScore(examCriteria,new PageRequest(curPage,pageSize));
-    }
-
-    @ApiOperation(value="查询所有考试分数",notes = "不分页")
-    @GetMapping("/exam_score/all")
-    public ResponseEntity getAllExamScore(@ModelAttribute ExamScore examCriteria){
-        return examScoreService.getAllExamScore(examCriteria);
-    }
-
-    @ApiOperation(value="按ID查询考试分数",notes = "ID查询")
-    @GetMapping("/exam_score/{id}")
-    public ResponseEntity<ExamScore> getExamScoreById(@PathVariable Long id){
-        return examScoreService.getExamScoreById(id);
-    }
-
-    @ApiOperation(value="新增考试分数",notes = "新增")
-    @PostMapping("/exam_score")
-    public ResponseEntity addExamScore(@RequestBody ExamScore examScore){
-        return examScoreService.saveExamScore(examScore);
-    }
-
-    @ApiOperation(value="更新考试分数",notes = "更新")
-    @PutMapping("/exam_score")
-    public ResponseEntity updateExamScore(@RequestBody ExamScore examScore){
-        return examScoreService.saveExamScore(examScore);
-    }
-
-    @ApiOperation(value="按ID删除考试分数",notes = "删除")
-    @DeleteMapping("/exam_score/{id}")
-    public ResponseEntity deleteExamScore(@PathVariable Long id){
-        return examScoreService.deleteExamScore(id);
-    }
-}

+ 1 - 1
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/CourseGroupBean.java → examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/CourseGroupDomain.java

@@ -16,7 +16,7 @@ import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
  * @author WANG
  *
  */
-public class CourseGroupBean implements JsonSerializable {
+public class CourseGroupDomain implements JsonSerializable {
 
 	private static final long serialVersionUID = -3335725218626631530L;
 

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

@@ -0,0 +1,104 @@
+package cn.com.qmth.examcloud.core.examwork.api.controller.bean;
+
+import java.util.Date;
+import java.util.Map;
+
+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 Map<String, String> properties;
+
+	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 Map<String, String> getProperties() {
+		return properties;
+	}
+
+	public void setProperties(Map<String, String> properties) {
+		this.properties = properties;
+	}
+
+}

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

@@ -12,6 +12,10 @@ import java.util.Map;
  */
 public enum ExamProperty {
 
+	/**
+	 * 是否允许上传附件(离线考试)
+	 */
+	CAN_UPLOAD_ATTACHMENT(31L, "是否允许上传附件(离线考试)"),
 	/**
 	 * 是否显示客观题成绩
 	 */

+ 5 - 5
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/CourseGroupRelationRepo.java

@@ -5,7 +5,7 @@ import java.util.List;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
-import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupRelation;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupRelationEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupRelationPK;
 
 /**
@@ -17,12 +17,12 @@ import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupRelationPK;
  */
 public interface CourseGroupRelationRepo
 		extends
-			JpaRepository<CourseGroupRelation, CourseGroupRelationPK>,
-			QueryByExampleExecutor<CourseGroupRelation> {
+			JpaRepository<CourseGroupRelationEntity, CourseGroupRelationPK>,
+			QueryByExampleExecutor<CourseGroupRelationEntity> {
 
-	List<CourseGroupRelation> findAllByGroupId(Long groupId);
+	List<CourseGroupRelationEntity> findAllByGroupId(Long groupId);
 
-	List<CourseGroupRelation> findAllByCourseIdAndExamId(Long courseId, Long examId);
+	List<CourseGroupRelationEntity> findAllByCourseIdAndExamId(Long courseId, Long examId);
 
 	void deleteByGroupId(Long groupId);
 

+ 28 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamOrgPropertyRepo.java

@@ -0,0 +1,28 @@
+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;
+
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgPropertyEntity;
+
+/**
+ * 类注释
+ *
+ * @author WANGWEI
+ * @date 2018年8月20日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public interface ExamOrgPropertyRepo
+		extends
+			JpaRepository<ExamOrgPropertyEntity, Long>,
+			QueryByExampleExecutor<ExamOrgPropertyEntity>,
+			JpaSpecificationExecutor<ExamOrgPropertyEntity> {
+
+	ExamOrgPropertyEntity findByexamIdAndOrgIdAndKeyId(Long examId, Long orgId, Long keyId);
+
+	List<ExamOrgPropertyEntity> findByexamIdAndOrgId(Long examId, Long orgId);
+
+}

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

@@ -4,16 +4,29 @@ 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;
+import org.springframework.transaction.annotation.Transactional;
 
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgEntity;
 
 public interface ExamOrgRepo
 		extends
 			JpaRepository<ExamOrgEntity, Long>,
-			QueryByExampleExecutor<ExamOrgEntity> {
+			QueryByExampleExecutor<ExamOrgEntity>,
+			JpaSpecificationExecutor<ExamOrgEntity> {
 
-	List<ExamOrgEntity> findAllByExamId(Long examId, Pageable pageable);
+	@Transactional
+	@Modifying
+	@Query("delete from ExamOrgEntity where examId = ?1")
+	void deleteByExamId(Long examId);
+
+	@Transactional
+	@Modifying
+	@Query("delete from ExamOrgEntity where examId = ?1 and orgId = ?2")
+	void deleteByExamIdAndOrgId(Long examId, Long orgId);
 
 	List<ExamOrgEntity> findAllByExamIdAndOrgId(Long examId, Long orgId, Pageable pageable);
 

+ 0 - 30
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamOrgTimeRepo.java

@@ -1,30 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao;
-
-import org.springframework.data.domain.Page;
-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.transaction.annotation.Transactional;
-
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
-
-import java.util.List;
-
-public interface ExamOrgTimeRepo
-		extends
-			JpaRepository<ExamOrgTime, Long>,
-			JpaSpecificationExecutor<ExamOrgTime> {
-
-	List<ExamOrgTime> findByExamId(Long examId);
-
-	Page<ExamOrgTime> findByExamId(Long examId, Pageable pageable);
-
-	ExamOrgTime findFirstByExamIdAndOrgId(Long examId, Long orgId);
-
-	@Transactional
-	@Modifying
-	@Query("delete from ExamOrgTime where examId = ?1")
-	void deleteByExamId(Long examId);
-}

+ 0 - 9
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamScoreRepo.java

@@ -1,9 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.repository.query.QueryByExampleExecutor;
-
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamScore;
-
-public interface ExamScoreRepo extends JpaRepository<ExamScore, Long>,QueryByExampleExecutor<ExamScore> {
-}

+ 0 - 43
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/bean/BasePageable.java

@@ -1,43 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.bean;
-
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-
-import java.io.Serializable;
-
-/**
- * Created by songyue on 18/4/2.
- */
-public abstract class BasePageable implements Serializable{
-
-    private static final long serialVersionUID = -183445483309358532L;
-
-    protected Integer curPage;
-
-    protected Integer pageSize;
-
-    public Integer getCurPage() {
-        return curPage;
-    }
-
-    public void setCurPage(Integer curPage) {
-        this.curPage = curPage;
-    }
-
-    public Integer getPageSize() {
-        return pageSize;
-    }
-
-    public void setPageSize(Integer pageSize) {
-        this.pageSize = pageSize;
-    }
-
-    public BasePageable() {
-        this.curPage = 0;
-        this.pageSize = 10;
-    }
-
-    public Pageable getPageable(){
-        return new PageRequest(this.curPage,this.pageSize);
-    }
-}

+ 0 - 78
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/bean/ExamCourseCriteria.java

@@ -1,78 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.bean;
-
-
-/**
- * Created by songyue on 18/4/2.
- */
-public class ExamCourseCriteria extends BasePageable{
-
-    private Long examId;
-
-    private String courseCode;
-
-    private String courseLevel;
-
-    private Long orgId;
-
-    public Long getExamId() {
-        return examId;
-    }
-
-    public void setExamId(Long examId) {
-        this.examId = examId;
-    }
-
-    public String getCourseCode() {
-        return courseCode;
-    }
-
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
-    }
-
-    public String getCourseLevel() {
-        return courseLevel;
-    }
-
-    public void setCourseLevel(String courseLevel) {
-        this.courseLevel = courseLevel;
-    }
-
-    public Long getOrgId() {
-        return orgId;
-    }
-
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
-    }
-
-    public ExamCourseCriteria(Long examId,
-                              String courseCode,
-                              String courseLevel,
-                              int curPage,
-                              int pageSize) {
-        this.examId = examId;
-        this.courseCode = courseCode;
-        this.courseLevel = courseLevel;
-        this.curPage = curPage;
-        this.pageSize = pageSize;
-    }
-
-    public ExamCourseCriteria(Long examId) {
-        this.examId = examId;
-    }
-
-    public ExamCourseCriteria(){
-
-    }
-
-    @Override
-    public String toString() {
-        return "ExamCourseCriteria{" +
-                "examId=" + examId +
-                ", courseCode='" + courseCode + '\'' +
-                ", courseLevel='" + courseLevel + '\'' +
-                ", orgId=" + orgId +
-                '}';
-    }
-}

+ 0 - 64
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/bean/ExamCourseDTO.java

@@ -1,64 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.bean;
-
-import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
-
-/**
- * Created by yuanpan on 2017/4/12.
- */
-public class ExamCourseDTO {
-
-    private Long examId;
-    private String examName;
-    private ExamType examType;
-    private String courseName;
-    private String courseCode;
-    private Long orgId;
-
-    public Long getExamId() {
-        return examId;
-    }
-
-    public void setExamId(Long examId) {
-        this.examId = examId;
-    }
-
-    public String getExamName() {
-        return examName;
-    }
-
-    public void setExamName(String examName) {
-        this.examName = examName;
-    }
-
-    public ExamType getExamType() {
-        return examType;
-    }
-
-    public void setExamType(ExamType examType) {
-        this.examType = examType;
-    }
-
-    public String getCourseName() {
-        return courseName;
-    }
-
-    public void setCourseName(String courseName) {
-        this.courseName = courseName;
-    }
-
-    public String getCourseCode() {
-        return courseCode;
-    }
-
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
-    }
-
-    public Long getOrgId() {
-        return orgId;
-    }
-
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
-    }
-}

+ 0 - 81
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/bean/OrgExamInfoDTO.java

@@ -1,81 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.bean;
-
-import java.io.Serializable;
-
-/**
- * @author  	chenken
- * @date    	2017年10月9日 下午4:37:56
- * @company 	QMTH
- * @description OrgExamIndo.java
- */
-public class OrgExamInfoDTO implements Serializable{
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -6886837934196751548L;
-	
-	private String orgId;
-	/**
-	 * 
-	 *	学习中心代码
-	 */
-	private String orgCode;
-	/**
-	 * 
-	 *	学习中心名称
-	 */
-	private String orgName;
-	
-	/**
-	 * 报考人数
-	 */
-	private Integer allNum;
-	/**
-	 * 实考人数
-	 */
-	private Integer completedNum;
-	/**
-	 * 完成比率
-	 */
-	private String proportion;
-	
-	public String getOrgId() {
-		return orgId;
-	}
-	public void setOrgId(String orgId) {
-		this.orgId = orgId;
-	}
-	public String getOrgCode() {
-		return orgCode;
-	}
-	public void setOrgCode(String orgCode) {
-		this.orgCode = orgCode;
-	}
-	public String getOrgName() {
-		return orgName;
-	}
-	public void setOrgName(String orgName) {
-		this.orgName = orgName;
-	}
-	public Integer getAllNum() {
-		return allNum;
-	}
-	public void setAllNum(Integer allNum) {
-		this.allNum = allNum;
-	}
-	public Integer getCompletedNum() {
-		return completedNum;
-	}
-	public void setCompletedNum(Integer completedNum) {
-		this.completedNum = completedNum;
-	}
-	public String getProportion() {
-		return proportion;
-	}
-	public void setProportion(String proportion) {
-		this.proportion = proportion;
-	}
-	
-}
-

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

@@ -18,7 +18,7 @@ import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
  *
  */
 @Entity
-@Table(name = "ecs_e_course_group")
+@Table(name = "EC_E_COURSE_GROUP")
 public class CourseGroupEntity extends JpaEntity {
 
 	private static final long serialVersionUID = -3335725218626631530L;

+ 3 - 3
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/CourseGroupRelation.java → examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/CourseGroupRelationEntity.java

@@ -1,12 +1,12 @@
 package cn.com.qmth.examcloud.core.examwork.dao.entity;
 
-import java.io.Serializable;
-
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.IdClass;
 import javax.persistence.Table;
 
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
+
 /**
  * 课程组关联课程
  * 
@@ -16,7 +16,7 @@ import javax.persistence.Table;
 @Entity
 @Table(name = "ecs_e_course_group_relation")
 @IdClass(CourseGroupRelationPK.class)
-public class CourseGroupRelation implements Serializable {
+public class CourseGroupRelationEntity extends JpaEntity {
 
 	private static final long serialVersionUID = -3335725218626631530L;
 

+ 35 - 5
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgEntity.java

@@ -3,8 +3,9 @@ package cn.com.qmth.examcloud.core.examwork.dao.entity;
 import java.util.Date;
 
 import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
-import javax.persistence.IdClass;
+import javax.persistence.Index;
 import javax.persistence.Table;
 
 import org.springframework.format.annotation.DateTimeFormat;
@@ -12,23 +13,36 @@ import org.springframework.format.annotation.DateTimeFormat;
 import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
- * 类注释
+ * 考试机构设置
  *
  * @author WANGWEI
  * @date 2018年5月16日
  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
  */
 @Entity
-@Table(name = "ecs_e_exam_org")
-@IdClass(ExamOrgPK.class)
+@Table(name = "EC_E_EXAM_ORG", indexes = {
+		@Index(name = "IDX_E_E_ORG_001001", columnList = "examId,orgId", unique = true)})
 public class ExamOrgEntity extends JpaEntity {
 
 	private static final long serialVersionUID = -3335725218626631530L;
 
 	@Id
+	@GeneratedValue
+	private Long id;
+
+	/**
+	 * 考试ID
+	 */
 	private Long examId;
 
-	@Id
+	/**
+	 * 顶级机构ID
+	 */
+	private Long rootOrgId;
+
+	/**
+	 * 机构ID
+	 */
 	private Long orgId;
 
 	/**
@@ -43,6 +57,14 @@ public class ExamOrgEntity extends JpaEntity {
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	private Date endTime;
 
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
 	public Long getExamId() {
 		return examId;
 	}
@@ -51,6 +73,14 @@ public class ExamOrgEntity extends JpaEntity {
 		this.examId = examId;
 	}
 
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
 	public Long getOrgId() {
 		return orgId;
 	}

+ 0 - 45
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgPK.java

@@ -1,45 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.entity;
-
-import java.io.Serializable;
-
-/**
- * 考试-学习中心 PK
- * 
- * @author WANG
- *
- */
-public class ExamOrgPK implements Serializable {
-
-	private static final long serialVersionUID = 3692854300698527252L;
-
-	private Long examId;
-
-	private Long orgId;
-
-	public ExamOrgPK() {
-		super();
-	}
-
-	public ExamOrgPK(Long examId, Long orgId) {
-		super();
-		this.examId = examId;
-		this.orgId = orgId;
-	}
-
-	public Long getExamId() {
-		return examId;
-	}
-
-	public void setExamId(Long examId) {
-		this.examId = examId;
-	}
-
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-
-}

+ 79 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgPropertyEntity.java

@@ -0,0 +1,79 @@
+package cn.com.qmth.examcloud.core.examwork.dao.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Index;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
+
+/**
+ * 机构属性配置
+ *
+ * @author WANGWEI
+ * @date 2018年8月6日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+@Entity
+@Table(name = "EC_E_EXAM_ORG_PROP", indexes = {
+		@Index(name = "IDX_E_E_ORG_PROP_001001", columnList = "examId,orgId,keyId", unique = true)})
+public class ExamOrgPropertyEntity extends JpaEntity {
+
+	private static final long serialVersionUID = 4009839764353162256L;
+
+	@Id
+	@GeneratedValue
+	private Long id;
+
+	private Long examId;
+
+	private Long orgId;
+
+	private Long keyId;
+
+	@Lob
+	private String value;
+
+	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 getOrgId() {
+		return orgId;
+	}
+
+	public void setOrgId(Long orgId) {
+		this.orgId = orgId;
+	}
+
+	public Long getKeyId() {
+		return keyId;
+	}
+
+	public void setKeyId(Long keyId) {
+		this.keyId = keyId;
+	}
+
+	public String getValue() {
+		return value;
+	}
+
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+}

+ 0 - 130
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgTime.java

@@ -1,130 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.entity;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 学习中心设置考试时间,只针对离线考试
- * Created by songyue on 18/2/1.
- */
-@Entity
-@Table(name = "ecs_exam_org_time")
-public class ExamOrgTime implements Serializable{
-
-    private static final long serialVersionUID = -6957590800607876766L;
-
-    @Id
-    @GeneratedValue
-    private Long id;
-
-    @NotNull
-    private Long examId;
-
-    @NotNull
-    private Long orgId;
-
-    private String orgCode;
-
-    private String orgName;
-
-    /**
-     * 该学习中心考试开始时间
-     */
-    private Date beginTime;
-
-    /**
-     * 该学习中心考试结束时间
-     */
-    private Date endTime;
-
-    /**
-     * 是否可上传
-     */
-    private Boolean canUpload;
-
-    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 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 String getOrgName() {
-        return orgName;
-    }
-
-    public void setOrgName(String orgName) {
-        this.orgName = orgName;
-    }
-
-    public Boolean getCanUpload() {
-        return canUpload;
-    }
-
-    public void setCanUpload(Boolean canUpload) {
-        this.canUpload = canUpload;
-    }
-
-    public String getOrgCode() {
-        return orgCode;
-    }
-
-    public void setOrgCode(String orgCode) {
-        this.orgCode = orgCode;
-    }
-
-    public ExamOrgTime(Long examId,
-                       Long orgId,
-                       String orgCode,
-                       String orgName,
-                       Date beginTime,
-                       Date endTime) {
-        this.examId = examId;
-        this.orgId = orgId;
-        this.orgCode = orgCode;
-        this.orgName = orgName;
-        this.beginTime = beginTime;
-        this.endTime = endTime;
-    }
-
-    public ExamOrgTime() {
-    }
-}

+ 0 - 54
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamScore.java

@@ -1,54 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.entity;
-
-import java.io.Serializable;
-
-import javax.persistence.*;
-
-/**
- * Created by songyue on 17/1/13.
- */
-@Entity
-@Table(name = "ecs_exam_score")
-public class ExamScore implements Serializable {
-
-	private static final long serialVersionUID = -3263640333978061256L;
-
-	@Id
-	@GeneratedValue
-	private Long id;
-
-	@OneToOne
-	@JoinColumn(name = "examStudentId")
-	private ExamStudentEntity examStudent;
-
-	private Double score;
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public static long getSerialVersionUID() {
-		return serialVersionUID;
-	}
-
-	public ExamStudentEntity getExamStudent() {
-		return examStudent;
-	}
-
-	public void setExamStudent(ExamStudentEntity examStudent) {
-		this.examStudent = examStudent;
-	}
-
-	public Double getScore() {
-		return score;
-	}
-
-	public void setScore(Double score) {
-		this.score = score;
-	}
-
-}

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

@@ -1,7 +1,9 @@
 package cn.com.qmth.examcloud.core.examwork.service;
 
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgEntity;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.ExamOrgInfo;
 
 /**
  * 类注释
@@ -21,4 +23,13 @@ public interface ExamService {
 	 */
 	ExamEntity saveExam(ExamInfo examInfo);
 
+	/**
+	 * 保存考试机构设置
+	 *
+	 * @author WANGWEI
+	 * @param examInfo
+	 * @return
+	 */
+	ExamOrgEntity saveExamOrg(ExamOrgInfo examInfo);
+
 }

+ 104 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/ExamOrgInfo.java

@@ -0,0 +1,104 @@
+package cn.com.qmth.examcloud.core.examwork.service.bean;
+
+import java.util.Date;
+import java.util.Map;
+
+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 ExamOrgInfo 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 Map<String, String> properties;
+
+	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 Map<String, String> getProperties() {
+		return properties;
+	}
+
+	public void setProperties(Map<String, String> properties) {
+		this.properties = properties;
+	}
+
+}

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

@@ -1,113 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.service.impl;
-
-import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamCourseCriteria;
-import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamCourseDTO;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageImpl;
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * Created by songyue on 18/4/2.
- */
-@Service
-public class ExamCourseService {
-
-    @Autowired
-    private JdbcTemplate jdbcTemplate;
-
-    @Autowired
-    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
-
-    public Page<ExamCourseDTO> findAllPage(ExamCourseCriteria examCourseCriteria){
-        StringBuilder sql = new StringBuilder();
-        sql.append(buildBaseSql());
-        sql.append(buildCriteriaSql(examCourseCriteria));
-        sql.append(buildGroupSql());
-        sql.append(buildPageSql(examCourseCriteria));
-        BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(ExamCourseDTO.class);
-        List<ExamCourseDTO> projectStatDTOs = this.namedParameterJdbcTemplate.query(sql.toString(), mapper);
-        long total = countAll(examCourseCriteria);
-        return new PageImpl<ExamCourseDTO>(projectStatDTOs,examCourseCriteria.getPageable(),total);
-
-    }
-
-    public List<ExamCourseDTO> findAll(ExamCourseCriteria examCourseCriteria){
-        StringBuilder sql = new StringBuilder();
-        sql.append(buildBaseSql());
-        sql.append(buildCriteriaSql(examCourseCriteria));
-        sql.append(buildGroupSql());
-        BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(ExamCourseDTO.class);
-        List<ExamCourseDTO> projectStatDTOs = this.namedParameterJdbcTemplate.query(sql.toString(), mapper);
-        return projectStatDTOs;
-    }
-
-    private long countAll(ExamCourseCriteria examCourseCriteria){
-        StringBuffer sql = new StringBuffer();
-        sql.append(buildCountSql(examCourseCriteria));
-        return this.jdbcTemplate.queryForObject(sql.toString(),Long.class);
-    }
-
-    private String buildPageSql(ExamCourseCriteria examCourseCriteria){
-        StringBuilder pageSql = new StringBuilder();
-        int currentNum = examCourseCriteria.getCurPage() * examCourseCriteria.getPageSize();
-        pageSql.append(" limit "+currentNum+","+examCourseCriteria.getPageSize());
-        return pageSql.toString();
-    }
-
-    private String buildCriteriaSql(ExamCourseCriteria examCourseCriteria){
-        StringBuilder criteriaSql = new StringBuilder();
-        if(examCourseCriteria.getExamId() != null){
-            criteriaSql.append(" and exam_id ="+examCourseCriteria.getExamId());
-        }
-        if(!StringUtils.isEmpty(examCourseCriteria.getCourseCode())){
-            criteriaSql.append(" and course_code ='"+examCourseCriteria.getCourseCode()+"'");
-        }
-        if(!StringUtils.isEmpty(examCourseCriteria.getCourseLevel())){
-            criteriaSql.append(" and course_level ='"+examCourseCriteria.getCourseLevel()+"'");
-        }
-        criteriaSql.append(" and exists (select 1 from ecs_core_course tc where tc.org_id = ts.root_org_id" +
-                                        " and tc.code = ts.course_code" +
-                                        " and tc.enable = 1)");
-        return criteriaSql.toString();
-    }
-
-    private String buildGroupSql(){
-        return " group by ts.course_code order by ts.course_code";
-    }
-
-    private String buildBaseSql(){
-        StringBuilder baseSql = new StringBuilder();
-        baseSql.append("select" +
-                        " ts.exam_id as exam_id," +
-                        " te.name as exam_name," +
-                        " te.exam_type as exam_type," +
-                        " ts.course_code as course_code," +
-                        " ts.course_name as course_name," +
-                        " ts.root_org_id as org_id" +
-                        " from" +
-                        " ecs_exam_student ts," +
-                        " ecs_exam te" +
-                        " where ts.exam_id = te.id");
-        return baseSql.toString();
-    }
-
-    private String buildCountSql(ExamCourseCriteria examCourseCriteria){
-        StringBuilder countSql = new StringBuilder();
-        countSql.append("select count(*) from (");
-        countSql.append(buildBaseSql());
-        countSql.append(buildCriteriaSql(examCourseCriteria));
-        countSql.append(buildGroupSql());
-        countSql.append(")as tt");
-        return countSql.toString();
-    }
-
-}

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

@@ -1,61 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.service.impl;
-
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by songyue on 18/3/1.
- */
-@Service
-public class ExamOrgTimeService {
-
-
-    @Autowired
-    private ExamOrgTimeRepo examOrgTimeRepo;
-
-    /**
-     * 获取所有学习中心考试时间(分页)
-     * @param examOrgTime
-     * @param pageable
-     * @return
-     * @return
-     */
-    public Page<ExamOrgTime> getAllOrgTime(ExamOrgTime examOrgTime, Pageable pageable){
-        Specification<ExamOrgTime> specification = getPageSpecification(examOrgTime);
-        Page<ExamOrgTime> examOrgTimes = examOrgTimeRepo.findAll(specification,pageable);
-        return examOrgTimes;
-    }
-
-    /**
-     * 生成查询条件
-     * @param examOrgTime
-     * @return
-     */
-    private Specification<ExamOrgTime> getPageSpecification(ExamOrgTime examOrgTime) {
-        Specification<ExamOrgTime> specification = (root, query, cb) -> {
-            List<Predicate> predicates = new ArrayList<>();
-            if(!StringUtils.isEmpty(examOrgTime.getExamId())){
-                predicates.add(cb.equal(root.get("examId"),examOrgTime.getExamId()));
-            }
-            if(!StringUtils.isEmpty(examOrgTime.getOrgCode())){
-                predicates.add(cb.like(root.get("orgCode"),"%"+examOrgTime.getOrgCode()+"%"));
-            }
-            if(!StringUtils.isEmpty(examOrgTime.getOrgName())){
-                predicates.add(cb.like(root.get("orgName"),"%"+examOrgTime.getOrgName()+"%"));
-            }
-            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-        };
-        return specification;
-    }
-}

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

@@ -1,85 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.service.impl;
-
-import cn.com.qmth.examcloud.core.examwork.dao.ExamScoreRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamScore;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
-import org.springframework.data.domain.ExampleMatcher;
-import org.springframework.data.domain.Pageable;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Service;
-
-import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
-
-/**
- * Created by songyue on 17/1/14.
- */
-@Service
-public class ExamScoreService {
-    @Autowired
-    ExamScoreRepo examScoreRepo;
-
-    /**
-     * 获取所有考试分数(分页)
-     * @param examCriteria
-     * @param pageable
-     * @return
-     */
-    public ResponseEntity getAllExamScore(ExamScore examCriteria, Pageable pageable){
-        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",startsWith());
-        Example<ExamScore> examExamScoreple = Example.of(examCriteria, exampleMatcher);
-        return new ResponseEntity(examScoreRepo.findAll(examExamScoreple,pageable), HttpStatus.OK);
-    }
-
-    /**
-     * 获取所有考试分数
-     * @param examCriteria
-     * @return
-     */
-    public ResponseEntity getAllExamScore(ExamScore examCriteria){
-        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",startsWith());
-        Example<ExamScore> examExamScoreple = Example.of(examCriteria, exampleMatcher);
-        return new ResponseEntity(examScoreRepo.findAll(examExamScoreple), HttpStatus.OK);
-    }
-
-    /**
-     * 按ID获取考试分数
-     * @param scoreId
-     * @return
-     */
-    public ResponseEntity<ExamScore> getExamScoreById(Long scoreId){
-        return new ResponseEntity<ExamScore>(examScoreRepo.findOne(scoreId),HttpStatus.OK);
-    }
-
-    /**
-     * 保存考试分数
-     * @param exam
-     * @return
-     */
-    public ResponseEntity saveExamScore(ExamScore exam){
-        return new ResponseEntity(examScoreRepo.save(exam),HttpStatus.OK);
-    }
-
-    /**
-     * 删除考试分数
-     * @param examId
-     * @return
-     */
-    public ResponseEntity deleteExamScore(Long examId){
-        examScoreRepo.delete(examId);
-        return new ResponseEntity(HttpStatus.OK);
-    }
-
-    /**
-     * 删除所有考试分数
-     * @return
-     */
-    public ResponseEntity deleteAllExamScore(){
-        examScoreRepo.deleteAll();
-        return new ResponseEntity(HttpStatus.OK);
-    }
-}

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

@@ -15,13 +15,17 @@ import com.google.common.collect.Maps;
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
 import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgPropertyRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgEntity;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgPropertyEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
 import cn.com.qmth.examcloud.core.examwork.service.ExamService;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
+import cn.com.qmth.examcloud.core.examwork.service.bean.ExamOrgInfo;
 
 /**
  * 类注释
@@ -39,7 +43,7 @@ public class ExamServiceImpl implements ExamService {
 	ExamStudentServiceImpl examStudentService;
 
 	@Autowired
-	ExamOrgTimeRepo examOrgTimeRepo;
+	ExamOrgRepo examOrgRepo;
 
 	@Autowired
 	OrgCloudService orgCloudService;
@@ -47,6 +51,9 @@ public class ExamServiceImpl implements ExamService {
 	@Autowired
 	ExamPropertyRepo examPropertyRepo;
 
+	@Autowired
+	ExamOrgPropertyRepo examOrgPropertyRepo;
+
 	/**
 	 * 删除考试批次
 	 * 
@@ -60,7 +67,7 @@ public class ExamServiceImpl implements ExamService {
 				throw new StatusException("", "[ " + exam.getName() + " ] 已经开考,不能删除");
 			}
 			// 删除学习中心考试时间
-			examOrgTimeRepo.deleteByExamId(exam.getId());
+			examOrgRepo.deleteByExamId(exam.getId());
 			examStudentService.deleteExamStudentsByExamId(exam.getId());
 			examRepo.delete(exam);
 		}
@@ -94,6 +101,7 @@ public class ExamServiceImpl implements ExamService {
 	public ExamEntity saveExam(ExamInfo examInfo) {
 
 		ExamEntity exam = new ExamEntity();
+		exam.setId(examInfo.getId());
 		exam.setBeginTime(examInfo.getBeginTime());
 		exam.setDuration(examInfo.getDuration());
 		exam.setEnable(examInfo.getEnable());
@@ -105,7 +113,46 @@ public class ExamServiceImpl implements ExamService {
 		exam.setRemark(examInfo.getRemark());
 		exam.setRootOrgId(examInfo.getRootOrgId());
 
+		if (null == exam.getExamType()) {
+			throw new StatusException("E-001005", "考试类型为空");
+		}
+
 		Map<String, String> properties = examInfo.getProperties();
+		Map<ExamProperty, String> map = checkAndGetExamProperties(properties);
+
+		ExamEntity findOne = examRepo.findByNameAndRootOrgId(exam.getName(), exam.getRootOrgId());
+		if (null != findOne && !findOne.getId().equals(exam.getId())) {
+			throw new StatusException("E-001001", "考试名称已存在");
+		}
+
+		ExamEntity saved = examRepo.save(exam);
+
+		for (Entry<ExamProperty, String> entry : map.entrySet()) {
+			ExamProperty prop = entry.getKey();
+			String value = entry.getValue();
+			ExamPropertyEntity entity = examPropertyRepo.findByexamIdAndKeyId(saved.getId(),
+					prop.getKeyId());
+			if (null == entity) {
+				entity = new ExamPropertyEntity();
+				entity.setExamId(saved.getId());
+				entity.setKeyId(prop.getKeyId());
+			}
+			entity.setValue(value);
+
+			examPropertyRepo.save(entity);
+		}
+
+		return saved;
+	}
+
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param properties
+	 * @return
+	 */
+	private Map<ExamProperty, String> checkAndGetExamProperties(Map<String, String> properties) {
 		Map<ExamProperty, String> map = Maps.newHashMap();
 		for (Entry<String, String> entry : properties.entrySet()) {
 			String key = entry.getKey();
@@ -122,10 +169,6 @@ public class ExamServiceImpl implements ExamService {
 			map.put(ep, value.trim());
 		}
 
-		if (null == exam.getExamType()) {
-			throw new StatusException("E-001005", "考试类型为空");
-		}
-
 		String beforeExamRemark = map.get(ExamProperty.BEFORE_EXAM_REMARK);
 		if (null != beforeExamRemark && beforeExamRemark.length() > 250000) {
 			throw new StatusException("E-001002", "考前说明内容过大");
@@ -141,26 +184,45 @@ public class ExamServiceImpl implements ExamService {
 			throw new StatusException("E-001002", "作弊说明内容过大");
 		}
 
-		ExamEntity findOne = examRepo.findByNameAndRootOrgId(exam.getName(), exam.getRootOrgId());
-		if (null != findOne && !findOne.getId().equals(exam.getId())) {
-			throw new StatusException("E-001001", "考试名称已存在");
-		}
+		return map;
+	}
 
-		ExamEntity saved = examRepo.save(exam);
+	/*
+	 * 实现
+	 *
+	 * @author WANGWEI
+	 * 
+	 * @see
+	 * cn.com.qmth.examcloud.core.examwork.service.ExamService#saveExamOrg(cn.
+	 * com.qmth.examcloud.core.examwork.service.bean.ExamOrgInfo)
+	 */
+	@Override
+	public ExamOrgEntity saveExamOrg(ExamOrgInfo examInfo) {
+		ExamOrgEntity examOrgEntity = new ExamOrgEntity();
+		examOrgEntity.setId(examInfo.getId());
+		examOrgEntity.setBeginTime(examInfo.getBeginTime());
+		examOrgEntity.setEndTime(examInfo.getEndTime());
+		examOrgEntity.setId(examInfo.getId());
+		examOrgEntity.setRootOrgId(examInfo.getRootOrgId());
+
+		Map<ExamProperty, String> map = checkAndGetExamProperties(examInfo.getProperties());
+
+		ExamOrgEntity saved = examOrgRepo.save(examOrgEntity);
 
 		for (Entry<ExamProperty, String> entry : map.entrySet()) {
 			ExamProperty prop = entry.getKey();
 			String value = entry.getValue();
-			ExamPropertyEntity entity = examPropertyRepo.findByexamIdAndKeyId(saved.getId(),
-					prop.getKeyId());
+			ExamOrgPropertyEntity entity = examOrgPropertyRepo.findByexamIdAndOrgIdAndKeyId(
+					saved.getExamId(), saved.getOrgId(), prop.getKeyId());
 			if (null == entity) {
-				entity = new ExamPropertyEntity();
-				entity.setExamId(saved.getId());
+				entity = new ExamOrgPropertyEntity();
+				entity.setExamId(saved.getExamId());
+				entity.setOrgId(saved.getOrgId());
 				entity.setKeyId(prop.getKeyId());
 			}
 			entity.setValue(value);
 
-			examPropertyRepo.save(entity);
+			examOrgPropertyRepo.save(entity);
 		}
 
 		return saved;

+ 2 - 2
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentServiceImpl.java

@@ -22,7 +22,7 @@ import cn.com.qmth.examcloud.core.basic.api.request.SaveCourseReq;
 import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
 import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
 import cn.com.qmth.examcloud.core.basic.api.response.SaveCourseResp;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
@@ -45,7 +45,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	ExamRepo examRepo;
 
 	@Autowired
-	ExamOrgTimeRepo examOrgTimeRepo;
+	ExamOrgRepo examOrgRepo;
 
 	@Autowired
 	OrgCloudService orgCloudService;