wangwei 6 лет назад
Родитель
Сommit
360dc36b05

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

@@ -475,7 +475,7 @@ public class UserController extends ControllerSupport {
 		loginInfo.setAccountType(AccountType.COMMON_LOGIN_NAME.name());
 		loginInfo.setAccountValue(user.getLoginName());
 		loginInfo.setPassword(user.getPassword());
-		loginInfo.setRootOrgId(String.valueOf(user.getRootOrgId()));
+		loginInfo.setRootOrgId(user.getRootOrgId());
 		User loginUser = authService.login(loginInfo);
 
 		Map<String, Object> ret = Maps.newHashMap();
@@ -499,7 +499,7 @@ public class UserController extends ControllerSupport {
 		loginInfo.setAccountType(AccountType.COMMON_LOGIN_NAME.name());
 		loginInfo.setAccountValue(user.getLoginName());
 		loginInfo.setPassword(user.getPassword());
-		loginInfo.setRootOrgId(String.valueOf(user.getRootOrgId()));
+		loginInfo.setRootOrgId(user.getRootOrgId());
 		User loginUser = authService.login(loginInfo);
 
 		Map<String, Object> ret = Maps.newHashMap();

+ 2 - 0
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/StudentRepo.java

@@ -28,6 +28,8 @@ public interface StudentRepo
 
 	Student findBySecurityPhoneAndRootOrgId(String securityPhone, Long rootOrgId);
 
+	Student findBySecurityPhone(String securityPhone);
+
 	List<Student> findAllByIdentityNumberAndRootOrgId(String identityNumber, Long rootOrgId);
 
 	List<Student> findAllByStudentCodeAndRootOrgId(String studentCode, Long rootOrgId);

+ 3 - 3
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/bean/LoginInfo.java

@@ -15,7 +15,7 @@ public class LoginInfo implements JsonSerializable {
 	/**
 	 * 顶级机构ID
 	 */
-	private String rootOrgId;
+	private Long rootOrgId;
 
 	/**
 	 * 域名
@@ -37,11 +37,11 @@ public class LoginInfo implements JsonSerializable {
 	 */
 	private String password;
 
-	public String getRootOrgId() {
+	public Long getRootOrgId() {
 		return rootOrgId;
 	}
 
-	public void setRootOrgId(String rootOrgId) {
+	public void setRootOrgId(Long rootOrgId) {
 		this.rootOrgId = rootOrgId;
 	}
 

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

@@ -79,20 +79,29 @@ public class AuthServiceImpl implements AuthService {
 	public User login(LoginInfo loginInfo) {
 
 		String accountType = loginInfo.getAccountType();
-		if (AccountType.STUDENT_PHONE.name().equals(accountType)) {
+		String accountValue = loginInfo.getAccountValue();
+		String password = loginInfo.getPassword();
 
+		Student student = null;
+
+		if (AccountType.STUDENT_PHONE.name().equals(accountType)) {
+			student = studentRepo.findBySecurityPhone(accountValue);
+			if (null == student) {
+				throw new StatusException("B-001110", "学生不存在");
+			}
+			loginInfo.setRootOrgId(student.getRootOrgId());
 		}
 
-		String rootOrgId = loginInfo.getRootOrgId();
+		Long rootOrgId = loginInfo.getRootOrgId();
 		Org rootOrg = null;
-		if (StringUtils.isBlank(rootOrgId)) {
+		if (null == rootOrgId) {
 			if (StringUtils.isBlank(loginInfo.getDomain())) {
 				throw new StatusException("B-001001", "domain,rootOrgId 必须有一个不为空");
 			}
 
 			try {
 				rootOrg = orgRepo.findRootOrg(loginInfo.getDomain());
-				rootOrgId = String.valueOf(rootOrg.getId());
+				rootOrgId = rootOrg.getId();
 			} catch (Exception e) {
 				throw new StatusException("B-001002", "机构不存在", e);
 			}
@@ -104,15 +113,11 @@ public class AuthServiceImpl implements AuthService {
 			}
 		}
 
-		String accountValue = loginInfo.getAccountValue();
-		String password = loginInfo.getPassword();
-
 		User user = new User();
 
 		// 常规账户登录
 		if (AccountType.COMMON_LOGIN_NAME.name().equals(accountType)) {
-			UserEntity userEntity = userRepo.findByRootOrgIdAndLoginName(Long.parseLong(rootOrgId),
-					accountValue);
+			UserEntity userEntity = userRepo.findByRootOrgIdAndLoginName(rootOrgId, accountValue);
 			if (null == userEntity) {
 				throw new StatusException("B-001004", "用户不存在");
 			}
@@ -133,7 +138,6 @@ public class AuthServiceImpl implements AuthService {
 			List<Role> roleList = getUserRoles(userEntity.getId());
 			user.setRoleList(roleList);
 		} else {
-			Student student = null;
 			// 学生学号登录
 			if (AccountType.STUDENT_CODE.name().equals(accountType)) {
 				student = studentRepo.findByStudentCodeAndRootOrgId(accountValue, rootOrg.getId());