package com.viettel.campaign.repository.ccms_full;

import com.viettel.campaign.model.ccms_full.ApParam;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ApParamRepository extends JpaRepository<ApParam, Long>, ApParamRepositoryCustom {

    Page<ApParam> findAll(Pageable pageable);

    @Query(value = "SELECT p FROM ApParam p WHERE parName LIKE concat('%', :parName, '%') ")
    List<ApParam> findParamByName(@Param("parName") String parName, Pageable pageable);

    @Query(value = "SELECT p FROM ApParam p WHERE status = 1 AND parType LIKE concat('%', :parType, '%') ")
    List<ApParam> findParamByParType(@Param("parType") String parType);

    @Query(value = "select a from  ApParam a WHERE status = 1 AND parType = 'CAMPAIGN_TYPE'")
    List<ApParam> findAllParam();
}
