package org.lym.pom.repository.mongo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;

/**
 * 一个用户对另一个用户的关注
 *
 * @author lym
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(collection = Follow.COLLECTION_NAME)
@CompoundIndex(name = "idx_follow", def = "{'userId': 1, 'followeeUserId': -1}")
public class Follow implements Serializable {

    public static final String COLLECTION_NAME = "follow";

    /**
     * id
     */
    @Id
    private String id;
    /**
     * 用户X [粉丝]
     */
    @Indexed
    private String userId;
    /**
     * 用户X关注的人 [博主]
     */
    @Indexed
    private String followeeUserId;

    // user 关注的领域，标签单独存储 ~/ tag/ post /watch~
    private String type;
    /**
     * 关注时间
     */
    @Field
    private Long createTime;
}
