Files
ai_site/platform
whm 3c9fe46359 feat: allow admins to bind member phone numbers
Members page previously only displayed phone status; add bind/replace UI and admin member update phone support for login and sync identity.
2026-08-05 14:41:27 +08:00
..

Platformgo-zero骨架

Publish校验蓝图 → 分配 schema → 生成/执行 DDL → 注册元数据)+ 动态 CRUD + JWT。

目录

platform/
  platform.go
  docker-compose.yml          # 本地 Postgres
  etc/platform.yaml
  internal/
    authx/                    # JWT 签发/校验 + Dev 头兜底
    blueprint/
    schema/                   # Postgres DDL数值 PK 用 IDENTITY
    meta/
    crud/                     # MemoryEngine + PostgresEngine
    logic/applogic/
    handler/

运行(内存 + JWT

cd platform
go test ./...
go run . -f etc/platform.yaml
# 另开终端
go run ./scripts/smoke.go

冒烟会:签发 JWT → publish → create → list → 非法 token 应 401。

运行Postgres 行级 Engine

docker compose up -d

etc/platform.yaml

DataSource: "postgres://platform:platform@127.0.0.1:5432/platform?sslmode=disable"
DevAuth: false

再启动服务。此时:

  • publish 真实建 schema/表
  • CRUD 走 PostgresEngine(参数化 SQL + tenant_id 强制条件)

JWT

POST /api/v1/auth/token
{"tenant_id":1,"user_id":1,"secret":"dev-only-change-me"}

→ {"access_token":"...","token_type":"Bearer","expires_at":...}

业务请求:

Authorization: Bearer <access_token>
配置 行为
DevAuth: false 必须带合法 JWT
DevAuth: true 无 JWT 时可用 X-Tenant-Id / X-User-Id(仅本地)
带了错误 Bearer 一律 401即使 DevAuth=true

生产请更换 Auth.AccessSecret / IssueSecret,并关掉 DevAuth

元数据落库

启用 DataSource 后自动迁移并使用 platform_meta.tenant_apps

  • 存 blueprint / ddl / endpoints / status
  • 进程重启后仍可按 slug 解析动态 CRUD
  • 无库时回退内存 MemoryStore