package com.jiayue.ssi.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * 用户实体
 *
 * @author xsl
 * @version 3.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "t_sys_user")
public class SysUser implements UserDetails {
    @TableId(value = "C_ID", type = IdType.AUTO)
    private Integer id;

    @TableField("C_LOCK_TIME")
    private Long lockTime;

    @TableField("C_NAME")
    private String name;

    @TableField("C_PASSWORD")
    private String password;

    @TableField("C_PWD_ERR_NUM")
    private Integer pwdErrNum;

    @TableField("C_ROLES")
    private String roles;

    @TableField("C_STATUS")
    private String status;

    @TableField("C_USERNAME")
    private String username;

    @TableField("C_MAIL_BOX")
    private String mailBox;

    @Override
    public boolean isEnabled() {
        return true;
    }
    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return password;
    }
}
