|
@@ -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());
|