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