Search in sources :

Example 1 with SysRoleMenu

use of com.xhuicloud.upms.entity.SysRoleMenu in project XHuiCloud by sindaZeng.

the class SysRoleMenuServiceImpl method saveRoleMenus.

@Override
@Transactional(rollbackFor = Exception.class)
public Boolean saveRoleMenus(Integer roleId, String menuIds) {
    this.remove(Wrappers.<SysRoleMenu>query().lambda().eq(SysRoleMenu::getRoleId, roleId));
    if (StringUtils.isEmpty(menuIds)) {
        return Boolean.TRUE;
    }
    List<SysRoleMenu> roleMenuList = Arrays.stream(menuIds.split(",")).map(menuId -> {
        SysRoleMenu roleMenu = new SysRoleMenu();
        roleMenu.setRoleId(roleId);
        roleMenu.setMenuId(Integer.valueOf(menuId));
        return roleMenu;
    }).collect(Collectors.toList());
    return saveBatch(roleMenuList);
}
Also used : ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) SysRoleMenu(com.xhuicloud.upms.entity.SysRoleMenu) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) Arrays(java.util.Arrays) List(java.util.List) SysRoleMenuService(com.xhuicloud.upms.service.SysRoleMenuService) Service(org.springframework.stereotype.Service) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) SysRoleMenuMapper(com.xhuicloud.upms.mapper.SysRoleMenuMapper) Transactional(org.springframework.transaction.annotation.Transactional) SysRoleMenu(com.xhuicloud.upms.entity.SysRoleMenu) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)1 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)1 SysRoleMenu (com.xhuicloud.upms.entity.SysRoleMenu)1 SysRoleMenuMapper (com.xhuicloud.upms.mapper.SysRoleMenuMapper)1 SysRoleMenuService (com.xhuicloud.upms.service.SysRoleMenuService)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Service (org.springframework.stereotype.Service)1 Transactional (org.springframework.transaction.annotation.Transactional)1