package com.red.circle.other.infra.database.mongo.entity.user.friend;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.red.circle.tool.core.text.StringUtils;
import java.io.Serial;
import java.io.Serializable;
import java.sql.Timestamp;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * 好友申请列表.
 *
 * @author pengliang on 2021/5/6
 */
@Data
@Accessors(chain = true)
@Document("friends_apply_list")
@FieldDefaults(level = AccessLevel.PRIVATE)
public class FriendsApply implements Serializable {

  @Serial
  private static final long serialVersionUID = 1L;

  /**
   * 记录Id.
   */
  @Id
  String id;

  /**
   * 时序ID.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  Long timingId;

  /**
   * 用户ID.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  Long userId;

  /**
   * 申请用户id.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  Long applyUserId;

  /**
   * 申请描述.
   */
  String applyDesc;

  /**
   * 状态.
   */
  FriendApplyStatus status;

  /**
   * 过期时间.
   */
  Timestamp expiredTime;

  /**
   * 创建时间.
   */
  Timestamp createTime;

  public void generateId() {
    this.id = StringUtils.sortAscNumberJoin("_", getApplyUserId(), getUserId());
  }

}
