package com.cirle.scientific.dao;

import com.cirle.scientific.po.QkjStudyRecordApp;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface QkjStudyRecordAppDao extends PagingAndSortingRepository<QkjStudyRecordApp, Long>,
        JpaSpecificationExecutor<QkjStudyRecordApp> {


    @Query(value = "SELECT * FROM qkj_study_record_app WHERE mem_card = ?1 and obj_type = ?2 and obj_id = ?3", nativeQuery = true)
    QkjStudyRecordApp findByMemCardAndTypeAndId(String memCard, Integer objType, Long objId);

    @Query(value = "SELECT * FROM qkj_study_record_app WHERE mem_card = ?1 and obj_type = ?2", nativeQuery = true)
    List<QkjStudyRecordApp> findByMemCardAndType(String memCard, Integer objType);

    @Query(value = "SELECT * FROM qkj_study_record_app WHERE mem_card = ?1 and obj_type = ?2 and study_accomplish = ?3", nativeQuery = true)
    List<QkjStudyRecordApp> findByMemCardAndTypeAndStudyAccomplish(String memCard, Integer objType, Integer studyAccomplish);

    @Query(value = "SELECT * FROM qkj_study_record_app WHERE mem_card = ?1 and obj_type = ?2 and obj_id = ?3", nativeQuery = true)
    QkjStudyRecordApp findByMemCardAndTypeAndObjId(String memCard, Integer objType, Long objId);

    @Query(value = "SELECT * FROM qkj_study_record_app WHERE mem_card = ?1 and  obj_id in ?2 and obj_type = ?3", nativeQuery = true)
    List<QkjStudyRecordApp> findByMemCardAndObjIdsAndType(String memCard , List<Long> ids, Integer objType);


}
