package com.red.circle.other.app.dto.cmd.sys;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.tool.core.text.StringPool;
import com.red.circle.tool.core.text.StringUtils;
import jakarta.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 被举报用户
 * </p>
 *
 * @author pengliang
 * @since 2019-10-31
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class UserReportedCmd extends AppExtCommand {

  /**
   * 举报用户.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  private Long reportUserId;

  /**
   * 被举报用户.
   *
   * @eo.required
   */
  @JsonSerialize(using = ToStringSerializer.class)
  @NotNull(message = "reportedUserId required.")
  private Long reportedUserId;

  /**
   * 0.非法信息 1.人生攻击 2.不适当的内容 3.发送垃圾邮件 4.诈骗.
   *
   * @eo.required
   */
  @NotNull(message = "reportType required.")
  private Integer reportType;

  /**
   * 举报内容.
   */
  private String reportedContent;

  /**
   * 关联id.
   */
  private Long relatedId;

  /**
   * 举报图片URL.
   */
  private String imageUrls;

  /**
   * 举报视频URL.
   */
  private String videoUrls;

  public List<String> imageUrlToList() {
    if (StringUtils.isBlank(imageUrls) || Objects
        .equals(imageUrls.toLowerCase(), StringPool.NULL_LOWER_CASE)) {
      return Collections.emptyList();
    }

    return Arrays.stream(imageUrls.split(",")).filter(StringUtils::isNotBlank)
        .collect(Collectors.toList());
  }

  public List<String> videoUrlsToList() {
    if (StringUtils.isBlank(videoUrls) || Objects
        .equals(videoUrls.toLowerCase(), StringPool.NULL_LOWER_CASE)) {
      return Collections.emptyList();
    }

    return Arrays.stream(videoUrls.split(",")).filter(StringUtils::isNotBlank)
        .collect(Collectors.toList());
  }

}
