账号与权限

8 张表的结构与字段说明。

本页由 docs:sync 从数据库结构生成,请勿手工编辑。

users

字段 类型 可空 默认 说明
id bigint unsigned 否 — —
tenant_id bigint unsigned 是 — —
name varchar(255) 否 — —
email varchar(255) 否 — —
phone varchar(20) 是 — —
wechat_openid varchar(255) 是 — 微信扫码登录绑定
email_verified_at timestamp 是 — —
password varchar(255) 否 — —
password_changed_at timestamp 是 — 最近改密时间(有效期判定;null 回退注册时间)
role varchar(30) 否 customer_viewer 角色:super_admin/platform_admin/customer_admin/customer_editor/customer_service/customer_viewer
remember_token varchar(100) 是 — —
created_at timestamp 是 — —
updated_at timestamp 是 — —
two_factor_secret text 是 — TOTP 密钥(Crypt 加密)
two_factor_recovery_codes text 是 — 恢复码 JSON(Crypt 加密,用一个划一个)
two_factor_confirmed_at timestamp 是 — 扫码确认完成时间;null=未启用或待确认
theme_developer tinyint(1) 否 0 主题开发者(仅服务器 CLI 授予)
is_provider tinyint(1) 否 0 服务商运维账号(独立部署交付后技术登录处理用)
disabled_at timestamp 是 — 停用时间;非空即不可登录,已有会话下一请求即退出

tenants

字段 类型 可空 默认 说明
id bigint unsigned 否 — —
name varchar(255) 否 — 客户企业名称
status varchar(20) 否 active active / suspended
created_at timestamp 是 — —
updated_at timestamp 是 — —
plan varchar(20) 否 trial 套餐:trial 试用 / standard 标准 / premium 高级
expires_at date 是 — 服务有效期(含当日);null 不限期。过期后该企业用户全部 403
expiry_reminded_on date 是 — 已发送到期提醒所针对的 expires_at 值
ai_monthly_limit int unsigned 是 — 建站助手每月 AI 调用上限(按助手回复条数计);null 不限
deletion_warned_on date 是 — 已就该到期日发过"宽限期满将永久删除网站"警告(按 expires_at 去重;续费后清空)
ai_token_monthly_limit bigint unsigned 是 — 租户级 token 月度额度覆盖(优先于套餐;null 用套餐值)
ai_token_balance bigint unsigned 否 0 充值 token 余额:月度额度用尽后消耗,不过期;管理员可调整/赠送
cms_bind_limit_override int unsigned 是 — CMS 绑定数人工提额(优先于套餐值;null=按套餐)

auth_settings

字段 类型 可空 默认 说明
id bigint unsigned 否 — —
sms_enabled tinyint(1) 否 0 —
sms_access_key_id text 是 — AccessKey ID(加密)
sms_access_key_secret text 是 — AccessKey Secret(加密)
sms_sign_name varchar(255) 是 — 短信签名
sms_template_code varchar(255) 是 — 短信模板 CODE
wechat_login_enabled tinyint(1) 否 0 —
wechat_app_id varchar(255) 是 — —
wechat_app_secret text 是 — AppSecret(加密)
created_at timestamp 是 — —
updated_at timestamp 是 — —
captcha_enabled tinyint(1) 是 — 登录图形验证码;null=跟随配置文件
password_min_length tinyint unsigned 否 8 密码最小长度(6-32)
password_require_mixed tinyint(1) 否 0 必须同时含字母与数字
password_max_age_days smallint unsigned 是 — 密码有效期天数(null=永不过期),过期强制改密
lockout_attempts tinyint unsigned 否 5 连续失败 N 次锁定账号(0=关闭;独立于 IP 级限流)
lockout_minutes smallint unsigned 否 15 账号锁定时长(分钟)
login_alert_enabled tinyint(1) 是 — 异常登录提醒(新 IP 登录成功时给账号邮箱发提醒);null=默认开启
admin_ip_whitelist text 是 — 平台后台(/admin)IP 白名单,逗号/换行分隔,支持 IPv4 CIDR;空=不启用
login_entry varchar(40) 是 — 安全入口串:非空时 /login 只对先访问过 /{入口串} 的浏览器开放

login_logs

字段 类型 可空 默认 说明
id bigint unsigned 否 — —
tenant_id bigint unsigned 是 — —
user_id bigint unsigned 是 — —
email varchar(255) 是 — 登录使用的邮箱
ip varchar(45) 是 — —
user_agent varchar(500) 是 — —
status varchar(10) 否 success success / failed
created_at timestamp 是 — —

admin_access_logs

字段 类型 可空 默认 说明
id bigint unsigned 否 — —
admin_id bigint unsigned 否 — 查看者(平台管理员)
tenant_id bigint unsigned 是 — 被查看数据所属租户(平台审计表,不挂租户作用域)
action varchar(40) 否 — 动作,如 widget_session.view
subject_type varchar(40) 否 — 对象类型
subject_id bigint unsigned 是 — 对象 id
ip varchar(45) 是 — —
created_at timestamp 是 — —

password_reset_tokens

字段 类型 可空 默认 说明
email varchar(255) 否 — —
token varchar(255) 否 — —
created_at timestamp 是 — —

moderation_logs

字段 类型 可空 默认 说明
id bigint unsigned 否 — —
tenant_id bigint unsigned 是 — —
site_id bigint unsigned 是 — —
scene varchar(30) 否 — build_content / widget_chat / lead 等场景
source varchar(30) 否 — 来源:ai_operation / visitor / lead
driver varchar(20) 否 — 命中驱动:keyword / aliyun
label varchar(50) 是 — 风险类别
hits json 是 — 命中的词/标签
excerpt text 否 — 被拦文本摘要(截断,便于复核)
created_at timestamp 是 — —
updated_at timestamp 是 — —

moderation_settings

字段 类型 可空 默认 说明
id bigint unsigned 否 — —
driver varchar(20) 是 — 审核驱动:none 关闭 / keyword 本地词库 / aliyun 阿里云内容安全
keywords text 是 — 本地词库,每行一个词(keyword 驱动用)
aliyun_access_key_id text 是 — 加密
aliyun_access_key_secret text 是 — 加密
aliyun_region varchar(30) 是 — 默认 cn-shanghai
aliyun_service varchar(60) 是 — 检测服务编码,默认 comment_detection
created_at timestamp 是 — —
updated_at timestamp 是 — —