package com.jy.system.model.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jy.framework.model.base.BaseIdPo;
import com.jy.framework.model.validation.AddGroup;
import com.jy.framework.model.validation.EditGroup;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * <p>
 * 用户
 * </p>
 *
 * @author
 * @since 2024-06-20
 */
@Getter
@Setter
@TableName("sys_user")
public class SysUser extends BaseIdPo {

    /**
     * 账号
     */
    @NotBlank(groups = AddGroup.class)
    @Size(min = 5, max = 20, groups = AddGroup.class)
    private String username;

    /**
     * 密码
     */
    @NotBlank(groups = AddGroup.class)
    @Size(min = 6, max = 30, groups = AddGroup.class)
    private String password;

    /**
     * 昵称
     */
    @NotBlank(groups = {AddGroup.class, EditGroup.class})
    private String nickname;

    /**
     * 部门id
     */
    @NotNull(groups = {AddGroup.class, EditGroup.class})
    private Long deptId;

    /**
     * 是否系统内置 1是 0否
     */
    @NotNull(groups = {AddGroup.class, EditGroup.class})
    private Integer builtin;

    /**
     * 状态 1启用 0禁用
     */
    @NotNull(groups = {AddGroup.class, EditGroup.class})
    private Integer status;

    /**
     * 用户性别 0男 1女 2未知
     */
    @NotNull(groups = {AddGroup.class, EditGroup.class})
    private Integer sex;

    /**
     * 手机号
     */
    @Pattern(regexp = "$|1[3-9][0-9]{9}$", groups = {AddGroup.class, EditGroup.class})
    private String phoneNumber;

    /**
     * 邮箱
     */
    @Email(groups = {AddGroup.class, EditGroup.class})
    private String email;

    /**
     * 头像地址
     */
    private String avatar;

    /**
     * 最后登录IP
     */
    @Null(groups = {AddGroup.class, EditGroup.class})
    private String loginIp;

    /**
     * 最后登录时间
     */
    @Null(groups = {AddGroup.class, EditGroup.class})
    private Date loginTime;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建人
     */
    @TableField(fill = FieldFill.INSERT)
    private Long createUser;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更新人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 逻辑删除标记
     */
    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private String delFlag;

}
