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

import com.eactive.eai.data.entity.onl.authoutbound.OutboundOAuthCredential;
import com.eactive.eai.data.entity.onl.authoutbound.QOutboundOAuthCredential;
import com.eactive.eai.data.entity.onl.messagekey.QMessageKey;
import com.eactive.eai.data.jpa.AbstractDataService;
import com.querydsl.core.BooleanBuilder;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class OutboundOAuthCredentialService extends AbstractDataService<OutboundOAuthCredential, String, OutboundOAuthCredentialRepository> {
    public Page<OutboundOAuthCredential>findAll(Pageable pageable, String searchAdapterGroupName) {
        QOutboundOAuthCredential qOutboundOAuthCredential = QOutboundOAuthCredential.outboundOAuthCredential;

        BooleanBuilder predicate = new BooleanBuilder();

        if (StringUtils.isNotBlank(searchAdapterGroupName)) {
            predicate.and(qOutboundOAuthCredential.adapterGroupName.containsIgnoreCase(searchAdapterGroupName));
        }

        return repository.findAll(predicate, pageable);
    }
}
