package com.webchat.domain.vo.response;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @Author: 程序员王七七 https://www.coderutil.com 网站作者
 * @Date: 2021-6-27 0027 17:47
 * @Description: 无描述信息
 */
@Data
public class CommentResponseVO {

    private Long id;

    @ApiModelProperty("评论作者id")
    private String author;

    @ApiModelProperty("资源id")
    private Long resourceId;

    @ApiModelProperty("资源类型")
    private String resourceType;

    @ApiModelProperty("评论正文")
    private String content;

    @ApiModelProperty("图片")
    private String images;

    @ApiModelProperty("图片列表")
    private List<String> imageList;

    @ApiModelProperty("状态")
    private String status;

    @ApiModelProperty("点赞量")
    private Long likeCount;

    @ApiModelProperty("发布时间")
    private Date pubDate;

    @ApiModelProperty("发布时间")
    private Long pubTime;

    @ApiModelProperty("发布时间")
    private String pubDateStr;

    private Boolean permission = false;

    @ApiModelProperty("评论作者")
    private UserBaseResponseInfoVO authorInfo;

    @ApiModelProperty("父评论")
    private CommentResponseVO reply;

    @ApiModelProperty("回复评论列表")
    private List<CommentResponseVO> replyToList;

    public List<String> getImageList() {
        if (StringUtils.isBlank(images)) {
            return Collections.emptyList();
        }
        return Arrays.asList(images.split(","));
    }

    public Long getPubTime() {
        return pubDate != null ? pubDate.getTime() : null;
    }
}
