package cn.reghao.tnb.search.app.comment.model.po;

import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.common.auth.UserContext;
import cn.reghao.tnb.search.app.comment.model.dto.CommentSbtDto;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author reghao
 * @date 2023-02-01 16:15:43
 */
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@Setter
@Getter
public class UserComment extends BaseObject<String> {
    private Long pCommentId;
    private Long commentId;
    private String content;
    private List<String> commentImages;
    private Integer likes;
    private String location;
    private String postId;
    private Long publishAt;
    private Long publishBy;
    private Long avId;
    private Long targetId;
    private String targetUsername;

    private Boolean liked;
    private Integer postType;
    private String imgSrc;

    public UserComment(long commentId, CommentSbtDto commentSbtDto) {
        this.pCommentId = commentSbtDto.getParentId();
        this.commentId = commentId;
        this.content = commentSbtDto.getContent();
        this.commentImages = new ArrayList<>();
        this.likes = 0;
        this.location = "";
        this.postId = commentSbtDto.getVideoId();
        this.publishAt = System.currentTimeMillis();
        this.publishBy = UserContext.getUserId();
        this.avId = 0L;
        this.targetId = commentSbtDto.getTargetId();
        this.targetUsername = commentSbtDto.getTargetUsername();
    }
}
