Search in sources :

Example 1 with DeployHistoryPO

use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.

the class DeployHistoryDaoTest method testUpdateStatus.

@Test
public void testUpdateStatus() {
    DeployHistoryPO po = createDeployHistoryPO();
    deployHistoryDao.insert(po);
    assertTrue(po.getHistoryId() > 0);
    DeployHistoryPO tmp = deployHistoryDao.get(po.getHistoryId());
    assertEq(po, tmp);
    short newStatus = DeployStatus.DEPLOYED.getValue();
    int rows = deployHistoryDao.updateStatus(po.getHistoryId(), newStatus, po.getDeployStatus());
    assertTrue(rows > 0);
    tmp = deployHistoryDao.get(po.getHistoryId());
    assertTrue(tmp.getDeployStatus() == newStatus);
}
Also used : DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) Test(org.junit.Test)

Example 2 with DeployHistoryPO

use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method getProjectByServerDeployIds.

@Override
public List<Project> getProjectByServerDeployIds(List<Integer> serverDeployIdList) {
    if (!CollectionUtils.isEmpty(serverDeployIdList)) {
        Set<Integer> projectIdSet = new HashSet<>();
        for (Integer serverDeployId : serverDeployIdList) {
            ServerDeployHistoryPO po = serverDeployHistoryDao.get(serverDeployId);
            if (po != null) {
                DeployHistoryPO historyPO = deployHistoryDao.get(po.getHistoryId());
                projectIdSet.add(historyPO.getProjectId());
            }
        }
        if (!CollectionUtils.isEmpty(projectIdSet)) {
            List<Project> projects = new ArrayList<>();
            for (Integer id : projectIdSet) {
                Project project = projectService.getProject(id);
                projects.add(project);
            }
            return projects;
        }
    }
    return Collections.emptyList();
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)

Example 3 with DeployHistoryPO

use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method getByHistoryId.

@Override
public DeployHistory getByHistoryId(int historyId) {
    DeployHistoryPO po = deployHistoryDao.get(historyId);
    if (po == null) {
        return null;
    }
    List<ServerDeployHistoryPO> servers = serverDeployHistoryDao.getByHistoryId(historyId);
    DeployHistory history = new DeployHistory();
    VOUtil.copy(po, history);
    List<ServerDeployHistory> deployHistoryList = VOUtil.fromList(servers, ServerDeployHistory.class);
    fillLogIntoServerDeploy(deployHistoryList);
    history.setServerDeployHistories(deployHistoryList);
    fillNames(history);
    return history;
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Example 4 with DeployHistoryPO

use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method cancel.

@Override
public void cancel(long accountId, int historyId) {
    DeployHistoryPO po = deployHistoryDao.get(historyId);
    if (po == null) {
        throw new IllegalArgumentException("发布记录不存在,historyId=" + historyId);
    }
    if (accountId != po.getAccountId()) {
        throw new IllegalArgumentException("你没有权限取消发布");
    }
    if (po.getDeployStatus() != DeployStatus.WAITING_FOR_AUDIT.getValue() && po.getDeployStatus() != DeployStatus.WAITING_FOR_DEPLOYMENT.getValue()) {
        throw new IllegalStateException("项目状态已改变,请先刷新页面");
    }
    int rows = deployHistoryDao.auditDeploy(historyId, DeployStatus.CANCELLED.getValue(), po.getDeployStatus(), accountId, new Date());
    logger.info("取消发布记录成功 | accountId: {}, historyId: {}, rows: {}", accountId, historyId, rows);
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)

Example 5 with DeployHistoryPO

use of com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method startDeploy.

@Override
public void startDeploy(int historyId, long accountId) {
    DeployHistoryPO historyPO = deployHistoryDao.get(historyId);
    Assert.notNull(historyPO, "没有找到该发布记录");
    // 1. 判断状态
    if (historyPO.getDeployStatus() != DeployStatus.WAITING_FOR_DEPLOYMENT.getValue()) {
        throw new IllegalStateException("发布记录状态错误,请刷新界面");
    }
    // 2. 判断权限
    if (historyPO.getAccountId() != accountId) {
        throw new IllegalArgumentException("只有创建者可以发布这个上线单");
    }
    // 3. 进行发布
    if (moduleStatusManagementService.isModuleDeploying(historyPO.getModuleId(), historyPO.getEnvId())) {
        throw new IllegalStateException("该模块正在发布中,请等待上一次发布完成");
    }
    threadPoolTaskExecutor.execute(new DeployTask(historyPO));
    logger.info("开始发布 .... historyId: " + historyId);
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)

Aggregations

DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)13 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)10 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)2 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)2 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)2 Server (com.ibeiliao.deployment.admin.vo.server.Server)2 Test (org.junit.Test)2 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 Project (com.ibeiliao.deployment.admin.vo.project.Project)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1