package com.mosquito.project.permission.entity;

import jakarta.persistence.*;
import java.time.LocalDateTime;

/**
 * 系统用户实体 - 用于管理后台用户管理
 */
@Entity
@Table(name = "sys_user")
public class SysUserEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, unique = true, length = 50)
    private String username;

    @Column(name = "password_hash", nullable = false)
    private String passwordHash;

    @Column(name = "real_name", length = 100)
    private String realName;

    @Column(length = 100)
    private String email;

    @Column(length = 20)
    private String phone;

    @Column(name = "department_id")
    private Long departmentId;

    @Column(name = "data_scope", length = 20)
    private String dataScope = "OWN";

    @Column(length = 20)
    private String status = "ACTIVE";

    @Column(name = "is_certified")
    private Boolean isCertified = false;

    @Column(name = "is_blacklisted")
    private Boolean isBlacklisted = false;

    @Column(name = "is_whitelisted")
    private Boolean isWhitelisted = false;

    @Column(name = "points")
    private Long points = 0L;

    @Column(name = "points_updated_at")
    private LocalDateTime pointsUpdatedAt;

    @Column(name = "points_updated_by")
    private Long pointsUpdatedBy;

    @Column(name = "last_login_at")
    private LocalDateTime lastLoginAt;

    @Column(name = "created_by")
    private Long createdBy;

    @Column(name = "created_at")
    private LocalDateTime createdAt = LocalDateTime.now();

    @Column(name = "updated_at")
    private LocalDateTime updatedAt = LocalDateTime.now();

    // Getters and Setters
    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 getPasswordHash() { return passwordHash; }
    public void setPasswordHash(String passwordHash) { this.passwordHash = passwordHash; }

    public String getRealName() { return realName; }
    public void setRealName(String realName) { this.realName = realName; }

    public String getEmail() { return email; }
    public void setEmail(String email) { this.email = email; }

    public String getPhone() { return phone; }
    public void setPhone(String phone) { this.phone = phone; }

    public Long getDepartmentId() { return departmentId; }
    public void setDepartmentId(Long departmentId) { this.departmentId = departmentId; }

    public String getDataScope() { return dataScope; }
    public void setDataScope(String dataScope) { this.dataScope = dataScope; }

    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }

    public Boolean getIsCertified() { return isCertified; }
    public void setIsCertified(Boolean isCertified) { this.isCertified = isCertified; }

    public Boolean getIsBlacklisted() { return isBlacklisted; }
    public void setIsBlacklisted(Boolean isBlacklisted) { this.isBlacklisted = isBlacklisted; }

    public Boolean getIsWhitelisted() { return isWhitelisted; }
    public void setIsWhitelisted(Boolean isWhitelisted) { this.isWhitelisted = isWhitelisted; }

    public Long getPoints() { return points; }
    public void setPoints(Long points) { this.points = points; }

    public LocalDateTime getPointsUpdatedAt() { return pointsUpdatedAt; }
    public void setPointsUpdatedAt(LocalDateTime pointsUpdatedAt) { this.pointsUpdatedAt = pointsUpdatedAt; }

    public Long getPointsUpdatedBy() { return pointsUpdatedBy; }
    public void setPointsUpdatedBy(Long pointsUpdatedBy) { this.pointsUpdatedBy = pointsUpdatedBy; }

    public LocalDateTime getLastLoginAt() { return lastLoginAt; }
    public void setLastLoginAt(LocalDateTime lastLoginAt) { this.lastLoginAt = lastLoginAt; }

    public Long getCreatedBy() { return createdBy; }
    public void setCreatedBy(Long createdBy) { this.createdBy = createdBy; }

    public LocalDateTime getCreatedAt() { return createdAt; }
    public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }

    public LocalDateTime getUpdatedAt() { return updatedAt; }
    public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
}
