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.LogOrderPackageEntity;
import org.ta.pddserver.model.api.request.LogOrderPackageListRequest;
import org.ta.pddserver.model.api.response.CollectMailDetailListResponse;

import java.util.List;

@Mapper
public interface LogOrderPackageMapper extends BaseMapper<LogOrderPackageEntity> {




    @Select("SELECT count(*) FROM `log_order_package` WHERE `logisticsOrderCode` LIKE '%${logisticsOrderCode}%' AND `packageType` LIKE '%${packageType}%';")
    Integer countUsable(LogOrderPackageListRequest logOrderPackageListRequest);

    @Select("SELECT `uid`, `logisticsOrderCode`, `packageType`, `length`, `width`, `height`, `weight`, `created` FROM `log_order_package` WHERE `logisticsOrderCode` LIKE '%${logisticsOrderCode}%' AND `packageType` LIKE '%${packageType}%' ORDER BY uid DESC LIMIT #{offset}, #{size}; ")
    List<CollectMailDetailListResponse> getListByRequest(LogOrderPackageListRequest logOrderPackageListRequest);

    @Select("SELECT * FROM `log_order_package` WHERE `logisticsOrderCode` = #{logisticsOrderCode}")
    LogOrderPackageEntity getInfoByCode(@Param("logisticsOrderCode") String logisticsOrderCode);
}
