|
@@ -100,13 +100,10 @@ public class StudentServiceImpl implements StudentService {
|
|
|
|
|
|
if (null != orgId) {
|
|
if (null != orgId) {
|
|
OrgEntity org = orgRepo.findOne(orgId);
|
|
OrgEntity org = orgRepo.findOne(orgId);
|
|
- if (!org.getParentId().equals(rootOrgId)) {
|
|
|
|
|
|
+ if (!org.getRootId().equals(rootOrgId)) {
|
|
throw new StatusException("B-160002", "orgId is wrong");
|
|
throw new StatusException("B-160002", "orgId is wrong");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- if (StringUtils.isBlank(orgCode)) {
|
|
|
|
- throw new StatusException("B-160004", "orgCode is blank");
|
|
|
|
- }
|
|
|
|
|
|
+ } else if (StringUtils.isNotBlank(orgCode)) {
|
|
OrgEntity org = orgRepo.findByRootIdAndCode(rootOrgId, orgCode);
|
|
OrgEntity org = orgRepo.findByRootIdAndCode(rootOrgId, orgCode);
|
|
if (null == org) {
|
|
if (null == org) {
|
|
if (StringUtils.isBlank(orgName)) {
|
|
if (StringUtils.isBlank(orgName)) {
|
|
@@ -123,60 +120,40 @@ public class StudentServiceImpl implements StudentService {
|
|
} else {
|
|
} else {
|
|
orgId = org.getId();
|
|
orgId = org.getId();
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ throw new StatusException("B-160082", "orgId,orgCode can not be all null");
|
|
}
|
|
}
|
|
|
|
|
|
String identityNumber = studentInfo.getIdentityNumber();
|
|
String identityNumber = studentInfo.getIdentityNumber();
|
|
if (StringUtils.isBlank(identityNumber)) {
|
|
if (StringUtils.isBlank(identityNumber)) {
|
|
throw new StatusException("B-160012", "身份证号不能为空");
|
|
throw new StatusException("B-160012", "身份证号不能为空");
|
|
}
|
|
}
|
|
- String studentCode = studentInfo.getStudentCode();
|
|
|
|
- if (StringUtils.isBlank(studentCode)) {
|
|
|
|
- studentCode = null;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- List<StudentEntity> list = studentRepo.findAllByIdentityNumberAndRootOrgId(identityNumber,
|
|
|
|
|
|
+ StudentEntity student = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber,
|
|
rootOrgId);
|
|
rootOrgId);
|
|
- if (1 < list.size()) {
|
|
|
|
- throw new StatusException("B-160007", "已经存在不同考生的身份证号相同的数据. 身份证号: " + identityNumber);
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(studentCode)) {
|
|
|
|
- list = studentRepo.findAllByStudentCodeAndRootOrgId(studentCode, rootOrgId);
|
|
|
|
- if (1 < list.size()) {
|
|
|
|
- throw new StatusException("B-160008", "已经存在不同考生的学号相同的数据. 学号: " + studentCode);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- StudentEntity studentByIdentity = studentRepo
|
|
|
|
- .findByIdentityNumberAndRootOrgId(identityNumber, rootOrgId);
|
|
|
|
-
|
|
|
|
- if (null != studentByIdentity) {
|
|
|
|
- String curStudentCode = studentByIdentity.getStudentCode();
|
|
|
|
- if (StringUtils.isNotBlank(curStudentCode) && !curStudentCode.equals(studentCode)) {
|
|
|
|
- throw new StatusException("B-160005", "身份证号已关联学号");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ String studentCode = studentInfo.getStudentCode();
|
|
if (StringUtils.isNotBlank(studentCode)) {
|
|
if (StringUtils.isNotBlank(studentCode)) {
|
|
StudentEntity studentByCode = studentRepo.findByStudentCodeAndRootOrgId(studentCode,
|
|
StudentEntity studentByCode = studentRepo.findByStudentCodeAndRootOrgId(studentCode,
|
|
rootOrgId);
|
|
rootOrgId);
|
|
- if (null != studentByCode) {
|
|
|
|
- String curIdentityNumber = studentByCode.getIdentityNumber();
|
|
|
|
- if (!curIdentityNumber.equals(identityNumber)) {
|
|
|
|
- throw new StatusException("B-160006", "学号已关联身份证号");
|
|
|
|
- }
|
|
|
|
|
|
+ if (null != studentByCode
|
|
|
|
+ && (!studentByCode.getIdentityNumber().equals(identityNumber))) {
|
|
|
|
+ throw new StatusException("B-160008", "学号被占用. 学号: " + studentCode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != student && (!student.getStudentCode().equals(studentCode))) {
|
|
|
|
+ throw new StatusException("B-160005", "身份证号已关联学号");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- StudentEntity student = null;
|
|
|
|
- if (null != studentByIdentity) {
|
|
|
|
- student = studentByIdentity;
|
|
|
|
|
|
+ if (null != student) {
|
|
if (null == student.getEnable()) {
|
|
if (null == student.getEnable()) {
|
|
student.setEnable(true);
|
|
student.setEnable(true);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
student = new StudentEntity();
|
|
student = new StudentEntity();
|
|
- if (StringUtils.isNotEmpty(identityNumber)
|
|
|
|
- && identityNumber.matches("[0-9a-zA-Z]{6,}")) {
|
|
|
|
|
|
+ student.setEnable(true);
|
|
|
|
+ if (identityNumber.matches("[0-9a-zA-Z]{6,}")) {
|
|
student.setPassword(
|
|
student.setPassword(
|
|
StringUtils.substring(identityNumber, -6, identityNumber.length()));
|
|
StringUtils.substring(identityNumber, -6, identityNumber.length()));
|
|
} else {
|
|
} else {
|
|
@@ -184,9 +161,6 @@ public class StudentServiceImpl implements StudentService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (null == student.getEnable()) {
|
|
|
|
- student.setEnable(true);
|
|
|
|
- }
|
|
|
|
student.setRootOrgId(rootOrgId);
|
|
student.setRootOrgId(rootOrgId);
|
|
student.setIdentityNumber(identityNumber);
|
|
student.setIdentityNumber(identityNumber);
|
|
student.setStudentCode(studentCode);
|
|
student.setStudentCode(studentCode);
|