package org.ta.pddserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.ta.pdd.entity.PackageDetailEntity;

import java.util.List;

@Mapper
public interface PackageDetailMapper extends BaseMapper<PackageDetailEntity> {

    @Delete("DELETE FROM `package_detail` WHERE `orderCode` = #{orderCode};")
    int removeByOrderCode(@Param("orderCode") String orderCode);
    
    @Select("SELECT * FROM `package_detail` WHERE `orderCode` = #{orderCode};")
    List<PackageDetailEntity> findByOrderCode(@Param("orderCode") String orderCode);

    @Select("SELECT COUNT(*) FROM `package_detail` WHERE `created` > #{date}")
    Long countFromDate(@Param("date") String date);
}
