From f5b06cb9b94f8c82568765e18db32599d008ab63 Mon Sep 17 00:00:00 2001 From: Leo <98382335+gaoziman@users.noreply.github.com> Date: Wed, 9 Jul 2025 16:44:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E4=BF=AE=E5=A4=8D=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=9D=83=E9=99=90=E5=88=86=E9=85=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E9=9B=AA=E8=8A=B1ID=E7=B2=BE=E5=BA=A6=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将菜单权限分配接口从URL参数改为请求体参数,避免URL过长 - 修改saveRoleMenuPermission函数,保持字符串格式避免精度丢失 - 更新RoleMenuPermissionBo类型定义,使用string类型处理大数字ID - 解决雪花ID在前端Number转换时精度丢失的问题 影响文件: - src/service/api/system/menu/index.ts - src/service/api/system/menu/types.ts --- src/service/api/system/menu/index.ts | 11 +++++++++-- src/service/api/system/menu/types.ts | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/service/api/system/menu/index.ts b/src/service/api/system/menu/index.ts index 4ddc1b3..a55974e 100644 --- a/src/service/api/system/menu/index.ts +++ b/src/service/api/system/menu/index.ts @@ -16,6 +16,7 @@ export type { MenuQueryBo, MenuRouterBo, MenuVo, + RoleMenuPermissionBo, } from './types' // 兼容性类型别名 @@ -120,8 +121,14 @@ export function getMenuIdsByRoleId(roleId: string) { * 保存角色和菜单权限之间的关系 */ export function saveRoleMenuPermission(roleId: string, menuIds: string[]) { - const menuIdsStr = menuIds.length > 0 ? menuIds.join(',') : '-1' - return request.Post>(`/coder/sysMenu/saveRoleMenu/${roleId}/${menuIdsStr}`) + // 空数组时传递 ["-1"] 表示取消所有权限 + // 保持字符串格式避免精度丢失 + const menuIdsStr = menuIds.length > 0 ? menuIds : ['-1'] + + return request.Post>('/coder/sysMenu/saveRoleMenu', { + roleId, + menuIds: menuIdsStr, + }) } // 兼容性导出 - 保持原有函数名以确保向后兼容 diff --git a/src/service/api/system/menu/types.ts b/src/service/api/system/menu/types.ts index 6f8b431..0aa5b68 100644 --- a/src/service/api/system/menu/types.ts +++ b/src/service/api/system/menu/types.ts @@ -95,3 +95,9 @@ export interface MenuNormalResponse { menuList: MenuVo[] spreadList: string[] // 改为字符串数组避免大整数精度丢失 } + +// 角色菜单权限分配请求参数 +export interface RoleMenuPermissionBo { + roleId: string // 字符串格式避免精度丢失 + menuIds: string[] // 字符串格式避免精度丢失 +}