package shop.alien.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import shop.alien.entity.store.LifeAppealManage;
import shop.alien.entity.store.vo.LifeAppealManageVo;

import java.util.List;

@Mapper
public interface LifeAppealManageMapper extends BaseMapper<LifeAppealManage> {

    /**
     * 申诉分页查询
     *
     * @param page         分页参数
     * @param queryWrapper 查询参数
     * @return IPage<LifeAppealManageVo>
     */
    @Select("SELECT a.*, b.dict_detail as appeal_type_str FROM life_appeal_manage a " +
            "left join store_dictionary b on a.appeal_type = b.dict_id and b.type_name = 'appealType' ${ew.customSqlSegment}")
    IPage<LifeAppealManageVo> getAppealHistory(IPage<LifeAppealManageVo> page, @Param(Constants.WRAPPER) QueryWrapper<LifeAppealManage> queryWrapper);

    /**
     * 申诉查询
     */
    IPage<LifeAppealManageVo> getAppealManagement(IPage<LifeAppealManageVo> page,
                                                  @Param("storeName") String storeName,
                                                  @Param("storeContact") String storeContact,
                                                  @Param("storePhone") String storePhone,
                                                  @Param("appealType") String appealType);

    List<LifeAppealManageVo> getAppealManagement(
            @Param("storeName") String storeName,
            @Param("storePhone") String storePhone,
            @Param("appealType") String appealType,
            @Param("storeContact") String storeContact);

    /**
     * 平台申诉管理：根据评论申诉主键 id 查询单条详情（与列表查询字段一致）
     *
     * @param id store_comment_appeal.id
     * @return 申诉详情，不存在时返回 null
     */
    LifeAppealManageVo getAppealDetailById(@Param("id") Integer id);

}
