package com.jwipc.tender.logic.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.page.PageUtil;
import com.jwipc.page.PageView;
import com.jwipc.tender.convert.BidQuotaConvert;
import com.jwipc.tender.dto.BidQuotaDTO;
import com.jwipc.tender.entity.BidQuota;
import com.jwipc.tender.logic.BidQuotaLogic;
import com.jwipc.tender.model.po.BidQuotaPO;
import com.jwipc.tender.model.query.BidQuotaQuery;
import com.jwipc.tender.service.IBidQuotaService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author AL
 * @date 2024/1/31 15:01
 * @desc 模具
 */
@Service
@RequiredArgsConstructor
public class BidQuotaLogicImpl implements BidQuotaLogic {

    private final IBidQuotaService bidQuotaService;
    private final BidQuotaConvert bidQuotaConvert;

    @Override
    public PageView findByPage(BidQuotaQuery query) {
        final Page<BidQuota> dbPage = PageUtil.toPage(query);

        List<BidQuotaPO> bidQuotaPOS = bidQuotaService.findPageByQuery(dbPage, query);

        return PageUtil.getPV(bidQuotaConvert.po2PageListDTO(bidQuotaPOS), dbPage.getTotal());
    }

    //列表主数据
    @Override
    public List<BidQuotaDTO> listAll(BidQuotaQuery query) {
        List<BidQuotaPO> bidQuotaPOS = bidQuotaService.findPageByQuery(null, query);
        return bidQuotaConvert.po2PageListDTO(bidQuotaPOS);
    }

}
