use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.
the class CreateDeploymentController method listRepository.
@RequestMapping("listRepository")
@MenuResource("查询分支列表")
@ResponseBody
public RestResult<List<Map<String, Object>>> listRepository(int moduleId) {
ProjectModule module = projectModuleService.getByModuleId(moduleId);
List<Map<String, Object>> tags = new ArrayList<>();
if (module != null) {
if (module.getRepoType() == ModuleRepoType.SVN.getValue()) {
String tagsPath = (module.getRepoUrl() + RepositoryConstants.TAGS).replaceAll("/" + RepositoryConstants.TAGS, RepositoryConstants.TAGS);
tags.addAll(fetchSvnTags(tagsPath, module));
String branchesPath = (module.getRepoUrl() + RepositoryConstants.BRANCHES).replaceAll("/" + RepositoryConstants.BRANCHES, RepositoryConstants.BRANCHES);
tags.addAll(fetchSvnTags(branchesPath, module));
} else if (module.getRepoType() == ModuleRepoType.GIT.getValue()) {
tags.addAll(fetchGitBranches(module.getRepoUrl(), module));
} else {
logger.warn("不支持类型 {}, moduleId: {}", module.getRepoType(), moduleId);
}
} else {
logger.error("module=null, moduleId: " + moduleId);
}
return new RestResult<>(tags);
}
use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.
the class ProjectServiceImpl method fillModuleInfo.
private void fillModuleInfo(List<Project> projects) {
List<Integer> projectIds = Lists.newArrayList();
for (Project project : projects) {
projectIds.add(project.getProjectId());
}
List<ProjectModule> projectModules = projectModuleService.getSimpleInfoByProjectIds(projectIds);
if (CollectionUtils.isEmpty(projectModules)) {
return;
}
ListMultimap<Integer, ProjectModule> projectId2ModulesMap = ArrayListMultimap.create();
for (ProjectModule module : projectModules) {
projectId2ModulesMap.put(module.getProjectId(), module);
}
for (Project project : projects) {
project.setProjectModules(projectId2ModulesMap.get(project.getProjectId()));
}
}
use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method checkIfDeployingModuleWithEnv.
private void checkIfDeployingModuleWithEnv(DeploymentOrder order) {
// 如果 module 正在 env 发布,不能再创建发布
if (moduleStatusManagementService.isModuleDeploying(order.getModuleId(), order.getEnvId())) {
ProjectModule module = projectModuleService.getByModuleId(order.getModuleId());
ProjectEnv env = projectEnvService.getById(order.getEnvId());
throw new IllegalStateException("模块 [" + module.getModuleName() + "] 正在 [" + env.getEnvName() + "] 环境发布,必须等待当前的发布结束才可以发布");
}
}
use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method createAndSaveRestart.
private DeployHistoryPO createAndSaveRestart(long accountId, String title, int serverId) {
Server server = serverService.getById(serverId);
AdminAccount account = adminAccountService.getById(accountId);
Assert.notNull(server, "服务器不存在");
Assert.notNull(account, "管理员不存在");
ServerGroup serverGroup = serverGroupService.getById(server.getGroupId());
ProjectModule module = projectModuleService.getByModuleId(serverGroup.getModuleId());
DeployHistoryPO po = new DeployHistoryPO();
po.setTagName("");
po.setAccountId(accountId);
po.setAuditorId(0);
po.setTitle(title);
po.setCreateTime(new Date());
po.setDeployStatus(DeployStatus.WAITING_FOR_DEPLOYMENT.getValue());
po.setAuditTime(po.getCreateTime());
po.setDeployServers(1);
po.setProjectId(module.getProjectId());
po.setModuleId(module.getModuleId());
po.setModuleName(module.getModuleName());
po.setVersionNo("");
po.setIsRestart(Constants.TRUE);
po.setEnvId(serverGroup.getEnvId());
po.setRealName(account.getRealname());
deployHistoryDao.insert(po);
ServerDeployHistoryPO serverDeployHistoryPO = new ServerDeployHistoryPO();
serverDeployHistoryPO.setHistoryId(po.getHistoryId());
serverDeployHistoryPO.setServerId(serverId);
serverDeployHistoryPO.setServerName(server.getServerName());
serverDeployHistoryPO.setServerIp(server.getIp());
serverDeployHistoryPO.setDeployStatus(ServerDeployResult.WAITING_FOR_DEPLOYMENT.getValue());
serverDeployHistoryDao.insert(serverDeployHistoryPO);
return deployHistoryDao.get(po.getHistoryId());
}
use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.
the class CreateDeploymentController method index.
/**
* 创建上线单主页,xhtml 仅用于展示页面,ajax 调用 .do 接口获取参数
*
* @return
*/
@MenuResource("创建上线单主页")
@RequestMapping("create.xhtml")
public String index(HttpServletRequest request) {
// 读取用户可以访问的项目
long accountId = AdminContext.getAccountId();
List<Project> projects = projectService.queryAdminProjects(accountId, null, 0L, null, 1, MAX_DISPLAY_PROJECTS);
List<ProjectModule> modules = new LinkedList<>();
List<ProjectModule> projectModules = null;
// 读取每个项目的module
for (Project project : projects) {
List<ProjectModule> tmpModules = projectModuleService.getByProjectId(project.getProjectId());
modules.addAll(tmpModules);
}
request.setAttribute("projects", projects);
request.setAttribute("allModules", JSON.toJSON(modules));
int moduleId = 0;
int projectId = 0;
if (request.getParameter("moduleId") != null) {
moduleId = NumberUtils.toInt(request.getParameter("moduleId"), 0);
if (moduleId > 0) {
ProjectModule module = projectModuleService.getByModuleId(moduleId);
if (module != null) {
projectId = module.getProjectId();
}
}
logger.info("输入参数 moduleId: " + moduleId + ", projectId: " + projectId);
}
if (projectId <= 0 && projects.size() > 0) {
projectId = projects.get(0).getProjectId();
projectModules = projectModuleService.getByProjectId(projectId);
} else if (projectId > 0) {
projectModules = projectModuleService.getByProjectId(projectId);
} else {
projectModules = Collections.emptyList();
}
String repoUrl = "";
if (moduleId <= 0 && projectModules.size() > 0) {
moduleId = projectModules.get(0).getModuleId();
repoUrl = projectModules.get(0).getRepoUrl();
} else {
for (ProjectModule pm : projectModules) {
if (pm.getModuleId() == moduleId) {
repoUrl = pm.getRepoUrl();
break;
}
}
}
// 指定发布的module
request.setAttribute("moduleId", moduleId);
request.setAttribute("projectId", projectId);
request.setAttribute("projectModules", projectModules);
request.setAttribute("repoUrl", repoUrl);
request.setAttribute("envList", projectEnvService.findAllEnv());
return ("/deploy/create_deployment");
}
Aggregations