|
@@ -126,7 +126,7 @@ public class StudentServiceImpl implements StudentService {
|
|
Long rootOrgId = studentInfo.getRootOrgId();
|
|
Long rootOrgId = studentInfo.getRootOrgId();
|
|
Org rootOrg = orgRepo.findOne(rootOrgId);
|
|
Org rootOrg = orgRepo.findOne(rootOrgId);
|
|
|
|
|
|
- if (null == rootOrg || (!rootOrg.getParentId().equals(0L))) {
|
|
|
|
|
|
+ if (null == rootOrg || null != rootOrg.getParentId()) {
|
|
throw new StatusException("B-160001", "顶级机构错误");
|
|
throw new StatusException("B-160001", "顶级机构错误");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -143,8 +143,8 @@ public class StudentServiceImpl implements StudentService {
|
|
if (StringUtils.isBlank(orgName)) {
|
|
if (StringUtils.isBlank(orgName)) {
|
|
throw new StatusException("B-160003", "orgName is blank");
|
|
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);
|
|
Org org = orgRepo.findByRootIdAndCode(rootOrgId, orgCode);
|
|
if (null == org) {
|
|
if (null == org) {
|
|
@@ -160,6 +160,17 @@ public class StudentServiceImpl implements StudentService {
|
|
String identityNumber = studentInfo.getIdentityNumber();
|
|
String identityNumber = studentInfo.getIdentityNumber();
|
|
String studentCode = studentInfo.getStudentCode();
|
|
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,
|
|
Student studentByIdentity = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber,
|
|
rootOrgId);
|
|
rootOrgId);
|
|
|
|
|
|
@@ -174,14 +185,15 @@ public class StudentServiceImpl implements StudentService {
|
|
if (null != studentByCode) {
|
|
if (null != studentByCode) {
|
|
String curIdentityNumber = studentByCode.getIdentityNumber();
|
|
String curIdentityNumber = studentByCode.getIdentityNumber();
|
|
if (!curIdentityNumber.equals(identityNumber)) {
|
|
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) {
|
|
if (null != studentByIdentity) {
|
|
updatedStudent = studentByIdentity;
|
|
updatedStudent = studentByIdentity;
|
|
} else {
|
|
} else {
|
|
|
|
+ updatedStudent = new Student();
|
|
if (StringUtils.isNotEmpty(identityNumber)
|
|
if (StringUtils.isNotEmpty(identityNumber)
|
|
&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {
|
|
&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {
|
|
updatedStudent.setPassword(
|
|
updatedStudent.setPassword(
|
|
@@ -204,9 +216,9 @@ public class StudentServiceImpl implements StudentService {
|
|
if (null != studentInfo.getRemark()) {
|
|
if (null != studentInfo.getRemark()) {
|
|
updatedStudent.setRemark(studentInfo.getRemark());
|
|
updatedStudent.setRemark(studentInfo.getRemark());
|
|
}
|
|
}
|
|
- studentRepo.save(updatedStudent);
|
|
|
|
|
|
+ Student saved = studentRepo.save(updatedStudent);
|
|
|
|
|
|
- return updatedStudent;
|
|
|
|
|
|
+ return saved;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|