package com.cool.store.request;

import com.cool.store.entity.LineAuditInfoDO;
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 zhangchenbiao
 * @FileName: AuditRentContractRequest
 * @Description:租赁合同审核
 * @date 2024-04-16 14:30
 */
@Data
public class AuditRentContractRequest {

    @NotNull
    @ApiModelProperty("店铺id")
    private Long shopId;

    @NotNull
    @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(AuditRentContractRequest 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.setResultType(AuditResultTypeEnum.PASS.getCode());
        }else{
            result.setRejectReason(request.getReason());
        }
        return result;
    }



}
