feat: add user_tenant associations

This commit is contained in:
2025-12-16 14:14:58 +08:00
parent d058b7ffda
commit 4722eef72c
9 changed files with 391 additions and 24 deletions

View File

@@ -20,3 +20,23 @@ field_type:
role: types.Array[consts.TenantUserRole]
status: consts.UserStatus
field_relate:
users:
OwnedTenant:
relation: belongs_to
table: tenants
json: owned
Tenants:
json: tenants
relation: many_to_many
table: tenants
pivot: tenant_users
# foreign_key: user_id # 当前表users用于关联的键转为结构体字段名 user_id
join_foreign_key: user_id # 中间表中指向当前表的列tenant_users.user_id
# references: id # 关联表tenants被引用的列转为结构体字段名 ID
join_references: tenant_id # 中间表中指向关联表的列tenant_users.tenant_id
tenants:
Users:
relation: many_to_many
table: users
pivot: tenant_users
json: users