| | |
| | | import java.util.Set;
|
| | | import org.springframework.security.core.GrantedAuthority;
|
| | | import org.springframework.security.core.userdetails.UserDetails;
|
| | | import com.fasterxml.jackson.annotation.JsonIgnore;
|
| | | import com.alibaba.fastjson2.annotation.JSONField;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | |
|
| | | /**
|
| | |
| | | public class LoginUser implements UserDetails
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | /**
|
| | | * 用户ID
|
| | | */
|
| | | private Long userId;
|
| | |
|
| | | /**
|
| | | * 部门ID
|
| | | */
|
| | | private Long [] deptIds;
|
| | |
|
| | | /**
|
| | | * 用户唯一标识
|
| | |
| | | */
|
| | | private SysUser user;
|
| | |
|
| | | /**
|
| | | * 租户ID
|
| | | */
|
| | | private Long tenantId;
|
| | |
|
| | | /** |
| | | * 当前部门id |
| | | */ |
| | | private Long currentDeptId; |
| | | |
| | | /** |
| | | * 是否开通AI功能(0否 1是) |
| | | */ |
| | | private Integer aiEnabled; |
| | | |
| | | private String dataScope; |
| | |
|
| | | public LoginUser()
|
| | | {
|
| | | }
|
| | |
|
| | | public LoginUser(SysUser user, Set<String> permissions) |
| | | { |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | this.aiEnabled = user == null ? null : user.getAiEnabled(); |
| | | } |
| | |
|
| | | public LoginUser(Long userId, Long [] deptId, SysUser user, Set<String> permissions) |
| | | { |
| | | this.userId = userId; |
| | | this.deptIds = deptId; |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | this.aiEnabled = user == null ? null : user.getAiEnabled(); |
| | | } |
| | |
|
| | | public LoginUser(Long userId, Long [] deptIds, SysUser user,Long tenantId, Set<String> permissions) |
| | | { |
| | | this.userId = userId; |
| | | this.deptIds = deptIds; |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | this.tenantId = tenantId; |
| | | this.aiEnabled = user == null ? null : user.getAiEnabled(); |
| | | } |
| | |
|
| | | public LoginUser(Long userId, Long [] deptIds, SysUser user,Long tenantId,Long currentDeptId, Set<String> permissions) |
| | | { |
| | | this.userId = userId; |
| | | this.deptIds = deptIds; |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | this.tenantId = tenantId; |
| | | this.currentDeptId = currentDeptId; |
| | | this.aiEnabled = user == null ? null : user.getAiEnabled(); |
| | | } |
| | |
|
| | | public Long getUserId()
|
| | | {
|
| | | return userId;
|
| | | }
|
| | |
|
| | | public void setUserId(Long userId)
|
| | | {
|
| | | this.userId = userId;
|
| | | }
|
| | |
|
| | | public Long [] getDeptIds()
|
| | | {
|
| | | return deptIds;
|
| | | }
|
| | |
|
| | | public void setDeptId(Long [] deptIds)
|
| | | {
|
| | | this.deptIds = deptIds;
|
| | | }
|
| | |
|
| | | public String getToken()
|
| | | {
|
| | | return token;
|
| | |
| | | this.token = token;
|
| | | }
|
| | |
|
| | | public LoginUser()
|
| | | {
|
| | | }
|
| | |
|
| | | public LoginUser(SysUser user, Set<String> permissions)
|
| | | {
|
| | | this.user = user;
|
| | | this.permissions = permissions;
|
| | | }
|
| | |
|
| | | @JsonIgnore
|
| | | @JSONField(serialize = false)
|
| | | @Override
|
| | | public String getPassword()
|
| | | {
|
| | |
| | | return user.getUserName();
|
| | | }
|
| | |
|
| | | public String getNickName()
|
| | | {
|
| | | return user.getNickName();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 账户是否未过期,过期无法验证
|
| | | */
|
| | | @JsonIgnore
|
| | | @JSONField(serialize = false)
|
| | | @Override
|
| | | public boolean isAccountNonExpired()
|
| | | {
|
| | |
| | | *
|
| | | * @return
|
| | | */
|
| | | @JsonIgnore
|
| | | @JSONField(serialize = false)
|
| | | @Override
|
| | | public boolean isAccountNonLocked()
|
| | | {
|
| | |
| | | *
|
| | | * @return
|
| | | */
|
| | | @JsonIgnore
|
| | | @JSONField(serialize = false)
|
| | | @Override
|
| | | public boolean isCredentialsNonExpired()
|
| | | {
|
| | |
| | | *
|
| | | * @return
|
| | | */
|
| | | @JsonIgnore
|
| | | @JSONField(serialize = false)
|
| | | @Override
|
| | | public boolean isEnabled()
|
| | | {
|
| | |
| | | return user;
|
| | | }
|
| | |
|
| | | public void setUser(SysUser user)
|
| | | {
|
| | | this.user = user;
|
| | | }
|
| | | public void setUser(SysUser user) |
| | | { |
| | | this.user = user; |
| | | this.aiEnabled = user == null ? null : user.getAiEnabled(); |
| | | } |
| | |
|
| | | @Override
|
| | | public Collection<? extends GrantedAuthority> getAuthorities()
|
| | | {
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | | public Long getTenantId() {
|
| | | return tenantId;
|
| | | }
|
| | |
|
| | | public void setTenantId(Long tenantId) {
|
| | | this.tenantId = tenantId;
|
| | | }
|
| | |
|
| | | public void setDeptIds(Long[] deptIds) {
|
| | | this.deptIds = deptIds;
|
| | | }
|
| | |
|
| | | public Long getCurrentDeptId() {
|
| | | return currentDeptId;
|
| | | }
|
| | |
|
| | | public void setCurrentDeptId(Long currentDeptId) { |
| | | this.currentDeptId = currentDeptId; |
| | | } |
| | | |
| | | public Integer getAiEnabled() { |
| | | if (aiEnabled != null) { |
| | | return aiEnabled; |
| | | } |
| | | if (user != null && user.getAiEnabled() != null) { |
| | | return user.getAiEnabled(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public void setAiEnabled(Integer aiEnabled) { |
| | | this.aiEnabled = aiEnabled; |
| | | } |
| | | |
| | | public String getDataScope() { |
| | | return dataScope; |
| | | } |
| | | |
| | | public void setDataScope(String dataScope) { |
| | | this.dataScope = dataScope; |
| | | } |
| | | } |