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);
}
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();
}
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;
}
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);
}
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);
}
Aggregations