80 lines
1.8 KiB
Java
80 lines
1.8 KiB
Java
package com.example.nto.entity;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Builder;
|
|
import lombok.Data;
|
|
import lombok.NoArgsConstructor;
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
|
|
import javax.persistence.*;
|
|
import java.time.LocalDateTime;
|
|
import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
|
|
@Data
|
|
@Entity
|
|
@Builder
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
@Table(name = "Employee")
|
|
public class Employee implements UserDetails {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private long id;
|
|
@Column(name = "login")
|
|
private String login;
|
|
@Column(name = "name")
|
|
private String name;
|
|
@Column(name = "password")
|
|
private String password;
|
|
@ManyToOne
|
|
@JoinColumn(name = "authority_id")
|
|
@JsonIgnore
|
|
private Authority authority;
|
|
@ManyToOne
|
|
@JoinColumn(name = "credentials")
|
|
@JsonIgnore
|
|
private Credentials credentials;
|
|
@Column(name = "photo")
|
|
private String photo;
|
|
@ManyToMany(fetch = FetchType.EAGER)
|
|
private Set<Authority> authorities;
|
|
@Column(name = "position")
|
|
private String position;
|
|
@Column(name = "lastVisit")
|
|
private LocalDateTime lastVisit;
|
|
|
|
@Override
|
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|
|
return List.of();
|
|
}
|
|
|
|
@Override
|
|
public String getUsername() {
|
|
return "";
|
|
}
|
|
|
|
@Override
|
|
public boolean isAccountNonExpired() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isAccountNonLocked() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isCredentialsNonExpired() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isEnabled() {
|
|
return true;
|
|
}
|
|
}
|