package shop.alien.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import shop.alien.entity.store.StoreCommentAppealSupplement;
import shop.alien.entity.store.vo.StoreCommentAppealSupplementVo;

import java.util.List;

/**
 * 评论申诉-用户补充内容 Mapper
 */
@Mapper
public interface StoreCommentAppealSupplementMapper extends BaseMapper<StoreCommentAppealSupplement> {

    /**
     * 按申诉ID查询补充列表（含用户信息）
     */
    @Select("SELECT s.*, u.user_name, u.user_image " +
            "FROM store_comment_appeal_supplement s " +
            "LEFT JOIN life_user u ON s.user_id = u.id AND u.delete_flag = 0 " +
            "WHERE s.appeal_id = #{appealId} AND s.delete_flag = 0 " +
            "ORDER BY s.created_time ASC")
    List<StoreCommentAppealSupplementVo> listByAppealId(@Param("appealId") Integer appealId);

    /**
     * 按评论ID查询补充列表（含用户信息）
     */
    @Select("SELECT s.*, u.user_name, u.user_image " +
            "FROM store_comment_appeal_supplement s " +
            "LEFT JOIN life_user u ON s.user_id = u.id AND u.delete_flag = 0 " +
            "WHERE s.comment_id = #{commentId} AND s.delete_flag = 0 " +
            "ORDER BY s.created_time ASC")
    List<StoreCommentAppealSupplementVo> listByCommentId(@Param("commentId") Integer commentId);

    /**
     * 查询补充详情（含用户信息）
     */
    @Select("SELECT s.*, u.user_name, u.user_image " +
            "FROM store_comment_appeal_supplement s " +
            "LEFT JOIN life_user u ON s.user_id = u.id AND u.delete_flag = 0 " +
            "WHERE s.id = #{id} AND s.delete_flag = 0 " +
            "LIMIT 1")
    StoreCommentAppealSupplementVo getDetailById(@Param("id") Integer id);
}
