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: 2024/10/10/下午1:35
 * @Version 1.0
 * @注释:
 */
@Data
public class PlatformBuildAuditRequest {

    @NotNull
    private Long shopId;

    @ApiModelProperty(value = "'1-抖音，2-快手，3-美团团购，4-饿了么，5-美团外卖")
    private Integer type;

    @ApiModelProperty("审核结果,0通过，1拒绝")
    private Integer resultType;

    @ApiModelProperty("原因")
    private String reason;

    @ApiModelProperty(value = "操作人id", hidden = true)
    private String operateUserId;

    @ApiModelProperty(value = "操作人姓名", hidden = true)
    private String operateUserName;

    public static ShopAuditInfoDO convert(PlatformBuildAuditRequest 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;

    }
}
