package com.cool.store.dto.contract;

import com.cool.store.common.PageBasicInfo;
import com.cool.store.enums.JoinModeEnum;
import com.cool.store.utils.StringUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author suzhuhong
 * @Date 2025/9/8 16:43
 * @Version 1.0
 */
public class ContractListDTO {

    @ApiModelProperty("主键 新建时忽略")
    private Long id;

    @ApiModelProperty("品牌")
    @NotBlank(message = "品牌不能为空")
    private String brand;

    @ApiModelProperty("合同名称")
    @NotBlank(message = "合同名称不能为空")
    private String contractName;

    @ApiModelProperty("甲方名称")
    @NotBlank(message = "甲方名称不能为空")
    private String partyA;

    @ApiModelProperty("乙方名称")
    @NotBlank(message = "乙方名称不能为空")
    private String partyB;

    @ApiModelProperty(" 丙方名称")
    private String partyC;

    @ApiModelProperty("加盟模式 多选 用逗号隔开")
    private List<FranchiseModeDTO> franchiseModeList;

    @ApiModelProperty("法大大模板ID")
    private String fadadaTemplateId;

    @ApiModelProperty("序号")
    @NotNull(message = "序号不能为空")
    private Integer serialNumber;

    @ApiModelProperty("收款方名称")
    private String payeeName;

    private String franchiseMode;

    @Data
    protected class FranchiseModeDTO{

        private String id;

        private String name;

    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getContractName() {
        return contractName;
    }

    public void setContractName(String contractName) {
        this.contractName = contractName;
    }

    public String getPartyA() {
        return partyA;
    }

    public void setPartyA(String partyA) {
        this.partyA = partyA;
    }

    public String getPartyB() {
        return partyB;
    }

    public void setPartyB(String partyB) {
        this.partyB = partyB;
    }

    public String getPartyC() {
        return partyC;
    }

    public void setPartyC(String partyC) {
        this.partyC = partyC;
    }

    public void setFranchiseModeList(List<FranchiseModeDTO> franchiseModeList) {
        this.franchiseModeList = franchiseModeList;
    }

    public String getFadadaTemplateId() {
        return fadadaTemplateId;
    }

    public void setFadadaTemplateId(String fadadaTemplateId) {
        this.fadadaTemplateId = fadadaTemplateId;
    }

    public Integer getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(Integer serialNumber) {
        this.serialNumber = serialNumber;
    }

    public String getPayeeName() {
        return payeeName;
    }

    public void setPayeeName(String payeeName) {
        this.payeeName = payeeName;
    }

    public String getFranchiseMode() {
        return franchiseMode;
    }

    public void setFranchiseMode(String franchiseMode) {
        this.franchiseMode = franchiseMode;
    }

    public List<FranchiseModeDTO> getFranchiseModeList(){
        String[] split = this.franchiseMode.split(",");
        ArrayList<FranchiseModeDTO> result = new ArrayList<>();
        Arrays.stream(split).filter(item -> StringUtil.isNotEmpty(item)).forEach(item -> {
            FranchiseModeDTO franchiseModeDTO = new FranchiseModeDTO();
            franchiseModeDTO.setId(item);
            franchiseModeDTO.setName(JoinModeEnum.getByCode(Integer.parseInt(item)));
            result.add(franchiseModeDTO);
        });
         return result;
    }



}
