package com.cirle.scientific.dao;

import java.util.List;

import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.cirle.scientific.po.QkjCatalogsDetail;


@Repository
public interface QkjCatalogsDetailDao extends PagingAndSortingRepository<QkjCatalogsDetail, Long>, JpaSpecificationExecutor<QkjCatalogsDetail> {

    @Query(value = "SELECT obj_id FROM qkj_catalogs_detail  WHERE obj_type=?1 AND catalogs_id=?2 ", nativeQuery = true)
    List<Integer> findByObjTypeAndCatalogsId(Integer objType, Integer catalogsId);

    @Query(value = "SELECT catalogs_id FROM qkj_catalogs_detail  WHERE obj_type=?1 AND obj_id=?2 ", nativeQuery = true)
    List<Integer> findByObjTypeAndobjId(Integer objType, Integer objId);

    @Query(value = "SELECT * FROM qkj_catalogs_detail  WHERE obj_type=?1 ", nativeQuery = true)
    List<QkjCatalogsDetail> findByObjType(Integer objType);

    @Query(value = "select * from  qkj_catalogs_detail where obj_type = :type  and  obj_id = :objId",nativeQuery = true)
    List<QkjCatalogsDetail> findObjectByObjTypeAndObjId(@Param("type") Integer type, @Param("objId")Long objId);

}
