package com.red.circle.other.app.dto.clientobject.team;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.io.Serializable;
import java.util.Objects;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author pengliang on 2022/12/1
 */
@Data
@Accessors(chain = true)
public class TeamCountryCO implements Serializable {

  private static final long serialVersionUID = 1L;

  /**
   * 国家id.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  private Long countryId;

  /**
   * 国家code.
   */
  private String countryCode;

  /**
   * 如果国家code是IA强制变更ID.适配印尼分国家
   */
  public void setCountryCode(String countryCode) {
    if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "IA")) {
      this.countryCode = "ID";
    } else if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "EY")) {
      this.countryCode = "EG";
    } else if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "AB")) {
      this.countryCode = "AE";
    } else if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "MB")) {
      this.countryCode = "MA";
    } else if (Objects.nonNull(countryCode) && Objects.equals(countryCode, "SP")) {
      this.countryCode = "SA";
    } else {
      this.countryCode = countryCode;
    }
  }

  /**
   * 国家名称.
   */
  private String countryName;

}
