package com.ruoyi.frequency.workscomment.entity;

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

/**
 * 作品评论对象 t_works_comment
 *
 * @author liwenlong
 * @date 2024-04-11
 */
@Data
@Accessors(chain = true)
@TableName("t_works_comment")
public class WorksComment extends BaseEntity
{
    private static final long serialVersionUID = 1L;


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

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

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

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

    @ApiModelProperty("作品id")
    @Excel(name = "作品id")
    private Long worksId;

    @ApiModelProperty("顶级评论id(对主体的直接评论)")
    @Excel(name = "顶级评论id(对主体的直接评论)")
    private Long topId;

    @ApiModelProperty("上级评论id 默认-1")
    @Excel(name = "上级评论id 默认-1")
    private Long parentId;

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

    @ApiModelProperty("上级评论用户id")
    @Excel(name = "上级评论用户id")
    private Long parentUserId;

    @ApiModelProperty("评论内容")
    @Excel(name = "评论内容")
    private String content;

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

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

    @ApiModelProperty("图片")
    @Excel(name = "图片")
    private String image;

    @ApiModelProperty("上级评论id集合，逗号拼接")
    @Excel(name = "上级评论id集合，逗号拼接")
    private String parentIds;

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

    @ApiModelProperty(value = "上级用户用户昵称")
    @TableField(exist = false)
    private UserInfo parentUserInfo;


    public WorksComment() {
    }
    public WorksComment(WorksCommentReq req, UserVo userVo) {
        this.id = SnowIdUtils.uniqueLong();
        this.userType = userVo.getUserType();
        this.userId = userVo.getUserId();
        this.worksId = req.getWorksId();
        this.content = req.getContent();
        this.image = req.getImage();
        this.parentId = req.getParentId();
    }
}
