package com.red.circle.other.inner.model.cmd.user;

import com.neovisionaries.i18n.CountryCode;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

/**
 * 用户资料.
 *
 * @author pengliang on 2023/5/22
 */
@Data
public class UserProfileCmd implements Serializable {

  @Serial
  private static final long serialVersionUID = 1L;

  /**
   * 用户id.
   */
  @NotNull(groups = Update.class, message = "id required.")
  private Long id;

  /**
   * 用户昵称.
   */
  private String userNickname;

  /**
   * 用户头像.
   */
  private String userAvatar;

  /**
   * 用户性别:0 女，1 男.
   */
  @Range(groups = Create.class, min = 0, max = 1, message = "userSex range 0~1")
  @NotNull(message = "userSex required.")
  private Integer userSex;

  /**
   * 出身年.
   */
  @NotNull(message = "bornYear required.")
  private Integer bornYear;

  /**
   * 出身月.
   */
  @NotNull(message = "bornMonth required.")
  private Integer bornMonth;

  /**
   * 出身日.
   */
  @NotNull(message = "bornDay required.")
  private Integer bornDay;

  /**
   * 用户年龄.
   */
  private Integer age;

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

  /**
   * 国家id.
   */
  private Long countryId;

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


  public boolean checkExistsCountryCode() {
    CountryCode countryCodeEnum = CountryCode.getByCodeIgnoreCase(this.countryCode);
    return Objects.nonNull(countryCodeEnum) && !Objects.equals(countryCodeEnum,
        CountryCode.UNDEFINED);
  }

  public interface Create {

  }

  public interface Update {

  }

}
