package org.ta.pddserver.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.ta.pdd.entity.PackageNoticeEntity;
import org.ta.pddserver.mapper.PackageNoticeMapper;
import org.ta.pddserver.model.api.request.PackageNoticeRequest;
import org.ta.pddserver.model.api.response.PackageNoticeResponse;
import org.ta.pddserver.service.PackageNoticeService;

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

@Service
public class PackageNoticeImpl extends ServiceImpl<PackageNoticeMapper, PackageNoticeEntity> implements PackageNoticeService {


    public Map<String, Object> getList(PackageNoticeRequest param) {

        Integer count = baseMapper.countUsable(param);
        param.checkPage(count,20);
        List<PackageNoticeResponse> 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;
    }

    public PackageNoticeEntity getByOrderCode(String orderCode) {
        return baseMapper.getByOrderCode(orderCode);
    }
}