refactor(models): convert to json format per database-table-definition-spec

This commit is contained in:
Hermes Agent 2026-05-27 13:23:31 +08:00
parent 40c480e488
commit 781216e11a
7 changed files with 884 additions and 807 deletions

View File

@ -3,119 +3,134 @@
{ {
"name": "accounting_records", "name": "accounting_records",
"title": "记账记录", "title": "记账记录",
"primary": "id", "primary": [
"id"
],
"classification": "business" "classification": "business"
} }
], ],
"fields": [ "fields": [
{ {
"name": "id", "name": "id",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "主键" "comment": "主键",
"length": 32
}, },
{ {
"name": "customer_id", "name": "customer_id",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "客户ID" "comment": "客户ID",
"length": 32
}, },
{ {
"name": "llmid", "name": "llmid",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "模型ID" "comment": "模型ID",
"length": 32
}, },
{ {
"name": "model_name", "name": "model_name",
"type": "VARCHAR(128)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "模型名称" "comment": "模型名称",
"length": 128
}, },
{ {
"name": "pricing_id", "name": "pricing_id",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "定价ID" "comment": "定价ID",
"length": 32
}, },
{ {
"name": "input_tokens", "name": "input_tokens",
"type": "BIGINT", "type": "long",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "输入token数" "comment": "输入token数"
}, },
{ {
"name": "output_tokens", "name": "output_tokens",
"type": "BIGINT", "type": "long",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "输出token数" "comment": "输出token数"
}, },
{ {
"name": "total_tokens", "name": "total_tokens",
"type": "BIGINT", "type": "long",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "总token数" "comment": "总token数"
}, },
{ {
"name": "quantity", "name": "quantity",
"type": "DECIMAL(15,4)", "type": "double",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "用量(图片数/分钟数等)" "comment": "用量(图片数/分钟数等)",
"length": 15,
"dec": 4
}, },
{ {
"name": "amount", "name": "amount",
"type": "DECIMAL(15,6)", "type": "double",
"nullable": false, "nullable": false,
"default": 0.0, "default": 0.0,
"comment": "金额" "comment": "金额",
"length": 15,
"dec": 6
}, },
{ {
"name": "currency", "name": "currency",
"type": "VARCHAR(8)", "type": "str",
"nullable": false, "nullable": false,
"default": "CNY", "default": "CNY",
"comment": "货币单位" "comment": "货币单位",
"length": 8
}, },
{ {
"name": "request_id", "name": "request_id",
"type": "VARCHAR(64)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "请求ID幂等键" "comment": "请求ID幂等键",
"length": 64
}, },
{ {
"name": "transno", "name": "transno",
"type": "VARCHAR(64)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "事务号" "comment": "事务号",
"length": 64
}, },
{ {
"name": "status", "name": "status",
"type": "VARCHAR(16)", "type": "str",
"nullable": false, "nullable": false,
"default": "pending", "default": "pending",
"comment": "状态: pending/accounted/failed" "comment": "状态: pending/accounted/failed",
"length": 16
}, },
{ {
"name": "created_at", "name": "created_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "创建时间" "comment": "创建时间"
}, },
{ {
"name": "updated_at", "name": "updated_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "更新时间" "comment": "更新时间"

View File

@ -3,70 +3,80 @@
{ {
"name": "customer_balance", "name": "customer_balance",
"title": "客户余额缓存", "title": "客户余额缓存",
"primary": "id", "primary": [
"id"
],
"classification": "cache" "classification": "cache"
} }
], ],
"fields": [ "fields": [
{ {
"name": "id", "name": "id",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "主键,即 customer_id" "comment": "主键,即 customer_id",
"length": 32
}, },
{ {
"name": "balance", "name": "balance",
"type": "DECIMAL(15,4)", "type": "double",
"nullable": false, "nullable": false,
"default": 0.0, "default": 0.0,
"comment": "当前余额" "comment": "当前余额",
"length": 15,
"dec": 4
}, },
{ {
"name": "currency", "name": "currency",
"type": "VARCHAR(8)", "type": "str",
"nullable": false, "nullable": false,
"default": "CNY", "default": "CNY",
"comment": "货币单位" "comment": "货币单位",
"length": 8
}, },
{ {
"name": "credit_limit", "name": "credit_limit",
"type": "DECIMAL(15,4)", "type": "double",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "信用额度" "comment": "信用额度",
"length": 15,
"dec": 4
}, },
{ {
"name": "last_recharge", "name": "last_recharge",
"type": "DATETIME", "type": "datetime",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "最后充值时间" "comment": "最后充值时间"
}, },
{ {
"name": "last_consumption", "name": "last_consumption",
"type": "DATETIME", "type": "datetime",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "最后消费时间" "comment": "最后消费时间"
}, },
{ {
"name": "status", "name": "status",
"type": "VARCHAR(16)", "type": "str",
"nullable": false, "nullable": false,
"default": "active", "default": "active",
"comment": "状态: active/suspended/arrears" "comment": "状态: active/suspended/arrears",
"length": 16
}, },
{ {
"name": "sync_version", "name": "sync_version",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "同步版本号" "comment": "同步版本号",
"length": 32
}, },
{ {
"name": "cached_at", "name": "cached_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "缓存更新时间" "comment": "缓存更新时间"

View File

@ -3,84 +3,94 @@
{ {
"name": "llmage_cache", "name": "llmage_cache",
"title": "模型API映射缓存", "title": "模型API映射缓存",
"primary": "id", "primary": [
"id"
],
"classification": "cache" "classification": "cache"
} }
], ],
"fields": [ "fields": [
{ {
"name": "id", "name": "id",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "主键" "comment": "主键",
"length": 32
}, },
{ {
"name": "llmid", "name": "llmid",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "关联模型ID" "comment": "关联模型ID",
"length": 32
}, },
{ {
"name": "model_name", "name": "model_name",
"type": "VARCHAR(128)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "模型名称" "comment": "模型名称",
"length": 128
}, },
{ {
"name": "upappid", "name": "upappid",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "上游应用ID" "comment": "上游应用ID",
"length": 32
}, },
{ {
"name": "apiname", "name": "apiname",
"type": "VARCHAR(128)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "API名称" "comment": "API名称",
"length": 128
}, },
{ {
"name": "api_url", "name": "api_url",
"type": "VARCHAR(512)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "API端点URL" "comment": "API端点URL",
"length": 512
}, },
{ {
"name": "api_params", "name": "api_params",
"type": "TEXT", "type": "text",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "API参数配置JSON" "comment": "API参数配置JSON"
}, },
{ {
"name": "model_params", "name": "model_params",
"type": "TEXT", "type": "text",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "模型参数配置JSONmax_tokens, temperature等" "comment": "模型参数配置JSONmax_tokens, temperature等"
}, },
{ {
"name": "status", "name": "status",
"type": "VARCHAR(16)", "type": "str",
"nullable": false, "nullable": false,
"default": "active", "default": "active",
"comment": "状态: active/inactive" "comment": "状态: active/inactive",
"length": 16
}, },
{ {
"name": "sync_version", "name": "sync_version",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "同步版本号" "comment": "同步版本号",
"length": 32
}, },
{ {
"name": "cached_at", "name": "cached_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "缓存写入时间" "comment": "缓存写入时间"

View File

@ -3,98 +3,113 @@
{ {
"name": "pricing_cache", "name": "pricing_cache",
"title": "定价数据缓存", "title": "定价数据缓存",
"primary": "id", "primary": [
"id"
],
"classification": "cache" "classification": "cache"
} }
], ],
"fields": [ "fields": [
{ {
"name": "id", "name": "id",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "主键,对应 pricing_program id (ppid)" "comment": "主键,对应 pricing_program id (ppid)",
"length": 32
}, },
{ {
"name": "llmid", "name": "llmid",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "关联模型ID" "comment": "关联模型ID",
"length": 32
}, },
{ {
"name": "model_name", "name": "model_name",
"type": "VARCHAR(128)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "模型名称" "comment": "模型名称",
"length": 128
}, },
{ {
"name": "pricing_type", "name": "pricing_type",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "计费类型: token/image/video/audio" "comment": "计费类型: token/image/video/audio",
"length": 32
}, },
{ {
"name": "input_price", "name": "input_price",
"type": "DECIMAL(10,6)", "type": "double",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "输入单价每千token" "comment": "输入单价每千token",
"length": 10,
"dec": 6
}, },
{ {
"name": "output_price", "name": "output_price",
"type": "DECIMAL(10,6)", "type": "double",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "输出单价每千token" "comment": "输出单价每千token",
"length": 10,
"dec": 6
}, },
{ {
"name": "unit_price", "name": "unit_price",
"type": "DECIMAL(10,6)", "type": "double",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "统一单价(按次/按图/按分钟等)" "comment": "统一单价(按次/按图/按分钟等)",
"length": 10,
"dec": 6
}, },
{ {
"name": "currency", "name": "currency",
"type": "VARCHAR(8)", "type": "str",
"nullable": false, "nullable": false,
"default": "CNY", "default": "CNY",
"comment": "货币单位" "comment": "货币单位",
"length": 8
}, },
{ {
"name": "status", "name": "status",
"type": "VARCHAR(16)", "type": "str",
"nullable": false, "nullable": false,
"default": "active", "default": "active",
"comment": "状态: active/inactive/deprecated" "comment": "状态: active/inactive/deprecated",
"length": 16
}, },
{ {
"name": "effective_from", "name": "effective_from",
"type": "DATETIME", "type": "datetime",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "生效时间" "comment": "生效时间"
}, },
{ {
"name": "effective_to", "name": "effective_to",
"type": "DATETIME", "type": "datetime",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "失效时间" "comment": "失效时间"
}, },
{ {
"name": "sync_version", "name": "sync_version",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "同步版本号" "comment": "同步版本号",
"length": 32
}, },
{ {
"name": "cached_at", "name": "cached_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "缓存写入时间" "comment": "缓存写入时间"

View File

@ -3,77 +3,84 @@
{ {
"name": "sync_state", "name": "sync_state",
"title": "同步状态跟踪", "title": "同步状态跟踪",
"primary": "id", "primary": [
"id"
],
"classification": "system" "classification": "system"
} }
], ],
"fields": [ "fields": [
{ {
"name": "id", "name": "id",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "主键" "comment": "主键",
"length": 32
}, },
{ {
"name": "entity_type", "name": "entity_type",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "实体类型: users/pricing/llmage/uapi" "comment": "实体类型: users/pricing/llmage/uapi",
"length": 32
}, },
{ {
"name": "entity_id", "name": "entity_id",
"type": "VARCHAR(64)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "实体标识(全量同步时为空)" "comment": "实体标识(全量同步时为空)",
"length": 64
}, },
{ {
"name": "last_sync_time", "name": "last_sync_time",
"type": "DATETIME", "type": "datetime",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "最后同步时间" "comment": "最后同步时间"
}, },
{ {
"name": "sync_version", "name": "sync_version",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "Sage返回的版本标识" "comment": "Sage返回的版本标识",
"length": 32
}, },
{ {
"name": "sync_status", "name": "sync_status",
"type": "VARCHAR(16)", "type": "str",
"nullable": false, "nullable": false,
"default": "success", "default": "success",
"comment": "同步状态: success/pending/failed" "comment": "同步状态: success/pending/failed",
"length": 16
}, },
{ {
"name": "error_msg", "name": "error_msg",
"type": "TEXT", "type": "text",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "失败原因" "comment": "失败原因"
}, },
{ {
"name": "retry_count", "name": "retry_count",
"type": "INT", "type": "int",
"nullable": false, "nullable": false,
"default": 0, "default": 0,
"comment": "重试次数" "comment": "重试次数"
}, },
{ {
"name": "created_at", "name": "created_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "创建时间" "comment": "创建时间"
}, },
{ {
"name": "updated_at", "name": "updated_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "更新时间" "comment": "更新时间"

View File

@ -3,84 +3,94 @@
{ {
"name": "uapi_cache", "name": "uapi_cache",
"title": "uapi定义缓存", "title": "uapi定义缓存",
"primary": "id", "primary": [
"id"
],
"classification": "cache" "classification": "cache"
} }
], ],
"fields": [ "fields": [
{ {
"name": "id", "name": "id",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "主键" "comment": "主键",
"length": 32
}, },
{ {
"name": "upappid", "name": "upappid",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "上游应用ID" "comment": "上游应用ID",
"length": 32
}, },
{ {
"name": "apiname", "name": "apiname",
"type": "VARCHAR(128)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "API名称" "comment": "API名称",
"length": 128
}, },
{ {
"name": "method", "name": "method",
"type": "VARCHAR(16)", "type": "str",
"nullable": true, "nullable": true,
"default": "POST", "default": "POST",
"comment": "HTTP方法" "comment": "HTTP方法",
"length": 16
}, },
{ {
"name": "endpoint", "name": "endpoint",
"type": "VARCHAR(512)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "API端点" "comment": "API端点",
"length": 512
}, },
{ {
"name": "auth_type", "name": "auth_type",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "bearer", "default": "bearer",
"comment": "认证类型" "comment": "认证类型",
"length": 32
}, },
{ {
"name": "rate_limit", "name": "rate_limit",
"type": "INT", "type": "int",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "速率限制(次/分钟)" "comment": "速率限制(次/分钟)"
}, },
{ {
"name": "description", "name": "description",
"type": "TEXT", "type": "text",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "API描述" "comment": "API描述"
}, },
{ {
"name": "status", "name": "status",
"type": "VARCHAR(16)", "type": "str",
"nullable": false, "nullable": false,
"default": "active", "default": "active",
"comment": "状态" "comment": "状态",
"length": 16
}, },
{ {
"name": "sync_version", "name": "sync_version",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "同步版本号" "comment": "同步版本号",
"length": 32
}, },
{ {
"name": "cached_at", "name": "cached_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "缓存写入时间" "comment": "缓存写入时间"

View File

@ -3,84 +3,94 @@
{ {
"name": "users_cache", "name": "users_cache",
"title": "用户数据缓存", "title": "用户数据缓存",
"primary": "id", "primary": [
"id"
],
"classification": "cache" "classification": "cache"
} }
], ],
"fields": [ "fields": [
{ {
"name": "id", "name": "id",
"type": "VARCHAR(32)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "主键,对应 users 表 id" "comment": "主键,对应 users 表 id",
"length": 32
}, },
{ {
"name": "username", "name": "username",
"type": "VARCHAR(128)", "type": "str",
"nullable": false, "nullable": false,
"default": "", "default": "",
"comment": "用户名" "comment": "用户名",
"length": 128
}, },
{ {
"name": "orgid", "name": "orgid",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "组织ID" "comment": "组织ID",
"length": 32
}, },
{ {
"name": "orgname", "name": "orgname",
"type": "VARCHAR(255)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "组织名称" "comment": "组织名称",
"length": 255
}, },
{ {
"name": "email", "name": "email",
"type": "VARCHAR(128)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "邮箱" "comment": "邮箱",
"length": 128
}, },
{ {
"name": "phone", "name": "phone",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "手机号" "comment": "手机号",
"length": 32
}, },
{ {
"name": "status", "name": "status",
"type": "VARCHAR(16)", "type": "str",
"nullable": false, "nullable": false,
"default": "active", "default": "active",
"comment": "状态: active/inactive/suspended" "comment": "状态: active/inactive/suspended",
"length": 16
}, },
{ {
"name": "created_at", "name": "created_at",
"type": "DATETIME", "type": "datetime",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "创建时间" "comment": "创建时间"
}, },
{ {
"name": "updated_at", "name": "updated_at",
"type": "DATETIME", "type": "datetime",
"nullable": true, "nullable": true,
"default": null, "default": null,
"comment": "更新时间" "comment": "更新时间"
}, },
{ {
"name": "sync_version", "name": "sync_version",
"type": "VARCHAR(32)", "type": "str",
"nullable": true, "nullable": true,
"default": "", "default": "",
"comment": "同步版本号" "comment": "同步版本号",
"length": 32
}, },
{ {
"name": "cached_at", "name": "cached_at",
"type": "DATETIME", "type": "datetime",
"nullable": false, "nullable": false,
"default": "CURRENT_TIMESTAMP", "default": "CURRENT_TIMESTAMP",
"comment": "缓存写入时间" "comment": "缓存写入时间"