package com.jwipc.order.logic.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.constant.DictCode;
import com.jwipc.order.entity.SapGoodReceipt;
import com.jwipc.order.logic.GoodReceiptLogic;
import com.jwipc.order.model.query.SapGoodReceiptQuery;
import com.jwipc.order.service.ISapGoodReceiptService;
import com.jwipc.page.PageUtil;
import com.jwipc.page.PageView;
import com.jwipc.sys.client.dto.DictDTO;
import com.jwipc.sys.client.dto.PurchaseGroupDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static com.baomidou.dynamic.datasource.support.DdConstants.SLAVE;

/**
 * @Author: swq
 * @Date: 2024/4/8 11:29
 */
@Service
@RequiredArgsConstructor
@DS(SLAVE)
public class GoodReceiptLogicImpl implements GoodReceiptLogic {
    private final ISapGoodReceiptService sapGoodReceiptService;

    @Override
    public PageView goodReceiptList(SapGoodReceiptQuery query){
        Page<SapGoodReceipt> page = PageUtil.toPage(query);
        List<SapGoodReceipt> list = sapGoodReceiptService.findForPage(page, query);
        return PageUtil.getPV(list, page.getTotal());
    }

    @Override
    public List<SapGoodReceipt> listAll(SapGoodReceiptQuery query) {
        List<SapGoodReceipt> list = sapGoodReceiptService.findForPage(null, query);
        return list;
    }

}
