Bladeren bron

更新创建菜单\权限相关对应角色

tags/V1.3.3^2
xiaoying 11 maanden geleden
bovenliggende
commit
b8631b840d
2 gewijzigde bestanden met toevoegingen van 31 en 25 verwijderingen
  1. +15
    -13
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/menu/MenuServiceImpl.java
  2. +16
    -12
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/permissions/OpPermissionsServiceImpl.java

+ 15
- 13
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/menu/MenuServiceImpl.java Bestand weergeven

@@ -4,11 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.tuoheng.admin.entity.Menu;
import com.tuoheng.admin.entity.OpPermissions;
import com.tuoheng.admin.entity.RoleMenu;
import com.tuoheng.admin.entity.Tenant;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.ClientEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.query.MenuQuery;
import com.tuoheng.admin.utils.CurrentUserUtil;
@@ -46,6 +45,8 @@ public class MenuServiceImpl implements IMenuService{

@Autowired
private RoleMenuMapper roleMenuMapper;
@Autowired
private RoleMapper roleMapper;

/**
* 获取菜单列表
@@ -135,15 +136,16 @@ public class MenuServiceImpl implements IMenuService{
if (result<=0) {
return JsonResult.error();
}
// //新增菜单直接讲菜单跟当前用户的租户进行关联
// RoleMenu roleMenu = new RoleMenu();
// String tenantId = CurrentUserUtil.getTenantId();
// Tenant tenant = tenantMapper.selectById(tenantId);
// if (null!=tenant) {
// roleMenu.setRoleId(tenant.getRoleId());
// roleMenu.setMenuId(entity.getId());
// roleMenuMapper.insert(roleMenu);
// }
RoleMenu roleMenu = new RoleMenu();
//新增菜单直接讲菜单跟当前用户的租户进行关联
Role aSuper = roleMapper.selectOne(Wrappers.<Role>lambdaQuery()
.eq(Role::getCode, "super")
.eq(Role::getMark, MarkEnum.VALID.getCode()));
if (null!=aSuper) {
roleMenu.setRoleId(aSuper.getId());
roleMenu.setMenuId(entity.getId());
roleMenuMapper.insert(roleMenu);
}
}
// 隐藏时同时隐藏所有子级
List<Menu> menus = menuMapper.selectList(new LambdaQueryWrapper<Menu>().eq(Menu::getParentId, entity.getId()));

+ 16
- 12
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/permissions/OpPermissionsServiceImpl.java Bestand weergeven

@@ -1,16 +1,12 @@
package com.tuoheng.admin.service.permissions;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.admin.dto.RolePermissionDto;
import com.tuoheng.admin.entity.Menu;
import com.tuoheng.admin.entity.OpPermissions;
import com.tuoheng.admin.entity.OpRolePermission;
import com.tuoheng.admin.entity.RoleMenu;
import com.tuoheng.admin.mapper.MenuMapper;
import com.tuoheng.admin.mapper.OpPermissionsMapper;
import com.tuoheng.admin.mapper.OpRolePermissionMapper;
import com.tuoheng.admin.mapper.RoleMenuMapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.query.RoleClientQuery;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.DateUtils;
@@ -31,7 +27,7 @@ import java.util.stream.Collectors;

@Service
@Slf4j
public class OpPermissionsServiceImpl extends ServiceImpl<OpPermissionsMapper, OpPermissions> implements OpPermissionsService{
public class OpPermissionsServiceImpl extends ServiceImpl<OpPermissionsMapper, OpPermissions> implements OpPermissionsService {

@Autowired
private MenuMapper menuMapper;
@@ -44,6 +40,8 @@ public class OpPermissionsServiceImpl extends ServiceImpl<OpPermissionsMapper, O

@Autowired
private OpRolePermissionMapper opRolePermissionMapper;
@Autowired
private RoleMapper roleMapper;


@Override
@@ -81,9 +79,15 @@ public class OpPermissionsServiceImpl extends ServiceImpl<OpPermissionsMapper, O
opPermissionsMapper.insert(opPermissions);
//添加对应创建权限时的关联关系
OpRolePermission opRolePermission = new OpRolePermission();
opRolePermission.setRoleId(CurrentUserUtil.getUserInfo().getRoleId());
opRolePermission.setPermissionId(opPermissions.getId());
opRolePermissionMapper.insert(opRolePermission);
//新增菜单直接讲菜单跟当前用户的租户进行关联
Role aSuper = roleMapper.selectOne(Wrappers.<Role>lambdaQuery()
.eq(Role::getCode, "super")
.eq(Role::getMark, MarkEnum.VALID.getCode()));
if (null != aSuper) {
opRolePermission.setRoleId(aSuper.getId());
opRolePermission.setPermissionId(opPermissions.getId());
opRolePermissionMapper.insert(opRolePermission);
}
} else {
opPermissions.setUpdateUser(CurrentUserUtil.getUserId());
opPermissions.setUpdateTime(DateUtils.now());

Laden…
Annuleren
Opslaan