package com.fs.his.mapper;

import java.util.List;
import com.fs.his.domain.FsInquiryOrderPing;
import com.fs.his.param.*;
import com.fs.his.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 评价Mapper接口
 *
 * @author fs
 * @date 2023-07-03
 */
public interface FsInquiryOrderPingMapper
{
    /**
     * 查询评价
     *
     * @param pingId 评价主键
     * @return 评价
     */
    public FsInquiryOrderPing selectFsInquiryOrderPingByPingId(Long pingId);

    /**
     * 查询评价列表
     *
     * @param fsInquiryOrderPing 评价
     * @return 评价集合
     */
    public List<FsInquiryOrderPing> selectFsInquiryOrderPingList(FsInquiryOrderPing fsInquiryOrderPing);

    /**
     * 新增评价
     *
     * @param fsInquiryOrderPing 评价
     * @return 结果
     */
    public int insertFsInquiryOrderPing(FsInquiryOrderPing fsInquiryOrderPing);

    /**
     * 修改评价
     *
     * @param fsInquiryOrderPing 评价
     * @return 结果
     */
    public int updateFsInquiryOrderPing(FsInquiryOrderPing fsInquiryOrderPing);

    /**
     * 删除评价
     *
     * @param pingId 评价主键
     * @return 结果
     */
    public int deleteFsInquiryOrderPingByPingId(Long pingId);

    /**
     * 批量删除评价
     *
     * @param pingIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsInquiryOrderPingByPingIds(Long[] pingIds);

    @Select({"<script> " +
            "select p.*,d.doctor_name,d.avatar  from fs_inquiry_order_ping p left join fs_doctor d on d.doctor_id=p.doctor_id   " +
            "where 1=1  " +
            "<if test = 'maps.userId != null     '> " +
            "and p.user_id = #{maps.userId} " +
            "</if>" +
            " order by p.ping_time desc "+
            "</script>"})
    List<FsInquiryOrderPingListUVO> selectFsInquiryOrderPingListUVO(@Param("maps") FsInquiryOrderPingListUParam param);
    @Select({"<script> " +
            "select p.*,u.nick_name,u.avatar  from fs_inquiry_order_ping p left join fs_user u on u.user_id=p.user_id   " +
            "where 1=1  " +
            "<if test = 'maps.doctorId != null     '> " +
            "and p.doctor_id = #{maps.doctorId} " +
            "</if>" +
            " order by p.ping_time desc "+
            "</script>"})
    List<FsDoctorPingUVO> selectFsDoctorPingListUVO(@Param("maps") FsDoctorPingListUParam param);
    @Select({"<script> " +
            "select p.*,u.nick_name,u.avatar  from fs_inquiry_order_ping p left join fs_user u on u.user_id=p.user_id   " +
            "where 1=1  " +
            "<if test = 'maps.doctorId != null     '> " +
            "and p.doctor_id = #{maps.doctorId} " +
            "</if>" +
            "<if test = 'maps.keyword != null and  maps.keyword != \"\"   '> " +
            "and u.nick_name like concat( #{maps.keyword}, '%') " +
            "</if>" +
            " order by p.ping_time desc "+
            "</script>"})
    List<FsInquiryOrderPingListDVO> selectFsInquiryOrderPingListDVO(@Param("maps") FsInquiryOrderPingListDParam param);


    @Select({"<script> " +
            "SELECT p.*,d.doctor_name,u.nick_name,u.phone,o.order_sn FROM fs_inquiry_order_ping p LEFT JOIN fs_doctor d ON p.doctor_id=d.doctor_id LEFT JOIN fs_user u ON p.user_id=u.user_id LEFT JOIN fs_inquiry_order o ON o.order_id=p.order_id "+
            "<where>  \n" +
            "            <if test=\"orderSn != null \"> and o.order_sn = #{orderSn}</if>\n" +
            "            <if test=\"pingContent != null  and p.pingContent != ''\"> and ping_content = #{pingContent}</if>\n" +

            "            <if test=\"sTime != null \">  and DATE(p.ping_time) &gt;= DATE(#{sTime})</if>\n" +
            "            <if test=\"eTime != null \">  and DATE(p.ping_time) &lt;= DATE(#{eTime})</if>\n" +
            "            <if test=\"doctorName != null \"> and doctor_name like concat('%', #{doctorName}, '%')</if>\n" +
            "        </where>"+
            " order by ping_id desc "+
            "</script>"})
    List<FsInquiryOrderPingListVO> selectFsInquiryOrderPingListVO(FsInquiryOrderDoctorPingParam fsInquiryOrderPing);

    @Select({"<script> " +
            "SELECT p.*,d.doctor_name,u.nick_name,u.phone,o.order_sn FROM fs_inquiry_order_ping p LEFT JOIN fs_doctor d ON p.doctor_id=d.doctor_id LEFT JOIN fs_user u ON p.user_id=u.user_id LEFT JOIN fs_inquiry_order o ON o.order_id=p.order_id "+
            "<where>  \n" +
            "            <if test=\"orderSn != null \"> and o.order_sn = #{orderSn}</if>\n" +
            "            <if test=\"pingContent != null  and p.pingContent != ''\"> and ping_content = #{pingContent}</if>\n" +

            "            <if test=\"sTime != null \">  and DATE(p.ping_time) &gt;= DATE(#{sTime})</if>\n" +
            "            <if test=\"eTime != null \">  and DATE(p.ping_time) &lt;= DATE(#{eTime})</if>\n" +
            "            <if test=\"doctorName != null \"> and doctor_name like concat('%', #{doctorName}, '%')</if>\n" +
            "        </where>"+
            " order by ping_id desc "+
            "</script>"})
    List<FsInquiryOrderPingExportListVO> selectFsInquiryOrderPingExportListVO(FsInquiryOrderDoctorPingParam fsInquiryOrderPing);
}
