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

import com.red.circle.common.business.enums.ConsoleAccountStatusEnum;
import com.red.circle.framework.core.dto.CommonCommand;
import com.red.circle.tool.core.text.StringUtils;
import jakarta.validation.constraints.NotBlank;
import java.io.Serial;
import java.util.Objects;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @author pengliang on 2020/1/14 12:07
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class ApprovalAccountCmd extends CommonCommand {

  @Serial
  private static final long serialVersionUID = 1L;

  /**
   * 审批用户
   */
  private Long approvalUserId;

  /**
   * 被审批用户
   */
  private Long beApprovalUserId;

  /**
   * 账号状态
   */
  private ConsoleAccountStatusEnum accountStatusEnum;

  /**
   * 描述备注
   */
  @NotBlank(message = "description not null")
  private String description;

  /**
   * 译文描述备注
   */
  private String descriptionTranslate;

  /**
   * 冻结天数.
   */
  private Integer days;

  public String getDescriptionContent() {
    String desc = StringUtils.isNotBlank(descriptionTranslate)
        ? descriptionTranslate
        : description;

    if (ConsoleAccountStatusEnum.FREEZE.eq(accountStatusEnum)) {
      return String.format("【冻结-%s天】%s", days, desc);
    }
    if (ConsoleAccountStatusEnum.ARCHIVE.eq(accountStatusEnum)) {
      return String.format("【封禁-%s天】%s", days, desc);
    }
    return desc;
  }

  public ConsoleAccountStatusEnum getAccountStatusEnumContent() {
    if (Objects.equals(accountStatusEnum, ConsoleAccountStatusEnum.UNTIE_DEVICE_AND_ACCOUNT)) {
      return ConsoleAccountStatusEnum.NORMAL;
    }
    return accountStatusEnum;
  }

  public boolean isNotCleanToken() {
    return ConsoleAccountStatusEnum.UNTIE_DEVICE.eq(getAccountStatusEnum())
        || ConsoleAccountStatusEnum.UNTIE_DEVICE_AND_ACCOUNT.eq(getAccountStatusEnum())
        || ConsoleAccountStatusEnum.WARNING.eq(getAccountStatusEnum());
  }
}
