package com.wzj.soopin.content.domain.bo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wzj.soopin.content.domain.po.Comment;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.dromara.common.core.domain.BaseBO;
import org.hibernate.validator.constraints.Length;


@Data
public class CommentBO extends BaseBO<Comment> {

    private Long id;

    @NotBlank(message = "留言信息不完整")
    private String vlogerId;

    @NotBlank(message = "留言信息不完整")
    private String fatherCommentId;

    @NotBlank(message = "留言信息不完整")
    private String vlogId;

    @NotBlank(message = "当前用户信息不正确，请尝试重新登录")
    private String commentUserId;

    @NotBlank(message = "评论内容不能为空")
    @Length(max = 50, message = "评论内容长度不能超过50")
    private String content;

    private String mobile;


    @Override
    public LambdaQueryWrapper<Comment> toWrapper() {
        return super.toWrapper().eq(id!=null,Comment::getId,id)
                .eq(vlogerId!=null,Comment::getVlogerId,vlogerId)
                .eq(fatherCommentId!=null,Comment::getFatherCommentId,fatherCommentId)
                .eq(vlogId!=null,Comment::getVlogId,vlogId)
                .eq(commentUserId!=null,Comment::getCommentUserId,commentUserId)
                .eq(content!=null,Comment::getContent,content);
    }
}
