Bladeren bron

。。。

wangwei 6 jaren geleden
bovenliggende
commit
3c6890f1c0

+ 10 - 5
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/AuthController.java

@@ -129,12 +129,17 @@ public class AuthController extends ControllerSupport {
 		User accessUser = getAccessUser();
 		Long studentId = accessUser.getStudentId();
 
-		if (null != studentId) {
-			Student s = studentRepo.findOne(studentId);
-			s.setSecurityPhone(phone);
-		} else {
-			throw new StatusException("B-001051", "绑定失败");
+		Student sb = studentRepo.findBySecurityPhone(phone);
+		if (null != sb) {
+			if (!sb.getId().equals(studentId)) {
+				throw new StatusException("B-001052", "手机号已被其他用户绑定,请更换手机号");
+			} else {
+				throw new StatusException("B-001053", "手机号已绑定成功,无需重复绑定");
+			}
 		}
+
+		Student s = studentRepo.findOne(studentId);
+		s.setSecurityPhone(phone);
 	}
 
 }