package org.ta.pddserver.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.ta.pddserver.entity.GDTicketEntity;
import org.ta.pddserver.mapper.GDTicketMapper;
import org.ta.pddserver.model.api.request.TicketListRequest;
import org.ta.pddserver.model.api.response.LogOrderListResponse;
import org.ta.pddserver.model.api.response.TicketListResponse;
import org.ta.pddserver.service.GDTicketService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class GDTicketImpl extends ServiceImpl<GDTicketMapper, GDTicketEntity> implements GDTicketService {


    public GDTicketEntity getByTicketId(Long ticketId) {
        return this.baseMapper.findByTicketId(ticketId);
    }

    public Map<String, Object> getListByRequest(TicketListRequest param) {
        Integer count = baseMapper.countUsable(param);
        param.checkPage(count,20);
        List<GDTicketEntity> list = baseMapper.getListByRequest(param);
        Map<String, Object> map = new HashMap<>();
        map.put("total", count);
        map.put("list", list);
        map.put("page", param.getPage());
        return map;
    }
}