package com.example.mapper; import com.example.entity.Comment; import org.apache.ibatis.annotations.Select; import java.util.List; // 评论数据访问接口 public interface CommentMapper { // 新增评论 int insert(Comment comment); // 根据ID删除评论 int deleteById(Integer id); // 根据ID修改评论 int updateById(Comment comment); // 根据ID查询评论 Comment selectById(Integer id); // 查询所有评论(可条件查询) List selectAll(Comment comment); // 根据商品ID查询评论(关联查询用户信息) @Select("select comment.*, user.avatar as userAvatar, user.name as userName from comment left join user on comment.user_id = user.id where comment.goods_id = #{id}") List selectByGoodsId(Integer id); }