feat(identity): 支持用户和用户组批量管理

增加原子批量启用、禁用和删除接口及管理端多选操作,目标缺失时整批回滚。\n\n拆分管理端与 API Key 权限缓存并在弹窗保存后刷新候选;补齐失效规则一键清理样式、固定右侧操作列和 OpenAPI 契约。
This commit is contained in:
2026-08-03 15:43:49 +08:00
parent 7376d6fab6
commit ad8cdd525b
19 changed files with 1167 additions and 74 deletions
+190 -10
View File
@@ -19,7 +19,7 @@
"BearerAuth": []
}
],
"description": "管理端返回用户组、租户、用户或 API Key 到平台、平台模型、基础模型的访问规则。",
"description": "管理端返回用户组、租户、用户或 API Key 到平台、平台模型、基础模型的分层访问规则。主体当前层无 allow 时继承上级,存在 allow 时仅允许白名单,deny 始终优先。",
"produces": [
"application/json"
],
@@ -60,7 +60,7 @@
"BearerAuth": []
}
],
"description": "管理端创建一条访问控制规则。",
"description": "管理端创建一条访问控制规则;同一主体层存在任意有效 allow 后该层启用白名单,deny 始终优先。",
"consumes": [
"application/json"
],
@@ -129,7 +129,7 @@
"BearerAuth": []
}
],
"description": "管理端为同一主体批量新增、更新或删除资源访问规则。",
"description": "管理端为同一主体批量新增、更新或删除资源访问规则。清空该主体全部 allow 会恢复上级继承。",
"consumes": [
"application/json"
],
@@ -4844,6 +4844,75 @@
}
}
},
"/api/admin/user-groups/batch": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "管理端原子批量启用、禁用或删除最多 500 个用户组;删除时同步删除其访问规则,关联默认用户组外键按数据库约束置空。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"identity"
],
"summary": "批量操作用户组",
"parameters": [
{
"description": "用户组批量操作",
"name": "input",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/store.IdentityBatchInput"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/httpapi.IdentityBatchResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
}
}
}
},
"/api/admin/user-groups/{groupID}": {
"delete": {
"security": [
@@ -5089,6 +5158,75 @@
}
}
},
"/api/admin/users/batch": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "管理端原子批量启用、禁用或软删除最多 500 个用户;任一目标不存在时整批不变更。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"identity"
],
"summary": "批量操作用户",
"parameters": [
{
"description": "用户批量操作",
"name": "input",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/store.IdentityBatchInput"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/httpapi.IdentityBatchResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/httpapi.ErrorEnvelope"
}
}
}
}
},
"/api/admin/users/{userID}": {
"delete": {
"security": [
@@ -5600,7 +5738,7 @@
"BearerAuth": []
}
],
"description": "返回当前本地用户可管理的 API Key 访问规则。",
"description": "返回当前本地用户拥有的 API Key 访问规则;不会混入其他用户或其他 API Key 的规则。",
"produces": [
"application/json"
],
@@ -5649,7 +5787,7 @@
"BearerAuth": []
}
],
"description": "当前本地用户为自己的 API Key 批量新增、更新或删除可访问资源。",
"description": "当前本地用户为自己的 API Key 批量新增、更新或删除白名单/拒绝资源;Key 无 allow 时继承父级范围,存在 allow 后仅允许命中项。",
"consumes": [
"application/json"
],
@@ -5718,7 +5856,7 @@
"BearerAuth": []
}
],
"description": "按当前用户自身的户、租户和用户组权限返回可分配给 API Key 的启用模型,不任何 API Key 权限规则影响。",
"description": "按当前用户自身的户、用户组和用户分层白名单返回可分配给 API Key 的启用模型,不应用任何 API Key 层规则。",
"produces": [
"application/json"
],
@@ -5817,7 +5955,7 @@
"BearerAuth": []
}
],
"description": "返回指定 API Key 所属用户组允许、全局启用且符合 KEY scope 的平台来源,并附带已有规则有效性诊断。",
"description": "返回全局启用、命中指定 API Key 的租户/用户组/用户基线且符合 Key scope 的可分配平台来源;当前 Key 的 allow/deny 不缩减候选,仅作为已有规则有效性诊断返回。",
"produces": [
"application/json"
],
@@ -7725,7 +7863,7 @@
"BearerAuth": []
}
],
"description": "按当前用户权限返回可用于 Playground 或 API 调用的模型列表。",
"description": "按全局启用、租户、用户组、用户、当前 API Key 分层白名单及 scope 的交集返回可用于 Playground 或 API 调用的平台来源;其他主体规则不参与求值。",
"produces": [
"application/json"
],
@@ -7823,7 +7961,7 @@
"BearerAuth": []
}
],
"description": "按当前用户权限返回可用于 Playground 或 API 调用的模型列表。",
"description": "按全局启用、租户、用户组、用户、当前 API Key 分层白名单及 scope 的交集返回可用于 Playground 或 API 调用的平台来源;其他主体规则不参与求值。",
"produces": [
"application/json"
],
@@ -10345,7 +10483,7 @@
"BearerAuth": []
}
],
"description": "按当前身份、API Key 访问规则及 scope 返回去重后的逻辑模型列表。",
"description": "按全局启用、租户、用户组、用户、当前 API Key 分层白名单及 scope 的交集返回去重后的逻辑模型列表;其他主体规则不参与求值。",
"produces": [
"application/json"
],
@@ -11217,6 +11355,29 @@
}
}
},
"httpapi.IdentityBatchResponse": {
"type": "object",
"properties": {
"action": {
"type": "string",
"example": "disable"
},
"affectedCount": {
"type": "integer",
"example": 2
},
"ids": {
"type": "array",
"items": {
"type": "string"
}
},
"requestedCount": {
"type": "integer",
"example": 2
}
}
},
"httpapi.ImageVectorizeRequest": {
"type": "object",
"properties": {
@@ -15263,6 +15424,25 @@
}
}
},
"store.IdentityBatchInput": {
"type": "object",
"properties": {
"action": {
"type": "string",
"enum": [
"enable",
"disable",
"delete"
]
},
"ids": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"store.LocalLoginInput": {
"type": "object",
"properties": {