package com.cool.store.request;

import com.cool.store.entity.ShopAuditInfoDO;
import com.cool.store.enums.AuditResultTypeEnum;
import com.cool.store.enums.AuditTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * @Author: WangShuo
 * @Date: 2025/04/17/13:36
 * @Version 1.0
 * @注释:
 */
@Data
public class AuditRequest {

    @NotNull
    private Long shopId;

    @ApiModelProperty(value = "当前阶段状态")
    @NotNull(message = "当前阶段状态不能为空")
    private Integer shopSubStageStatus;

    @ApiModelProperty(value = "审核结果,0通过，1拒绝")
    @NotNull(message = "审核结果不能为空")
    private Integer resultType;

    @ApiModelProperty(value = "审核原因")
    private String reason;

    @ApiModelProperty(value = "操作人id", hidden = true)
    private String operateUserId;
    @ApiModelProperty(value = "操作人姓名", hidden = true)
    private String operateUserName;
    public static ShopAuditInfoDO convert(AuditRequest request, AuditTypeEnum auditType) {
        ShopAuditInfoDO result = new ShopAuditInfoDO();
        result.setShopId(request.getShopId());
        result.setAuditType(auditType.getCode());
        result.setSubmittedUserId(request.getOperateUserId());
        result.setSubmittedUserName(request.getOperateUserName());
        result.setResultType(request.getResultType());
        if (AuditResultTypeEnum.PASS.getCode().equals(request.getResultType())) {
            result.setPassReason(request.getReason());
        } else {
            result.setRejectReason(request.getReason());
        }
        return result;

    }
}
