package com.cool.store.vo;

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

import java.util.Date;
import java.util.Objects;

@Data
public class AuditInfoVO {

    @ApiModelProperty("审核id")
    private Long auditId;

    @ApiModelProperty("结果类型 0通过,1拒绝,2结束跟进")
    private Integer resultType;

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

    @ApiModelProperty("明文件或凭证")
    private String certifyFile;

    @ApiModelProperty("审批时间")
    private Date createTime;

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

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

    public static AuditInfoVO convertVO(ShopAuditInfoDO auditInfo) {
        if(Objects.isNull(auditInfo)){
            return null;
        }
        AuditInfoVO result = new AuditInfoVO();
        result.setAuditId(auditInfo.getId());
        result.setResultType(auditInfo.getResultType());
        if(AuditResultTypeEnum.PASS.getCode().equals(result.getResultType())){
            result.setReason(auditInfo.getPassReason());
        }else if(AuditResultTypeEnum.REJECT.getCode().equals(result.getResultType())){
            result.setReason(auditInfo.getRejectReason());
        }
        result.setOperateUserId(auditInfo.getSubmittedUserId());
        result.setOperateUserName(auditInfo.getSubmittedUserName());
        result.setCertifyFile(auditInfo.getCertifyFile());
        result.setCreateTime(auditInfo.getCreateTime());
        return result;
    }
}