package com.webchat.domain.vo.response;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * @Author: 程序员王七七 https://www.coderutil.com 网站作者
 * @Date: 2021-7-11 0011 14:36
 * @Description: 无描述信息
 */
@Data
public class MomentResponseBaseVO {

    protected Long id;

    private String content;

    private String images;

    private String video;

    private String author;

    private String status;

    private Boolean isLike = false;

    private Long likeCount = 0L;

    private Long rewardUserCount = 0L;

    private Long clickCount = 0L;

    private Long commentCount = 0L;

    private Date pubDate;

    private Long pubTime;

    private String client;

    public String getFirstImage() {
        if (StringUtils.isNotBlank(images)) {
            return images.split(",")[0];
        }
        return null;
    }

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

    public String getSubContent() {
        if (StringUtils.isBlank(content)) {
            return "";
        }
        return content.trim().substring(0, 20 > content.trim().length() ? content.trim().length() : 20);
    }
}
