Search in sources :

Example 1 with Menu

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;
}
Also used : ObjectMap(com.plumdo.common.model.ObjectMap) ArrayList(java.util.ArrayList) Menu(com.plumdo.identity.domain.Menu)

Example 2 with Menu

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);
}
Also used : Menu(com.plumdo.identity.domain.Menu) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 3 with 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;
}
Also used : ObjectMap(com.plumdo.common.model.ObjectMap) ArrayList(java.util.ArrayList) Menu(com.plumdo.identity.domain.Menu)

Example 4 with Menu

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);
}
Also used : Menu(com.plumdo.identity.domain.Menu) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Aggregations

Menu (com.plumdo.identity.domain.Menu)4 ObjectMap (com.plumdo.common.model.ObjectMap)2 ArrayList (java.util.ArrayList)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)2 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1 PutMapping (org.springframework.web.bind.annotation.PutMapping)1