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.CollectOutMailDetailIoEntity;
import org.ta.pddserver.entity.LogOrderMailDetailIoEntity;
import org.ta.pddserver.model.api.request.CollectOutMailDetailIoRequest;
import org.ta.pddserver.model.api.request.LogOrderMailDetailIoRequest;
import org.ta.pddserver.model.api.response.CollectOutMailDetailIoListResponse;
import org.ta.pddserver.model.api.response.LogOrderMailDetailIoListResponse;

import java.util.List;

@Mapper
public interface CollectOutMailDetailIoMapper extends BaseMapper<CollectOutMailDetailIoEntity> {

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

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

}
