package shop.alien.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import shop.alien.entity.store.StoreEvaluation;
import shop.alien.entity.store.dto.GroupRes;

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

public interface StoreEvaluationMapper extends BaseMapper<StoreEvaluation> {

    List<GroupRes> groupCount(@Param("storeId") String storeId);


    String avgSource(@Param("storeId") String storeId);

    // 获取全部店铺平均分
    @Select("select store_id,ifnull(round(avg(score), 1), 0) avg_score,count(*) total_num\n" +
            "from store_comment eval,store_info store\n" +
            "where eval.store_id = store.id and eval.delete_flag = 0 and eval.business_type = 5\n" +
            "group by store_id ")
    List<Map<String, Object>> allStoreAvgScore();
}
