22 lines
734 B
Java
22 lines
734 B
Java
package com.bao.dating.mapper;
|
|
|
|
|
|
import com.bao.dating.pojo.entity.Comments;
|
|
import org.apache.ibatis.annotations.*;
|
|
|
|
import java.util.List;
|
|
|
|
public interface CommentsMapper {
|
|
// 添加评论
|
|
@Insert("INSERT INTO dating.comments(content, user_id, post_id, created_at) VALUES(#{content}, #{user_id}, #{post_id}, #{created_at})")
|
|
int addComment(Comments comments);
|
|
|
|
// 删除评论
|
|
@Delete("DELETE FROM dating.comments WHERE user_id = #{user_id}")
|
|
int deleteComments(@Param("user_id") Long user_id);
|
|
|
|
// 根据动态ID查询评论列表
|
|
@Select("SELECT * FROM dating.comments WHERE post_id = #{post_id} ORDER BY created_at DESC")
|
|
List<Comments> getCommentsByPostId(@Param("post_id") Long post_id);
|
|
}
|