package com.jwipc.sys.logic.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.page.PageUtil;
import com.jwipc.page.PageView;
import com.jwipc.sys.convert.DigitalSealConfigConvert;
import com.jwipc.sys.dto.DigitalSealConfigDTO;
import com.jwipc.sys.entity.DigitalSealConfig;
import com.jwipc.sys.entity.PurchaseOrg;
import com.jwipc.sys.logic.DigitalSealConfigLogic;
import com.jwipc.sys.model.po.PurchaseOrgPO;
import com.jwipc.sys.model.query.DigitalSealConfigQuery;
import com.jwipc.sys.service.IDigitalSealConfigService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenyang.ou
 * @date 2024/6/19 11:09
 * @desc
 */
@Service
@RequiredArgsConstructor
public class DigitalSealConfigLogicImpl implements DigitalSealConfigLogic {
    private final IDigitalSealConfigService digitalSealConfigService;
    private final DigitalSealConfigConvert digitalSealConfigConvert;

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

        List<DigitalSealConfig> digitalSealConfigs = digitalSealConfigService.findPageByQuery(dbPage, query);

        return PageUtil.getPV(digitalSealConfigConvert.entity2PageListDTO(digitalSealConfigs), dbPage.getTotal());
    }

    @Override
    public List<DigitalSealConfigDTO> listAll(DigitalSealConfigQuery query) {
        List<DigitalSealConfig> digitalSealConfigs = digitalSealConfigService.findPageByQuery(null, query);
        return digitalSealConfigConvert.entity2PageListDTO(digitalSealConfigs);
    }
}
