package com.eactive.eai.rms.onl.apim.approval.apprequest;

import com.eactive.apim.portal.apprequest.entity.AppRequest;
import com.eactive.apim.portal.apprequest.entity.AppRequestType;
import com.eactive.apim.portal.apprequest.entity.QAppRequest;
import com.eactive.apim.portal.apprequest.repository.AppRequestRepository;
import com.eactive.eai.rms.data.jpa.AbstractEMSDataSerivce;
import com.querydsl.core.BooleanBuilder;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class PortalAppRequestService extends AbstractEMSDataSerivce<AppRequest, String, AppRequestRepository> {

    public Page<AppRequest> findAllProd(Pageable pageable, AppRequestUISearch uiSearch) {
        QAppRequest qAppRequest = QAppRequest.appRequest;

        BooleanBuilder predicate = new BooleanBuilder();
        predicate.and(qAppRequest.type.eq(AppRequestType.PROD_NEW));

        return repository.findAll(predicate, pageable);
    }

}
