package cn.palmte.work.model;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ProjectInstanceRelationRepository extends JpaRepository<ProjectInstanceRelation,Integer> {

    @Query(value = "select * from project_instance_relation where project_id = ? and project_type=0 order by create_time desc", nativeQuery = true)
    List<ProjectInstanceRelation> findByProjectIdOrderByCreateTimeDesc(int projectId);

    @Query(value = "select * from project_instance_relation where project_id = ? and project_type=? order by create_time desc limit 1", nativeQuery = true)
    ProjectInstanceRelation findByProjectIdAndProjectType(int projectId, int projectType);
}
