package com.qqchen.deploy.backend.deploy.repository;

import com.qqchen.deploy.backend.framework.repository.IBaseRepository;
import com.qqchen.deploy.backend.deploy.entity.RepositoryProject;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface IRepositoryProjectRepository extends IBaseRepository<RepositoryProject, Long> {

    /**
     * 根据外部系统ID和仓库组ID查找项目列表
     *
     * @param externalSystemId 外部系统ID
     * @param groupId          仓库组ID
     * @return 项目列表
     */
    List<RepositoryProject> findByExternalSystemIdAndRepoGroupId(Long externalSystemId, Long groupId);

    /**
     * 统计指定外部系统下的项目数量
     *
     * @param externalSystemId 外部系统ID
     * @return 项目数量
     */
    Long countByExternalSystemId(Long externalSystemId);

    List<RepositoryProject> findByExternalSystemId(Long externalSystemId);

    void deleteByExternalSystemId(Long externalSystemId);

    List<RepositoryProject> findByExternalSystemIdAndDeletedFalse(Long externalSystemId);

    Optional<RepositoryProject> findByRepoProjectId(Long repoProjectId);
}