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.GDTicketEntity;
import org.ta.pddserver.model.api.request.TicketListRequest;

import java.util.List;

@Mapper
public interface GDTicketMapper extends BaseMapper<GDTicketEntity> {

    @Select("SELECT * FROM `gd_ticket` WHERE `ticket_id` = #{ticketId};")
    GDTicketEntity findByTicketId(Long ticketId);

    @Select("SELECT COUNT(*) FROM `gd_ticket`")
    Integer countUsable(TicketListRequest param);

    @Select("SELECT `uid`, `title`, `ticket_id`, `waybill_no`, `description`, `create_at`, `update_at` FROM `gd_ticket` ORDER BY `update_at` DESC LIMIT #{offset}, #{size} ")
    List<GDTicketEntity> getListByRequest(TicketListRequest param);
}
