|
|
@@ -7,22 +7,25 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.tuoheng.admin.dto.MenuVo; |
|
|
|
import com.tuoheng.admin.dto.OpPermissionsVo; |
|
|
|
import com.tuoheng.admin.dto.RoleMenuPermissionDto; |
|
|
|
import com.tuoheng.admin.dto.UserRoleDto; |
|
|
|
import com.tuoheng.admin.entity.OpRolePermission; |
|
|
|
import com.tuoheng.admin.entity.Role; |
|
|
|
import com.tuoheng.admin.entity.RoleMenu; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.entity.*; |
|
|
|
import com.tuoheng.admin.enums.RoleEnum; |
|
|
|
import com.tuoheng.admin.enums.code.role.RoleDeleteEnum; |
|
|
|
import com.tuoheng.admin.mapper.*; |
|
|
|
import com.tuoheng.admin.query.RoleClientQuery; |
|
|
|
import com.tuoheng.admin.query.RoleQuery; |
|
|
|
import com.tuoheng.admin.service.menu.IMenuService; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.vo.RoleListVo; |
|
|
|
import com.tuoheng.common.core.common.BaseEntity; |
|
|
|
import com.tuoheng.common.core.common.BaseServiceImpl; |
|
|
|
import com.tuoheng.common.core.utils.DateUtils; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
@@ -49,6 +52,15 @@ public class RoleServiceImpl implements IRoleService { |
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IMenuService menuService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MenuMapper menuMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private OpPermissionsMapper opPermissionsMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@@ -193,8 +205,64 @@ public class RoleServiceImpl implements IRoleService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public JsonResult getMenuList(RoleClientQuery query) { |
|
|
|
RoleMenuPermissionDto dto = new RoleMenuPermissionDto(); |
|
|
|
Integer roleId = query.getRoleId(); |
|
|
|
List<Menu> menuList = menuMapper.selectList(Wrappers.<Menu>lambdaQuery() |
|
|
|
.eq(Menu::getMark, 1) |
|
|
|
.eq(Menu::getStatus, 1) |
|
|
|
.eq(StringUtils.isNotEmpty(query.getClientId()), Menu::getClientId, query.getClientId()) |
|
|
|
.orderByAsc(Menu::getSort)); |
|
|
|
if(!menuList.isEmpty()){ |
|
|
|
// 获取角色菜单列表 |
|
|
|
QueryWrapper<RoleMenu> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("role_id", roleId); |
|
|
|
queryWrapper.select("menu_id"); |
|
|
|
List<RoleMenu> roleMenus = roleMenuMapper.selectList(queryWrapper); |
|
|
|
List<Integer> menuIds = roleMenus.stream().map(p -> p.getMenuId()).collect(Collectors.toList()); |
|
|
|
menuList.forEach(item->{ |
|
|
|
if (menuIds.contains(item.getId())) { |
|
|
|
item.setChecked(true); |
|
|
|
item.setOpen(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
List<MenuVo> collect = menuList.stream().map(t -> { |
|
|
|
MenuVo vo = new MenuVo(); |
|
|
|
BeanUtils.copyProperties(t, vo); |
|
|
|
vo.setIdentificationId(t.getId().toString()); |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
dto.setOpMenusList(collect); |
|
|
|
//根基小程序或者pc标识 |
|
|
|
List<OpPermissions> permissions = opPermissionsMapper.selectList(Wrappers.<OpPermissions>lambdaQuery() |
|
|
|
.eq(OpPermissions::getMark, 1) |
|
|
|
.eq(StringUtils.isNotEmpty(query.getClientId()), OpPermissions::getClientId, query.getClientId())); |
|
|
|
if(!permissions.isEmpty()){ |
|
|
|
//获取角色菜单列表 |
|
|
|
QueryWrapper<OpRolePermission> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("role_id", roleId); |
|
|
|
queryWrapper.select("permission_id"); |
|
|
|
List<OpRolePermission> roleMenuList = opRolePermissionMapper.selectList(queryWrapper); |
|
|
|
List<Integer> permissionIds = roleMenuList.stream().map(p -> p.getPermissionId()).collect(Collectors.toList()); |
|
|
|
permissions.forEach(item -> { |
|
|
|
if (permissionIds.contains(item.getId())) { |
|
|
|
item.setChecked(true); |
|
|
|
item.setOpen(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
List<OpPermissionsVo> collect1 = permissions.stream().map(t -> { |
|
|
|
OpPermissionsVo vo = new OpPermissionsVo(); |
|
|
|
BeanUtils.copyProperties(t, vo); |
|
|
|
//用"_"进行区分 |
|
|
|
vo.setIdentificationId(t.getMenuId() + "_" + t.getId()); |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
dto.setPermissionsList(collect1); |
|
|
|
dto.setRoleId(roleId); |
|
|
|
|
|
|
|
return null; |
|
|
|
return JsonResult.success(dto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |