package com.webchat.domain.vo.response;

import com.webchat.common.enums.CommonStatusEnum;
import com.webchat.common.util.DateUtils;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

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

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

    private String statusDesc;

    private Long commentCount = 0L;

    /***
     * 是否有删除权限
     */
    private Boolean hasDeleteAuth = false;

    private UserBaseResponseInfoVO userInfo;

    private List<UserBaseResponseInfoVO> likeUsers;

    /***
     * 外显评论
     */
    private List<CommentOutResponseVO> outComments;

    public boolean getHasImage() {
        return StringUtils.isNotBlank(super.getImages());
    }

    public String getFirstImage() {
        List<String> images = getImageList();
        if (CollectionUtils.isNotEmpty(images)) {
            return images.get(0);
        }
        return null;
    }

    public List<String> getImageList() {
        if (getHasImage()) {
            return new ArrayList<>(Arrays.asList(super.getImages().split(",")));
        }
        return new ArrayList<>();
    }

    public boolean getHasVideo() {
        return StringUtils.isNotBlank(super.getVideo());
    }

    public String getPubDateStr() {
        if (super.getPubDate() == null) {
            return "";
        }
        return DateUtils.getDate2String(super.getPubDate());
    }

    public Long getPubDateTime() {
        if (super.getPubDate() == null) {
            return 0L;
        }
        return super.getPubDate().getTime();
    }

    public String getStatusDescStr() {
       return CommonStatusEnum.getStatusDescByStatus(super.getStatus());
    }
}
