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

import com.red.circle.framework.core.dto.PageCommand;
import com.red.circle.other.inner.enums.live.RoomContributionCountType;
import com.red.circle.tool.core.date.LocalDateUtils;
import com.red.circle.tool.core.text.StringUtils;
import java.io.Serial;
import java.util.Objects;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 活跃房间搜索条件.
 *
 * @author pengshigang on 2022/10/25
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class RoomContributionCountPageQryCmd extends PageCommand {

  @Serial
  private static final long serialVersionUID = 1L;

  /**
   * 房间ID
   */
  private Long roomId;

  /**
   * WEEKLY 周， DAILY 日
   */
  private RoomContributionCountType type;

  /**
   * 时间 yyyyMMdd.
   */
  private String dateNumber;

  public boolean isDaily() {

    return Objects.equals(RoomContributionCountType.DAILY, this.type);
  }

  public boolean isWeekly() {
    return Objects.equals(RoomContributionCountType.WEEKLY, this.type);
  }

  public void setDefaultDateNumber() {
    if (StringUtils.isNotBlank(this.dateNumber)) {
      return;
    }
    if (this.isDaily()) {
      this.dateNumber = LocalDateUtils.formatNow("yyyyMMdd");
    }
    if (this.isWeekly()) {
      this.dateNumber = LocalDateUtils.nowWeekMondayToStr();
    }
  }
}
