package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;

import cn.estsh.i3plus.ext.mes.api.base.IModuleFileImportLotService;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesModuleFileImportLot;
import cn.estsh.i3plus.ext.mes.pojo.repository.MesModuleFileImportLotRepository;
import cn.estsh.i3plus.ext.mes.pojo.sqlpack.MesExtHqlPack;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wangjie
 * @version 1.0
 * @date 2021/1/13 9:28
 **/
@Slf4j
@Service
public class ModuleFileImportLotService implements IModuleFileImportLotService {

    @Autowired
    private MesModuleFileImportLotRepository moduleFileImportLotRepository;

    @Override
    public ListPager<MesModuleFileImportLot> queryModuleFileImportLotByPager(MesModuleFileImportLot moduleFileImportLot, Pager pager) {
        DdlPackBean hqlPack = MesExtHqlPack.getModuleFileImportLot(moduleFileImportLot);
        pager = PagerHelper.getPager(pager, moduleFileImportLotRepository.findByHqlWhereCount(hqlPack));
        hqlPack.setOrderByStr(" order by createDatetime desc ");
        return new ListPager(moduleFileImportLotRepository.findByHqlWherePage(hqlPack, pager), pager);
    }
}
