package org.jeecg.modules.system.app.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.system.app.dto.evaluate.FindEvaluateRequestDTO;
import org.jeecg.modules.system.app.dto.evaluate.FindEvaluateResponseDTO;
import org.jeecg.modules.system.app.entity.Evaluate;

import java.util.List;
import java.util.Map;

/**
 * @Description: 评价管理
 * @Author: jeecg-boot
 * @Date:   2025-07-07
 * @Version: V1.0
 */
public interface EvaluateMapper extends BaseMapper<Evaluate> {

    IPage<FindEvaluateResponseDTO> findPage(@Param("page") Page<FindEvaluateResponseDTO> page,@Param("findEvaluateRequestDTO") FindEvaluateRequestDTO findEvaluateRequestDTO);

    IPage<FindEvaluateResponseDTO> findBySiteId(@Param("page")  Page<FindEvaluateResponseDTO> page,@Param("siteId")  String siteId);

    IPage<FindEvaluateResponseDTO> findByCoursesId(@Param("page") Page<FindEvaluateResponseDTO> page,@Param("coursesIds") List<String> coursesIds);

    Evaluate findByOrderId(@Param("orderId") String orderId);

    Long findByAverageScore(@Param("siteId")String siteId);

    Long findByScoreNum(@Param("siteId")String siteId);

    Long findByAverageScoreByCoursesId(@Param("coursesIds") List<String> coursesIds);

    Long findByScoreNumByCoursesId(@Param("coursesIds") List<String> coursesIds);

    Long findByGoodScoreNum(@Param("siteId")String siteId);

    Long findByGoodScoreNumByCoursesId(@Param("coursesIds")List<String> coursesIds);

    String findPositiveRating(@Param("id") String id);

    /**
     * 批量查询多个教练的好评率
     * @param instructorIds 教练ID列表
     * @return 教练ID与好评率的映射列表
     */
    List<Map<String, Object>> batchFindGoodRateByInstructorIds(@Param("instructorIds") List<String> instructorIds);

    /**
     * 批量查询多个场地的评论统计（评论数和评分总和）
     * @param siteIds 场地ID列表
     * @return 场地ID与评论统计的映射列表
     */
    List<Map<String, Object>> batchFindEvaluateStatsBySiteIds(@Param("siteIds") List<String> siteIds);
}
