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

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);

}
