Search in sources :

Example 1 with ProjectModulePO

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

the class ModuleJvmServiceImplTest method test.

@Test
public void test() {
    ProjectModulePO projectModulePO = projectModuleDao.get(14);
    projectModulePO.setModuleNameZh("测试");
    projectModuleDao.update(projectModulePO);
}
Also used : ProjectModulePO(com.ibeiliao.deployment.admin.po.project.ProjectModulePO) Test(org.junit.Test)

Example 2 with ProjectModulePO

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

the class ProjectModuleServiceImpl method getProjectModuleByAccountId.

@Override
public List<ProjectModule> getProjectModuleByAccountId(long accountId) {
    Assert.isTrue(accountId > 0);
    List<ProjectAccountRelationPO> relationPOS = projectAccountRelationDao.getByAccountId(accountId);
    if (CollectionUtils.isEmpty(relationPOS)) {
        return Collections.emptyList();
    }
    ArrayList<Integer> projectIds = Lists.newArrayList();
    for (ProjectAccountRelationPO relationPO : relationPOS) {
        projectIds.add(relationPO.getProjectId());
    }
    List<ProjectModulePO> modulePOS = projectModuleDao.getByProjectIds(projectIds);
    if (CollectionUtils.isEmpty(modulePOS)) {
        return Collections.emptyList();
    }
    return rebuildModuleName(projectIds, modulePOS);
}
Also used : ProjectModulePO(com.ibeiliao.deployment.admin.po.project.ProjectModulePO) ProjectAccountRelationPO(com.ibeiliao.deployment.admin.po.project.ProjectAccountRelationPO)

Example 3 with ProjectModulePO

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

the class ProjectModuleServiceImpl method saveProjectModule.

@Override
@Transactional
public void saveProjectModule(long accountId, ProjectModule projectModule) {
    validateModule(projectModule);
    ProjectModulePO projectModulePO = VOUtil.from(projectModule, ProjectModulePO.class);
    encodeAccountAndPassword(projectModulePO);
    initEmptyValue(projectModulePO);
    if (projectModule.getModuleId() > 0) {
        ProjectModulePO current = projectModuleDao.get(projectModule.getModuleId());
        Assert.notNull(current, "模块不存在");
        // if (projectAccountRelationService.canModify(accountId, projectModule.getProjectId())) {
        projectModuleDao.update(projectModulePO);
    // } else {
    // logger.error("没有权限修改模块 | moduleId: {}, accountId: {}", projectModule.getModuleId(), accountId);
    // throw new IllegalStateException("你没有权限修改此模块,请联系项目管理员或超级管理员");
    // }
    } else {
        projectModulePO.setCreateTime(new Date());
        projectModuleDao.insert(projectModulePO);
        projectModule.setModuleId(projectModulePO.getModuleId());
    }
    saveServerGroupAndServer(projectModule.getServerGroups(), projectModule.getModuleId());
    saveModuleJvms(projectModule, projectModule.getModuleId());
    saveResinConf(projectModule);
    logger.info("修改/新增模块完成 | moduleId: {}, accountId: {}", projectModule.getModuleId(), accountId);
}
Also used : ProjectModulePO(com.ibeiliao.deployment.admin.po.project.ProjectModulePO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with ProjectModulePO

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

the class ProjectModuleServiceImpl method getSimpleInfoByProjectIds.

@Override
public List<ProjectModule> getSimpleInfoByProjectIds(List<Integer> projectIds) {
    List<ProjectModulePO> modulePOS = projectModuleDao.getByProjectIds(projectIds);
    if (CollectionUtils.isEmpty(modulePOS)) {
        return Collections.emptyList();
    }
    List<ProjectModule> modules = Lists.newArrayList();
    for (ProjectModulePO modulePO : modulePOS) {
        ProjectModule module = new ProjectModule();
        module.setModuleId(modulePO.getModuleId());
        module.setProjectId(modulePO.getProjectId());
        module.setModuleName(modulePO.getModuleName());
        module.setModuleNameZh(modulePO.getModuleNameZh());
        modules.add(module);
    }
    return modules;
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) ProjectModulePO(com.ibeiliao.deployment.admin.po.project.ProjectModulePO)

Example 5 with ProjectModulePO

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

the class ProjectModuleServiceImpl method buildOccupyInfoMap.

private Map<String, String> buildOccupyInfoMap(ProjectModule projectModule, List<Server> allServers) {
    List<ModuleConfPO> matchModuleConfList = getModuleConf(projectModule);
    if (CollectionUtils.isEmpty(matchModuleConfList)) {
        return Collections.emptyMap();
    }
    List<Integer> moduleIds = Lists.newArrayList();
    for (ModuleConfPO po : matchModuleConfList) {
        if (projectModule.getModuleId() > 0 && po.getModuleId() == projectModule.getModuleId()) {
            continue;
        }
        moduleIds.add(po.getModuleId());
    }
    List<ServerGroup> serverGroupList = serverGroupService.getByModuleIds(moduleIds, true);
    if (CollectionUtils.isEmpty(serverGroupList)) {
        return Collections.emptyMap();
    }
    List<ProjectModulePO> modulePOs = projectModuleDao.getByModuleIds(moduleIds);
    HashMap<Integer, ProjectModulePO> moduleId2ModuleMap = Maps.newHashMap();
    for (ProjectModulePO modulePO : modulePOs) {
        moduleId2ModuleMap.put(modulePO.getModuleId(), modulePO);
    }
    HashMap<Integer, ModuleConfPO> moduleId2ConfMap = Maps.newHashMap();
    for (ModuleConfPO confPO : matchModuleConfList) {
        moduleId2ConfMap.put(confPO.getModuleId(), confPO);
    }
    Set<String> moduleServerIps = Sets.newHashSet();
    for (Server server : allServers) {
        moduleServerIps.add(server.getIp());
    }
    HashMap<String, String> port2OccupyInfoMap = Maps.newHashMap();
    // 找到有相同的服务器,再看看是哪个端口有冲突
    for (ServerGroup group : serverGroupList) {
        List<Server> servers = group.getServers();
        if (CollectionUtils.isEmpty(servers)) {
            continue;
        }
        for (Server server : servers) {
            if (moduleServerIps.contains(server.getIp()) && moduleId2ModuleMap.get(group.getModuleId()) != null && moduleId2ConfMap.get(group.getModuleId()) != null) {
                ProjectModulePO modulePO = moduleId2ModuleMap.get(group.getModuleId());
                ModuleConfPO confPO = moduleId2ConfMap.get(group.getModuleId());
                ResinConf resinConf = projectModule.getResinConf();
                String occupyInfo = " 已被项目id为 " + modulePO.getProjectId() + " 的" + modulePO.getModuleNameZh() + " 模块所占用,相关服务器IP为 " + server.getIp();
                if (confPO.getConfValue().contains("\"httpPort\":" + resinConf.getHttpPort())) {
                    port2OccupyInfoMap.put("http端口" + resinConf.getHttpPort(), occupyInfo);
                }
                if (confPO.getConfValue().contains("\"serverPort\":" + resinConf.getServerPort())) {
                    port2OccupyInfoMap.put("服务器端口" + resinConf.getServerPort(), occupyInfo);
                }
                if (confPO.getConfValue().contains("\"watchdogPort\":" + resinConf.getWatchdogPort())) {
                    port2OccupyInfoMap.put("watchdog端口" + resinConf.getWatchdogPort(), occupyInfo);
                }
            }
        }
    }
    return port2OccupyInfoMap;
}
Also used : ResinConf(com.ibeiliao.deployment.transfer.vo.ResinConf) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server) ModuleConfPO(com.ibeiliao.deployment.admin.po.project.ModuleConfPO) ProjectModulePO(com.ibeiliao.deployment.admin.po.project.ProjectModulePO)

Aggregations

ProjectModulePO (com.ibeiliao.deployment.admin.po.project.ProjectModulePO)6 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)2 ModuleConfPO (com.ibeiliao.deployment.admin.po.project.ModuleConfPO)1 ProjectAccountRelationPO (com.ibeiliao.deployment.admin.po.project.ProjectAccountRelationPO)1 ModuleJvm (com.ibeiliao.deployment.admin.vo.project.ModuleJvm)1 Server (com.ibeiliao.deployment.admin.vo.server.Server)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1 ResinConf (com.ibeiliao.deployment.transfer.vo.ResinConf)1 Test (org.junit.Test)1 Transactional (org.springframework.transaction.annotation.Transactional)1