|
@@ -13,6 +13,7 @@ import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
|
import com.yonge.cooleshow.common.security.AuthUser;
|
|
|
import com.yonge.cooleshow.common.security.SecurityConstants;
|
|
|
import com.yonge.cooleshow.common.util.WebUtil;
|
|
|
+import com.yonge.toolset.base.result.BaseResult;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.authentication.LockedException;
|
|
@@ -26,6 +27,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
@Service
|
|
|
public class DefaultUserDetailsService implements UserDetailsService {
|
|
@@ -71,7 +73,8 @@ public class DefaultUserDetailsService implements UserDetailsService {
|
|
|
}
|
|
|
//判断用户是否被锁定
|
|
|
if (SysUserType.STUDENT.getCode().equals(clientId)) {
|
|
|
- StudentApi data = adminFeignService.getStudent(sysUser.getId()).getData();
|
|
|
+ StudentApi data = Optional.ofNullable(adminFeignService.getStudent(sysUser.getId()))
|
|
|
+ .map(BaseResult::getData).orElse(null);
|
|
|
if (data == null) {
|
|
|
throw new UsernameNotFoundException("账户不存在");
|
|
|
}
|
|
@@ -79,7 +82,8 @@ public class DefaultUserDetailsService implements UserDetailsService {
|
|
|
throw new LockedException("账户被锁定");
|
|
|
}
|
|
|
}else if(SysUserType.TEACHER.getCode().equals(clientId)) {
|
|
|
- TeacherApi data = adminFeignService.getTeacher(sysUser.getId()).getData();
|
|
|
+ TeacherApi data = Optional.ofNullable(adminFeignService.getTeacher(sysUser.getId()))
|
|
|
+ .map(BaseResult::getData).orElse(null);
|
|
|
if (data == null) {
|
|
|
throw new UsernameNotFoundException("账户不存在");
|
|
|
}
|
|
@@ -87,7 +91,8 @@ public class DefaultUserDetailsService implements UserDetailsService {
|
|
|
throw new LockedException("账户被锁定");
|
|
|
}
|
|
|
}else if(SysUserType.SYSTEM.getCode().equals(clientId)) {
|
|
|
- EmployeeApi data = adminFeignService.getEmployee(sysUser.getId()).getData();
|
|
|
+ EmployeeApi data = Optional.ofNullable(adminFeignService.getEmployee(sysUser.getId()))
|
|
|
+ .map(BaseResult::getData).orElse(null);
|
|
|
if (data == null) {
|
|
|
throw new UsernameNotFoundException("账户不存在");
|
|
|
}
|
|
@@ -95,7 +100,8 @@ public class DefaultUserDetailsService implements UserDetailsService {
|
|
|
throw new LockedException("账户被锁定");
|
|
|
}
|
|
|
} else if (SysUserType.ORGANIZATION.getCode().equals(clientId)) {
|
|
|
- TenantWrapper.Staff tenantStaff = adminFeignService.getTenantStaff(sysUser.getId()).getData();
|
|
|
+ TenantWrapper.Staff tenantStaff = Optional.ofNullable(adminFeignService.getTenantStaff(sysUser.getId()))
|
|
|
+ .map(BaseResult::getData).orElse(null);
|
|
|
if (tenantStaff == null) {
|
|
|
throw new UsernameNotFoundException("账户不存在");
|
|
|
}
|