2022-08-23 02:34:25 +00:00
|
|
|
package com.dbnt.faisp.userInfo.model;
|
2022-08-18 06:21:44 +00:00
|
|
|
|
2022-08-23 09:08:49 +00:00
|
|
|
import com.dbnt.faisp.config.BaseModel;
|
2022-08-18 06:21:44 +00:00
|
|
|
import lombok.Getter;
|
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
|
import lombok.Setter;
|
|
|
|
|
import org.hibernate.annotations.DynamicInsert;
|
|
|
|
|
import org.hibernate.annotations.DynamicUpdate;
|
|
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
|
|
|
|
|
|
|
|
import javax.persistence.*;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
@Getter
|
|
|
|
|
@Setter
|
|
|
|
|
@Entity
|
|
|
|
|
@NoArgsConstructor
|
|
|
|
|
@DynamicInsert
|
|
|
|
|
@DynamicUpdate
|
2022-08-19 02:04:38 +00:00
|
|
|
@Table(name = "user_info")
|
2022-08-18 06:21:44 +00:00
|
|
|
public class UserInfo extends BaseModel implements UserDetails{
|
|
|
|
|
@Id
|
|
|
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
2022-08-19 02:04:38 +00:00
|
|
|
@Column(name = "user_seq")
|
2022-08-18 06:21:44 +00:00
|
|
|
private Integer userSeq;
|
2022-08-19 02:04:38 +00:00
|
|
|
@Column(name = "user_id")
|
2022-08-18 06:21:44 +00:00
|
|
|
private String userId;
|
2022-08-19 02:04:38 +00:00
|
|
|
@Column(name = "passwd")
|
2022-08-18 06:21:44 +00:00
|
|
|
private String password;
|
2022-08-19 02:04:38 +00:00
|
|
|
@Column(name = "name")
|
2022-08-18 06:21:44 +00:00
|
|
|
private String name;
|
2022-08-19 02:04:38 +00:00
|
|
|
@Column(name = "user_role")
|
2022-08-18 06:21:44 +00:00
|
|
|
private String userRole;
|
2022-08-19 02:04:38 +00:00
|
|
|
@Column(name = "user_status")
|
2022-08-18 06:21:44 +00:00
|
|
|
private String userStatus;
|
|
|
|
|
|
|
|
|
|
@Transient
|
|
|
|
|
private String modifyPassword;
|
|
|
|
|
@Transient
|
|
|
|
|
private String positionName;
|
|
|
|
|
@Transient
|
|
|
|
|
private String departmentName;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|
|
|
|
|
Set<GrantedAuthority> roles = new HashSet<>();
|
|
|
|
|
for (String role : userRole.split(",")) {
|
|
|
|
|
roles.add(new SimpleGrantedAuthority(role));
|
|
|
|
|
}
|
|
|
|
|
return roles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getUsername() {
|
|
|
|
|
return userId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isAccountNonExpired() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isAccountNonLocked() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isCredentialsNonExpired() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isEnabled() {
|
2022-08-19 05:30:04 +00:00
|
|
|
return userStatus.equals("ST003");
|
2022-08-18 06:21:44 +00:00
|
|
|
}
|
|
|
|
|
}
|