Search in sources :

Example 1 with RoleMenuRel

use of com.zy.usercenteradmin.entity.RoleMenuRel in project usercenteradmin by caijiya.

the class RoleServiceImpl method grantMenus.

@Override
@Transactional(rollbackFor = Exception.class)
public void grantMenus(GrantMenuDTO grantMenuDTO) {
    roleMenuRelService.remove(new LambdaQueryWrapper<RoleMenuRel>().eq(RoleMenuRel::getRoleId, grantMenuDTO.getRoleId()));
    roleMenuRelService.saveBatch(grantMenuDTO.getMenuIds().stream().map(menuId -> {
        RoleMenuRel roleMenuRel = new RoleMenuRel();
        roleMenuRel.setRoleId(roleMenuRel.getRoleId());
        roleMenuRel.setMenuId(menuId);
        return roleMenuRel;
    }).collect(Collectors.toList()));
}
Also used : RoleMenuRel(com.zy.usercenteradmin.entity.RoleMenuRel) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 RoleMenuRel (com.zy.usercenteradmin.entity.RoleMenuRel)1 Transactional (org.springframework.transaction.annotation.Transactional)1