package org.ta.pddserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.ta.pddserver.entity.LogOrderEntity;
import org.ta.pddserver.entity.LogOrderIoEntity;
import org.ta.pddserver.model.api.request.LogOrderIoRequest;
import org.ta.pddserver.model.api.request.LogOrderListRequest;
import org.ta.pddserver.model.api.response.LogOrderIoListResponse;
import org.ta.pddserver.model.api.response.LogOrderListResponse;

import java.util.List;

@Mapper
public interface LogOrderIoMapper extends BaseMapper<LogOrderIoEntity> {

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

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

}
