package com.webchat.domain.vo.response;

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;

    private String author;

    private Long resourceId;

    private String resourceType;

    private String content;

    private String images;

    private List<String> imageList;

    private String status;

    private Long likeCount;

    private Date pubDate;

    private Long pubTime;

    private String pubDateStr;

    private Boolean permission = false;

    private UserBaseResponseInfoVO authorInfo;

    private CommentResponseVO reply;

    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;
    }
}
