package com.ruoyi.post.frequency.post.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.post.controller.req.PostReleaseReq;
import com.ruoyi.post.controller.vo.SelectedComment;
import com.ruoyi.vo.UserInfo;
import com.ruoyi.vo.UserVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * 帖子对象 t_post
 *
 * @author liwenlong
 * @date 2023-10-09
 */
@Data
@Accessors(chain = true)
@TableName("t_post")
public class Post extends BaseEntity
{
    private static final long serialVersionUID = 1L;


    @ApiModelProperty("租户号")
    private Long id;

    @ApiModelProperty("删除标识 1 正常 2 删除 3 禁用")
    private Integer delFlag;

    @ApiModelProperty("帖子分类id")
    @Excel(name = "帖子分类id")
    private Long postTypeId;

    @ApiModelProperty("用户类型")
    @Excel(name = "用户类型")
    private Integer userType;

    @ApiModelProperty("用户id")
    @Excel(name = "用户id")
    private Long userId;

    @ApiModelProperty("标题")
    @Excel(name = "标题")
    private String title;

    @ApiModelProperty("文字描述(富文本)")
    @Excel(name = "文字描述(富文本)")
    private String content;

    @ApiModelProperty("封面图")
    @Excel(name = "封面图")
    private String coverImage;

    @ApiModelProperty("视频路径（一个）")
    @Excel(name = "视频路径", readConverterExp = "一=个")
    private String videoUrl;

    @ApiModelProperty("分享数")
    @Excel(name = "分享数")
    private Integer shareNum;

    @ApiModelProperty("点赞数")
    @Excel(name = "点赞数")
    private Integer likeNum;

    @ApiModelProperty("评论数")
    @Excel(name = "评论数")
    private Integer commentNum;

    @ApiModelProperty("收藏数")
    @Excel(name = "收藏数")
    private Integer collectNum;

    @ApiModelProperty("浏览数")
    @Excel(name = "浏览数")
    private Integer browseNum;

    @ApiModelProperty("状态 1 待审核 2 通过 3 拒绝")
    @Excel(name = "状态 1 待审核 2 通过 3 拒绝")
    private Integer result;

    @ApiModelProperty("拒绝原因")
    @Excel(name = "拒绝原因")
    private String reason;


    @Excel(name = "地址")
    @ApiModelProperty("地址")
    private String address;


    @ApiModelProperty("精彩评论id")
    private Long commentId;

    @ApiModelProperty("帖子类型 1 帖子 2资讯")
    private Integer type;

    @ApiModelProperty("描述")
    private String describes;

    @ApiModelProperty("热度时间")
    private Date trendsTime;

    @ApiModelProperty("帖子分类名称")
    @Excel(name = "帖子分类名称")
    @TableField(exist = false)
    private String postTypeName;

    @ApiModelProperty("用户信息")
    @TableField(exist = false)
    private UserInfo userInfo;

    @ApiModelProperty("精选评论")
    @TableField(exist = false)
    private SelectedComment selectedComment;

    @ApiModelProperty("是否推荐 1否 2是")
    @TableField(exist = false)
    private Integer isRecommend;

    @ApiModelProperty("开始时间")
    @TableField(exist = false)
    private Date beginTime;

    @ApiModelProperty("结束时间")
    @TableField(exist = false)
    private Date endTime;

    @ApiModelProperty("企业id")
    @TableField(exist = false)
    private Long enterpriseId;

    public Post() {
    }

    public Post(PostReleaseReq req, UserVo userVo) {
        this.userId = userVo.getUserId();
        this.userType = userVo.getUserType();
        this.title = req.getTitle();
        this.content = req.getContent();
        this.coverImage = req.getCoverImage();
        this.videoUrl = req.getVideoUrl();
        this.postTypeId = req.getPostTypeId();
        this.address = req.getAddress();
    }
}
