package com.cico.nest.lcdp.boot.core.system.dal.dataobject.oauth2;

import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cico.nest.lcdp.framework.mybatis.core.dataobject.BaseDO;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * OAuth2 批准 DO
 *
 * 用户在 sso.vue 界面时，记录接受的 scope 列表
 *
 * @author zws
 */
@TableName(value = "system_oauth2_approve", autoResultMap = true)
@KeySequence("system_oauth2_approve_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库，可不写。
@Data
@EqualsAndHashCode(callSuper = true)
public class OAuth2ApproveDO extends BaseDO {

    /**
     * 编号，数据库自增
     */
    @TableId
    private Long id;
    /**
     * 用户编号
     */
    private Long userId;
    /**
     * 用户类型
     *
     * 枚举 {@link UserTypeEnum}
     */
    private Integer userType;
    /**
     * 客户端编号
     *
     * 关联 {@link OAuth2ClientDO#getId()}
     */
    private String clientId;
    /**
     * 授权范围
     */
    private String scope;
    /**
     * 是否接受
     *
     * true - 接受
     * false - 拒绝
     */
    private Boolean approved;
    /**
     * 过期时间
     */
    private LocalDateTime expiresTime;

    public OAuth2ApproveDO setUserId(Long userId) {
        this.userId = userId;
        return this;
    }

    public OAuth2ApproveDO setUserType(Integer userType) {
        this.userType = userType;
        return this;
    }

    public OAuth2ApproveDO setId(Long id) {
        this.id = id;
        return this;
    }

    public OAuth2ApproveDO setClientId(String clientId) {
        this.clientId = clientId;
        return this;
    }

    public OAuth2ApproveDO setScope(String scope) {
        this.scope = scope;
        return this;
    }

    public OAuth2ApproveDO setApproved(Boolean approved) {
        this.approved = approved;
        return this;
    }

    public OAuth2ApproveDO setExpiresTime(LocalDateTime expiresTime) {
        this.expiresTime = expiresTime;
        return this;
    }
}
