|
@@ -1,6 +1,9 @@
|
|
|
package com.lantone.userauth.domain;
|
|
|
|
|
|
import com.lantone.common.domain.UserDto;
|
|
|
+import com.lantone.common.enums.StatusEnum;
|
|
|
+import com.lantone.common.util.ListUtil;
|
|
|
+import com.lantone.common.util.StringUtil;
|
|
|
import lombok.Data;
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
@@ -24,7 +27,7 @@ public class SecurityUser implements UserDetails {
|
|
|
/**
|
|
|
* 用户名
|
|
|
*/
|
|
|
- private String username;
|
|
|
+ private String userName;
|
|
|
/**
|
|
|
* 用户密码
|
|
|
*/
|
|
@@ -32,7 +35,7 @@ public class SecurityUser implements UserDetails {
|
|
|
/**
|
|
|
* 用户状态
|
|
|
*/
|
|
|
- private Boolean enabled;
|
|
|
+ private String status;
|
|
|
/**
|
|
|
* 登录客户端ID
|
|
|
*/
|
|
@@ -42,17 +45,13 @@ public class SecurityUser implements UserDetails {
|
|
|
*/
|
|
|
private Collection<SimpleGrantedAuthority> authorities;
|
|
|
|
|
|
- public SecurityUser() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
public SecurityUser(UserDto userDto) {
|
|
|
this.setId(userDto.getId());
|
|
|
- this.setUsername(userDto.getUsername());
|
|
|
+ this.setUserName(userDto.getUserName());
|
|
|
this.setPassword(userDto.getPassword());
|
|
|
- this.setEnabled(userDto.getStatus() == 1);
|
|
|
+ this.setStatus(userDto.getStatus());
|
|
|
this.setClientId(userDto.getClientId());
|
|
|
- if (userDto.getRoles() != null) {
|
|
|
+ if (ListUtil.isNotEmpty(userDto.getRoles())) {
|
|
|
authorities = new ArrayList<>();
|
|
|
userDto.getRoles().forEach(item -> authorities.add(new SimpleGrantedAuthority(item)));
|
|
|
}
|
|
@@ -70,7 +69,7 @@ public class SecurityUser implements UserDetails {
|
|
|
|
|
|
@Override
|
|
|
public String getUsername() {
|
|
|
- return this.username;
|
|
|
+ return this.userName;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -90,7 +89,7 @@ public class SecurityUser implements UserDetails {
|
|
|
|
|
|
@Override
|
|
|
public boolean isEnabled() {
|
|
|
- return this.enabled;
|
|
|
+ return StringUtil.isNotBlank(this.status) && this.status.equals(StatusEnum.Enable.getKey());
|
|
|
}
|
|
|
|
|
|
}
|