Search in sources :

Example 1 with RoleMenuDto

use of com.albedo.java.modules.sys.domain.dto.RoleMenuDto in project albedo by somowhere.

the class RoleMenuServiceImpl method saveRoleMenus.

/**
 * @param roleMenuDto 角色菜单
 */
@Override
@Transactional(rollbackFor = Exception.class)
public Result saveRoleMenus(RoleMenuDto roleMenuDto) {
    this.remove(Wrappers.<RoleMenuDo>query().lambda().eq(RoleMenuDo::getRoleId, roleMenuDto.getRoleId()));
    List<RoleMenuDo> roleMenuDoList = roleMenuDto.getMenuIdList().stream().map(menuId -> {
        RoleMenuDo roleMenuDo = new RoleMenuDo();
        roleMenuDo.setRoleId(roleMenuDto.getRoleId());
        roleMenuDo.setMenuId(menuId);
        return roleMenuDo;
    }).collect(Collectors.toList());
    this.saveBatch(roleMenuDoList);
    SysCacheUtil.delRoleCaches(roleMenuDto.getRoleId());
    return Result.buildOk("操作成功");
}
Also used : Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) Result(com.albedo.java.common.core.util.Result) RoleMenuDo(com.albedo.java.modules.sys.domain.RoleMenuDo) BaseServiceImpl(com.albedo.java.plugins.database.mybatis.service.impl.BaseServiceImpl) Collectors(java.util.stream.Collectors) RoleMenuService(com.albedo.java.modules.sys.service.RoleMenuService) SysCacheUtil(com.albedo.java.modules.sys.util.SysCacheUtil) List(java.util.List) Service(org.springframework.stereotype.Service) RoleMenuRepository(com.albedo.java.modules.sys.repository.RoleMenuRepository) RoleMenuDto(com.albedo.java.modules.sys.domain.dto.RoleMenuDto) AllArgsConstructor(lombok.AllArgsConstructor) Transactional(org.springframework.transaction.annotation.Transactional) RoleMenuDo(com.albedo.java.modules.sys.domain.RoleMenuDo) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Result (com.albedo.java.common.core.util.Result)1 RoleMenuDo (com.albedo.java.modules.sys.domain.RoleMenuDo)1 RoleMenuDto (com.albedo.java.modules.sys.domain.dto.RoleMenuDto)1 RoleMenuRepository (com.albedo.java.modules.sys.repository.RoleMenuRepository)1 RoleMenuService (com.albedo.java.modules.sys.service.RoleMenuService)1 SysCacheUtil (com.albedo.java.modules.sys.util.SysCacheUtil)1 BaseServiceImpl (com.albedo.java.plugins.database.mybatis.service.impl.BaseServiceImpl)1 Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 AllArgsConstructor (lombok.AllArgsConstructor)1 Service (org.springframework.stereotype.Service)1 Transactional (org.springframework.transaction.annotation.Transactional)1