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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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