45 lines
1.4 KiB
Java
45 lines
1.4 KiB
Java
package com.learn.entity;
|
||
|
||
import jakarta.persistence.*;
|
||
import java.io.Serializable;
|
||
import java.time.LocalDateTime;
|
||
|
||
@Entity
|
||
@Table(name = "users")
|
||
public class User implements Serializable {
|
||
private static final long serialVersionUID = 1L;
|
||
|
||
@Id
|
||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||
private Long id;
|
||
|
||
@Column(nullable = false, unique = true, length = 50)
|
||
private String username;
|
||
|
||
@Column(nullable = false, length = 200)
|
||
private String password; // BCrypt 加密后的密文
|
||
|
||
@Column(nullable = false, length = 20)
|
||
private String role; // ADMIN / USER(第 3 天 RBAC)
|
||
|
||
@Column(nullable = false)
|
||
private Integer enabled = 1;
|
||
|
||
@Column(name = "create_time", insertable = false, updatable = false)
|
||
private LocalDateTime createTime;
|
||
|
||
public User() {}
|
||
|
||
public Long getId() { return id; }
|
||
public void setId(Long id) { this.id = id; }
|
||
public String getUsername() { return username; }
|
||
public void setUsername(String username) { this.username = username; }
|
||
public String getPassword() { return password; }
|
||
public void setPassword(String password) { this.password = password; }
|
||
public String getRole() { return role; }
|
||
public void setRole(String role) { this.role = role; }
|
||
public Integer getEnabled() { return enabled; }
|
||
public void setEnabled(Integer enabled) { this.enabled = enabled; }
|
||
public LocalDateTime getCreateTime() { return createTime; }
|
||
}
|