74 lines
1.7 KiB
Java
74 lines
1.7 KiB
Java
package com.dbnt.kcgfilemanager.model;
|
|
|
|
import lombok.*;
|
|
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.Date;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
@Getter
|
|
@Setter
|
|
@NoArgsConstructor
|
|
@Entity
|
|
@Table(name = "USER_INFO")
|
|
public class UserInfo implements UserDetails{
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
@Column(name = "USER_SEQ")
|
|
private Integer userSeq;
|
|
@Column(name = "USER_ID")
|
|
private String userId;
|
|
@Column(name = "PASSWORD")
|
|
private String password;
|
|
@Column(name = "NAME")
|
|
private String name;
|
|
@Column(name = "POSITION")
|
|
private int position;
|
|
@Column(name = "DEPARTMENT")
|
|
private int department;
|
|
@Column(name = "USER_ROLE")
|
|
private String userRole;
|
|
@Column(name = "CREATE_DATE")
|
|
private Date createDate;
|
|
|
|
|
|
@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() {
|
|
return true;
|
|
}
|
|
}
|