package com.chinaweal.aiccs.org.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * OAuth授权码
 * </p>
 *
 * @author chinaweal
 * @since 2025-11-21
 */
@Data
@Accessors(chain = true)
@TableName(value = "oauth_authorization_code")
@ApiModel(description = "OAuth授权码")
public class OauthAuthorizationCode implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 授权码
     */
    @ApiModelProperty(value = "授权码", example = "auth_code_12345")
    @TableId(value = "code_id", type = IdType.ASSIGN_UUID)
    private String codeId;

    /**
     * 授权码
     */
    @ApiModelProperty(value = "授权码", example = "SplxlOBeZQQYbYS6WxSbIA")
    @TableField("authorization_code")
    private String authorizationCode;

    /**
     * 客户端ID
     */
    @ApiModelProperty(value = "客户端ID", example = "client123")
    @TableField("client_id")
    private String clientId;

    /**
     * 用户ID
     */
    @ApiModelProperty(value = "用户ID", example = "user456")
    @TableField("user_id")
    private String userId;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名", example = "john.doe")
    @TableField("user_name")
    private String userName;

    /**
     * 授权范围
     */
    @ApiModelProperty(value = "授权范围", example = "read write")
    @TableField("scope")
    private String scope;

    /**
     * 重定向URI
     */
    @ApiModelProperty(value = "重定向URI", example = "https://client.example.com/callback")
    @TableField("redirect_uri")
    private String redirectUri;

    /**
     * 状态参数
     */
    @ApiModelProperty(value = "状态参数", example = "xyz123")
    @TableField("state")
    private String state;

    /**
     * 授权类型
     */
    @ApiModelProperty(value = "授权类型", example = "authorization_code")
    @TableField("grant_type")
    private String grantType;

    /**
     * 过期时间
     */
    @ApiModelProperty(value = "过期时间", example = "2025-11-21T11:30:00")
    @TableField("expires_at")
    private LocalDateTime expiresAt;

    /**
     * 是否已使用（0否1是）
     */
    @ApiModelProperty(value = "是否已使用（0否1是）", example = "0")
    @TableField("is_used")
    private String isUsed;

    /**
     * 是否有效（0否1是）
     */
    @ApiModelProperty(value = "是否有效（0否1是）", example = "1")
    @TableField("is_active")
    private String isActive;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间", example = "2025-11-21T10:30:00")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间", example = "2025-11-21T10:35:00")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
}