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.ta.pdd.entity.PickRecordEntity;
import org.ta.pddserver.model.api.request.PackageNoticeRequest;

import java.util.List;

@Mapper
public interface PickRecordMapper extends BaseMapper<PickRecordEntity> {

    @Select("SELECT * FROM `pick_record` WHERE `orderCode` = #{orderCode} OR #{orderCode} = '' ORDER BY uid DESC LIMIT #{offset}, #{size};")
    List<PickRecordEntity> getListByRequest(PackageNoticeRequest param);

    @Select("SELECT COUNT(*) FROM `pick_record` WHERE `orderCode` = #{orderCode} OR #{orderCode} = '' ;")
    Integer countUsable(PackageNoticeRequest param);

    @Select("SELECT * FROM `pick_record` WHERE `orderCode` = #{orderCode};")
    PickRecordEntity findByOrderCode(@Param("orderCode") String orderCode);
}
