package cn.reghao.bnt.web.devops.app.db.query;

import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
import cn.reghao.bnt.web.devops.app.model.po.log.BuildLog;
import cn.reghao.bnt.web.devops.app.model.vo.AppBuildingVO;
import cn.reghao.bnt.web.devops.app.model.vo.AppConfigVO;
import cn.reghao.bnt.web.devops.app.model.vo.BuildLogVO;
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 java.util.List;
import java.util.Map;

/**
 * @author reghao
 * @date 2021-06-02 15:01:18
 */
public interface AppBuildQuery {
    Page<AppConfigVO> getByEnvAndType(String env, String type, Pageable pageable);
    Page<AppConfig> queryByFields(Map<String, String> kv, Pageable pageable);
    AppConfig getByRepoAndBranch(String repo, String branch);
    AppConfig getAppConfig(String appId);

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

    Page<AppBuildingVO> getByPage(String appEnv, String appType, Pageable pageable);
    Page<BuildLogVO> buildLogVOs(String appId, Pageable pageable);
    boolean isBuilding(String appId);
    BuildLog getBuildLog(String buildLogId);
    String getBuildResult(String buildLogId);
}
