package com.css.simulation.oauth.server.cofiguration.security;

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

import java.io.Serializable;
import java.util.Set;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MyUserDetails implements UserDetails, Serializable {
    private static final long serialVersionUID = -158357727659030597L;
    private String id;
    private String username;
    private String password;
    private String roleCode;
    private String useType;       // 占用类型
    private String createUserId;
    private Set<GrantedAuthority> authorities;


    /**
     * 默认 false 是将用户账号过期，需改成 true 不过期
     */
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    /**
     * 默认 false 是将用户上锁，需改成 true 不上锁
     */
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    /**
     * 默认 false 是用户凭证国汽，需改成 true 不过期
     */
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    /**
     * 默认 false 是将用户失效，需改成 true 不失效
     */
    @Override
    public boolean isEnabled() {
        return true;
    }
}
