package com.dora.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 实名认证响应DTO
 *
 * @author Dora
 */
@Data
@Schema(description = "实名认证响应结果")
public class IdentityVerifyResponseDto {

    @Schema(description = "验证是否通过", example = "true")
    private Boolean passed;

    @Schema(description = "验证结果状态码", example = "PASS")
    private String resultStatus;

    @Schema(description = "验证结果描述", example = "验证通过")
    private String resultMessage;

    @Schema(description = "阿里云请求ID", example = "1234567890-ABCD-1234-5678-123456789012")
    private String requestId;

    @Schema(description = "认证任务ID", example = "VERIFY_TASK_123456")
    private String certifyId;

    @Schema(description = "用户是否已完成实名认证", example = "true")
    private Boolean isVerified;

    @Schema(description = "认证时间", example = "2024-08-31 12:34:56")
    private String verifyTime;

    // 每日请求限制相关字段
    @Schema(description = "今日已请求次数", example = "2")
    private Integer todayRequestCount;

    @Schema(description = "每日请求限制", example = "3")
    private Integer dailyLimit;

    @Schema(description = "剩余请求次数", example = "1")
    private Integer remainingRequests;

    @Schema(description = "限制重置时间戳（毫秒）", example = "1640995200000")
    private Long resetTime;

    /**
     * 构造认证成功的响应
     */
    public static IdentityVerifyResponseDto success(String requestId, String certifyId) {
        IdentityVerifyResponseDto response = new IdentityVerifyResponseDto();
        response.setPassed(true);
        response.setResultStatus("PASS");
        response.setResultMessage("实名认证通过");
        response.setRequestId(requestId);
        response.setCertifyId(certifyId);
        response.setIsVerified(true);
        return response;
    }

    /**
     * 构造认证失败的响应
     */
    public static IdentityVerifyResponseDto failure(String requestId, String message) {
        IdentityVerifyResponseDto response = new IdentityVerifyResponseDto();
        response.setPassed(false);
        response.setResultStatus("FAIL");
        response.setResultMessage(message != null ? message : "实名认证未通过");
        response.setRequestId(requestId);
        response.setIsVerified(false);
        return response;
    }

    /**
     * 构造错误的响应
     */
    public static IdentityVerifyResponseDto error(String requestId, String message) {
        IdentityVerifyResponseDto response = new IdentityVerifyResponseDto();
        response.setPassed(false);
        response.setResultStatus("ERROR");
        response.setResultMessage(message != null ? message : "系统错误，请稍后重试");
        response.setRequestId(requestId);
        response.setIsVerified(false);
        return response;
    }
}
