use of com.ibeiliao.deployment.admin.vo.project.Project in project Corgi by kevinYin.
the class InitTestDataService method init.
/**
* 创建初始化数据
*/
public InitData init() {
// 1. 创建 account
// 2. 创建 project
// 3. 创建 module
// 4. 初始化 env
// 5. 创建 server group & server
List<ProjectEnv> envs = createProjectEnv();
AdminAccount account = createAdminAccount();
Project project = createProject(account);
ProjectModule module = createModule(account.getUid(), project, envs);
return new InitData(account, project, module, envs);
}
use of com.ibeiliao.deployment.admin.vo.project.Project in project Corgi by kevinYin.
the class InitTestDataService method createProject.
private Project createProject(AdminAccount account) {
Project project = new Project();
project.setJoinerNames(account.getRealname());
project.setProjectName("测试项目");
project.setManagerId((int) account.getUid());
project.setProgramLanguage("java");
project.setManagerEmail(account.getAccount());
project.setManagerPhone(account.getMobileNo());
project.setProjectNo("test_project");
project.setManagerName(account.getRealname());
ProjectAccountRelation relation = new ProjectAccountRelation();
relation.setAccountId(account.getUid());
relation.setIsAdmin(Constants.TRUE);
// relation.setProjectId(newProject.getProjectId());
relation.setRealName(account.getRealname());
List<ProjectAccountRelation> relations = new ArrayList<>();
relations.add(relation);
project.setProjectAccountRelations(relations);
Project newProject = projectService.saveProject(account.getUid(), project);
Assert.notNull(projectService.getProject(newProject.getProjectId()));
List<ProjectAccountRelation> tmpList = projectAccountRelationService.getByProjectId(newProject.getProjectId());
Assert.notEmpty(tmpList);
Assert.isTrue(tmpList.size() == 1);
return newProject;
}
use of com.ibeiliao.deployment.admin.vo.project.Project in project Corgi by kevinYin.
the class LogMessageProcessor method hasPermission.
private boolean hasPermission(WebSocketSession webSocketSession, ShellLogRequestMessage message) {
List<Integer> ids = message.getServerDeployIdList();
if (CollectionUtils.isEmpty(ids)) {
return false;
}
DeployHistoryService deployHistoryService = SpringContextUtil.getBean(DeployHistoryService.class);
List<Project> projects = deployHistoryService.getProjectByServerDeployIds(ids);
if (CollectionUtils.isEmpty(projects)) {
logger.error("要读取的数据不属于任何project");
}
if (projects.size() != 1) {
logger.error("不能同时读取多个项目的日志, size: " + projects.size());
}
logger.info("读取log, ids=" + JSON.toJSONString(ids));
AdminLoginUser adminLoginUser = UserIdentitySessionHolder.getInstance().getSessionValue(webSocketSession);
if (adminLoginUser == null) {
logger.error("找不到登录用户的信息, session: " + webSocketSession.getId());
return false;
}
long accountId = adminLoginUser.getAccountId();
ProjectAccountRelationService projectAccountRelationService = SpringContextUtil.getBean(ProjectAccountRelationService.class);
for (Project p : projects) {
if (!projectAccountRelationService.hasRelation(accountId, p.getProjectId())) {
logger.error("用户:{} 没有项目:{} 的权限", accountId, p.getProjectId());
// return false;
}
}
return true;
}
use of com.ibeiliao.deployment.admin.vo.project.Project in project Corgi by kevinYin.
the class DeployHistoryServiceImpl method fillNames.
private void fillNames(DeployHistory history) {
ProjectEnv env = projectEnvService.getById(history.getEnvId());
if (env != null) {
history.setEnvName(env.getEnvName());
}
Project project = projectService.getProject(history.getProjectId());
if (project != null) {
history.setProjectName(project.getProjectName());
}
}
use of com.ibeiliao.deployment.admin.vo.project.Project 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();
}
Aggregations