tenant: add member management APIs

This commit is contained in:
2025-12-18 17:29:17 +08:00
parent 5029234e47
commit de574bbd9d
11 changed files with 815 additions and 14 deletions

View File

@@ -803,6 +803,154 @@ const docTemplate = `{
}
}
},
"/t/{tenantCode}/v1/admin/users": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "成员列表(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Limit is page size; only values in {10,20,50,100} are accepted (otherwise defaults to 10).",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Page is 1-based page index; values \u003c= 0 are normalized to 1.",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "UserID 按用户ID过滤可选。",
"name": "user_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/requests.Pager"
},
{
"type": "object",
"properties": {
"items": {
"$ref": "#/definitions/models.TenantUser"
}
}
}
]
}
}
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}/join": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "添加租户成员(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"type": "integer",
"format": "int64",
"description": "UserID",
"name": "userID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.AdminTenantUserJoinResponse"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}/role": {
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "设置成员角色(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"type": "integer",
"format": "int64",
"description": "UserID",
"name": "userID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantUserRoleUpdateForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.AdminTenantUserJoinResponse"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}/topup": {
"post": {
"consumes": [
@@ -1553,6 +1701,28 @@ const docTemplate = `{
}
}
},
"dto.AdminTenantUserJoinResponse": {
"type": "object",
"properties": {
"tenant_user": {
"description": "TenantUser 租户成员关系记录。",
"allOf": [
{
"$ref": "#/definitions/models.TenantUser"
}
]
}
}
},
"dto.AdminTenantUserRoleUpdateForm": {
"type": "object",
"properties": {
"role": {
"description": "Role 角色member/tenant_admin。",
"type": "string"
}
}
},
"dto.AdminTopupForm": {
"type": "object",
"properties": {

View File

@@ -797,6 +797,154 @@
}
}
},
"/t/{tenantCode}/v1/admin/users": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "成员列表(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Limit is page size; only values in {10,20,50,100} are accepted (otherwise defaults to 10).",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Page is 1-based page index; values \u003c= 0 are normalized to 1.",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "UserID 按用户ID过滤可选。",
"name": "user_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/requests.Pager"
},
{
"type": "object",
"properties": {
"items": {
"$ref": "#/definitions/models.TenantUser"
}
}
}
]
}
}
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}/join": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "添加租户成员(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"type": "integer",
"format": "int64",
"description": "UserID",
"name": "userID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.AdminTenantUserJoinResponse"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}/role": {
"patch": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "设置成员角色(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"type": "integer",
"format": "int64",
"description": "UserID",
"name": "userID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantUserRoleUpdateForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.AdminTenantUserJoinResponse"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}/topup": {
"post": {
"consumes": [
@@ -1547,6 +1695,28 @@
}
}
},
"dto.AdminTenantUserJoinResponse": {
"type": "object",
"properties": {
"tenant_user": {
"description": "TenantUser 租户成员关系记录。",
"allOf": [
{
"$ref": "#/definitions/models.TenantUser"
}
]
}
}
},
"dto.AdminTenantUserRoleUpdateForm": {
"type": "object",
"properties": {
"role": {
"description": "Role 角色member/tenant_admin。",
"type": "string"
}
}
},
"dto.AdminTopupForm": {
"type": "object",
"properties": {

View File

@@ -185,6 +185,19 @@ definitions:
退款原因:建议必填(由业务侧校验);用于审计与追责。
type: string
type: object
dto.AdminTenantUserJoinResponse:
properties:
tenant_user:
allOf:
- $ref: '#/definitions/models.TenantUser'
description: TenantUser 租户成员关系记录。
type: object
dto.AdminTenantUserRoleUpdateForm:
properties:
role:
description: Role 角色member/tenant_admin。
type: string
type: object
dto.AdminTopupForm:
properties:
amount:
@@ -1511,6 +1524,102 @@ paths:
summary: 订单退款(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/users:
get:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: Limit is page size; only values in {10,20,50,100} are accepted
(otherwise defaults to 10).
in: query
name: limit
type: integer
- description: Page is 1-based page index; values <= 0 are normalized to 1.
in: query
name: page
type: integer
- description: UserID 按用户ID过滤可选
in: query
name: user_id
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/requests.Pager'
- properties:
items:
$ref: '#/definitions/models.TenantUser'
type: object
summary: 成员列表(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/users/{userID}/join:
post:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: UserID
format: int64
in: path
name: userID
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.AdminTenantUserJoinResponse'
summary: 添加租户成员(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/users/{userID}/role:
patch:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: UserID
format: int64
in: path
name: userID
required: true
type: integer
- description: Form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.AdminTenantUserRoleUpdateForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.AdminTenantUserJoinResponse'
summary: 设置成员角色(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/users/{userID}/topup:
post:
consumes: