wangwei пре 7 година
родитељ
комит
1371e29af2

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

@@ -98,8 +98,7 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
 			throw new StatusException("B-150002", "机构错误");
 		}
 
-		Student student = studentRepo.findByIdentityNumberAndStudentCodeAndRootOrgId(identityNumber,
-				studentCode, rootOrgId);
+		Student student = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber, rootOrgId);
 
 		if (null == student) {
 			throw new StatusException("B-150005", "学生不存在");

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

@@ -4,7 +4,6 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
 import javax.transaction.Transactional;
@@ -19,16 +18,12 @@ import org.springframework.stereotype.Service;
 
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
-import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
 import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
 import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
 import cn.com.qmth.examcloud.core.basic.dao.constants.Consts;
 import cn.com.qmth.examcloud.core.basic.dao.entity.Org;
 import cn.com.qmth.examcloud.core.basic.dao.entity.Student;
-import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
-import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
-import cn.com.qmth.examcloud.core.basic.dao.enums.UserScope;
 import cn.com.qmth.examcloud.core.basic.service.StudentService;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
 
@@ -165,13 +160,27 @@ public class StudentServiceImpl implements StudentService {
 		String identityNumber = studentInfo.getIdentityNumber();
 		String studentCode = studentInfo.getStudentCode();
 
-		Student student = studentRepo.findByIdentityNumberAndStudentCodeAndRootOrgId(identityNumber,
-				studentCode, rootOrgId);
+		Student studentByIdentity = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber,
+				rootOrgId);
+
+		if (null != studentByIdentity) {
+			String curStudentCode = studentByIdentity.getStudentCode();
+			if (StringUtils.isNotBlank(curStudentCode) && !curStudentCode.equals(studentCode)) {
+				throw new StatusException("B-160005", "studentCode is wrong");
+			}
+		}
+
+		Student studentByCode = studentRepo.findByStudentCodeAndRootOrgId(studentCode, rootOrgId);
+		if (null != studentByCode) {
+			String curIdentityNumber = studentByCode.getIdentityNumber();
+			if (!curIdentityNumber.equals(identityNumber)) {
+				throw new StatusException("B-160005", "studentCode is wrong");
+			}
+		}
 
 		Student updatedStudent = new Student();
-		if (null != student) {
-			updatedStudent.setId(student.getId());
-			updatedStudent.setPassword(student.getPassword());
+		if (null != studentByIdentity) {
+			updatedStudent = studentByIdentity;
 		} else {
 			if (StringUtils.isNotEmpty(identityNumber)
 					&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {