package com.njcn.product.event.transientes.security;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @Author: cdf
 * @CreateTime: 2025-06-26
 * @Description:
 */
@Data
public class MyUserDetails implements UserDetails {

    private  String userId;        // 用户唯一标识
    private  String username;      // 用户名
    private  String password;      // 密码
    private  String deptId;    // 部门信息
    private  Collection<? extends GrantedAuthority> authorities; // 权限集合
    private  boolean accountNonExpired;    // 账户是否未过期
    private  boolean accountNonLocked;     // 账户是否未锁定
    private  boolean credentialsNonExpired; // 凭证是否未过期
    private  boolean enabled;              // 账户是否启用

    public MyUserDetails(String userId,String username, String password, String deptId,Collection<? extends GrantedAuthority> authorities) {
        this.userId = userId;
        this.username = username;
        this.password = password;
        this.deptId = deptId;
        this.authorities = authorities;
    }

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

    @Override
    public String getUsername() {
        return this.username;
    }

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

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

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

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