use of com.ibeiliao.deployment.admin.utils.resource.MenuResource 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.utils.resource.MenuResource in project Corgi by kevinYin.
the class EditRoleController method listAllAppMenu.
/**
* 读取所有APP的菜单,及角色的菜单权限
* @param roleId 角色ID
* @return
*/
@MenuResource("读取角色菜单")
@RequestMapping("allAppMenus")
@ResponseBody
public Map<String, Object> listAllAppMenu(int roleId) {
Map<String, Object> map = new HashMap<>(4);
List<AppDefine> apps = appService.listAll();
List<MenuItem> appMenus = new ArrayList<>(apps.size());
for (AppDefine app : apps) {
appMenus.add(menuService.getMenuTree(app.getAppId()));
}
map.put("success", Boolean.TRUE);
map.put("appList", apps);
map.put("appMenus", appMenus);
if (roleId > 0) {
List<RoleMenuRelation> menuIds = roleService.listRoleMenus(roleId);
map.put("menuIds", menuIds);
Role role = roleService.getById(roleId);
map.put("role", role);
List<RoleResRelation> resList = roleService.listRoleResources(roleId);
map.put("resIds", resList);
}
return map;
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuResource in project Corgi by kevinYin.
the class ListAccountController method lockOrUnlockAccount.
/**
* 冻结解冻管理员帐号,调用一次接口,做一次反操作。
* 比如当前是正常状态,操作一次后变成冻结,再操作一次变成解冻
* @param uid 管理员ID
* @return result.success=true为成功, result.object=新的状态
*/
@RequestMapping(value = "lockOrUnlockAccount.do", method = RequestMethod.POST)
@MenuResource("冻结/解冻管理员")
@ResponseBody
@AdminLog
public RestResult<Integer> lockOrUnlockAccount(long uid) {
AdminAccount account = adminAccountService.getById(uid);
RestResult<Integer> result = null;
if (account == null) {
result = new RestResult<>(ApiCode.FAILURE, "帐号不存在,uid=" + uid);
} else {
String message = null;
int newStatus = 0;
if (account.getAccountStatus() == AdminAccount.LOCKED) {
adminAccountService.unlockAccount(uid);
message = "解冻帐号成功.";
newStatus = AdminAccount.NOMAL;
logger.info("admin#account#lockOrUnlockAccount | 解冻帐号成功 | uid: " + uid);
} else {
adminAccountService.lockAccount(uid);
newStatus = AdminAccount.LOCKED;
message = "冻结帐号成功.";
}
result = new RestResult<>(ApiCode.SUCCESS, message, newStatus);
logger.info("admin#account#lockOrUnlockAccount | 冻结帐号成功 | uid: " + uid);
}
return result;
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuResource in project Corgi by kevinYin.
the class ListAccountController method listAccount.
/**
* 读取管理员列表
* @param keyword 搜索的关键字
* @param page 第几页
* @param pageSize 每页多少
* @return result.object=数据列表,数据列表不为null
*/
@RequestMapping("queryAccount")
@MenuResource("读取管理员列表")
@ResponseBody
public PageResult<List<AdminAccount>> listAccount(String keyword, int page, int pageSize, HttpServletRequest request) {
List<AdminAccount> list = adminAccountService.listAccounts(keyword, page, pageSize);
int total = adminAccountService.statAccount(keyword);
for (AdminAccount account : list) {
StringBuilder buf = new StringBuilder();
List<AccountRoleRelation> tmpList = adminAccountService.listAccountRoles(account.getUid());
for (AccountRoleRelation arr : tmpList) {
Role role = roleService.getById(arr.getRoleId());
if (role != null) {
if (buf.length() > 0)
buf.append(",");
buf.append(role.getRoleName());
}
}
account.setRoleName(buf.toString());
}
PageResult<List<AdminAccount>> result = new PageResult<>(list);
result.setCurrentPage(page);
result.setPageSize(pageSize);
result.setCount(total);
return result;
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuResource 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);
}
Aggregations