WANG il y a 6 ans
Parent
commit
0d41d7a888
32 fichiers modifiés avec 290 ajouts et 445 suppressions
  1. 2 1
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/AuthController.java
  2. 13 9
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/CourseController.java
  3. 13 6
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/CourseSpeciatlyRelationController.java
  4. 3 2
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/ExamSiteController.java
  5. 3 1
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/FaceController.java
  6. 3 3
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/LogController.java
  7. 16 15
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/OrgController.java
  8. 17 9
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/RolePrivilegeController.java
  9. 8 3
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/SpecialtyController.java
  10. 26 18
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/StudentController.java
  11. 28 17
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/TestController.java
  12. 64 40
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/UserController.java
  13. 3 2
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/CommonCloudServiceProvider.java
  14. 3 2
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/CourseCloudServiceProvider.java
  15. 5 2
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/FaceCloudServiceProvider.java
  16. 5 4
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/OrgCloudServiceProvider.java
  17. 3 1
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/RolePrivilegeCloudServiceProvider.java
  18. 5 4
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/StudentCloudServiceProvider.java
  19. 1 1
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/SysConfigCloudServiceProvider.java
  20. 9 7
      examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/UserCloudServiceProvider.java
  21. 9 7
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/AuthServiceImpl.java
  22. 3 2
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/CourseServiceImpl.java
  23. 4 3
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/ExamSiteServiceImpl.java
  24. 6 3
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/FaceServiceImpl.java
  25. 5 4
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/OrgServiceImpl.java
  26. 5 4
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/RolePrivilegeServiceImpl.java
  27. 2 1
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/SpecialtyServiceImpl.java
  28. 7 6
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/StudentServiceImpl.java
  29. 3 3
      examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/SysConfigServiceImpl.java
  30. 16 100
      examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/CoreBasicApp.java
  31. 0 39
      examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/config/AppSelfInspection.java
  32. 0 126
      examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/config/DefaultWebMvcConfigurerAdapter.java

+ 2 - 1
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/AuthController.java

@@ -24,6 +24,7 @@ import cn.com.qmth.examcloud.core.basic.service.ImgCodeService;
 import cn.com.qmth.examcloud.core.basic.service.SmsCodeService;
 import cn.com.qmth.examcloud.core.basic.service.StudentService;
 import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.web.support.StatusResponseX;
@@ -162,7 +163,7 @@ public class AuthController extends ControllerSupport {
 			}
 		}
 
-		StudentEntity s = studentRepo.findOne(studentId);
+		StudentEntity s = GlobalHelper.getEntity(studentRepo, studentId, StudentEntity.class);
 		s.setSecurityPhone(phone);
 		studentRepo.saveAndFlush(s);
 	}

+ 13 - 9
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/CourseController.java

@@ -53,6 +53,7 @@ import cn.com.qmth.examcloud.core.basic.service.bean.CourseInfo;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
 import cn.com.qmth.examcloud.task.api.request.SyncCourseReq;
 import cn.com.qmth.examcloud.web.config.SystemConfig;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -67,6 +68,9 @@ public class CourseController extends ControllerSupport {
 	@Autowired
 	CourseRepo courseRepo;
 
+	@Autowired
+	SystemConfig systemConfig;
+
 	@Autowired
 	CourseService courseService;
 
@@ -135,7 +139,7 @@ public class CourseController extends ControllerSupport {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(curPage, pageSize,
+		PageRequest pageRequest = PageRequest.of(curPage, pageSize,
 				new Sort(Direction.DESC, "updateTime"));
 
 		Page<CourseEntity> page = courseRepo.findAll(specification, pageRequest);
@@ -199,7 +203,7 @@ public class CourseController extends ControllerSupport {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(0, 50, new Sort(Direction.DESC, "updateTime"));
+		PageRequest pageRequest = PageRequest.of(0, 50, new Sort(Direction.DESC, "updateTime"));
 
 		Page<CourseEntity> page = courseRepo.findAll(specification, pageRequest);
 
@@ -233,7 +237,7 @@ public class CourseController extends ControllerSupport {
 	@ApiOperation(value = "按ID查询课程", notes = "ID查询")
 	@GetMapping("{id}")
 	public CourseEntity getCourseById(@PathVariable Long id) {
-		CourseEntity course = courseRepo.findOne(id);
+		CourseEntity course = GlobalHelper.getEntity(courseRepo, id, CourseEntity.class);
 		if (null == course) {
 			throw new StatusException("B-540001", "课程不存在");
 		}
@@ -352,7 +356,7 @@ public class CourseController extends ControllerSupport {
 		List<Long> courseIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
 				.collect(Collectors.toList());
 		for (Long courseId : courseIds) {
-			CourseEntity one = courseRepo.findOne(courseId);
+			CourseEntity one = GlobalHelper.getEntity(courseRepo, courseId, CourseEntity.class);
 			if (null == one) {
 				continue;
 			}
@@ -437,7 +441,7 @@ public class CourseController extends ControllerSupport {
 			datas.add(new Object[]{cur.getName(), cur.getCode(), cur.getLevel().getName()});
 		}
 
-		String filePath = SystemConfig.getTempDataDir() + File.separator
+		String filePath = systemConfig.getTempDataDir() + File.separator
 				+ System.currentTimeMillis() + ".xlsx";
 		File file = new File(filePath);
 
@@ -463,13 +467,13 @@ public class CourseController extends ControllerSupport {
 				.collect(Collectors.toList());
 
 		for (Long courseId : courseIds) {
-			CourseEntity course = courseRepo.findOne(courseId);
+			CourseEntity course = GlobalHelper.getEntity(courseRepo, courseId, CourseEntity.class);
 			course.setEnable(false);
 			courseRepo.save(course);
 		}
 
 		for (Long courseId : courseIds) {
-			CourseEntity ce = courseRepo.findOne(courseId);
+			CourseEntity ce = GlobalHelper.getEntity(courseRepo, courseId, CourseEntity.class);
 			SyncCourseReq req = new SyncCourseReq();
 			req.setCode(ce.getCode());
 			req.setEnable(ce.getEnable());
@@ -498,13 +502,13 @@ public class CourseController extends ControllerSupport {
 				.collect(Collectors.toList());
 
 		for (Long courseId : courseIds) {
-			CourseEntity course = courseRepo.findOne(courseId);
+			CourseEntity course = GlobalHelper.getEntity(courseRepo, courseId, CourseEntity.class);
 			course.setEnable(true);
 			courseRepo.save(course);
 		}
 
 		for (Long courseId : courseIds) {
-			CourseEntity ce = courseRepo.findOne(courseId);
+			CourseEntity ce = GlobalHelper.getEntity(courseRepo, courseId, CourseEntity.class);
 			SyncCourseReq req = new SyncCourseReq();
 			req.setCode(ce.getCode());
 			req.setEnable(ce.getEnable());

+ 13 - 6
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/CourseSpeciatlyRelationController.java

@@ -17,6 +17,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.CourseEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.CourseSpeciatlyRelationEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.CourseSpeciatlyRelationPK;
 import cn.com.qmth.examcloud.core.basic.dao.entity.SpecialtyEntity;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -53,14 +54,16 @@ public class CourseSpeciatlyRelationController extends ControllerSupport {
 			throw new StatusException("B-320002", "specialtyId is null");
 		}
 
-		CourseEntity courseEntity = courseRepo.findOne(courseId);
+		CourseEntity courseEntity = GlobalHelper.getEntity(courseRepo, courseId,
+				CourseEntity.class);
 		if (null == courseEntity) {
 			throw new StatusException("B-320001", "courseId is wrong");
 		}
 
 		this.validateRootOrgIsolation(courseEntity.getRootOrgId());
 
-		SpecialtyEntity specialtyEntity = specialtyRepo.findOne(specialtyId);
+		SpecialtyEntity specialtyEntity = GlobalHelper.getEntity(specialtyRepo, specialtyId,
+				SpecialtyEntity.class);
 		if (null == specialtyEntity) {
 			throw new StatusException("B-320001", "specialtyId is wrong");
 		}
@@ -71,7 +74,8 @@ public class CourseSpeciatlyRelationController extends ControllerSupport {
 		pk.setCourseId(courseId);
 		pk.setSpecialtyId(specialtyId);
 
-		CourseSpeciatlyRelationEntity one = courseSpeciatlyRelationRepo.findOne(pk);
+		CourseSpeciatlyRelationEntity one = GlobalHelper.getEntity(courseSpeciatlyRelationRepo, pk,
+				CourseSpeciatlyRelationEntity.class);
 		if (null != one) {
 			throw new StatusException("B-320003", "课程专业已关联");
 		}
@@ -99,14 +103,16 @@ public class CourseSpeciatlyRelationController extends ControllerSupport {
 			throw new StatusException("B-320002", "specialtyId is null");
 		}
 
-		CourseEntity courseEntity = courseRepo.findOne(courseId);
+		CourseEntity courseEntity = GlobalHelper.getEntity(courseRepo, courseId,
+				CourseEntity.class);
 		if (null == courseEntity) {
 			throw new StatusException("B-320001", "courseId is wrong");
 		}
 
 		this.validateRootOrgIsolation(courseEntity.getRootOrgId());
 
-		SpecialtyEntity specialtyEntity = specialtyRepo.findOne(specialtyId);
+		SpecialtyEntity specialtyEntity = GlobalHelper.getEntity(specialtyRepo, specialtyId,
+				SpecialtyEntity.class);
 		if (null == specialtyEntity) {
 			throw new StatusException("B-320001", "specialtyId is wrong");
 		}
@@ -117,7 +123,8 @@ public class CourseSpeciatlyRelationController extends ControllerSupport {
 		pk.setCourseId(courseId);
 		pk.setSpecialtyId(specialtyId);
 
-		CourseSpeciatlyRelationEntity one = courseSpeciatlyRelationRepo.findOne(pk);
+		CourseSpeciatlyRelationEntity one = GlobalHelper.getEntity(courseSpeciatlyRelationRepo, pk,
+				CourseSpeciatlyRelationEntity.class);
 		if (null == one) {
 			throw new StatusException("B-320003", "课程专业未关联");
 		}

+ 3 - 2
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/ExamSiteController.java

@@ -32,6 +32,7 @@ import cn.com.qmth.examcloud.core.basic.dao.ExamSiteRepo;
 import cn.com.qmth.examcloud.core.basic.dao.entity.ExamSiteEntity;
 import cn.com.qmth.examcloud.core.basic.service.bean.ExamSiteInfo;
 import cn.com.qmth.examcloud.core.basic.service.impl.ExamSiteServiceImpl;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -80,7 +81,7 @@ public class ExamSiteController extends ControllerSupport {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(curPage, pageSize,
+		PageRequest pageRequest = PageRequest.of(curPage, pageSize,
 				new Sort(Direction.DESC, "updateTime"));
 
 		Page<ExamSiteEntity> page = examSiteRepo.findAll(specification, pageRequest);
@@ -168,7 +169,7 @@ public class ExamSiteController extends ControllerSupport {
 		List<Long> examSiteIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
 				.collect(Collectors.toList());
 		for (Long id : examSiteIds) {
-			ExamSiteEntity one = examSiteRepo.findOne(id);
+			ExamSiteEntity one = GlobalHelper.getEntity(examSiteRepo, id, ExamSiteEntity.class);
 			if (null == one) {
 				continue;
 			}

+ 3 - 1
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/FaceController.java

@@ -19,6 +19,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.FacesetEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.StudentFaceEntity;
 import cn.com.qmth.examcloud.core.basic.service.FaceService;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentFaceInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -76,7 +77,8 @@ public class FaceController extends ControllerSupport {
 			throw new StatusException("B-710001", "studentId is null");
 		}
 
-		StudentFaceEntity studentFaceEntity = studentFaceRepo.findOne(studentId);
+		StudentFaceEntity studentFaceEntity = GlobalHelper.getEntity(studentFaceRepo, studentId,
+				StudentFaceEntity.class);
 
 		if (null == studentFaceEntity) {
 			throw new StatusException("B-710001", "studentFaceEntity is null");

+ 3 - 3
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/LogController.java

@@ -2,7 +2,7 @@ package cn.com.qmth.examcloud.core.basic.api.controller;
 
 import java.util.Map;
 
-import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.RegExUtils;
 import org.slf4j.MDC;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -39,7 +39,7 @@ public class LogController extends ControllerSupport {
 	public String logByStudentClient(@PathVariable String level, @PathVariable String code,
 			@RequestBody String info) {
 		log("STU_CLIENT_LOGGER", level, code, info);
-		return DateUtil.getNowISO();
+		return DateUtil.chinaNow();
 	}
 
 	/**
@@ -56,7 +56,7 @@ public class LogController extends ControllerSupport {
 			throw new StatusException("B-500002",
 					"code must match regular expression:  \\w{1,2}\\-\\d{6}");
 		}
-		info = StringUtils.replaceAll(info, "[\n\r]", "  ");
+		info = RegExUtils.replaceAll(info, "[\n\r]", "  ");
 		ExamCloudLog log = getLogger(logger);
 		MDC.put("CODE", code);
 		if ("debug".equalsIgnoreCase(level)) {

+ 16 - 15
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/OrgController.java

@@ -59,6 +59,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.OrgPropertyEntity;
 import cn.com.qmth.examcloud.core.basic.dao.enums.OrgProperty;
 import cn.com.qmth.examcloud.core.basic.service.bean.OrgInfo;
 import cn.com.qmth.examcloud.core.basic.service.impl.OrgServiceImpl;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -86,7 +87,7 @@ public class OrgController extends ControllerSupport {
 			@RequestParam(required = false) String name,
 			@RequestParam(required = false) String propertyKeys) {
 
-		Pageable pageable = new PageRequest(curPage, pageSize, Sort.Direction.DESC, "updateTime");
+		Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime");
 
 		Specification<OrgEntity> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();
@@ -157,7 +158,7 @@ public class OrgController extends ControllerSupport {
 			@RequestParam(required = false) String name,
 			@RequestParam(required = false) String propertyKeys) {
 
-		Pageable pageable = new PageRequest(curPage, pageSize, Sort.Direction.DESC, "updateTime");
+		Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime");
 
 		Specification<OrgEntity> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();
@@ -245,7 +246,7 @@ public class OrgController extends ControllerSupport {
 	@ApiOperation(value = "按ID查询顶级机构", notes = "ID查询")
 	@GetMapping("rootOrg/{rootOrgId}")
 	public OrgEntity getRootOrg(@PathVariable Long rootOrgId) {
-		OrgEntity orgEntity = orgRepo.findOne(rootOrgId);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-001250", "rootOrgId is wrong");
 		}
@@ -267,7 +268,7 @@ public class OrgController extends ControllerSupport {
 	@ApiOperation(value = "按ID查询子机构", notes = "ID查询")
 	@GetMapping("subOrg/{orgId}")
 	public OrgEntity getSubOrg(@PathVariable Long orgId) {
-		OrgEntity orgEntity = orgRepo.findOne(orgId);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-001250", "orgId is wrong");
 		}
@@ -316,13 +317,13 @@ public class OrgController extends ControllerSupport {
 			throw new StatusException("B-001249", "parentId is null");
 		}
 
-		OrgEntity parentOrg = orgRepo.findOne(parentId);
+		OrgEntity parentOrg = GlobalHelper.getEntity(orgRepo, parentId, OrgEntity.class);
 		if (null == parentOrg) {
 			throw new StatusException("B-001250", "parentId is wrong");
 		}
 		validateRootOrgIsolation(parentOrg.getRootId());
 
-		Pageable pageable = new PageRequest(curPage, pageSize, Sort.Direction.DESC, "updateTime");
+		Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime");
 
 		Specification<OrgEntity> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();
@@ -446,7 +447,7 @@ public class OrgController extends ControllerSupport {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(0, 50, new Sort(Direction.DESC, "updateTime"));
+		PageRequest pageRequest = PageRequest.of(0, 50, new Sort(Direction.DESC, "updateTime"));
 		Page<OrgEntity> page = orgRepo.findAll(specification, pageRequest);
 		Iterator<OrgEntity> iterator = page.iterator();
 		List<OrgEntity> list = Lists.newArrayList();
@@ -537,7 +538,7 @@ public class OrgController extends ControllerSupport {
 	@GetMapping("allProperties/{orgId}")
 	public Map<String, String> getAllOrgProperties(@PathVariable Long orgId) {
 
-		OrgEntity orgEntity = orgRepo.findOne(orgId);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-001250", "orgId is wrong");
 		}
@@ -565,7 +566,7 @@ public class OrgController extends ControllerSupport {
 	@ApiOperation(value = "查询机构单个属性")
 	@GetMapping("property/{orgId}/{key}")
 	public String getOrgProperty(@PathVariable Long orgId, @PathVariable String key) {
-		OrgEntity orgEntity = orgRepo.findOne(orgId);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-001250", "orgId is wrong");
 		}
@@ -586,7 +587,7 @@ public class OrgController extends ControllerSupport {
 			@RequestParam(required = false) String domainName, @PathVariable String key) {
 		OrgEntity orgEntity = null;
 		if (null != orgId) {
-			orgEntity = orgRepo.findOne(orgId);
+			orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 			if (null == orgEntity) {
 				throw new StatusException("B-001250", "orgId is wrong");
 			}
@@ -672,7 +673,7 @@ public class OrgController extends ControllerSupport {
 			throw new StatusException("B-140001", "id is null");
 		}
 
-		OrgEntity orgEntity = orgRepo.findOne(id);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, id, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-140002", "orgEntity is null");
 		}
@@ -768,7 +769,7 @@ public class OrgController extends ControllerSupport {
 			throw new StatusException("B-140001", "id is null");
 		}
 
-		OrgEntity orgEntity = orgRepo.findOne(id);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, id, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-140002", "orgEntity is null");
 		}
@@ -808,7 +809,7 @@ public class OrgController extends ControllerSupport {
 		List<Long> orgIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
 				.collect(Collectors.toList());
 		for (Long orgId : orgIds) {
-			OrgEntity org = orgRepo.findOne(orgId);
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 			org.setEnable(true);
 			orgRepo.save(org);
 		}
@@ -826,7 +827,7 @@ public class OrgController extends ControllerSupport {
 		List<Long> orgIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
 				.collect(Collectors.toList());
 		for (Long orgId : orgIds) {
-			OrgEntity org = orgRepo.findOne(orgId);
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 			org.setEnable(false);
 			orgRepo.save(org);
 		}
@@ -874,7 +875,7 @@ public class OrgController extends ControllerSupport {
 	public void importLogo(@PathVariable Long orgId, HttpServletRequest request,
 			@RequestParam CommonsMultipartFile file) throws IOException {
 
-		OrgEntity orgEntity = orgRepo.findOne(orgId);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-140002", "orgEntity is null");
 		}

+ 17 - 9
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/RolePrivilegeController.java

@@ -46,6 +46,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.RolePrivilegeRelationEntity;
 import cn.com.qmth.examcloud.core.basic.service.RolePrivilegeService;
 import cn.com.qmth.examcloud.core.basic.service.bean.RoleInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.helpers.tree.EleTreeNode;
 import cn.com.qmth.examcloud.web.helpers.tree.TreeUtil;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
@@ -201,7 +202,7 @@ public class RolePrivilegeController extends ControllerSupport {
 			PrivilegeGroupDomain bean = new PrivilegeGroupDomain();
 			bean.setId(cur.getId());
 			bean.setAppId(cur.getAppId());
-			AppEntity app = appRepo.findOne(cur.getAppId());
+			AppEntity app = GlobalHelper.getEntity(appRepo, cur.getAppId(), AppEntity.class);
 			if (null != app) {
 				bean.setAppName(app.getName());
 			}
@@ -217,7 +218,8 @@ public class RolePrivilegeController extends ControllerSupport {
 	@ApiOperation(value = "查询权限树")
 	@GetMapping("getPrivilegeTree/{groupId}")
 	public EleTreeNode getPrivilegeTree(@PathVariable Long groupId) {
-		PrivilegeGroupEntity group = privilegeGroupRepo.findOne(groupId);
+		PrivilegeGroupEntity group = GlobalHelper.getEntity(privilegeGroupRepo, groupId,
+				PrivilegeGroupEntity.class);
 		List<PrivilegeEntity> privilegeList = privilegeRepo
 				.findAllByGroupIdOrderByWeightDesc(groupId);
 		EleTreeNode rootNode = new EleTreeNode(BasicConsts.ROOT_PRIVILEGE_ID, group.getName());
@@ -270,7 +272,8 @@ public class RolePrivilegeController extends ControllerSupport {
 			throw new StatusException("B-020101", "权限编码必须由字母,数字和下划线组成");
 		}
 
-		PrivilegeGroupEntity group = privilegeGroupRepo.findOne(privilege.getGroupId());
+		PrivilegeGroupEntity group = GlobalHelper.getEntity(privilegeGroupRepo,
+				privilege.getGroupId(), PrivilegeGroupEntity.class);
 		if (null == group) {
 			throw new StatusException("B-020001", "权限组不存在");
 		}
@@ -279,7 +282,8 @@ public class RolePrivilegeController extends ControllerSupport {
 				|| BasicConsts.ROOT_PRIVILEGE_ID == privilege.getParentId()) {
 			privilege.setParentId(null);
 		} else {
-			PrivilegeEntity parentPrivilege = privilegeRepo.findOne(privilege.getParentId());
+			PrivilegeEntity parentPrivilege = GlobalHelper.getEntity(privilegeRepo,
+					privilege.getParentId(), PrivilegeEntity.class);
 			if (null == parentPrivilege) {
 				throw new StatusException("B-020002", "父权限不存在");
 			}
@@ -300,13 +304,15 @@ public class RolePrivilegeController extends ControllerSupport {
 		privilege.setName(privilege.getName().trim());
 		privilege.setCode(privilege.getCode().trim());
 		privilege.setDescription(privilege.getDescription());
-		PrivilegeGroupEntity group = privilegeGroupRepo.findOne(privilege.getGroupId());
+		PrivilegeGroupEntity group = GlobalHelper.getEntity(privilegeGroupRepo,
+				privilege.getGroupId(), PrivilegeGroupEntity.class);
 		if (null == group) {
 			throw new StatusException("B-020001", "权限组不存在");
 		}
 
 		if (null != privilege.getParentId()) {
-			PrivilegeEntity parentPrivilege = privilegeRepo.findOne(privilege.getParentId());
+			PrivilegeEntity parentPrivilege = GlobalHelper.getEntity(privilegeRepo,
+					privilege.getParentId(), PrivilegeEntity.class);
 			if (null == parentPrivilege) {
 				throw new StatusException("B-020002", "父权限不存在");
 			}
@@ -323,7 +329,8 @@ public class RolePrivilegeController extends ControllerSupport {
 	@ApiOperation(value = "删除权限")
 	@DeleteMapping("deletePrivilege/{id}")
 	public void deletePrivilege(@PathVariable Long id) {
-		PrivilegeEntity privilege = privilegeRepo.findOne(id);
+		PrivilegeEntity privilege = GlobalHelper.getEntity(privilegeRepo, id,
+				PrivilegeEntity.class);
 		if (null == privilege) {
 			throw new StatusException("B-020004", "权限不存在");
 		}
@@ -333,14 +340,15 @@ public class RolePrivilegeController extends ControllerSupport {
 			throw new StatusException("B-020005", "存在子权限");
 		}
 
-		privilegeRepo.delete(id);
+		privilegeRepo.deleteById(id);
 		rolePrivilegeRelationRepo.deleteByPrivilegeId(id);
 	}
 
 	@ApiOperation(value = "查询权限")
 	@GetMapping("getPrivilege/{id}")
 	public PrivilegeEntity getPrivilege(@PathVariable Long id) {
-		PrivilegeEntity privilege = privilegeRepo.findOne(id);
+		PrivilegeEntity privilege = GlobalHelper.getEntity(privilegeRepo, id,
+				PrivilegeEntity.class);
 		if (null == privilege) {
 			throw new StatusException("B-020004", "权限不存在");
 		}

+ 8 - 3
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/SpecialtyController.java

@@ -50,6 +50,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.SpecialtyEntity;
 import cn.com.qmth.examcloud.core.basic.service.SpecialtyService;
 import cn.com.qmth.examcloud.core.basic.service.bean.SpecialtyInfo;
 import cn.com.qmth.examcloud.web.config.SystemConfig;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -66,6 +67,9 @@ public class SpecialtyController extends ControllerSupport {
 	@Autowired
 	SpecialtyService specialtyService;
 
+	@Autowired
+	SystemConfig systemConfig;
+
 	@Autowired
 	SpecialtyRepo specialtyRepo;
 
@@ -128,7 +132,7 @@ public class SpecialtyController extends ControllerSupport {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(curPage, pageSize,
+		PageRequest pageRequest = PageRequest.of(curPage, pageSize,
 				new Sort(Direction.DESC, "updateTime"));
 
 		Page<SpecialtyEntity> page = specialtyRepo.findAll(specification, pageRequest);
@@ -282,7 +286,8 @@ public class SpecialtyController extends ControllerSupport {
 		List<Long> specialtyIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
 				.collect(Collectors.toList());
 		for (Long specialtyId : specialtyIds) {
-			SpecialtyEntity one = specialtyRepo.findOne(specialtyId);
+			SpecialtyEntity one = GlobalHelper.getEntity(specialtyRepo, specialtyId,
+					SpecialtyEntity.class);
 			if (null == one) {
 				continue;
 			}
@@ -364,7 +369,7 @@ public class SpecialtyController extends ControllerSupport {
 			datas.add(new Object[]{cur.getName(), cur.getCode()});
 		}
 
-		String filePath = SystemConfig.getTempDataDir() + File.separator
+		String filePath = systemConfig.getTempDataDir() + File.separator
 				+ System.currentTimeMillis() + ".xlsx";
 		File file = new File(filePath);
 

+ 26 - 18
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/StudentController.java

@@ -47,6 +47,7 @@ import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
 import cn.com.qmth.examcloud.task.api.request.SyncStudentReq;
 import cn.com.qmth.examcloud.web.config.SystemConfig;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -61,6 +62,9 @@ public class StudentController extends ControllerSupport {
 	@Autowired
 	StudentRepo studentRepo;
 
+	@Autowired
+	SystemConfig systemConfig;
+
 	@Autowired
 	StudentService studentService;
 
@@ -131,7 +135,7 @@ public class StudentController extends ControllerSupport {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(curPage, pageSize,
+		PageRequest pageRequest = PageRequest.of(curPage, pageSize,
 				new Sort(Direction.DESC, "updateTime"));
 
 		Page<StudentEntity> studentList = studentRepo.findAll(specification, pageRequest);
@@ -166,7 +170,8 @@ public class StudentController extends ControllerSupport {
 
 			bean.setOrgId(next.getOrgId());
 			if (null != bean.getOrgId()) {
-				OrgEntity org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
+				OrgEntity org = GlobalHelper.getEntity(orgRepo, Long.valueOf(bean.getOrgId()),
+						OrgEntity.class);
 				if (null != org) {
 					bean.setOrgName(org.getName());
 				}
@@ -238,7 +243,8 @@ public class StudentController extends ControllerSupport {
 			String orgCode = null;
 			String orgName = null;
 			if (null != cur.getOrgId()) {
-				OrgEntity org = orgRepo.findOne(Long.valueOf(cur.getOrgId()));
+				OrgEntity org = GlobalHelper.getEntity(orgRepo, Long.valueOf(cur.getOrgId()),
+						OrgEntity.class);
 				if (null != org) {
 					orgCode = org.getCode();
 					orgName = org.getName();
@@ -248,7 +254,7 @@ public class StudentController extends ControllerSupport {
 					cur.getIdentityNumber(), orgCode, orgName});
 		}
 
-		String filePath = SystemConfig.getTempDataDir() + File.separator
+		String filePath = systemConfig.getTempDataDir() + File.separator
 				+ System.currentTimeMillis() + ".xlsx";
 		File file = new File(filePath);
 
@@ -270,11 +276,11 @@ public class StudentController extends ControllerSupport {
 	@ApiOperation(value = "按ID删除学生", notes = "删除")
 	@DeleteMapping("{id}")
 	public Long deleteStudent(@PathVariable Long id) {
-		StudentEntity s = studentRepo.findOne(id);
+		StudentEntity s = GlobalHelper.getEntity(studentRepo, id, StudentEntity.class);
 		if (null != s) {
 			validateRootOrgIsolation(s.getRootOrgId());
 		}
-		studentRepo.delete(id);
+		studentRepo.deleteById(id);
 		return id;
 	}
 
@@ -292,7 +298,7 @@ public class StudentController extends ControllerSupport {
 				.collect(Collectors.toList());
 		List<String> ret = Lists.newArrayList();
 		for (Long cur : studentIds) {
-			StudentEntity s = studentRepo.findOne(cur);
+			StudentEntity s = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
 			s.setEnable(true);
 			studentRepo.save(s);
 			ret.add(s.getId() + ":" + s.getName());
@@ -314,7 +320,7 @@ public class StudentController extends ControllerSupport {
 				.collect(Collectors.toList());
 		List<String> ret = Lists.newArrayList();
 		for (Long cur : studentIds) {
-			StudentEntity s = studentRepo.findOne(cur);
+			StudentEntity s = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
 			s.setEnable(false);
 			studentRepo.save(s);
 			ret.add(s.getId() + ":" + s.getName());
@@ -328,7 +334,7 @@ public class StudentController extends ControllerSupport {
 		List<Long> studentIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
 				.collect(Collectors.toList());
 		for (Long cur : studentIds) {
-			StudentEntity s = studentRepo.findOne(cur);
+			StudentEntity s = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
 			if (null == s) {
 				throw new StatusException("B-450110", "学生不存在");
 			}
@@ -363,7 +369,8 @@ public class StudentController extends ControllerSupport {
 			throw new StatusException("B-450203", "密码必须是6至18位字母或数字");
 		}
 
-		StudentEntity s = studentRepo.findOne(accessUser.getUserId());
+		StudentEntity s = GlobalHelper.getEntity(studentRepo, accessUser.getUserId(),
+				StudentEntity.class);
 		s.setPassword(newPassword);
 		studentRepo.save(s);
 		return s.getId();
@@ -393,7 +400,8 @@ public class StudentController extends ControllerSupport {
 			throw new StatusException("B-450111", "密码必须是6至18位字母或数字");
 		}
 
-		StudentEntity s = studentRepo.findOne(accessUser.getUserId());
+		StudentEntity s = GlobalHelper.getEntity(studentRepo, accessUser.getUserId(),
+				StudentEntity.class);
 
 		if (StringUtils.isNotBlank(s.getPassword()) && !s.getPassword().equals(password)) {
 			throw new StatusException("B-450111", "当前密码错误");
@@ -447,7 +455,7 @@ public class StudentController extends ControllerSupport {
 		List<Long> studentIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
 				.collect(Collectors.toList());
 		for (Long cur : studentIds) {
-			StudentEntity s = studentRepo.findOne(cur);
+			StudentEntity s = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
 			if (null == s) {
 				throw new StatusException("B-450110", "学生不存在");
 			}
@@ -458,7 +466,7 @@ public class StudentController extends ControllerSupport {
 		}
 
 		for (Long cur : studentIds) {
-			StudentEntity saved = studentRepo.findOne(cur);
+			StudentEntity saved = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
 			SyncStudentReq req = new SyncStudentReq();
 			req.setEnable(saved.getEnable());
 			req.setId(saved.getId());
@@ -466,7 +474,7 @@ public class StudentController extends ControllerSupport {
 			req.setName(saved.getName());
 
 			req.setOrgId(saved.getOrgId());
-			OrgEntity org = orgRepo.findOne(saved.getOrgId());
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, saved.getOrgId(), OrgEntity.class);
 			req.setOrgCode(org.getCode());
 			req.setOrgName(org.getName());
 
@@ -492,7 +500,7 @@ public class StudentController extends ControllerSupport {
 		if (null == rootOrgId) {
 			rootOrgId = getRootOrgId();
 		} else {
-			OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+			OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 			if (null == rootOrg) {
 				throw new StatusException("B-450110", "rootOrgId is wrong");
 			}
@@ -511,7 +519,7 @@ public class StudentController extends ControllerSupport {
 		List<Long> studentIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
 				.collect(Collectors.toList());
 		for (Long cur : studentIds) {
-			StudentEntity s = studentRepo.findOne(cur);
+			StudentEntity s = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
 			if (null == s) {
 				throw new StatusException("B-450110", "学生不存在");
 			}
@@ -522,7 +530,7 @@ public class StudentController extends ControllerSupport {
 		}
 
 		for (Long cur : studentIds) {
-			StudentEntity saved = studentRepo.findOne(cur);
+			StudentEntity saved = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
 			SyncStudentReq req = new SyncStudentReq();
 			req.setEnable(saved.getEnable());
 			req.setId(saved.getId());
@@ -530,7 +538,7 @@ public class StudentController extends ControllerSupport {
 			req.setName(saved.getName());
 
 			req.setOrgId(saved.getOrgId());
-			OrgEntity org = orgRepo.findOne(saved.getOrgId());
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, saved.getOrgId(), OrgEntity.class);
 			req.setOrgCode(org.getCode());
 			req.setOrgName(org.getName());
 

+ 28 - 17
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/TestController.java

@@ -1,16 +1,19 @@
 package cn.com.qmth.examcloud.core.basic.api.controller;
 
+import java.util.Collections;
+
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import cn.com.qmth.examcloud.commons.util.DateUtil;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import io.swagger.annotations.ApiOperation;
 
 /**
  * 测试状态.勿修改或删除
@@ -24,28 +27,36 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping("${$rmp.ctr.basic}")
 public class TestController extends ControllerSupport {
 
-	@ApiOperation(value = "测试")
-	@GetMapping()
+	@RequestMapping(value = {"/", ""}, method = RequestMethod.GET)
 	public String get() {
-		return DateUtil.getNowISO();
+		return DateUtil.chinaNow();
+	}
+
+	@RequestMapping(value = {"/", ""}, method = RequestMethod.HEAD)
+	public ResponseEntity<?> head() {
+		return new ResponseEntity<Object>(HttpStatus.NO_CONTENT);
+	}
+
+	@RequestMapping(value = {"/", ""}, method = RequestMethod.OPTIONS)
+	public HttpEntity<?> options() {
+		HttpHeaders headers = new HttpHeaders();
+		headers.setAllow(Collections.singleton(HttpMethod.GET));
+		return new ResponseEntity<Object>(headers, HttpStatus.OK);
 	}
 
-	@ApiOperation(value = "测试")
-	@PostMapping()
+	@RequestMapping(value = {"/", ""}, method = RequestMethod.POST)
 	public String post() {
-		return DateUtil.getNowISO();
+		return DateUtil.chinaNow();
 	}
 
-	@ApiOperation(value = "测试")
-	@PutMapping()
+	@RequestMapping(value = {"/", ""}, method = RequestMethod.PUT)
 	public String put() {
-		return DateUtil.getNowISO();
+		return DateUtil.chinaNow();
 	}
 
-	@ApiOperation(value = "测试")
-	@DeleteMapping()
+	@RequestMapping(value = {"/", ""}, method = RequestMethod.DELETE)
 	public String delete() {
-		return DateUtil.getNowISO();
+		return DateUtil.chinaNow();
 	}
 
 }

+ 64 - 40
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/UserController.java

@@ -52,6 +52,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.UserRoleRelationEntity;
 import cn.com.qmth.examcloud.core.basic.service.UserService;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -94,10 +95,12 @@ public class UserController extends ControllerSupport {
 	 */
 	@ApiOperation(value = "查询所有用户", notes = "")
 	@GetMapping("all/{curPage}/{pageSize}")
-	public PageInfo<UserDomain> getUserPage(@PathVariable Integer curPage, @PathVariable Integer pageSize,
-			@RequestParam(required = false) Long rootOrgId, @RequestParam String loginName, @RequestParam String name,
-			@RequestParam(required = false) Boolean enable, @RequestParam(required = false) Long roleId,
-			@RequestParam(required = false) Long orgId, @RequestParam(required = false) String roleCode) {
+	public PageInfo<UserDomain> getUserPage(@PathVariable Integer curPage,
+			@PathVariable Integer pageSize, @RequestParam(required = false) Long rootOrgId,
+			@RequestParam String loginName, @RequestParam String name,
+			@RequestParam(required = false) Boolean enable,
+			@RequestParam(required = false) Long roleId, @RequestParam(required = false) Long orgId,
+			@RequestParam(required = false) String roleCode) {
 
 		User accessUser = getAccessUser();
 
@@ -109,7 +112,7 @@ public class UserController extends ControllerSupport {
 
 		final Long finalRootOrgId = rootOrgId;
 
-		OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 		if (null == rootOrg) {
 			throw new StatusException("B-150003", "机构不存在");
 		}
@@ -118,14 +121,15 @@ public class UserController extends ControllerSupport {
 		}
 
 		if (null != roleId) {
-			RoleEntity roleEntity = roleRepo.findOne(roleId);
+			RoleEntity roleEntity = GlobalHelper.getEntity(roleRepo, roleId, RoleEntity.class);
 			if (null == roleEntity) {
 				throw new StatusException("B-150002", "角色不存在");
 			}
 		} else if (StringUtils.isNotBlank(roleCode)) {
 			RoleEntity roleEntity = roleRepo.findByCodeAndRootOrgIdIsNull(roleCode.trim());
 			if (null == roleEntity) {
-				roleEntity = roleRepo.findByCodeAndRootOrgId(roleCode.trim(), accessUser.getRootOrgId());
+				roleEntity = roleRepo.findByCodeAndRootOrgId(roleCode.trim(),
+						accessUser.getRootOrgId());
 			}
 			if (null == roleEntity) {
 				throw new StatusException("B-150002", "角色不存在");
@@ -152,7 +156,8 @@ public class UserController extends ControllerSupport {
 				predicates.add(cb.equal(root.get("enable"), enable));
 			}
 			if (null != finalRoleId) {
-				Subquery<UserRoleRelationEntity> subquery = query.subquery(UserRoleRelationEntity.class);
+				Subquery<UserRoleRelationEntity> subquery = query
+						.subquery(UserRoleRelationEntity.class);
 				Root<UserRoleRelationEntity> subRoot = subquery.from(UserRoleRelationEntity.class);
 				subquery.select(subRoot.get("userId"));
 				Predicate p1 = cb.equal(subRoot.get("roleId"), finalRoleId);
@@ -162,7 +167,8 @@ public class UserController extends ControllerSupport {
 			}
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
-		Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC, "updateTime");
+		Pageable pageable = PageRequest.of(curPage - 1, pageSize, Sort.Direction.DESC,
+				"updateTime");
 
 		Page<UserEntity> userList = userRepo.findAll(specification, pageable);
 
@@ -181,7 +187,8 @@ public class UserController extends ControllerSupport {
 			bean.setOrgId(next.getOrgId());
 			bean.setPhoneNumber(next.getPhoneNumber());
 			if (null != bean.getOrgId()) {
-				OrgEntity org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
+				OrgEntity org = GlobalHelper.getEntity(orgRepo, Long.valueOf(bean.getOrgId()),
+						OrgEntity.class);
 				if (null != org) {
 					bean.setOrgName(org.getName());
 					bean.setOrgCode(org.getCode());
@@ -190,12 +197,14 @@ public class UserController extends ControllerSupport {
 			bean.setRootOrgName(rootOrg.getName());
 			bean.setEnable(next.getEnable());
 
-			List<UserRoleRelationEntity> relationList = userRoleRelationRepo.findAllByUserId(next.getId());
+			List<UserRoleRelationEntity> relationList = userRoleRelationRepo
+					.findAllByUserId(next.getId());
 			List<String> roleNameList = Lists.newArrayList();
 			List<Long> roleIdList = Lists.newArrayList();
 			List<String> roleCodeList = Lists.newArrayList();
 			for (UserRoleRelationEntity cur : relationList) {
-				RoleEntity curRoleEntity = roleRepo.findOne(cur.getRoleId());
+				RoleEntity curRoleEntity = GlobalHelper.getEntity(roleRepo, cur.getRoleId(),
+						RoleEntity.class);
 				if (null == curRoleEntity) {
 					throw new StatusException("B-150002", "角色错误");
 				}
@@ -219,15 +228,17 @@ public class UserController extends ControllerSupport {
 	@ApiOperation(value = "模糊查询用户", notes = "")
 	@GetMapping("query")
 	public List<UserDomain> query(@RequestParam(required = false) Long rootOrgId,
-			@RequestParam(required = false) String rootOrgCode, @RequestParam(required = false) String loginName,
-			@RequestParam(required = false) String name, @RequestParam(required = false) Boolean enable,
+			@RequestParam(required = false) String rootOrgCode,
+			@RequestParam(required = false) String loginName,
+			@RequestParam(required = false) String name,
+			@RequestParam(required = false) Boolean enable,
 			@RequestParam(required = false) Long roleId, @RequestParam(required = false) Long orgId,
 			@RequestParam(required = false) String roleCode) {
 
 		OrgEntity rootOrg = null;
 
 		if (null != rootOrgId) {
-			rootOrg = orgRepo.findOne(rootOrgId);
+			rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 			if (null == rootOrg) {
 				throw new StatusException("B-150003", "机构不存在");
 			}
@@ -248,7 +259,7 @@ public class UserController extends ControllerSupport {
 		final Long finalRootOrgId = rootOrgId;
 
 		if (null != roleId) {
-			RoleEntity roleEntity = roleRepo.findOne(roleId);
+			RoleEntity roleEntity = GlobalHelper.getEntity(roleRepo, roleId, RoleEntity.class);
 			if (null == roleEntity) {
 				throw new StatusException("B-150002", "角色不存在");
 			}
@@ -285,7 +296,8 @@ public class UserController extends ControllerSupport {
 				predicates.add(cb.equal(root.get("enable"), enable));
 			}
 			if (null != finalRoleId) {
-				Subquery<UserRoleRelationEntity> subquery = query.subquery(UserRoleRelationEntity.class);
+				Subquery<UserRoleRelationEntity> subquery = query
+						.subquery(UserRoleRelationEntity.class);
 				Root<UserRoleRelationEntity> subRoot = subquery.from(UserRoleRelationEntity.class);
 				subquery.select(subRoot.get("userId"));
 				Predicate p1 = cb.equal(subRoot.get("roleId"), finalRoleId);
@@ -296,7 +308,7 @@ public class UserController extends ControllerSupport {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(0, 50, new Sort(Direction.DESC, "updateTime"));
+		PageRequest pageRequest = PageRequest.of(0, 50, new Sort(Direction.DESC, "updateTime"));
 
 		Page<UserEntity> userList = userRepo.findAll(specification, pageRequest);
 
@@ -314,7 +326,8 @@ public class UserController extends ControllerSupport {
 			bean.setCreationTime(next.getCreationTime());
 			bean.setOrgId(next.getOrgId());
 			if (null != bean.getOrgId()) {
-				OrgEntity org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
+				OrgEntity org = GlobalHelper.getEntity(orgRepo, Long.valueOf(bean.getOrgId()),
+						OrgEntity.class);
 				if (null != org) {
 					bean.setOrgName(org.getName());
 					bean.setOrgCode(org.getCode());
@@ -323,12 +336,14 @@ public class UserController extends ControllerSupport {
 			bean.setRootOrgName(rootOrg.getName());
 			bean.setEnable(next.getEnable());
 
-			List<UserRoleRelationEntity> relationList = userRoleRelationRepo.findAllByUserId(next.getId());
+			List<UserRoleRelationEntity> relationList = userRoleRelationRepo
+					.findAllByUserId(next.getId());
 			List<String> roleNameList = Lists.newArrayList();
 			List<Long> roleIdList = Lists.newArrayList();
 			List<String> roleCodeList = Lists.newArrayList();
 			for (UserRoleRelationEntity cur : relationList) {
-				RoleEntity curRoleEntity = roleRepo.findOne(cur.getRoleId());
+				RoleEntity curRoleEntity = GlobalHelper.getEntity(roleRepo, cur.getRoleId(),
+						RoleEntity.class);
 				if (null == curRoleEntity) {
 					throw new StatusException("B-150002", "角色错误");
 				}
@@ -357,7 +372,8 @@ public class UserController extends ControllerSupport {
 	@GetMapping("getUserBySession")
 	public UserDomain getUserBySession() {
 		User accessUser = getAccessUser();
-		UserEntity userEntity = userRepo.findOne(accessUser.getUserId());
+		UserEntity userEntity = GlobalHelper.getEntity(userRepo, accessUser.getUserId(),
+				UserEntity.class);
 
 		UserDomain bean = new UserDomain();
 		bean.setId(userEntity.getId());
@@ -368,7 +384,8 @@ public class UserController extends ControllerSupport {
 		bean.setCreationTime(userEntity.getCreationTime());
 		bean.setOrgId(userEntity.getOrgId());
 		if (null != bean.getOrgId()) {
-			OrgEntity org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, Long.valueOf(bean.getOrgId()),
+					OrgEntity.class);
 			if (null != org) {
 				bean.setOrgName(org.getName());
 				bean.setOrgCode(org.getCode());
@@ -388,7 +405,7 @@ public class UserController extends ControllerSupport {
 	@ApiOperation(value = "按id查询用户", notes = "id查询")
 	@GetMapping("/{id}")
 	public UserDomain getUserById(@PathVariable long id) {
-		UserEntity userEntity = userRepo.findOne(id);
+		UserEntity userEntity = GlobalHelper.getEntity(userRepo, id, UserEntity.class);
 
 		UserDomain bean = new UserDomain();
 		bean.setId(userEntity.getId());
@@ -399,7 +416,8 @@ public class UserController extends ControllerSupport {
 		bean.setCreationTime(userEntity.getCreationTime());
 		bean.setOrgId(userEntity.getOrgId());
 		if (null != bean.getOrgId()) {
-			OrgEntity org = orgRepo.findOne(Long.valueOf(bean.getOrgId()));
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, Long.valueOf(bean.getOrgId()),
+					OrgEntity.class);
 			if (null != org) {
 				bean.setOrgName(org.getName());
 				bean.setOrgCode(org.getCode());
@@ -467,7 +485,8 @@ public class UserController extends ControllerSupport {
 			throw new StatusException("B-150009", "user ID is null");
 		}
 
-		UserEntity userEntity = userRepo.findOne(userForm.getId());
+		UserEntity userEntity = GlobalHelper.getEntity(userRepo, userForm.getId(),
+				UserEntity.class);
 		if (null == userEntity) {
 			throw new StatusException("B-150010", "用户不存在");
 		}
@@ -506,7 +525,7 @@ public class UserController extends ControllerSupport {
 		if (null == rootOrgId) {
 			throw new StatusException("B-150002", "rootOrgId is null");
 		}
-		OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 		if (null == rootOrg) {
 			throw new StatusException("B-150003", "机构不存在");
 		}
@@ -517,7 +536,7 @@ public class UserController extends ControllerSupport {
 		validateRootOrgIsolation(rootOrgId);
 
 		if (null != orgId) {
-			OrgEntity org = orgRepo.findOne(orgId);
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 			if (null == org) {
 				throw new StatusException("B-150101", "子机构不存在");
 			}
@@ -545,7 +564,7 @@ public class UserController extends ControllerSupport {
 		List<UserRoleRelationEntity> userRoles = Lists.newArrayList();
 		List<Long> roleIds = userForm.getRoleIds();
 		for (Long cur : roleIds) {
-			RoleEntity curRoleEntity = roleRepo.findOne(cur);
+			RoleEntity curRoleEntity = GlobalHelper.getEntity(roleRepo, cur, RoleEntity.class);
 			if (null == curRoleEntity) {
 				throw new StatusException("B-150005", "角色错误");
 			}
@@ -565,12 +584,13 @@ public class UserController extends ControllerSupport {
 				}
 			}
 
-			UserRoleRelationEntity relation = new UserRoleRelationEntity(saved.getId(), curRoleEntity.getId());
+			UserRoleRelationEntity relation = new UserRoleRelationEntity(saved.getId(),
+					curRoleEntity.getId());
 			userRoles.add(relation);
 		}
 
 		userRoleRelationRepo.deleteByUserId(saved.getId());
-		List<UserRoleRelationEntity> savedRelationList = userRoleRelationRepo.save(userRoles);
+		List<UserRoleRelationEntity> savedRelationList = userRoleRelationRepo.saveAll(userRoles);
 
 		Map<String, Object> ret = Maps.newHashMap();
 		ret.put("userId", saved.getId());
@@ -591,7 +611,7 @@ public class UserController extends ControllerSupport {
 		if (CollectionUtils.isNotEmpty(relationList)) {
 			for (UserRoleRelationEntity cur : relationList) {
 				Long roleId = cur.getRoleId();
-				RoleEntity roleEntity = roleRepo.findOne(roleId);
+				RoleEntity roleEntity = GlobalHelper.getEntity(roleRepo, roleId, RoleEntity.class);
 				if (roleEntity.getCode().equals(RoleMeta.SUPER_ADMIN.name())) {
 					return true;
 				}
@@ -604,13 +624,14 @@ public class UserController extends ControllerSupport {
 	@ApiOperation(value = "重置用户密码", notes = "重置密码")
 	@PutMapping("/resetPass/{id}")
 	public void resetPass(@PathVariable String id) {
-		List<Long> ids = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
+		List<Long> ids = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim()))
+				.collect(Collectors.toList());
 
 		for (Long userId : ids) {
 			if (isSuperAdmin(userId)) {
 				throw new StatusException("B-150410", "超级管理员账号不允许修改");
 			}
-			UserEntity user = userRepo.findOne(userId);
+			UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
 			user.setPassword(BasicConsts.DEFAULT_PASSWORD);
 			userRepo.save(user);
 		}
@@ -619,13 +640,14 @@ public class UserController extends ControllerSupport {
 	@ApiOperation(value = "启用用户", notes = "启用用户")
 	@PutMapping("/enable/{ids}")
 	public List<String> enableUser(@PathVariable String ids) {
-		List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
+		List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+				.collect(Collectors.toList());
 		List<String> ret = Lists.newArrayList();
 		for (Long userId : userIds) {
 			if (isSuperAdmin(userId)) {
 				throw new StatusException("B-150410", "超级管理员账号不允许修改");
 			}
-			UserEntity user = userRepo.findOne(userId);
+			UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
 			user.setEnable(true);
 			userRepo.save(user);
 			ret.add(user.getId() + ":" + user.getName());
@@ -636,13 +658,14 @@ public class UserController extends ControllerSupport {
 	@ApiOperation(value = "禁用用户", notes = "禁用用户")
 	@PutMapping("/disable/{ids}")
 	public List<String> disableUser(@PathVariable String ids) {
-		List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
+		List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+				.collect(Collectors.toList());
 		List<String> ret = Lists.newArrayList();
 		for (Long userId : userIds) {
 			if (isSuperAdmin(userId)) {
 				throw new StatusException("B-150410", "超级管理员账号不允许修改");
 			}
-			UserEntity user = userRepo.findOne(userId);
+			UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
 			user.setEnable(false);
 			userRepo.save(user);
 			ret.add(user.getId() + ":" + user.getName());
@@ -673,9 +696,10 @@ public class UserController extends ControllerSupport {
 	@ApiOperation(value = "按id删除用户", notes = "删除")
 	@DeleteMapping("/{ids}")
 	public void deleteUser(@PathVariable String ids) {
-		List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
+		List<Long> userIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+				.collect(Collectors.toList());
 		for (Long userId : userIds) {
-			userRepo.delete(userId);
+			userRepo.deleteById(userId);
 		}
 	}
 

+ 3 - 2
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/CommonCloudServiceProvider.java

@@ -15,6 +15,7 @@ import cn.com.qmth.examcloud.core.basic.api.response.GetThirdPartyAccessInfoResp
 import cn.com.qmth.examcloud.core.basic.dao.ThirdPartyAccessRepo;
 import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccessEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccessPK;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -44,8 +45,8 @@ public class CommonCloudServiceProvider extends ControllerSupport implements Com
 		String appId = req.getAppId();
 		Long rootOrgId = req.getRootOrgId();
 
-		ThirdPartyAccessEntity entity = thirdPartyAccessRepo
-				.findOne(new ThirdPartyAccessPK(rootOrgId, appId));
+		ThirdPartyAccessEntity entity = GlobalHelper.getEntity(thirdPartyAccessRepo,
+				new ThirdPartyAccessPK(rootOrgId, appId), ThirdPartyAccessEntity.class);
 
 		if (null == entity) {
 			throw new StatusException("B-001001", "第三方接入信息不存在");

+ 3 - 2
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/CourseCloudServiceProvider.java

@@ -22,6 +22,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
 import cn.com.qmth.examcloud.core.basic.dao.enums.CourseLevel;
 import cn.com.qmth.examcloud.core.basic.service.CourseService;
 import cn.com.qmth.examcloud.core.basic.service.bean.CourseInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import io.swagger.annotations.ApiOperation;
 
 /**
@@ -90,7 +91,7 @@ public class CourseCloudServiceProvider implements CourseCloudService {
 		if (null == rootOrgId) {
 			throw new StatusException("B-160000", "rootOrgId is null");
 		}
-		OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 		if (null == rootOrg) {
 			throw new StatusException("B-160001", "机构不存在");
 		}
@@ -100,7 +101,7 @@ public class CourseCloudServiceProvider implements CourseCloudService {
 
 		CourseEntity c = null;
 		if (null != id) {
-			c = courseRepo.findOne(id);
+			c = GlobalHelper.getEntity(courseRepo, id, CourseEntity.class);
 
 		} else if (StringUtils.isNotBlank(code)) {
 			c = courseRepo.findByRootOrgIdAndCode(rootOrgId, code);

+ 5 - 2
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/FaceCloudServiceProvider.java

@@ -28,6 +28,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.FacesetEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.StudentFaceEntity;
 import cn.com.qmth.examcloud.core.basic.service.FaceService;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentFaceInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -113,7 +114,8 @@ public class FaceCloudServiceProvider extends ControllerSupport implements FaceC
 			throw new StatusException("B-710001", "studentId is null");
 		}
 
-		StudentFaceEntity studentFaceEntity = studentFaceRepo.findOne(studentId);
+		StudentFaceEntity studentFaceEntity = GlobalHelper.getEntity(studentFaceRepo, studentId,
+				StudentFaceEntity.class);
 
 		if (null == studentFaceEntity) {
 			throw new StatusException("B-710001", "studentFaceEntity is null");
@@ -131,7 +133,8 @@ public class FaceCloudServiceProvider extends ControllerSupport implements FaceC
 		resp.setStudentFaceBean(studentFaceBean);
 
 		if (null != studentFaceEntity.getFacesetId()) {
-			FacesetEntity facesetEntity = facesetRepo.findOne(studentFaceEntity.getFacesetId());
+			FacesetEntity facesetEntity = GlobalHelper.getEntity(facesetRepo,
+					studentFaceEntity.getFacesetId(), FacesetEntity.class);
 			if (null != facesetEntity) {
 				FacesetBean facesetBean = new FacesetBean();
 				facesetBean.setDisplayName(facesetEntity.getDisplayName());

+ 5 - 4
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/OrgCloudServiceProvider.java

@@ -45,6 +45,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.OrgPropertyEntity;
 import cn.com.qmth.examcloud.core.basic.dao.enums.OrgProperty;
 import cn.com.qmth.examcloud.core.basic.service.bean.OrgInfo;
 import cn.com.qmth.examcloud.core.basic.service.impl.OrgServiceImpl;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -101,7 +102,7 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
 
 		OrgEntity org = null;
 		if (null != orgId) {
-			org = orgRepo.findOne(orgId);
+			org = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		} else if (StringUtils.isNotBlank(orgCode)) {
 			if (null == rootOrgId) {
 				throw new StatusException("B-150001", "rootOrgId is null");
@@ -137,7 +138,7 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
 
 		final long start = null == req.getStart() ? 1 : req.getStart();
 
-		Pageable pageable = new PageRequest(0, 100, Sort.Direction.ASC, "id");
+		Pageable pageable = PageRequest.of(0, 100, Sort.Direction.ASC, "id");
 
 		Specification<OrgEntity> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();
@@ -188,7 +189,7 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
 	public GetAllOrgPropertiesResp getAllOrgProperties(@RequestBody GetAllOrgPropertiesReq req) {
 		Long orgId = req.getOrgId();
 
-		OrgEntity orgEntity = orgRepo.findOne(orgId);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-001250", "orgId is wrong");
 		}
@@ -215,7 +216,7 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
 		Long keyId = req.getKeyId();
 		String keyName = req.getKeyName();
 
-		OrgEntity orgEntity = orgRepo.findOne(orgId);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		if (null == orgEntity) {
 			throw new StatusException("B-001250", "orgId is wrong");
 		}

+ 3 - 1
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/RolePrivilegeCloudServiceProvider.java

@@ -28,6 +28,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.RolePrivilegeRelationEntity;
 import cn.com.qmth.examcloud.core.basic.service.RolePrivilegeService;
 import cn.com.qmth.examcloud.core.basic.service.bean.RoleInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -120,7 +121,8 @@ public class RolePrivilegeCloudServiceProvider extends ControllerSupport
 		List<String> privilegeCodeList = Lists.newArrayList();
 		for (RolePrivilegeRelationEntity cur : relationList) {
 
-			PrivilegeEntity privilegeEntity = privilegeRepo.findOne(cur.getPrivilegeId());
+			PrivilegeEntity privilegeEntity = GlobalHelper.getEntity(privilegeRepo,
+					cur.getPrivilegeId(), PrivilegeEntity.class);
 			privilegeCodeList.add(privilegeEntity.getCode());
 		}
 

+ 5 - 4
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/StudentCloudServiceProvider.java

@@ -28,6 +28,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
 import cn.com.qmth.examcloud.core.basic.service.StudentService;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -85,7 +86,7 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
 		resp.setRootOrgId(student.getRootOrgId());
 
 		if (null != student.getOrgId()) {
-			OrgEntity org = orgRepo.findOne(student.getOrgId());
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, student.getOrgId(), OrgEntity.class);
 			resp.setOrgId(org.getId());
 			resp.setOrgName(org.getName());
 		}
@@ -103,7 +104,7 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
 
 		StudentEntity student = null;
 		if (null != studentId) {
-			student = studentRepo.findOne(studentId);
+			student = GlobalHelper.getEntity(studentRepo, studentId, StudentEntity.class);
 		} else {
 
 			if (null == rootOrgId) {
@@ -113,7 +114,7 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
 				throw new StatusException("B-150004", "identityNumber is null");
 			}
 
-			OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+			OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 			if (null == rootOrg) {
 				throw new StatusException("B-150001", "机构不存在");
 			}
@@ -135,7 +136,7 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
 		studentBean.setStudentCode(student.getStudentCode());
 		studentBean.setRootOrgId(student.getRootOrgId());
 		if (null != student.getOrgId()) {
-			OrgEntity org = orgRepo.findOne(student.getOrgId());
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, student.getOrgId(), OrgEntity.class);
 			studentBean.setOrgId(org.getId());
 			studentBean.setOrgCode(org.getCode());
 			studentBean.setOrgName(org.getName());

+ 1 - 1
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/SysConfigCloudServiceProvider.java

@@ -64,7 +64,7 @@ public class SysConfigCloudServiceProvider extends ControllerSupport
 		if (null == value) {
 			strValue = null;
 		} else if (value instanceof Date) {
-			strValue = DateUtil.format((Date) value, DatePatterns.ISO);
+			strValue = DateUtil.format((Date) value, DatePatterns.CHINA_DEFAULT);
 		} else {
 			strValue = String.valueOf(value);
 		}

+ 9 - 7
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/UserCloudServiceProvider.java

@@ -45,6 +45,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.UserRoleRelationEntity;
 import cn.com.qmth.examcloud.core.basic.service.UserService;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.ApiOperation;
 
@@ -129,7 +130,7 @@ public class UserCloudServiceProvider extends ControllerSupport implements UserC
 		}
 
 		userRoleRelationRepo.deleteByUserId(saved.getId());
-		userRoleRelationRepo.save(userRoles);
+		userRoleRelationRepo.saveAll(userRoles);
 		AddUserResp resp = new AddUserResp();
 		resp.setUserId(saved.getId());
 
@@ -146,7 +147,7 @@ public class UserCloudServiceProvider extends ControllerSupport implements UserC
 
 		UserEntity userEntity = null;
 		if (null != userId) {
-			userEntity = userRepo.findOne(userId);
+			userEntity = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
 		} else if (StringUtils.isNotBlank(loginName)) {
 			userEntity = userRepo.findByRootOrgIdAndLoginName(rootOrgId, loginName);
 		} else {
@@ -168,11 +169,12 @@ public class UserCloudServiceProvider extends ControllerSupport implements UserC
 		userBean.setDisplayName(userEntity.getLoginName() + " (" + userEntity.getName() + ")");
 		userBean.setOrgId(userEntity.getOrgId());
 		userBean.setRootOrgId(userEntity.getRootOrgId());
-		OrgEntity rootOrg = orgRepo.findOne(userBean.getRootOrgId());
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, userBean.getRootOrgId(),
+				OrgEntity.class);
 		userBean.setRootOrgName(rootOrg.getName());
 
 		if (null != userBean.getOrgId()) {
-			OrgEntity org = orgRepo.findOne(userBean.getOrgId());
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, userBean.getOrgId(), OrgEntity.class);
 			userBean.setOrgName(org.getName());
 		}
 
@@ -196,7 +198,7 @@ public class UserCloudServiceProvider extends ControllerSupport implements UserC
 		if (CollectionUtils.isNotEmpty(relationList)) {
 			for (UserRoleRelationEntity cur : relationList) {
 				Long roleId = cur.getRoleId();
-				RoleEntity roleEntity = roleRepo.findOne(roleId);
+				RoleEntity roleEntity = GlobalHelper.getEntity(roleRepo, roleId, RoleEntity.class);
 				if (null == roleEntity) {
 					throw new StatusException("B-002002", "roleId wrong. roleId=" + roleId);
 				}
@@ -217,7 +219,7 @@ public class UserCloudServiceProvider extends ControllerSupport implements UserC
 		String roleCode = req.getRoleCode();
 
 		if (null != roleId) {
-			RoleEntity roleEntity = roleRepo.findOne(roleId);
+			RoleEntity roleEntity = GlobalHelper.getEntity(roleRepo, roleId, RoleEntity.class);
 			if (null == roleEntity) {
 				throw new StatusException("B-150001", "角色不存在");
 			}
@@ -237,7 +239,7 @@ public class UserCloudServiceProvider extends ControllerSupport implements UserC
 
 		final long start = null == req.getStart() ? 1 : req.getStart();
 
-		Pageable pageable = new PageRequest(0, 100, Sort.Direction.ASC, "id");
+		Pageable pageable = PageRequest.of(0, 100, Sort.Direction.ASC, "id");
 
 		Specification<UserEntity> specification = (root, query, cb) -> {
 			List<Predicate> predicates = new ArrayList<>();

+ 9 - 7
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/AuthServiceImpl.java

@@ -47,6 +47,7 @@ import cn.com.qmth.examcloud.core.basic.service.SmsCodeService;
 import cn.com.qmth.examcloud.core.basic.service.SysConfigService;
 import cn.com.qmth.examcloud.core.basic.service.UserService;
 import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 
 /**
@@ -170,7 +171,7 @@ public class AuthServiceImpl implements AuthService {
 			}
 
 		} else {
-			rootOrg = orgRepo.findOne(Long.valueOf(rootOrgId));
+			rootOrg = GlobalHelper.getEntity(orgRepo, Long.valueOf(rootOrgId), OrgEntity.class);
 			if (null == rootOrg) {
 				throw new StatusException("B-001002", "机构不存在");
 			}
@@ -299,7 +300,7 @@ public class AuthServiceImpl implements AuthService {
 
 		OrgEntity org = null;
 		if (null != orgId) {
-			org = orgRepo.findOne(orgId);
+			org = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		}
 
 		boolean isLcUser = isLcUser(user);
@@ -387,7 +388,8 @@ public class AuthServiceImpl implements AuthService {
 			boolean first = true;
 			for (RolePrivilegeRelationEntity cur : relationList) {
 
-				PrivilegeEntity privilegeEntity = privilegeRepo.findOne(cur.getPrivilegeId());
+				PrivilegeEntity privilegeEntity = GlobalHelper.getEntity(privilegeRepo,
+						cur.getPrivilegeId(), PrivilegeEntity.class);
 				if (first) {
 					sb.append(privilegeEntity.getCode());
 					first = false;
@@ -517,13 +519,13 @@ public class AuthServiceImpl implements AuthService {
 	public User thirdPartyAccess(Long rootOrgId, String loginName, String appId, String timestamp,
 			String token, String clientIp) throws StatusException {
 
-		OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 		if (null == rootOrg) {
 			throw new StatusException("B-001002", "机构不存在");
 		}
 
-		ThirdPartyAccessEntity thirdPartyAccess = thirdPartyAccessRepo
-				.findOne(new ThirdPartyAccessPK(rootOrgId, appId));
+		ThirdPartyAccessEntity thirdPartyAccess = GlobalHelper.getEntity(thirdPartyAccessRepo,
+				new ThirdPartyAccessPK(rootOrgId, appId), ThirdPartyAccessEntity.class);
 
 		if (null == thirdPartyAccess) {
 			throw new StatusException("B-001201", "第三方系统接入信息未配置");
@@ -610,7 +612,7 @@ public class AuthServiceImpl implements AuthService {
 		if (CollectionUtils.isNotEmpty(relationList)) {
 			for (UserRoleRelationEntity cur : relationList) {
 				Long roleId = cur.getRoleId();
-				RoleEntity roleEntity = roleRepo.findOne(roleId);
+				RoleEntity roleEntity = GlobalHelper.getEntity(roleRepo, roleId, RoleEntity.class);
 				if (null == roleEntity) {
 					throw new StatusException("B-002002", "roleId is wrong. roleId=" + roleId);
 				}

+ 3 - 2
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/CourseServiceImpl.java

@@ -26,6 +26,7 @@ import cn.com.qmth.examcloud.core.basic.service.CourseService;
 import cn.com.qmth.examcloud.core.basic.service.bean.CourseInfo;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
 import cn.com.qmth.examcloud.task.api.request.SyncCourseReq;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
 @Service
 public class CourseServiceImpl implements CourseService {
@@ -62,7 +63,7 @@ public class CourseServiceImpl implements CourseService {
 		if (null == rootOrgId) {
 			throw new StatusException("B-160000", "rootOrgId is null");
 		}
-		OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 		if (null == rootOrg) {
 			throw new StatusException("B-160001", "机构不存在");
 		}
@@ -73,7 +74,7 @@ public class CourseServiceImpl implements CourseService {
 		CourseEntity course = null;
 
 		if (null != courseId) {
-			course = courseRepo.findOne(courseId);
+			course = GlobalHelper.getEntity(courseRepo, courseId, CourseEntity.class);
 
 			if (null == course) {
 				throw new StatusException("B-160006", "课程ID错误");

+ 4 - 3
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/ExamSiteServiceImpl.java

@@ -11,6 +11,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.ExamSiteEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
 import cn.com.qmth.examcloud.core.basic.service.ExamSiteService;
 import cn.com.qmth.examcloud.core.basic.service.bean.ExamSiteInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
 /**
  * 类注释
@@ -46,7 +47,7 @@ public class ExamSiteServiceImpl implements ExamSiteService {
 		if (null == orgId) {
 			throw new StatusException("B-160001", "rootOrgId is null");
 		}
-		OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 		if (null == rootOrg) {
 			throw new StatusException("B-160002", "顶级机构不存在");
 		}
@@ -54,7 +55,7 @@ public class ExamSiteServiceImpl implements ExamSiteService {
 			throw new StatusException("B-160003", "顶级机构错误");
 		}
 
-		OrgEntity org = orgRepo.findOne(orgId);
+		OrgEntity org = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
 		if (null == org) {
 			throw new StatusException("B-160004", "机构不存在");
 		}
@@ -65,7 +66,7 @@ public class ExamSiteServiceImpl implements ExamSiteService {
 		ExamSiteEntity entity = null;
 
 		if (null != id) {
-			entity = examSiteRepo.findOne(id);
+			entity = GlobalHelper.getEntity(examSiteRepo, id, ExamSiteEntity.class);
 
 			if (null == entity) {
 				throw new StatusException("B-160006", "考点ID错误");

+ 6 - 3
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/FaceServiceImpl.java

@@ -26,6 +26,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.StudentFaceEntity;
 import cn.com.qmth.examcloud.core.basic.service.FaceService;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentFaceInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
 /**
  * 类注释
@@ -85,7 +86,8 @@ public class FaceServiceImpl implements FaceService {
 			throw new StatusException("B-680013", "faceCount is less than 1");
 		}
 
-		StudentEntity studentEntity = studentRepo.findOne(studentId);
+		StudentEntity studentEntity = GlobalHelper.getEntity(studentRepo, studentId,
+				StudentEntity.class);
 
 		if (null == studentEntity) {
 			throw new StatusException("B-680009", "studentEntity is null");
@@ -103,7 +105,8 @@ public class FaceServiceImpl implements FaceService {
 		String photoPath = rootOrgId + "/" + studentId + "/" + photoName;
 		studentEntity.setPhotoPath(photoPath);
 
-		StudentFaceEntity studentFaceEntity = studentFaceRepo.findOne(studentId);
+		StudentFaceEntity studentFaceEntity = GlobalHelper.getEntity(studentFaceRepo, studentId,
+				StudentFaceEntity.class);
 		if (null == studentFaceEntity) {
 			studentFaceEntity = new StudentFaceEntity();
 			studentFaceEntity.setStudentId(studentId);
@@ -136,7 +139,7 @@ public class FaceServiceImpl implements FaceService {
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
-		PageRequest pageRequest = new PageRequest(0, 10, new Sort(Direction.DESC, "updateTime"));
+		PageRequest pageRequest = PageRequest.of(0, 10, new Sort(Direction.DESC, "updateTime"));
 
 		Page<FacesetEntity> studentList = facesetRepo.findAll(specification, pageRequest);
 

+ 5 - 4
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/OrgServiceImpl.java

@@ -39,6 +39,7 @@ import cn.com.qmth.examcloud.core.basic.service.OrgService;
 import cn.com.qmth.examcloud.core.basic.service.bean.OrgInfo;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
 import cn.com.qmth.examcloud.task.api.request.SyncOrgReq;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
 @Service
 public class OrgServiceImpl implements OrgService {
@@ -190,7 +191,7 @@ public class OrgServiceImpl implements OrgService {
 			throw new StatusException("B-150003", "parentId is null");
 		}
 
-		OrgEntity rootOrgEntity = orgRepo.findOne(rootId);
+		OrgEntity rootOrgEntity = GlobalHelper.getEntity(orgRepo, rootId, OrgEntity.class);
 		if (null == rootOrgEntity) {
 			throw new StatusException("B-150004", "rootId is wrong");
 		}
@@ -198,7 +199,7 @@ public class OrgServiceImpl implements OrgService {
 			throw new StatusException("B-150005", "rootId is wrong");
 		}
 
-		OrgEntity parentOrgEntity = orgRepo.findOne(parentId);
+		OrgEntity parentOrgEntity = GlobalHelper.getEntity(orgRepo, parentId, OrgEntity.class);
 		if (null == parentOrgEntity) {
 			throw new StatusException("B-150006", "parentId is wrong");
 		}
@@ -296,7 +297,7 @@ public class OrgServiceImpl implements OrgService {
 
 	@Override
 	public void deleteSubOrg(Long subOrgId, boolean cascade) {
-		OrgEntity orgEntity = orgRepo.findOne(subOrgId);
+		OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, subOrgId, OrgEntity.class);
 		if (null == orgEntity.getParentId()) {
 			throw new StatusException("E-001004", "该机构非子机构");
 		}
@@ -448,7 +449,7 @@ public class OrgServiceImpl implements OrgService {
 		UserRoleRelationEntity relation = new UserRoleRelationEntity(savedUser.getId(),
 				role.getId());
 		userRoles.add(relation);
-		userRoleRelationRepo.save(userRoles);
+		userRoleRelationRepo.saveAll(userRoles);
 	}
 
 	private Map<String, Object> newError(int lineNum, String msg) {

+ 5 - 4
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/RolePrivilegeServiceImpl.java

@@ -22,6 +22,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.RolePrivilegeRelationEntity;
 import cn.com.qmth.examcloud.core.basic.dao.entity.RolePrivilegeRelationPK;
 import cn.com.qmth.examcloud.core.basic.service.RolePrivilegeService;
 import cn.com.qmth.examcloud.core.basic.service.bean.RoleInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
 /**
  * 类注释
@@ -71,13 +72,13 @@ public class RolePrivilegeServiceImpl implements RolePrivilegeService {
 			}
 
 			RolePrivilegeRelationPK pk = new RolePrivilegeRelationPK(roleId, id, rootOrgId);
-			if (rolePrivilegeRelationRepo.exists(pk)) {
+			if (rolePrivilegeRelationRepo.findById(pk).isPresent()) {
 				rolePrivilegeRelationRepo
-						.delete(new RolePrivilegeRelationPK(roleId, id, rootOrgId));
+						.deleteById(new RolePrivilegeRelationPK(roleId, id, rootOrgId));
 			}
 		}
 
-		rolePrivilegeRelationRepo.save(list);
+		rolePrivilegeRelationRepo.saveAll(list);
 	}
 
 	@Override
@@ -124,7 +125,7 @@ public class RolePrivilegeServiceImpl implements RolePrivilegeService {
 
 		RoleEntity roleEntity = null;
 		if (null != id) {
-			roleEntity = roleRepo.findOne(id);
+			roleEntity = GlobalHelper.getEntity(roleRepo, id, RoleEntity.class);
 		} else if (StringUtils.isNotBlank(code)) {
 			roleEntity = roleRepo.findByCodeAndRootOrgId(code, rootOrgId);
 		} else {

+ 2 - 1
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/SpecialtyServiceImpl.java

@@ -21,6 +21,7 @@ import cn.com.qmth.examcloud.core.basic.dao.SpecialtyRepo;
 import cn.com.qmth.examcloud.core.basic.dao.entity.SpecialtyEntity;
 import cn.com.qmth.examcloud.core.basic.service.SpecialtyService;
 import cn.com.qmth.examcloud.core.basic.service.bean.SpecialtyInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
 @Service
 public class SpecialtyServiceImpl implements SpecialtyService {
@@ -44,7 +45,7 @@ public class SpecialtyServiceImpl implements SpecialtyService {
 		SpecialtyEntity entity = null;
 
 		if (null != id) {
-			entity = specialtyRepo.findOne(id);
+			entity = GlobalHelper.getEntity(specialtyRepo, id, SpecialtyEntity.class);
 			if (null == entity) {
 				throw new StatusException("B-620001", "id is wrong");
 			}

+ 7 - 6
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/StudentServiceImpl.java

@@ -25,6 +25,7 @@ import cn.com.qmth.examcloud.core.basic.service.UserService;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
 import cn.com.qmth.examcloud.task.api.request.SyncStudentReq;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
 /**
  * 学生服务类 Created by songyue on 17/1/14.
@@ -63,7 +64,7 @@ public class StudentServiceImpl implements StudentService {
 	@Transactional
 	public StudentEntity saveStudent(StudentInfo studentInfo) {
 		Long rootOrgId = studentInfo.getRootOrgId();
-		OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 
 		if (null == rootOrg || null != rootOrg.getParentId()) {
 			throw new StatusException("B-160001", "顶级机构错误");
@@ -71,7 +72,7 @@ public class StudentServiceImpl implements StudentService {
 
 		OrgEntity org = null;
 		if (null != studentInfo.getOrgId()) {
-			org = orgRepo.findOne(studentInfo.getOrgId());
+			org = GlobalHelper.getEntity(orgRepo, studentInfo.getOrgId(), OrgEntity.class);
 			if (null == org) {
 				throw new StatusException("B-160050", "orgId is wrong");
 			}
@@ -215,7 +216,7 @@ public class StudentServiceImpl implements StudentService {
 		int count = 0;
 		if (null != studentId) {
 			count++;
-			s = studentRepo.findOne(studentId);
+			s = GlobalHelper.getEntity(studentRepo, studentId, StudentEntity.class);
 		}
 		if (StringUtils.isNotBlank(identityNumber)) {
 			count++;
@@ -246,7 +247,7 @@ public class StudentServiceImpl implements StudentService {
 		info.setName(s.getName());
 		info.setOrgId(s.getOrgId());
 		if (null != s.getOrgId()) {
-			OrgEntity org = orgRepo.findOne(s.getOrgId());
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, s.getOrgId(), OrgEntity.class);
 			if (null != org) {
 				info.setOrgCode(org.getCode());
 				info.setOrgName(org.getName());
@@ -265,7 +266,7 @@ public class StudentServiceImpl implements StudentService {
 
 		info.setRemark(s.getRemark());
 		info.setRootOrgId(s.getRootOrgId());
-		OrgEntity rootOrg = orgRepo.findOne(s.getRootOrgId());
+		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, s.getRootOrgId(), OrgEntity.class);
 		info.setRootOrgName(rootOrg.getName());
 		info.setSecurityPhone(s.getSecurityPhone());
 		info.setStudentCode(s.getStudentCode());
@@ -313,7 +314,7 @@ public class StudentServiceImpl implements StudentService {
 			req.setName(saved.getName());
 
 			req.setOrgId(saved.getOrgId());
-			OrgEntity org = orgRepo.findOne(saved.getOrgId());
+			OrgEntity org = GlobalHelper.getEntity(orgRepo, saved.getOrgId(), OrgEntity.class);
 			req.setOrgCode(org.getCode());
 			req.setOrgName(org.getName());
 

+ 3 - 3
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/SysConfigServiceImpl.java

@@ -55,8 +55,8 @@ public class SysConfigServiceImpl implements SysConfigService {
 			}
 		} else if (dataType.equals(DataType.DATE)) {
 			try {
-				sysConf.setValue(
-						DateUtil.format(DateUtil.parse(value, DatePatterns.ISO), DatePatterns.ISO));
+				sysConf.setValue(DateUtil.format(DateUtil.parse(value, DatePatterns.CHINA_DEFAULT),
+						DatePatterns.CHINA_DEFAULT));
 			} catch (Exception e) {
 				throw new StatusException("B-350002", "value is wrong");
 			}
@@ -104,7 +104,7 @@ public class SysConfigServiceImpl implements SysConfigService {
 			}
 		} else if (dataType.equals(DataType.DATE)) {
 			try {
-				return DateUtil.parse(value, DatePatterns.ISO);
+				return DateUtil.parse(value, DatePatterns.CHINA_DEFAULT);
 			} catch (Exception e) {
 				throw new StatusException("B-350002", "value is wrong");
 			}

+ 16 - 100
examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/CoreBasicApp.java

@@ -1,56 +1,37 @@
 package cn.com.qmth.examcloud.core.basic.starter;
 
-import java.util.Properties;
-
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.client.loadbalancer.LoadBalanced;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
-import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
 import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.web.multipart.MultipartResolver;
-import org.springframework.web.multipart.commons.CommonsMultipartResolver;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.code.kaptcha.impl.DefaultKaptcha;
-import com.google.code.kaptcha.util.Config;
 
-import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
-import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
-import cn.com.qmth.examcloud.commons.logging.SLF4JImpl;
-import cn.com.qmth.examcloud.core.basic.dao.enums.OrgProperty;
-import cn.com.qmth.examcloud.web.boot.ExamCloudApp;
-import cn.com.qmth.examcloud.web.redis.RedisClient;
-import cn.com.qmth.examcloud.web.redis.RedisClientImpl;
-import cn.com.qmth.examcloud.web.support.CustomResponseErrorHandler;
+import cn.com.qmth.examcloud.web.bootstrap.AppBootstrap;
 
-@ComponentScan(basePackages = {"cn.com.qmth"})
-@EntityScan(basePackages = {"cn.com.qmth"})
-@EnableJpaRepositories(basePackages = {"cn.com.qmth"})
+@SpringBootApplication
+@Configuration
+@EnableAutoConfiguration
 @EnableJpaAuditing
 @EnableTransactionManagement
-@SpringBootApplication
 @EnableEurekaClient
 @EnableDiscoveryClient
-@EnableAutoConfiguration(exclude = {MultipartAutoConfiguration.class})
+@ComponentScan(basePackages = {"cn.com.qmth"})
+@EntityScan(basePackages = {"cn.com.qmth"})
+@EnableJpaRepositories(basePackages = {"cn.com.qmth"})
 public class CoreBasicApp {
 
-	private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(CoreBasicApp.class);
+	static {
+		String runtimeLevel = System.getProperty("log.commonLevel");
+		if (null == runtimeLevel) {
+			System.setProperty("log.commonLevel", "DEBUG");
+		}
+		System.setProperty("hibernate.dialect.storage_engine", "innodb");
+	}
 
 	/**
 	 * main
@@ -60,72 +41,7 @@ public class CoreBasicApp {
 	 * @throws Exception
 	 */
 	public static void main(String[] args) throws Exception {
-
-		if (LOG instanceof SLF4JImpl) {
-			MDC.put("TRACE_ID", Thread.currentThread().getName());
-		}
-
-		OrgProperty.init();
-
-		ExamCloudApp.run(CoreBasicApp.class, "basic", args);
-	}
-
-	@Bean
-	@LoadBalanced
-	public RestTemplate restTemplate() {
-		RestTemplate restTemplate = new RestTemplate();
-		restTemplate.setErrorHandler(new CustomResponseErrorHandler());
-		return restTemplate;
-	}
-
-	@Bean
-	public RedisTemplate<String, Object> redisTemplate(
-			RedisConnectionFactory redisConnectionFactory) {
-		RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
-		redisTemplate.setConnectionFactory(redisConnectionFactory);
-		Jackson2JsonRedisSerializer<?> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(
-				Object.class);
-		ObjectMapper objectMapper = new ObjectMapper();
-		objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
-		objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
-		jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
-		redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
-		redisTemplate.setKeySerializer(new StringRedisSerializer());
-		redisTemplate.afterPropertiesSet();
-		return redisTemplate;
-	}
-
-	@Bean
-	@Autowired
-	public RedisClient redisClient(RedisTemplate<String, Object> redisTemplate) {
-		return new RedisClientImpl(redisTemplate);
-	}
-
-	@Bean(name = "multipartResolver")
-	public MultipartResolver multipartResolver() {
-		CommonsMultipartResolver resolver = new CommonsMultipartResolver();
-		resolver.setDefaultEncoding("UTF-8");
-		resolver.setResolveLazily(true);
-		resolver.setMaxInMemorySize(2);
-		resolver.setMaxUploadSize(200 * 1024 * 1024);
-		return resolver;
-	}
-
-	@Bean
-	public DefaultKaptcha getDefaultKaptcha() {
-		DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
-		Properties properties = new Properties();
-		properties.setProperty("kaptcha.border", "no");
-		properties.setProperty("kaptcha.border.color", "105,179,90");
-		properties.setProperty("kaptcha.textproducer.font.color", "blue");
-		properties.setProperty("kaptcha.image.width", "120");
-		properties.setProperty("kaptcha.image.height", "50");
-		properties.setProperty("kaptcha.textproducer.char.length", "4");
-		properties.setProperty("kaptcha.textproducer.font.names", "Microsoft Yahei");
-		Config config = new Config(properties);
-		defaultKaptcha.setConfig(config);
-
-		return defaultKaptcha;
+		AppBootstrap.run(CoreBasicApp.class, args);
 	}
 
 }

+ 0 - 39
examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/config/AppSelfInspection.java

@@ -1,39 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.starter.config;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-
-import cn.com.qmth.examcloud.web.support.RemoteProcedureCallTester;
-
-/**
- * 应用自检
- *
- * @author WANGWEI
- * @date 2018年6月21日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-@Component
-@Order(1)
-public class AppSelfInspection implements ApplicationRunner {
-
-	@Autowired
-	RemoteProcedureCallTester remoteCallTester;
-
-	/**
-	 * 自检
-	 *
-	 * @author WANGWEI
-	 */
-	private void inspect() {
-		// remoteCallTester.testRestTemplate("XXXXX");
-	}
-
-	@Override
-	public void run(ApplicationArguments args) throws Exception {
-		inspect();
-	}
-
-}

+ 0 - 126
examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/config/DefaultWebMvcConfigurerAdapter.java

@@ -1,126 +0,0 @@
-package cn.com.qmth.examcloud.core.basic.starter.config;
-
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
-
-import com.google.common.collect.Sets;
-
-import cn.com.qmth.examcloud.api.commons.security.bean.Role;
-import cn.com.qmth.examcloud.api.commons.security.bean.User;
-import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
-import cn.com.qmth.examcloud.api.commons.security.enums.RoleMeta;
-import cn.com.qmth.examcloud.commons.util.PathUtil;
-import cn.com.qmth.examcloud.commons.util.PropertiesUtil;
-import cn.com.qmth.examcloud.commons.util.RegExpUtil;
-import cn.com.qmth.examcloud.web.interceptor.FirstInterceptor;
-import cn.com.qmth.examcloud.web.interceptor.SeqlockInterceptor;
-import cn.com.qmth.examcloud.web.redis.RedisClient;
-import cn.com.qmth.examcloud.web.security.RequestPermissionInterceptor;
-import cn.com.qmth.examcloud.web.security.SpringCloudInterceptor;
-
-/**
- * 默认WebMvcConfigurer
- *
- * @author WANGWEI
- * @date 2018年5月22日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
- */
-@Configuration
-public class DefaultWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {
-
-	@Autowired
-	RedisClient redisClient;
-
-	static {
-		PropertiesUtil.configure(PathUtil.getResoucePath("security-mapping.properties"));
-	}
-
-	@Override
-	public void addInterceptors(InterceptorRegistry registry) {
-		registry.addInterceptor(new FirstInterceptor()).addPathPatterns("/**");
-
-		SpringCloudInterceptor springCloudInterceptor = new SpringCloudInterceptor();
-		springCloudInterceptor.setRedisClient(redisClient);
-		registry.addInterceptor(springCloudInterceptor).addPathPatterns("/**");
-
-		RequestPermissionInterceptor requestPermissionInterceptor = getRequestPermissionInterceptor();
-		requestPermissionInterceptor.configure("security-exclusions.conf");
-		registry.addInterceptor(requestPermissionInterceptor).addPathPatterns("/**");
-
-		registry.addInterceptor(new SeqlockInterceptor(redisClient)).addPathPatterns("/**");
-
-		super.addInterceptors(registry);
-	}
-
-	@Bean
-	public RequestPermissionInterceptor getRequestPermissionInterceptor() {
-		return new RequestPermissionInterceptor(redisClient) {
-
-			@Override
-			public boolean hasPermission(String mappingPath, User user) {
-
-				// 学生鉴权
-				if (user.getUserType().equals(UserType.STUDENT)) {
-					String key = "[s]" + mappingPath;
-					return PropertiesUtil.getBoolean(key, false);
-				}
-
-				List<Role> roleList = user.getRoleList();
-
-				if (CollectionUtils.isEmpty(roleList)) {
-					return false;
-				}
-
-				for (Role role : roleList) {
-					if (role.getRoleCode().equals(RoleMeta.SUPER_ADMIN.name())) {
-						return true;
-					}
-				}
-
-				// 权限组集合
-				String privilegeGroups = PropertiesUtil.getString(mappingPath);
-				if (StringUtils.isBlank(privilegeGroups)) {
-					return true;
-				}
-
-				// 用户权限集合
-				Set<String> rolePrivilegeList = Sets.newHashSet();
-				Long rootOrgId = user.getRootOrgId();
-				for (Role role : roleList) {
-					String key = "$_P_" + rootOrgId + "_" + role.getRoleId();
-					String rolePrivileges = redisClient.get(key, String.class);
-
-					List<String> rpList = RegExpUtil.findAll(rolePrivileges, "\\w+");
-					rolePrivilegeList.addAll(rpList);
-				}
-
-				List<String> privilegeGroupList = RegExpUtil.findAll(privilegeGroups, "[^\\;]+");
-
-				for (String pg : privilegeGroupList) {
-					pg = pg.trim();
-					if (StringUtils.isBlank(pg)) {
-						continue;
-					}
-
-					List<String> pList = RegExpUtil.findAll(pg, "[^\\,]+");
-					if (rolePrivilegeList.containsAll(pList)) {
-						return true;
-					} else {
-						continue;
-					}
-				}
-
-				return false;
-			}
-
-		};
-	}
-}