package cn.reghao.bnt.web.devops.app.db.repository.config;

import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
import cn.reghao.bnt.web.devops.build.model.po.CompilerConfig;
import cn.reghao.bnt.web.devops.build.model.po.PackerConfig;
import cn.reghao.bnt.web.devops.build.model.po.RepoAuthConfig;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 *
 * @author reghao
 * @date 2020-01-21 14:53:03
 */
public interface AppConfigRepository extends JpaRepository<AppConfig, Integer>, JpaSpecificationExecutor<AppConfig> {
    void deleteByAppId(String appId);

    AppConfig findByAppId(String appId);
    AppConfig findByDeletedFalseAndAppId(String appId);
    List<AppConfig> findByAppRepoAndRepoBranch(String repo, String branch);
    Page<AppConfig> findByEnv(String env, Pageable pageable);
    Page<AppConfig> findByEnvAndAppType(String env, String type, Pageable pageable);

    List<AppConfig> findAllByRepoAuthConfig(RepoAuthConfig repoAuthConfig);
    List<AppConfig> findAllByCompilerConfig(CompilerConfig compilerConfig);
    List<AppConfig> findAllByPackerConfig(PackerConfig packerConfig);
}
