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

import com.qqchen.deploy.backend.deploy.entity.RepositorySyncHistory;
import com.qqchen.deploy.backend.deploy.enums.ExternalSystemSyncStatus;
import com.qqchen.deploy.backend.deploy.enums.RepositorySyncType;
import com.qqchen.deploy.backend.framework.repository.IBaseRepository;
import org.springframework.stereotype.Repository;

/**
 * Git同步历史记录 Repository
 */
@Repository
public interface IRepositorySyncHistoryRepository extends IBaseRepository<RepositorySyncHistory, Long> {

    /**
     * 查询最后一次同步记录
     *
     * @param externalSystemId 外部系统ID
     * @param syncType 同步类型
     * @param status 同步状态
     * @return 同步历史记录
     */
    RepositorySyncHistory findTopByExternalSystemIdAndSyncTypeAndStatusOrderByStartTimeDesc(
        Long externalSystemId,
        RepositorySyncType syncType,
        ExternalSystemSyncStatus status
    );
}