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

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.other.inner.enums.user.AuthTypeEnum;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 用户认证检测.
 *
 * @author pengliang on 2020/11/4
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class UserChannelCredentialCmd extends AppExtCommand {

  /**
   * 认证类型（MOBILE、FACEBOOK、GOOGLE、HUAWEI、APPLE）.
   *
   * @eo.required
   */
  @NotNull(message = "authType required.")
  private AuthTypeEnum authType;

  /**
   * 注册id.
   *
   * @eo.required
   */
  @NotBlank(message = "openId required.")
  private String openId;

  public String openId() {
    if (openId.contains("_") && !AuthTypeEnum.HUAWEI.name().equals(authType.name())) {
      return openId;
    }
    return this.getOpenId().concat("_").concat(this.requireReqSysOrigin());
  }

}
