20260808:bug修复,项目列表只能查自己即以下结构用户

This commit is contained in:
zhugongping 2026-08-09 08:08:06 +08:00
parent b2d9fe05c7
commit a4996c1c5d
5 changed files with 60 additions and 2 deletions

View File

@ -66,6 +66,19 @@ public class SysUserController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
/**
* 获取机构范围内用户列表
* 超级管理员可查询全部人员,其他用户仅可查询本人机构及其子机构人员
*/
@ApiOperation("获取机构范围内用户列表")
@PreAuthorize("@ss.hasAnyPermi('system:user:list,iot:project:list,iot:device:list')")
@GetMapping("/listByScope")
public TableDataInfo listByScope(SysUser user) {
startPage();
List<SysUser> list = userService.selectUserListByScope(user);
return getDataTable(list);
}
@ApiOperation("导出用户列表") @ApiOperation("导出用户列表")
@Log(title = "用户管理", businessType = BusinessType.EXPORT) @Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')") @PreAuthorize("@ss.hasPermi('system:user:export')")

View File

@ -18,6 +18,15 @@ public interface ISysUserService {
*/ */
public List<SysUser> selectUserList(SysUser user); public List<SysUser> selectUserList(SysUser user);
/**
* 根据当前用户机构范围查询用户列表
* 超级管理员可查询全部人员,其他用户仅可查询本人机构及其子机构人员
*
* @param user 用户信息
* @return 用户信息集合信息
*/
public List<SysUser> selectUserListByScope(SysUser user);
/** /**
* 根据条件分页查询已分配用户角色列表 * 根据条件分页查询已分配用户角色列表
* *

View File

@ -74,6 +74,33 @@ public class SysUserServiceImpl implements ISysUserService {
return sysUserList; return sysUserList;
} }
/**
* 根据当前用户机构范围查询用户列表
* 超级管理员可查询全部人员,其他用户仅可查询本人机构及其子机构人员
*
* @param user 用户信息
* @return 用户信息集合信息
*/
@Override
public List<SysUser> selectUserListByScope(SysUser user) {
// 清空数据权限参数,防止注入并避免依赖角色数据范围配置
user.getParams().put("dataScope", "");
SysUser loginUser = getLoginUser().getUser();
if (loginUser.isAdmin()) {
// 超级管理员查询全部人员
user.setDeptId(null);
user.setShowChild(null);
} else {
// 非超级管理员强制限定为本人机构及其子机构
if (loginUser.getDeptId() == null || loginUser.getDeptId() == 0L) {
return new ArrayList<>();
}
user.setDeptId(loginUser.getDeptId());
user.setShowChild(true);
}
return userMapper.selectUserList(user);
}
/** /**
* 根据条件分页查询已分配用户角色列表 * 根据条件分页查询已分配用户角色列表
* *

View File

@ -10,6 +10,15 @@ export function listUser(query) {
}); });
} }
// 查询机构范围内用户列表(非超管仅可查询本人机构及其子机构人员)
export function listUserByScope(query) {
return request({
url: '/system/user/listByScope',
method: 'get',
params: query,
});
}
// 查询终端用户列表 // 查询终端用户列表
export function terminalUserList(query) { export function terminalUserList(query) {
return request({ return request({

View File

@ -176,7 +176,7 @@
<script> <script>
import { listProject, getProject, delProject, addProject, updateProject } from '@/api/iot/project'; import { listProject, getProject, delProject, addProject, updateProject } from '@/api/iot/project';
import { listUser } from '@/api/system/user'; import { listUserByScope } from '@/api/system/user';
import { DEFAULT_TIANDITU_AK, DEFAULT_TIANDITU_TILE_KEY, loadTiandituMap } from '@/utils/tdtMap'; import { DEFAULT_TIANDITU_AK, DEFAULT_TIANDITU_TILE_KEY, loadTiandituMap } from '@/utils/tdtMap';
import ProjectDeviceSelect from './device-select.vue'; import ProjectDeviceSelect from './device-select.vue';
@ -243,7 +243,7 @@ export default {
}, },
/** 查询用户列表 */ /** 查询用户列表 */
getUserList() { getUserList() {
listUser({ pageNum: 1, pageSize: 1000 }).then(response => { listUserByScope({ pageNum: 1, pageSize: 100 }).then(response => {
this.userList = response.rows || []; this.userList = response.rows || [];
}); });
}, },