package com.ruoyi.project.business.domain.vo.account;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author fangk
 * @date 2024/6/19
 * @desc CancelMergeReq 取消合并vo
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AgentAddAccount {
    /** 区域 */
    private Long areaId;

    /** 区域名称 */
    @Excel(name = "区域")
    private String areaName;

    /** 国家 */
//    private Long countryId;
    private String countryId;

    /** 国家名称 */
    @Excel(name = "国家")
    private String countryName;

    /** 城市 */
    @Excel(name = "城市")
    private String city;

    /** 代理商 */
    private Long ownerAgent;

    /** 代理商名称 */
    @Excel(name = "代理商")
    private String ownerAgentName;

    /** 新建客户数量 */
    @Excel(name = "新建客户数量")
    private Long sumWeek;

    /** 合计客户数量 */
    @Excel(name = "合计客户数量")
    private Long sumTotal;

    /** 数据权限字符 */
    private String permissionChar;

    @TableField(exist = false)
    private List<Long> countryIds;
    public List<Long> getCountryIds() {
        if (CollectionUtils.isEmpty(countryIds) && countryId != null) {
            countryIds = Arrays.stream(countryId.split(","))
                    .map(Long::parseLong)
                    .collect(Collectors.toList());
        }
        return countryIds;
    }

    public void setCountryIds(List<Long> countryIds) {
        this.countryIds = countryIds;
        if (countryIds != null && !countryIds.isEmpty()) {
            this.countryId = countryIds.stream()
                    .map(Object::toString)
                    .collect(Collectors.joining(","));
        } else {
            this.countryId = null;
        }
    }

}