feat(user): 全局用户准确来源 + 丰富跨端字段(全端口兼容)
- users 增: wx_unionid/wx_mini_openid(微信绑定), source(来源枚举), auth_type, register_ip, last_login_ip/at, email, gender, birthday, compute_provisioned/username/quota/used_quota(算力镜像); alembic 0006 - 来源: register/phone-login/wx-login(读 X-Client 头,回退 body.source,再回退按 auth_type 推断)、admin 创建=admin、seed=seed - auth: 登录(签发令牌)记 last_login; profile 返回 source/auth_type/compute; email/gender/birthday 可编辑 - 对账 sync-users 回写 compute_* 镜像到平台用户 - _user_to_dict 含全部新字段; 迁移已应用, 导入/零依赖校验通过(dict 含 source/算力)
This commit is contained in:
@@ -36,14 +36,19 @@ class User(Base):
|
||||
password_hash: Mapped[str] = mapped_column(String, nullable=False)
|
||||
password_salt: Mapped[str] = mapped_column(String, nullable=False)
|
||||
# 统一登录:微信 openid(登录即建 opc_member 身份);phone 与 username(手机号)对齐
|
||||
wx_openid: Mapped[str] = mapped_column(String, default="", index=True)
|
||||
wx_openid: Mapped[str] = mapped_column(String, default="", index=True) # 公众号/网页开放平台
|
||||
wx_unionid: Mapped[str] = mapped_column(String, default="", index=True) # 微信 unionid(跨应用统一)
|
||||
wx_mini_openid: Mapped[str] = mapped_column(String, default="", index=True) # 小程序 openid(与网页不同)
|
||||
phone: Mapped[str] = mapped_column(String, default="")
|
||||
email: Mapped[str] = mapped_column(String, default="")
|
||||
nickname: Mapped[str] = mapped_column(String, default="")
|
||||
account: Mapped[str] = mapped_column(String, default="")
|
||||
company: Mapped[str] = mapped_column(String, default="")
|
||||
room: Mapped[str] = mapped_column(String, default="")
|
||||
avatar: Mapped[str] = mapped_column(String, default="")
|
||||
company_avatar: Mapped[str] = mapped_column(String, default="")
|
||||
gender: Mapped[str] = mapped_column(String, default="") # male|female|unknown
|
||||
birthday: Mapped[str] = mapped_column(String, default="") # YYYY-MM-DD
|
||||
# RBAC
|
||||
role: Mapped[str] = mapped_column(String, default="opc_member") # 业务角色
|
||||
sub_role: Mapped[str] = mapped_column(String, nullable=True) # 政务级/运营方内部
|
||||
@@ -51,6 +56,17 @@ class User(Base):
|
||||
region_id: Mapped[str | None] = mapped_column(ForeignKey("regions.id"), nullable=True)
|
||||
status: Mapped[str] = mapped_column(String, default="active") # active | disabled
|
||||
token_version: Mapped[int] = mapped_column(Integer, default=0) # revoke-all 递增
|
||||
# ── 来源与登录跟踪(全局用户统一,记录准确来源) ──
|
||||
source: Mapped[str] = mapped_column(String, default="") # mini_program|web|desktop|park|admin|seed|wx|phone|unknown
|
||||
auth_type: Mapped[str] = mapped_column(String, default="") # password|phone|wx_openid|admin
|
||||
register_ip: Mapped[str] = mapped_column(String, default="")
|
||||
last_login_ip: Mapped[str] = mapped_column(String, default="")
|
||||
last_login_at: Mapped[str] = mapped_column(String, default="")
|
||||
# ── 算力(引擎用户镜像,全局一致) ──
|
||||
compute_provisioned: Mapped[bool] = mapped_column(Boolean, default=False) # 是否已在算力引擎建号
|
||||
compute_username: Mapped[str] = mapped_column(String, default="") # 引擎用户名(= username)
|
||||
compute_quota: Mapped[int] = mapped_column(Integer, default=0) # 缓存引擎可用额度
|
||||
compute_used_quota: Mapped[int] = mapped_column(Integer, default=0) # 缓存引擎已用额度
|
||||
created_at: Mapped[str] = mapped_column(String, default="")
|
||||
updated_at: Mapped[str] = mapped_column(String, default="")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user