use of com.plumdo.identity.domain.Menu in project plumdo-work by wengwh.
the class RoleConverter method convertDetail.
public static ObjectMap convertDetail(Role role, List<Menu> allMenus, List<Menu> roleMenus) {
ObjectMap detailMap = new ObjectMap();
detailMap.put("id", role.getId());
detailMap.put("name", role.getName());
detailMap.put("remark", role.getRemark());
detailMap.put("tenantId", role.getTenantId());
List<ObjectMap> menuList = new ArrayList<>();
for (Menu menu : allMenus) {
if (menu.getType() == TableConstant.MENU_TYPE_CHILD) {
continue;
}
menuList.add(ObjectMap.of("id", menu.getId(), "name", menu.getName(), "group", true));
for (Menu childMenu : allMenus) {
if (menu.getId().equals(childMenu.getParentId())) {
ObjectMap menuMap = ObjectMap.of("id", childMenu.getId(), "name", childMenu.getName());
if (roleMenus.contains(childMenu)) {
menuMap.put("selected", true);
} else {
menuMap.put("selected", false);
}
menuList.add(menuMap);
}
}
menuList.add(ObjectMap.of("group", false));
}
detailMap.put("menus", menuList);
return detailMap;
}
use of com.plumdo.identity.domain.Menu in project plumdo-work by wengwh.
the class MenuResource method deleteMenu.
@DeleteMapping(value = "/menus/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteMenu(@PathVariable Integer id) {
Menu menu = getMenuFromRequest(id);
menuRepository.delete(menu);
}
use of com.plumdo.identity.domain.Menu in project plumdo-work by wengwh.
the class MenuConverter method convertSelectedTree.
public static List<ObjectMap> convertSelectedTree(List<Menu> menus, List<Menu> roleMenus) {
List<ObjectMap> menuList = new ArrayList<>();
for (Menu menu : menus) {
if (menu.getType() == TableConstant.MENU_TYPE_CHILD) {
continue;
}
menuList.add(ObjectMap.of("id", menu.getId(), "name", menu.getName(), "group", true));
for (Menu childMenu : menus) {
if (menu.getId().equals(childMenu.getParentId())) {
if (ObjectUtils.isNotEmpty(roleMenus) && roleMenus.contains(childMenu)) {
menuList.add(ObjectMap.of("id", childMenu.getId(), "name", childMenu.getName(), "selected", true));
} else {
menuList.add(ObjectMap.of("id", childMenu.getId(), "name", childMenu.getName(), "selected", false));
}
}
}
menuList.add(ObjectMap.of("group", false));
}
return menuList;
}
use of com.plumdo.identity.domain.Menu in project plumdo-work by wengwh.
the class MenuResource method updateMenu.
@PutMapping(value = "/menus/{id}")
@ResponseStatus(value = HttpStatus.OK)
public Menu updateMenu(@PathVariable Integer id, @RequestBody Menu menuRequest) {
Menu menu = getMenuFromRequest(id);
menu.setName(menuRequest.getName());
menu.setCode(menuRequest.getCode());
menu.setIcon(menuRequest.getIcon());
menu.setOrder(menuRequest.getOrder());
menu.setParentId(menuRequest.getParentId());
menu.setType(menuRequest.getType());
menu.setUrl(menuRequest.getUrl());
menu.setRemark(menuRequest.getRemark());
menu.setTenantId(menuRequest.getTenantId());
return menuRepository.save(menu);
}
Aggregations