Search in sources :

Example 1 with Project

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);
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount)

Example 2 with Project

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;
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectAccountRelation(com.ibeiliao.deployment.admin.vo.project.ProjectAccountRelation)

Example 3 with Project

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;
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) AdminLoginUser(com.ibeiliao.deployment.admin.context.AdminLoginUser) DeployHistoryService(com.ibeiliao.deployment.admin.service.deploy.DeployHistoryService) ProjectAccountRelationService(com.ibeiliao.deployment.admin.service.project.ProjectAccountRelationService)

Example 4 with Project

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());
    }
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv)

Example 5 with Project

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

Aggregations

Project (com.ibeiliao.deployment.admin.vo.project.Project)8 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)3 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)2 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)2 ProjectAccountRelation (com.ibeiliao.deployment.admin.vo.project.ProjectAccountRelation)2 AdminLoginUser (com.ibeiliao.deployment.admin.context.AdminLoginUser)1 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)1 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)1 DeployHistoryService (com.ibeiliao.deployment.admin.service.deploy.DeployHistoryService)1 ProjectAccountRelationService (com.ibeiliao.deployment.admin.service.project.ProjectAccountRelationService)1 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1