package org.ta.pddserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.ta.pddserver.entity.LogOrderMailDetailIoEntity;
import org.ta.pddserver.model.api.request.LogOrderMailDetailIoRequest;
import org.ta.pddserver.model.api.response.LogOrderMailDetailIoListResponse;

import java.util.List;

@Mapper
public interface LogOrderMailDetailIoMapper extends BaseMapper<LogOrderMailDetailIoEntity> {

    @Select("SELECT count(t.uid) FROM ( SELECT a.uid  FROM  `log_order_mail_detail_io` a WHERE  a.`logisticsOrderCode` LIKE '%${logisticsOrderCode}%'  AND `mailNo` LIKE '%${mailNo}%'  AND `status` = #{status} ) t")
    Integer countUsable(LogOrderMailDetailIoRequest param);

    @Select("SELECT `uid`, `created`,`status`, `logisticsOrderCode`, `expressCode`, `mailNo`, `action`  FROM `log_order_mail_detail_io` WHERE  `logisticsOrderCode` LIKE '%${logisticsOrderCode}%' AND `mailNo` LIKE '%${mailNo}%'  AND `status` = #{status} ORDER BY uid DESC LIMIT #{offset}, #{size}; ")
    List<LogOrderMailDetailIoListResponse> getListByRequest(LogOrderMailDetailIoRequest param);

}
