use of com.ibeiliao.deployment.admin.common.RestResult in project Corgi by kevinYin.
the class EditRoleController method updateRole.
/**
* 增加或修改角色信息
* @param role JSON格式数据, {roleId:角色ID, rolename:角色名称, remarks:备注}
* @param menuIds JSON格式数据,菜单ID列表 []
* @param resIds JSON格式数据,资源ID列表 []
* @param appIds JSON格式数据,APP ID 列表 []
* @return result.success=true表示成功
*/
@MenuResource("增加/修改角色信息")
@RequestMapping(value = "updateRole.do", method = RequestMethod.POST)
@AdminLog
@ResponseBody
public RestResult<Object> updateRole(String role, String menuIds, String resIds, String appIds) {
logger.info("admin#role#updateRole | 新增/修改角色 | role: " + role + ", menuIds: " + menuIds + ", resIds: " + resIds + ", appIds: " + appIds);
ParameterUtil.assertNotBlank(role, "role不能为空");
ParameterUtil.assertNotBlank(menuIds, "menuIds不能为空");
ParameterUtil.assertNotBlank(resIds, "resIds不能为空");
Map<String, Object> myRole = JsonUtil.parseObject(role, new TypeReference<HashMap<String, Object>>() {
});
List<Integer> menuIdList = JsonUtil.parseObject(menuIds, new TypeReference<List<Integer>>() {
});
List<Integer> appIdList = JsonUtil.parseObject(appIds, new TypeReference<List<Integer>>() {
});
List<Integer> resIdList = JsonUtil.parseObject(resIds, new TypeReference<List<Integer>>() {
});
logger.info("admin#role#updateRole | 新增/修改角色 | role: {}, menuIdList: {}, appIdList: {} ", JsonUtil.toJSONString(myRole), JsonUtil.toJSONString(menuIdList), JsonUtil.toJSONString(appIdList));
Role theRole = validateRole(myRole, menuIdList, appIdList);
roleService.authRole(theRole, ListUtils.toSet(appIdList), ListUtils.toSet(menuIdList), ListUtils.toSet(resIdList));
return new RestResult<>(ApiCode.SUCCESS, "操作成功.");
}
use of com.ibeiliao.deployment.admin.common.RestResult in project Corgi by kevinYin.
the class CreateDeploymentController method enoughServerRes.
/**
* 判断服务器资源是否足够
* @param order
* @return ApiCode.SUCCESS=足够
* @author linyi 2017/5/11
*/
private RestResult<Object> enoughServerRes(DeploymentOrder order) {
List<DeployHistory> histories = deployHistoryService.queryDeployHistory(order.getEnvId(), order.getModuleId(), 1, 10);
// 静态项目不做判断
ProjectModule module = projectModuleService.getByModuleId(order.getModuleId());
if (module.getModuleType() == ModuleType.STATIC.getValue()) {
return new RestResult<>(ApiCode.SUCCESS, "");
}
/* if (CollectionUtils.isEmpty(histories)) {
logger.info("第一次发布");
String jvmArgs = getJvmArgs(order.getModuleId(), order.getEnvId());
for (int serverId : order.getServerId()) {
Server server = serverService.getById(serverId);
if (server == null || StringUtils.isBlank(server.getIp())) {
return new RestResult<>(ApiCode.FAILURE, "serverId或IP不存在, serverId: " + serverId);
}
RestResult<Object> result = AliyunEcsUtil.isEnoughResByIp(server.getIp(), jvmArgs);
if (!result.isSuccess()) {
return result;
}
}
}*/
return new RestResult<>(ApiCode.SUCCESS, "");
}
use of com.ibeiliao.deployment.admin.common.RestResult in project Corgi by kevinYin.
the class CreateDeploymentController method listRepository.
@RequestMapping("listRepository")
@MenuResource("查询分支列表")
@ResponseBody
public RestResult<List<Map<String, Object>>> listRepository(int moduleId) {
ProjectModule module = projectModuleService.getByModuleId(moduleId);
List<Map<String, Object>> tags = new ArrayList<>();
if (module != null) {
if (module.getRepoType() == ModuleRepoType.SVN.getValue()) {
String tagsPath = (module.getRepoUrl() + RepositoryConstants.TAGS).replaceAll("/" + RepositoryConstants.TAGS, RepositoryConstants.TAGS);
tags.addAll(fetchSvnTags(tagsPath, module));
String branchesPath = (module.getRepoUrl() + RepositoryConstants.BRANCHES).replaceAll("/" + RepositoryConstants.BRANCHES, RepositoryConstants.BRANCHES);
tags.addAll(fetchSvnTags(branchesPath, module));
} else if (module.getRepoType() == ModuleRepoType.GIT.getValue()) {
tags.addAll(fetchGitBranches(module.getRepoUrl(), module));
} else {
logger.warn("不支持类型 {}, moduleId: {}", module.getRepoType(), moduleId);
}
} else {
logger.error("module=null, moduleId: " + moduleId);
}
return new RestResult<>(tags);
}
use of com.ibeiliao.deployment.admin.common.RestResult in project Corgi by kevinYin.
the class CreateDeploymentController method queryModuleServer.
/**
* 查询模块在某个环境的服务器列表
*
* @param moduleId 模块ID
* @param envId 环境ID,必定大于0
* @return
*/
@RequestMapping("queryModuleServer")
@ResponseBody
@MenuResource("查询模块服务器列表")
public RestResult<Map<String, Object>> queryModuleServer(int moduleId, int envId) {
Assert.isTrue(moduleId > 0);
Assert.isTrue(envId > 0);
List<ServerGroup> groups = serverGroupService.getByModuleAndEnv(moduleId, envId);
List<Integer> groupIds = new ArrayList<>(groups.size());
for (ServerGroup group : groups) {
groupIds.add(group.getGroupId());
}
List<Server> servers = serverService.getByGroupIds(groupIds);
Map<String, Object> result = new HashMap<>(4);
result.put("servers", servers);
result.put("groups", groups);
return new RestResult<>(result);
}
use of com.ibeiliao.deployment.admin.common.RestResult in project Corgi by kevinYin.
the class MenuController method updateMenu.
/**
* 重新生成系统菜单
*
* @return
*/
@ResponseBody
@RequestMapping("updateMenu.do")
public RestResult<Object> updateMenu(HttpServletRequest request) {
int appId = getAppId(request);
logger.info("将更新菜单, appId=" + appId);
RestResult<Object> result = null;
if (appId > 0) {
String[] scanPath = getScanPath(appId);
try {
MenuItem root = SearchResource.scanMenuTree(scanPath);
menuService.updateMenu(appId, root);
logger.info("更新菜单成功,菜单: " + JsonUtil.toJSONString(root));
result = new RestResult<>(ApiCode.SUCCESS, "成功");
} catch (Exception e) {
logger.error("重新生成系统菜单错误, appId=" + appId, e);
result = new RestResult<>(ApiCode.FAILURE, e.getMessage());
}
} else {
result = new RestResult<>(ApiCode.FAILURE, "appId为空");
}
return result;
}
Aggregations