接口调试

This commit is contained in:
xiang
2026-03-22 00:31:27 +08:00
parent 81dd7ee546
commit a89b71fe80
13 changed files with 140 additions and 82 deletions

View File

@@ -107,7 +107,7 @@ public interface ISysDeptService {
*
* @param deptId 部门id
*/
void checkDeptDataScope(Long deptId, String token);
void checkDeptDataScope(Long deptId, Long userId);
/**
* 新增保存部门信息

View File

@@ -95,7 +95,7 @@ public interface ISysRoleService {
*
* @param roleIds 角色id
*/
void checkRoleDataScope(String token, Long... roleIds);
void checkRoleDataScope(Long userId, Long... roleIds);
/**
* 通过角色ID查询角色使用数量
@@ -158,7 +158,7 @@ public interface ISysRoleService {
*
* @return 结果
*/
int deleteRoleByIds(String token, Long[] roleIds);
int deleteRoleByIds(Long userId, Long[] roleIds);
/**
* 取消授权用户角色

View File

@@ -1,6 +1,5 @@
package com.xiang.xs.service.biz.impl;
import com.xiang.xs.api.client.TokenApi;
import com.xiang.xs.service.biz.ISysDeptService;
import com.xiang.xs.service.contants.UserConstants;
import com.xiang.xs.service.entity.SysDept;
@@ -35,9 +34,6 @@ public class SysDeptServiceImpl implements ISysDeptService {
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private TokenApi tokenApi;
/**
* 查询部门管理数据
*
@@ -186,8 +182,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
* @param deptId 部门id
*/
@Override
public void checkDeptDataScope(Long deptId, String token) {
if (!SysUser.isAdmin(tokenApi.getUserId(token)) && Objects.nonNull(deptId)) {
public void checkDeptDataScope(Long deptId, Long userId) {
if (!SysUser.isAdmin(userId) && Objects.nonNull(deptId)) {
SysDept dept = new SysDept();
dept.setDeptId(deptId);
List<SysDept> depts = selectDeptList(dept);

View File

@@ -1,6 +1,5 @@
package com.xiang.xs.service.biz.impl;
import com.xiang.xs.api.client.TokenApi;
import com.xiang.xs.service.biz.ISysRoleService;
import com.xiang.xs.service.contants.UserConstants;
import com.xiang.xs.service.entity.SysRole;
@@ -12,7 +11,6 @@ import com.xiang.xs.service.repository.mapper.SysRoleDeptMapper;
import com.xiang.xs.service.repository.mapper.SysRoleMapper;
import com.xiang.xs.service.repository.mapper.SysRoleMenuMapper;
import com.xiang.xs.service.repository.mapper.SysUserRoleMapper;
import com.xiang.xservice.basic.exception.BusinessException;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -44,9 +42,6 @@ public class SysRoleServiceImpl implements ISysRoleService {
@Autowired
private SysRoleDeptMapper roleDeptMapper;
@Autowired
private TokenApi tokenApi;
/**
* 根据条件分页查询角色数据
*
@@ -186,9 +181,9 @@ public class SysRoleServiceImpl implements ISysRoleService {
* @param roleIds 角色id
*/
@Override
public void checkRoleDataScope(String token, Long... roleIds) {
public void checkRoleDataScope(Long userId, Long... roleIds) {
if (!SysUser.isAdmin(tokenApi.getUserId(token))) {
if (!SysUser.isAdmin(userId)) {
for (Long roleId : roleIds) {
SysRole role = new SysRole();
role.setRoleId(roleId);
@@ -342,10 +337,10 @@ public class SysRoleServiceImpl implements ISysRoleService {
*/
@Override
@Transactional
public int deleteRoleByIds(String token, Long[] roleIds) {
public int deleteRoleByIds(Long userId, Long[] roleIds) {
for (Long roleId : roleIds) {
checkRoleAllowed(new SysRole(roleId));
checkRoleDataScope(token, roleId);
checkRoleDataScope(userId, roleId);
SysRole role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0) {
throw new com.xiang.xservice.basic.exception.BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName()));