tenant: add invites and join requests

This commit is contained in:
2025-12-18 18:27:23 +08:00
parent 462bde351d
commit ec4506fd2d
28 changed files with 5206 additions and 201 deletions

View File

@@ -603,6 +603,342 @@ const docTemplate = `{
}
}
},
"/t/{tenantCode}/v1/admin/invites": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "邀请码列表(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Code 按邀请码模糊过滤可选支持部分匹配like。",
"name": "code",
"in": "query"
},
{
"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"
},
{
"enum": [
"active",
"disabled",
"expired"
],
"type": "string",
"x-enum-varnames": [
"TenantInviteStatusActive",
"TenantInviteStatusDisabled",
"TenantInviteStatusExpired"
],
"description": "Status 按状态过滤可选active/disabled/expired。",
"name": "status",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/requests.Pager"
},
{
"type": "object",
"properties": {
"items": {
"$ref": "#/definitions/models.TenantInvite"
}
}
}
]
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "创建邀请码(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantInviteCreateForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantInvite"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/invites/{inviteID}/disable": {
"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": "InviteID",
"name": "inviteID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantInviteDisableForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantInvite"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/join-requests": {
"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"
},
{
"enum": [
"pending",
"approved",
"rejected"
],
"type": "string",
"x-enum-varnames": [
"TenantJoinRequestStatusPending",
"TenantJoinRequestStatusApproved",
"TenantJoinRequestStatusRejected"
],
"description": "Status 按申请状态过滤可选pending/approved/rejected。",
"name": "status",
"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.TenantJoinRequest"
}
}
}
]
}
}
}
}
},
"/t/{tenantCode}/v1/admin/join-requests/{requestID}/approve": {
"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": "RequestID",
"name": "requestID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantJoinRequestDecideForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantJoinRequest"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/join-requests/{requestID}/reject": {
"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": "RequestID",
"name": "requestID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantJoinRequestDecideForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantJoinRequest"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/orders": {
"get": {
"consumes": [
@@ -849,11 +1185,33 @@ const docTemplate = `{
"name": "role",
"in": "query"
},
{
"enum": [
"pending_verify",
"verified",
"banned"
],
"type": "string",
"x-enum-varnames": [
"UserStatusPendingVerify",
"UserStatusVerified",
"UserStatusBanned"
],
"description": "Status 按成员状态过滤可选pending_verify/verified/banned。",
"name": "status",
"in": "query"
},
{
"type": "integer",
"description": "UserID 按用户ID过滤可选。",
"name": "user_id",
"in": "query"
},
{
"type": "string",
"description": "Username 按用户名模糊查询(可选,支持包含匹配)。",
"name": "username",
"in": "query"
}
],
"responses": {
@@ -878,6 +1236,45 @@ const docTemplate = `{
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}": {
"delete": {
"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/requests.Pager"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}/join": {
"post": {
"consumes": [
@@ -1239,6 +1636,86 @@ const docTemplate = `{
}
}
},
"/t/{tenantCode}/v1/join/invite": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"TenantJoin"
],
"summary": "通过邀请码加入租户",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.JoinByInviteForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantUser"
}
}
}
}
},
"/t/{tenantCode}/v1/join/request": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"TenantJoin"
],
"summary": "提交加入租户申请",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.JoinRequestCreateForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantJoinRequest"
}
}
}
}
},
"/t/{tenantCode}/v1/me": {
"get": {
"consumes": [
@@ -1629,6 +2106,32 @@ const docTemplate = `{
"RoleSuperAdmin"
]
},
"consts.TenantInviteStatus": {
"type": "string",
"enum": [
"active",
"disabled",
"expired"
],
"x-enum-varnames": [
"TenantInviteStatusActive",
"TenantInviteStatusDisabled",
"TenantInviteStatusExpired"
]
},
"consts.TenantJoinRequestStatus": {
"type": "string",
"enum": [
"pending",
"approved",
"rejected"
],
"x-enum-varnames": [
"TenantJoinRequestStatusPending",
"TenantJoinRequestStatusApproved",
"TenantJoinRequestStatusRejected"
]
},
"consts.TenantLedgerType": {
"type": "string",
"enum": [
@@ -1715,6 +2218,45 @@ const docTemplate = `{
}
}
},
"dto.AdminTenantInviteCreateForm": {
"type": "object",
"properties": {
"code": {
"description": "Code 邀请码(可选):为空时由后端生成;建议只包含数字/字母,便于人工输入。",
"type": "string"
},
"expires_at": {
"description": "ExpiresAt 过期时间(可选):为空表示不过期;到期后不可再使用。",
"type": "string"
},
"max_uses": {
"description": "MaxUses 最大可使用次数可选0 表示不限次数;大于 0 时用尽后自动失效。",
"type": "integer"
},
"remark": {
"description": "Remark 备注(可选):用于审计记录生成目的/投放渠道等。",
"type": "string"
}
}
},
"dto.AdminTenantInviteDisableForm": {
"type": "object",
"properties": {
"reason": {
"description": "Reason 禁用原因(可选):用于审计与追溯。",
"type": "string"
}
}
},
"dto.AdminTenantJoinRequestDecideForm": {
"type": "object",
"properties": {
"reason": {
"description": "Reason 审核说明(可选):用于审计记录通过/拒绝原因。",
"type": "string"
}
}
},
"dto.AdminTenantUserItem": {
"type": "object",
"properties": {
@@ -1965,6 +2507,24 @@ const docTemplate = `{
}
}
},
"dto.JoinByInviteForm": {
"type": "object",
"properties": {
"invite_code": {
"description": "InviteCode 邀请码:由租户管理员生成;用户提交后加入对应租户。",
"type": "string"
}
}
},
"dto.JoinRequestCreateForm": {
"type": "object",
"properties": {
"reason": {
"description": "Reason 申请原因(可选):用于向租户管理员说明申请加入的目的。",
"type": "string"
}
}
},
"dto.LoginForm": {
"type": "object",
"properties": {
@@ -2769,6 +3329,116 @@ const docTemplate = `{
}
}
},
"models.TenantInvite": {
"type": "object",
"properties": {
"code": {
"description": "邀请码:用户加入租户时提交;同一租户内唯一",
"type": "string"
},
"created_at": {
"description": "创建时间:默认 now()",
"type": "string"
},
"disabled_at": {
"description": "禁用时间租户管理员禁用该邀请的时间UTC",
"type": "string"
},
"disabled_operator_user_id": {
"description": "禁用操作人用户ID租户管理员审计用",
"type": "integer"
},
"expires_at": {
"description": "过期时间到期后不可再使用UTC为空表示不过期",
"type": "string"
},
"id": {
"description": "主键ID自增",
"type": "integer"
},
"max_uses": {
"description": "最大可使用次数0 表示不限制;\u003e0 时 used_count 达到该值后视为失效",
"type": "integer"
},
"remark": {
"description": "备注:生成/禁用原因等(审计用)",
"type": "string"
},
"status": {
"description": "邀请状态active/disabled/expiredexpired 也可由 expires_at 推导,业务侧需保持一致",
"allOf": [
{
"$ref": "#/definitions/consts.TenantInviteStatus"
}
]
},
"tenant_id": {
"description": "租户ID多租户隔离关键字段所有查询/写入必须限定 tenant_id",
"type": "integer"
},
"updated_at": {
"description": "更新时间:默认 now()",
"type": "string"
},
"used_count": {
"description": "已使用次数:每次成功加入时 +1需事务保证并发下不超发",
"type": "integer"
},
"user_id": {
"description": "创建人用户ID生成邀请码的租户管理员审计用",
"type": "integer"
}
}
},
"models.TenantJoinRequest": {
"type": "object",
"properties": {
"created_at": {
"description": "创建时间:默认 now()",
"type": "string"
},
"decided_at": {
"description": "处理时间:审核通过/拒绝时记录UTC",
"type": "string"
},
"decided_operator_user_id": {
"description": "处理人用户ID租户管理员审计用",
"type": "integer"
},
"decided_reason": {
"description": "处理说明:管理员通过/拒绝的原因(可选,审计用)",
"type": "string"
},
"id": {
"description": "主键ID自增",
"type": "integer"
},
"reason": {
"description": "申请原因:用户填写的加入说明(可选)",
"type": "string"
},
"status": {
"description": "申请状态pending/approved/rejected状态变更需记录 decided_at 与 decided_operator_user_id",
"allOf": [
{
"$ref": "#/definitions/consts.TenantJoinRequestStatus"
}
]
},
"tenant_id": {
"description": "租户ID多租户隔离关键字段所有查询/写入必须限定 tenant_id",
"type": "integer"
},
"updated_at": {
"description": "更新时间:默认 now()",
"type": "string"
},
"user_id": {
"description": "申请人用户ID发起加入申请的用户",
"type": "integer"
}
}
},
"models.TenantLedger": {
"type": "object",
"properties": {

View File

@@ -597,6 +597,342 @@
}
}
},
"/t/{tenantCode}/v1/admin/invites": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "邀请码列表(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Code 按邀请码模糊过滤可选支持部分匹配like。",
"name": "code",
"in": "query"
},
{
"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"
},
{
"enum": [
"active",
"disabled",
"expired"
],
"type": "string",
"x-enum-varnames": [
"TenantInviteStatusActive",
"TenantInviteStatusDisabled",
"TenantInviteStatusExpired"
],
"description": "Status 按状态过滤可选active/disabled/expired。",
"name": "status",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/requests.Pager"
},
{
"type": "object",
"properties": {
"items": {
"$ref": "#/definitions/models.TenantInvite"
}
}
}
]
}
}
}
},
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Tenant"
],
"summary": "创建邀请码(租户管理)",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantInviteCreateForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantInvite"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/invites/{inviteID}/disable": {
"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": "InviteID",
"name": "inviteID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantInviteDisableForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantInvite"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/join-requests": {
"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"
},
{
"enum": [
"pending",
"approved",
"rejected"
],
"type": "string",
"x-enum-varnames": [
"TenantJoinRequestStatusPending",
"TenantJoinRequestStatusApproved",
"TenantJoinRequestStatusRejected"
],
"description": "Status 按申请状态过滤可选pending/approved/rejected。",
"name": "status",
"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.TenantJoinRequest"
}
}
}
]
}
}
}
}
},
"/t/{tenantCode}/v1/admin/join-requests/{requestID}/approve": {
"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": "RequestID",
"name": "requestID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantJoinRequestDecideForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantJoinRequest"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/join-requests/{requestID}/reject": {
"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": "RequestID",
"name": "requestID",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AdminTenantJoinRequestDecideForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantJoinRequest"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/orders": {
"get": {
"consumes": [
@@ -843,11 +1179,33 @@
"name": "role",
"in": "query"
},
{
"enum": [
"pending_verify",
"verified",
"banned"
],
"type": "string",
"x-enum-varnames": [
"UserStatusPendingVerify",
"UserStatusVerified",
"UserStatusBanned"
],
"description": "Status 按成员状态过滤可选pending_verify/verified/banned。",
"name": "status",
"in": "query"
},
{
"type": "integer",
"description": "UserID 按用户ID过滤可选。",
"name": "user_id",
"in": "query"
},
{
"type": "string",
"description": "Username 按用户名模糊查询(可选,支持包含匹配)。",
"name": "username",
"in": "query"
}
],
"responses": {
@@ -872,6 +1230,45 @@
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}": {
"delete": {
"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/requests.Pager"
}
}
}
}
},
"/t/{tenantCode}/v1/admin/users/{userID}/join": {
"post": {
"consumes": [
@@ -1233,6 +1630,86 @@
}
}
},
"/t/{tenantCode}/v1/join/invite": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"TenantJoin"
],
"summary": "通过邀请码加入租户",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.JoinByInviteForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantUser"
}
}
}
}
},
"/t/{tenantCode}/v1/join/request": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"TenantJoin"
],
"summary": "提交加入租户申请",
"parameters": [
{
"type": "string",
"description": "Tenant Code",
"name": "tenantCode",
"in": "path",
"required": true
},
{
"description": "Form",
"name": "form",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.JoinRequestCreateForm"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.TenantJoinRequest"
}
}
}
}
},
"/t/{tenantCode}/v1/me": {
"get": {
"consumes": [
@@ -1623,6 +2100,32 @@
"RoleSuperAdmin"
]
},
"consts.TenantInviteStatus": {
"type": "string",
"enum": [
"active",
"disabled",
"expired"
],
"x-enum-varnames": [
"TenantInviteStatusActive",
"TenantInviteStatusDisabled",
"TenantInviteStatusExpired"
]
},
"consts.TenantJoinRequestStatus": {
"type": "string",
"enum": [
"pending",
"approved",
"rejected"
],
"x-enum-varnames": [
"TenantJoinRequestStatusPending",
"TenantJoinRequestStatusApproved",
"TenantJoinRequestStatusRejected"
]
},
"consts.TenantLedgerType": {
"type": "string",
"enum": [
@@ -1709,6 +2212,45 @@
}
}
},
"dto.AdminTenantInviteCreateForm": {
"type": "object",
"properties": {
"code": {
"description": "Code 邀请码(可选):为空时由后端生成;建议只包含数字/字母,便于人工输入。",
"type": "string"
},
"expires_at": {
"description": "ExpiresAt 过期时间(可选):为空表示不过期;到期后不可再使用。",
"type": "string"
},
"max_uses": {
"description": "MaxUses 最大可使用次数可选0 表示不限次数;大于 0 时用尽后自动失效。",
"type": "integer"
},
"remark": {
"description": "Remark 备注(可选):用于审计记录生成目的/投放渠道等。",
"type": "string"
}
}
},
"dto.AdminTenantInviteDisableForm": {
"type": "object",
"properties": {
"reason": {
"description": "Reason 禁用原因(可选):用于审计与追溯。",
"type": "string"
}
}
},
"dto.AdminTenantJoinRequestDecideForm": {
"type": "object",
"properties": {
"reason": {
"description": "Reason 审核说明(可选):用于审计记录通过/拒绝原因。",
"type": "string"
}
}
},
"dto.AdminTenantUserItem": {
"type": "object",
"properties": {
@@ -1959,6 +2501,24 @@
}
}
},
"dto.JoinByInviteForm": {
"type": "object",
"properties": {
"invite_code": {
"description": "InviteCode 邀请码:由租户管理员生成;用户提交后加入对应租户。",
"type": "string"
}
}
},
"dto.JoinRequestCreateForm": {
"type": "object",
"properties": {
"reason": {
"description": "Reason 申请原因(可选):用于向租户管理员说明申请加入的目的。",
"type": "string"
}
}
},
"dto.LoginForm": {
"type": "object",
"properties": {
@@ -2763,6 +3323,116 @@
}
}
},
"models.TenantInvite": {
"type": "object",
"properties": {
"code": {
"description": "邀请码:用户加入租户时提交;同一租户内唯一",
"type": "string"
},
"created_at": {
"description": "创建时间:默认 now()",
"type": "string"
},
"disabled_at": {
"description": "禁用时间租户管理员禁用该邀请的时间UTC",
"type": "string"
},
"disabled_operator_user_id": {
"description": "禁用操作人用户ID租户管理员审计用",
"type": "integer"
},
"expires_at": {
"description": "过期时间到期后不可再使用UTC为空表示不过期",
"type": "string"
},
"id": {
"description": "主键ID自增",
"type": "integer"
},
"max_uses": {
"description": "最大可使用次数0 表示不限制;\u003e0 时 used_count 达到该值后视为失效",
"type": "integer"
},
"remark": {
"description": "备注:生成/禁用原因等(审计用)",
"type": "string"
},
"status": {
"description": "邀请状态active/disabled/expiredexpired 也可由 expires_at 推导,业务侧需保持一致",
"allOf": [
{
"$ref": "#/definitions/consts.TenantInviteStatus"
}
]
},
"tenant_id": {
"description": "租户ID多租户隔离关键字段所有查询/写入必须限定 tenant_id",
"type": "integer"
},
"updated_at": {
"description": "更新时间:默认 now()",
"type": "string"
},
"used_count": {
"description": "已使用次数:每次成功加入时 +1需事务保证并发下不超发",
"type": "integer"
},
"user_id": {
"description": "创建人用户ID生成邀请码的租户管理员审计用",
"type": "integer"
}
}
},
"models.TenantJoinRequest": {
"type": "object",
"properties": {
"created_at": {
"description": "创建时间:默认 now()",
"type": "string"
},
"decided_at": {
"description": "处理时间:审核通过/拒绝时记录UTC",
"type": "string"
},
"decided_operator_user_id": {
"description": "处理人用户ID租户管理员审计用",
"type": "integer"
},
"decided_reason": {
"description": "处理说明:管理员通过/拒绝的原因(可选,审计用)",
"type": "string"
},
"id": {
"description": "主键ID自增",
"type": "integer"
},
"reason": {
"description": "申请原因:用户填写的加入说明(可选)",
"type": "string"
},
"status": {
"description": "申请状态pending/approved/rejected状态变更需记录 decided_at 与 decided_operator_user_id",
"allOf": [
{
"$ref": "#/definitions/consts.TenantJoinRequestStatus"
}
]
},
"tenant_id": {
"description": "租户ID多租户隔离关键字段所有查询/写入必须限定 tenant_id",
"type": "integer"
},
"updated_at": {
"description": "更新时间:默认 now()",
"type": "string"
},
"user_id": {
"description": "申请人用户ID发起加入申请的用户",
"type": "integer"
}
}
},
"models.TenantLedger": {
"type": "object",
"properties": {

View File

@@ -116,6 +116,26 @@ definitions:
x-enum-varnames:
- RoleUser
- RoleSuperAdmin
consts.TenantInviteStatus:
enum:
- active
- disabled
- expired
type: string
x-enum-varnames:
- TenantInviteStatusActive
- TenantInviteStatusDisabled
- TenantInviteStatusExpired
consts.TenantJoinRequestStatus:
enum:
- pending
- approved
- rejected
type: string
x-enum-varnames:
- TenantJoinRequestStatusPending
- TenantJoinRequestStatusApproved
- TenantJoinRequestStatusRejected
consts.TenantLedgerType:
enum:
- credit_topup
@@ -185,6 +205,33 @@ definitions:
退款原因:建议必填(由业务侧校验);用于审计与追责。
type: string
type: object
dto.AdminTenantInviteCreateForm:
properties:
code:
description: Code 邀请码(可选):为空时由后端生成;建议只包含数字/字母,便于人工输入。
type: string
expires_at:
description: ExpiresAt 过期时间(可选):为空表示不过期;到期后不可再使用。
type: string
max_uses:
description: MaxUses 最大可使用次数可选0 表示不限次数;大于 0 时用尽后自动失效。
type: integer
remark:
description: Remark 备注(可选):用于审计记录生成目的/投放渠道等。
type: string
type: object
dto.AdminTenantInviteDisableForm:
properties:
reason:
description: Reason 禁用原因(可选):用于审计与追溯。
type: string
type: object
dto.AdminTenantJoinRequestDecideForm:
properties:
reason:
description: Reason 审核说明(可选):用于审计记录通过/拒绝原因。
type: string
type: object
dto.AdminTenantUserItem:
properties:
tenant_user:
@@ -345,6 +392,18 @@ definitions:
- $ref: '#/definitions/consts.ContentVisibility'
description: Visibility updates the visibility when provided.
type: object
dto.JoinByInviteForm:
properties:
invite_code:
description: InviteCode 邀请码:由租户管理员生成;用户提交后加入对应租户。
type: string
type: object
dto.JoinRequestCreateForm:
properties:
reason:
description: Reason 申请原因(可选):用于向租户管理员说明申请加入的目的。
type: string
type: object
dto.LoginForm:
properties:
password:
@@ -875,6 +934,83 @@ definitions:
uuid:
type: string
type: object
models.TenantInvite:
properties:
code:
description: 邀请码:用户加入租户时提交;同一租户内唯一
type: string
created_at:
description: 创建时间:默认 now()
type: string
disabled_at:
description: 禁用时间租户管理员禁用该邀请的时间UTC
type: string
disabled_operator_user_id:
description: 禁用操作人用户ID租户管理员审计用
type: integer
expires_at:
description: 过期时间到期后不可再使用UTC为空表示不过期
type: string
id:
description: 主键ID自增
type: integer
max_uses:
description: 最大可使用次数0 表示不限制;>0 时 used_count 达到该值后视为失效
type: integer
remark:
description: 备注:生成/禁用原因等(审计用)
type: string
status:
allOf:
- $ref: '#/definitions/consts.TenantInviteStatus'
description: 邀请状态active/disabled/expiredexpired 也可由 expires_at 推导,业务侧需保持一致
tenant_id:
description: 租户ID多租户隔离关键字段所有查询/写入必须限定 tenant_id
type: integer
updated_at:
description: 更新时间:默认 now()
type: string
used_count:
description: 已使用次数:每次成功加入时 +1需事务保证并发下不超发
type: integer
user_id:
description: 创建人用户ID生成邀请码的租户管理员审计用
type: integer
type: object
models.TenantJoinRequest:
properties:
created_at:
description: 创建时间:默认 now()
type: string
decided_at:
description: 处理时间:审核通过/拒绝时记录UTC
type: string
decided_operator_user_id:
description: 处理人用户ID租户管理员审计用
type: integer
decided_reason:
description: 处理说明:管理员通过/拒绝的原因(可选,审计用)
type: string
id:
description: 主键ID自增
type: integer
reason:
description: 申请原因:用户填写的加入说明(可选)
type: string
status:
allOf:
- $ref: '#/definitions/consts.TenantJoinRequestStatus'
description: 申请状态pending/approved/rejected状态变更需记录 decided_at 与 decided_operator_user_id
tenant_id:
description: 租户ID多租户隔离关键字段所有查询/写入必须限定 tenant_id
type: integer
updated_at:
description: 更新时间:默认 now()
type: string
user_id:
description: 申请人用户ID发起加入申请的用户
type: integer
type: object
models.TenantLedger:
properties:
amount:
@@ -1400,6 +1536,227 @@ paths:
summary: 设置内容价格与折扣
tags:
- Tenant
/t/{tenantCode}/v1/admin/invites:
get:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: Code 按邀请码模糊过滤可选支持部分匹配like
in: query
name: code
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: Status 按状态过滤可选active/disabled/expired。
enum:
- active
- disabled
- expired
in: query
name: status
type: string
x-enum-varnames:
- TenantInviteStatusActive
- TenantInviteStatusDisabled
- TenantInviteStatusExpired
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/requests.Pager'
- properties:
items:
$ref: '#/definitions/models.TenantInvite'
type: object
summary: 邀请码列表(租户管理)
tags:
- Tenant
post:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: Form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.AdminTenantInviteCreateForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.TenantInvite'
summary: 创建邀请码(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/invites/{inviteID}/disable:
patch:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: InviteID
format: int64
in: path
name: inviteID
required: true
type: integer
- description: Form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.AdminTenantInviteDisableForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.TenantInvite'
summary: 禁用邀请码(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/join-requests:
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: Status 按申请状态过滤可选pending/approved/rejected。
enum:
- pending
- approved
- rejected
in: query
name: status
type: string
x-enum-varnames:
- TenantJoinRequestStatusPending
- TenantJoinRequestStatusApproved
- TenantJoinRequestStatusRejected
- 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.TenantJoinRequest'
type: object
summary: 加入申请列表(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/join-requests/{requestID}/approve:
post:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: RequestID
format: int64
in: path
name: requestID
required: true
type: integer
- description: Form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.AdminTenantJoinRequestDecideForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.TenantJoinRequest'
summary: 通过加入申请(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/join-requests/{requestID}/reject:
post:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: RequestID
format: int64
in: path
name: requestID
required: true
type: integer
- description: Form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.AdminTenantJoinRequestDecideForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.TenantJoinRequest'
summary: 拒绝加入申请(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/orders:
get:
consumes:
@@ -1564,10 +1921,26 @@ paths:
x-enum-varnames:
- TenantUserRoleMember
- TenantUserRoleTenantAdmin
- description: Status 按成员状态过滤可选pending_verify/verified/banned。
enum:
- pending_verify
- verified
- banned
in: query
name: status
type: string
x-enum-varnames:
- UserStatusPendingVerify
- UserStatusVerified
- UserStatusBanned
- description: UserID 按用户ID过滤可选
in: query
name: user_id
type: integer
- description: Username 按用户名模糊查询(可选,支持包含匹配)。
in: query
name: username
type: string
produces:
- application/json
responses:
@@ -1583,6 +1956,32 @@ paths:
summary: 成员列表(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/users/{userID}:
delete:
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/requests.Pager'
summary: 移除租户成员(租户管理)
tags:
- Tenant
/t/{tenantCode}/v1/admin/users/{userID}/join:
post:
consumes:
@@ -1821,6 +2220,58 @@ paths:
summary: 购买内容(余额支付)
tags:
- Tenant
/t/{tenantCode}/v1/join/invite:
post:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: Form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.JoinByInviteForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.TenantUser'
summary: 通过邀请码加入租户
tags:
- TenantJoin
/t/{tenantCode}/v1/join/request:
post:
consumes:
- application/json
parameters:
- description: Tenant Code
in: path
name: tenantCode
required: true
type: string
- description: Form
in: body
name: form
required: true
schema:
$ref: '#/definitions/dto.JoinRequestCreateForm'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.TenantJoinRequest'
summary: 提交加入租户申请
tags:
- TenantJoin
/t/{tenantCode}/v1/me:
get:
consumes: