Search in sources :

Example 1 with RoleMenu

use of com.plumdo.identity.domain.RoleMenu in project plumdo-work by wengwh.

the class RoleResource method saveRoleAndMenu.

private Role saveRoleAndMenu(Role role, ObjectMap roleRequest) {
    if (role == null) {
        role = new Role();
    }
    role.setName(roleRequest.getAsString("name"));
    role.setRemark(roleRequest.getAsString("remark"));
    role.setTenantId(roleRequest.getAsString("tenantId"));
    roleRepository.save(role);
    roleMenuRepository.deleteByRoleId(role.getId());
    List<ObjectMap> menus = roleRequest.getAsList("roleMenus");
    for (ObjectMap menu : menus) {
        RoleMenu roleMenu = new RoleMenu();
        roleMenu.setMenuId(menu.getAsInteger("id"));
        roleMenu.setRoleId(role.getId());
        roleMenuRepository.save(roleMenu);
    }
    return role;
}
Also used : Role(com.plumdo.identity.domain.Role) ObjectMap(com.plumdo.common.model.ObjectMap) RoleMenu(com.plumdo.identity.domain.RoleMenu)

Aggregations

ObjectMap (com.plumdo.common.model.ObjectMap)1 Role (com.plumdo.identity.domain.Role)1 RoleMenu (com.plumdo.identity.domain.RoleMenu)1