package com.eactive.eai.rms.data.entity.onl.inflow;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.eactive.eai.data.entity.onl.inflow.InflowControlLog;
import com.eactive.eai.data.entity.onl.inflow.InflowControlLogId;
import com.eactive.eai.data.entity.onl.inflow.QInflowControlLog;
import com.eactive.eai.data.jpa.AbstractDataService;
import com.eactive.eai.rms.onl.manage.inflow.history.InflowControlHistoryManUISearch;
import com.querydsl.core.BooleanBuilder;

@Service
public class InflowControlLogService
		extends AbstractDataService<InflowControlLog, InflowControlLogId, InflowControlLogRepository> {

	public Page<InflowControlLog> findAll(Pageable pageable, InflowControlHistoryManUISearch uiSearch) {
		QInflowControlLog qInflowConfrolLog = QInflowControlLog.inflowControlLog;
		BooleanBuilder booleanBuilder = new BooleanBuilder();
		booleanBuilder
				.and(qInflowConfrolLog.id.msgdpstyms
						.between(uiSearch.getSearchStartDate() + "000000000",
								uiSearch.getSearchEndDate() + "235959999"));
		return super.repository.findAll(booleanBuilder, pageable);
	}

	public Iterable<InflowControlLog> findAll(InflowControlHistoryManUISearch uiSearch) {
		QInflowControlLog qInflowConfrolLog = QInflowControlLog.inflowControlLog;
		BooleanBuilder booleanBuilder = new BooleanBuilder();
		booleanBuilder
				.and(qInflowConfrolLog.id.msgdpstyms
						.between(uiSearch.getSearchStartDate() + "000000000",
								uiSearch.getSearchEndDate() + "235959999"));
		return super.repository.findAll(booleanBuilder);
	}
}
