wangwei 7 years ago
parent
commit
39c8a0ebdf

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

@@ -54,6 +54,7 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
 		studentInfo.setStudentCode(req.getStudentCode());
 		studentInfo.setRootOrgId(req.getRootOrgId());
 
+		studentInfo.setOrgId(req.getOrgId());
 		studentInfo.setOrgCode(req.getOrgCode());
 		studentInfo.setOrgName(req.getOrgName());
 

+ 6 - 3
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/StudentRepo.java

@@ -1,5 +1,7 @@
 package cn.com.qmth.examcloud.core.basic.dao;
 
+import java.util.List;
+
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
@@ -10,8 +12,6 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.Student;
  */
 public interface StudentRepo extends JpaRepository<Student, Long>, QueryByExampleExecutor<Student> {
 
-	Student findByUserId(long userId);
-
 	Student findByIdentityNumber(String identityNumber);
 
 	Student findByIdentityNumberAndStudentCodeAndRootOrgId(String identityNumber,
@@ -21,5 +21,8 @@ public interface StudentRepo extends JpaRepository<Student, Long>, QueryByExampl
 
 	Student findByStudentCodeAndRootOrgId(String studentCode, Long rootOrgId);
 
-	Student findByRootOrgIdAndStudentCode(Long rootOrgId, String studentCode);
+	List<Student> findAllByIdentityNumberAndRootOrgId(String identityNumber, Long rootOrgId);
+
+	List<Student> findAllByStudentCodeAndRootOrgId(String studentCode, Long rootOrgId);
+
 }

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

@@ -126,7 +126,7 @@ public class StudentServiceImpl implements StudentService {
 		Long rootOrgId = studentInfo.getRootOrgId();
 		Org rootOrg = orgRepo.findOne(rootOrgId);
 
-		if (null == rootOrg || (!rootOrg.getParentId().equals(0L))) {
+		if (null == rootOrg || null != rootOrg.getParentId()) {
 			throw new StatusException("B-160001", "顶级机构错误");
 		}
 
@@ -143,8 +143,8 @@ public class StudentServiceImpl implements StudentService {
 			if (StringUtils.isBlank(orgName)) {
 				throw new StatusException("B-160003", "orgName is blank");
 			}
-			if (StringUtils.isBlank(orgName)) {
-				throw new StatusException("B-160004", "orgName is blank");
+			if (StringUtils.isBlank(orgCode)) {
+				throw new StatusException("B-160004", "orgCode is blank");
 			}
 			Org org = orgRepo.findByRootIdAndCode(rootOrgId, orgCode);
 			if (null == org) {
@@ -160,6 +160,17 @@ public class StudentServiceImpl implements StudentService {
 		String identityNumber = studentInfo.getIdentityNumber();
 		String studentCode = studentInfo.getStudentCode();
 
+		List<Student> list = studentRepo.findAllByIdentityNumberAndRootOrgId(identityNumber,
+				rootOrgId);
+		if (1 < list.size()) {
+			throw new StatusException("B-160007",
+					"已经存在不同考生的身份证号相同的数据. identityNumber: " + identityNumber);
+		}
+		list = studentRepo.findAllByStudentCodeAndRootOrgId(studentCode, rootOrgId);
+		if (1 < list.size()) {
+			throw new StatusException("B-160008", "已经存在不同考生的学号相同的数据. studentCode: " + studentCode);
+		}
+
 		Student studentByIdentity = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber,
 				rootOrgId);
 
@@ -174,14 +185,15 @@ public class StudentServiceImpl implements StudentService {
 		if (null != studentByCode) {
 			String curIdentityNumber = studentByCode.getIdentityNumber();
 			if (!curIdentityNumber.equals(identityNumber)) {
-				throw new StatusException("B-160005", "studentCode is wrong");
+				throw new StatusException("B-160006", "studentCode is wrong");
 			}
 		}
 
-		Student updatedStudent = new Student();
+		Student updatedStudent = null;
 		if (null != studentByIdentity) {
 			updatedStudent = studentByIdentity;
 		} else {
+			updatedStudent = new Student();
 			if (StringUtils.isNotEmpty(identityNumber)
 					&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {
 				updatedStudent.setPassword(
@@ -204,9 +216,9 @@ public class StudentServiceImpl implements StudentService {
 		if (null != studentInfo.getRemark()) {
 			updatedStudent.setRemark(studentInfo.getRemark());
 		}
-		studentRepo.save(updatedStudent);
+		Student saved = studentRepo.save(updatedStudent);
 
-		return updatedStudent;
+		return saved;
 	}
 
 }

+ 1 - 1
examcloud-core-basic-starter/src/main/resources/application-dev.properties

@@ -15,4 +15,4 @@ spring.rabbitmq.listener.acknowledgeMode=MANUAL
 
 $croe.basic.resource.schoolLogoPath=D:/Temp/logo
 
-$core.basic.sessionTimeout=600
+$core.basic.sessionTimeout=3600

+ 5 - 2
examcloud-core-basic-starter/src/main/resources/security-exclusions.conf

@@ -1,7 +1,7 @@
 regexp:.*login.*
 regexp:.*\[getLoginUser\].*
+
  [${$rmp.ctr.basic}/auth][/thirdPartyAccess][POST]
- 
 [${$rmp.ctr.basic}/org][/download][GET]
 [${$rmp.ctr.basic}/course][/download][GET]
 [${$rmp.ctr.basic}/course][][GET]
@@ -11,8 +11,11 @@ regexp:.*\[getLoginUser\].*
 [${$rmp.ctr.basic}/studentFaceInfo][/identityNumber][GET]
 [${$rmp.ctr.basic}/user][/{id}][GET]
 [${$rmp.ctr.basic}/org][/logo][GET]
-[${$rmp.cloud.basic}demo][getXxx,getYYY][POST]
 [${$rmp.ctr.basic}/course][/export][GET]
 [${$rmp.ctr.basic}/specialty][/export][GET]
 [${$rmp.ctr.basic}/specialty][/download][GET]
 
+[${$rmp.cloud.basic}demo][getXxx,getYYY][POST]
+[${$rmp.cloud.basic}student][insertOrUpdateStudent][POST]
+[${$rmp.cloud.basic}org][getOrg][POST]
+