فهرست منبع

默认学习中心

WANG 5 سال پیش
والد
کامیت
a5ac0cad1a

+ 10 - 0
examcloud-core-basic-base/src/main/java/cn/com/qmth/examcloud/core/basic/base/constants/BasicConsts.java

@@ -19,4 +19,14 @@ public interface BasicConsts {
 	 */
 	String DEFAULT_PASSWORD = "123456";
 
+	/**
+	 * 默认机构代码
+	 */
+	String DEFAULT_ORG_COEE = "QMTH-DEFAULT";
+
+	/**
+	 * 默认机构名称
+	 */
+	String DEFAULT_ORG_NAME = "默认学习中心";
+
 }

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

@@ -85,6 +85,14 @@ public class StudentServiceImpl implements StudentService {
 			throw new StatusException("160001", "顶级机构错误");
 		}
 
+		String identityNumber = studentInfo.getIdentityNumber();
+		if (StringUtils.isBlank(identityNumber)) {
+			throw new StatusException("160012", "身份证号不能为空");
+		}
+
+		StudentEntity student = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber,
+				rootOrgId);
+
 		OrgEntity org = null;
 		if (null != studentInfo.getOrgId()) {
 			org = GlobalHelper.getEntity(orgRepo, studentInfo.getOrgId(), OrgEntity.class);
@@ -116,17 +124,22 @@ public class StudentServiceImpl implements StudentService {
 				org = orgRepo.save(org);
 			}
 		} else {
-			throw new StatusException("160082", "orgId,orgCode can not be all null");
-		}
-
-		String identityNumber = studentInfo.getIdentityNumber();
-		if (StringUtils.isBlank(identityNumber)) {
-			throw new StatusException("160012", "身份证号不能为空");
+			if (null != student) {
+				org = GlobalHelper.getEntity(orgRepo, student.getOrgId(), OrgEntity.class);
+			} else {
+				org = orgRepo.findByRootIdAndCode(rootOrgId, BasicConsts.DEFAULT_ORG_COEE);
+				if (null == org) {
+					org = new OrgEntity();
+					org.setParentId(rootOrgId);
+					org.setCode(BasicConsts.DEFAULT_ORG_COEE);
+					org.setName(BasicConsts.DEFAULT_ORG_NAME);
+					org.setEnable(true);
+					org.setRootId(rootOrgId);
+					org = orgRepo.save(org);
+				}
+			}
 		}
 
-		StudentEntity student = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber,
-				rootOrgId);
-
 		long updateTime = 0L;
 		if (null != student) {
 			if (null != student.getUpdateTime()) {