刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 1 | package com.pt5.pthouduan.mapper; |
| 2 | |
| 3 | import com.pt5.pthouduan.entity.Comment; |
| 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 5 | import org.apache.ibatis.annotations.Mapper; |
ym923 | 55ec83a | 2025-06-03 17:15:13 +0800 | [diff] [blame] | 6 | import org.apache.ibatis.annotations.Param; |
| 7 | |
| 8 | import java.util.List; |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 9 | |
| 10 | /** |
| 11 | * <p> |
ym923 | 55ec83a | 2025-06-03 17:15:13 +0800 | [diff] [blame] | 12 | * 评论 Mapper 接口 |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 13 | * </p> |
| 14 | * |
ym923 | 55ec83a | 2025-06-03 17:15:13 +0800 | [diff] [blame] | 15 | * 功能:增、删、改、查(按帖子ID) |
| 16 | * |
| 17 | * @author ym |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 18 | * @since 2025-04-14 |
| 19 | */ |
| 20 | @Mapper |
| 21 | public interface CommentMapper extends BaseMapper<Comment> { |
| 22 | |
ym923 | 55ec83a | 2025-06-03 17:15:13 +0800 | [diff] [blame] | 23 | // 创建评论 |
| 24 | void save(Comment comment); |
| 25 | |
| 26 | // 根据评论ID删除 |
| 27 | int deleteByCommentid(@Param("commentid") Integer commentid); |
| 28 | |
| 29 | // 更新评论 |
| 30 | int updateComment(Comment comment); |
| 31 | |
| 32 | // 获取指定帖子下的所有评论 |
| 33 | List<Comment> selectByPostid(@Param("postid") Integer postid); |
| 34 | |
| 35 | // 点赞 +1 |
| 36 | int incrementLikes(@Param("commentid") Integer commentid); |
| 37 | |
| 38 | // 取消点赞 -1(最小为0) |
| 39 | int decrementLikes(@Param("commentid") Integer commentid); |
| 40 | |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 41 | } |