This commit is contained in:
张成
2026-04-01 10:42:33 +08:00
parent 7199c6b5cf
commit 433077f08a
14 changed files with 10 additions and 76 deletions

2
.vscode/launch.json vendored
View File

@@ -1,7 +1,7 @@
{ {
"configurations": [ "configurations": [
{ {
"name": "启动", "name": "启动后端",
"program": "${workspaceFolder}/app.js", "program": "${workspaceFolder}/app.js",
"request": "launch", "request": "launch",
"skipFiles": [ "skipFiles": [

View File

@@ -8,17 +8,14 @@ module.exports = (db) => {
user_id: { user_id: {
type: Sequelize.BIGINT.UNSIGNED, type: Sequelize.BIGINT.UNSIGNED,
allowNull: false, allowNull: false,
comment: "业务用户ID",
}, },
token_id: { token_id: {
type: Sequelize.BIGINT.UNSIGNED, type: Sequelize.BIGINT.UNSIGNED,
allowNull: false, allowNull: false,
comment: "使用的Token ID",
}, },
api_path: { api_path: {
type: Sequelize.STRING(200), type: Sequelize.STRING(200),
allowNull: false, allowNull: false,
comment: "接口路径,如 /user/GetProfile",
}, },
http_method: { http_method: {
type: Sequelize.STRING(10), type: Sequelize.STRING(10),
@@ -29,18 +26,15 @@ module.exports = (db) => {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
allowNull: false, allowNull: false,
defaultValue: 0, defaultValue: 0,
comment: "上游返回的HTTP状态码",
}, },
response_time: { response_time: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
allowNull: false, allowNull: false,
defaultValue: 0, defaultValue: 0,
comment: "上游响应耗时ms",
}, },
call_date: { call_date: {
type: Sequelize.DATEONLY, type: Sequelize.DATEONLY,
allowNull: false, allowNull: false,
comment: "调用日期,方便按天统计",
}, },
created_at: { created_at: {
type: Sequelize.DATE, type: Sequelize.DATE,
@@ -48,17 +42,7 @@ module.exports = (db) => {
defaultValue: Sequelize.NOW, defaultValue: Sequelize.NOW,
}, },
}, },
{
tableName: "biz_api_call_log",
timestamps: false,
underscored: true,
comment: "API调用日志",
indexes: [
{ fields: ["user_id", "call_date"], name: "idx_user_date" },
{ fields: ["api_path", "call_date"], name: "idx_api_date" },
{ fields: ["user_id", "api_path"], name: "idx_user_api" },
],
}
); );
return biz_api_call_log; return biz_api_call_log;
}; };

View File

@@ -12,7 +12,6 @@ module.exports = (db) => {
plan_id: { plan_id: {
type: Sequelize.BIGINT.UNSIGNED, type: Sequelize.BIGINT.UNSIGNED,
allowNull: true, allowNull: true,
comment: "冗余:鉴权时少联表",
}, },
token_name: { token_name: {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
@@ -32,12 +31,6 @@ module.exports = (db) => {
expire_at: { type: Sequelize.DATE, allowNull: false }, expire_at: { type: Sequelize.DATE, allowNull: false },
last_used_at: { type: Sequelize.DATE, allowNull: true }, last_used_at: { type: Sequelize.DATE, allowNull: true },
}, },
{
tableName: "biz_api_tokens",
timestamps: false,
underscored: true,
comment: "API Token",
}
); );
// biz_api_token.sync({ force: true }); // biz_api_token.sync({ force: true });
return biz_api_token; return biz_api_token;

View File

@@ -35,7 +35,6 @@ module.exports = (db) => {
tableName: "biz_audit_log", tableName: "biz_audit_log",
timestamps: false, timestamps: false,
underscored: true, underscored: true,
comment: "审计日志",
} }
); );
// biz_audit_log.sync({ alter: true }); // biz_audit_log.sync({ alter: true });

View File

@@ -34,18 +34,15 @@ module.exports = (db) => {
enabled_features: { enabled_features: {
type: Sequelize.JSON, type: Sequelize.JSON,
allowNull: true, allowNull: true,
comment: "JSON 功能点白名单",
}, },
allowed_apis: { allowed_apis: {
type: Sequelize.JSON, type: Sequelize.JSON,
allowNull: true, allowNull: true,
comment: "可访问的接口路径列表,如 [\"/user/GetProfile\",\"/message/SendText\"]null 表示不限制",
}, },
api_call_quota: { api_call_quota: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
allowNull: false, allowNull: false,
defaultValue: 0, defaultValue: 0,
comment: "每月 API 总调用次数上限0=不限制",
}, },
status: { status: {
type: Sequelize.ENUM("active", "inactive"), type: Sequelize.ENUM("active", "inactive"),
@@ -57,7 +54,6 @@ module.exports = (db) => {
tableName: "biz_plans", tableName: "biz_plans",
timestamps: false, timestamps: false,
underscored: true, underscored: true,
comment: "套餐",
} }
); );
// biz_plan.sync({ alter: true }); // biz_plan.sync({ alter: true });

View File

@@ -38,7 +38,6 @@ module.exports = (db) => {
tableName: "biz_subscriptions", tableName: "biz_subscriptions",
timestamps: false, timestamps: false,
underscored: true, underscored: true,
comment: "订阅",
} }
); );
// biz_subscription.sync({ alter: true }); // biz_subscription.sync({ alter: true });

View File

@@ -16,7 +16,6 @@ module.exports = (db) => {
stat_month: { stat_month: {
type: Sequelize.STRING(7), type: Sequelize.STRING(7),
allowNull: false, allowNull: false,
comment: "YYYY-MM",
}, },
msg_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 }, msg_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
mass_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 }, mass_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
@@ -27,14 +26,11 @@ module.exports = (db) => {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
allowNull: false, allowNull: false,
defaultValue: 0, defaultValue: 0,
comment: "当月 API 转发总调用次数",
}, },
}, },
{ {
tableName: "biz_usage_monthly",
timestamps: false, timestamps: false,
underscored: true, underscored: true,
comment: "月用量",
} }
); );
// biz_usage_monthly.sync({ alter: true }); // biz_usage_monthly.sync({ alter: true });

View File

@@ -9,12 +9,10 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "姓名/称呼",
}, },
mobile: { mobile: {
type: Sequelize.STRING(20), type: Sequelize.STRING(20),
allowNull: true, allowNull: true,
comment: "手机号",
}, },
email: { email: {
type: Sequelize.STRING(120), type: Sequelize.STRING(120),
@@ -23,7 +21,6 @@ module.exports = (db) => {
company_name: { company_name: {
type: Sequelize.STRING(200), type: Sequelize.STRING(200),
allowNull: true, allowNull: true,
comment: "公司名",
}, },
status: { status: {
type: Sequelize.ENUM("active", "disabled"), type: Sequelize.ENUM("active", "disabled"),
@@ -32,12 +29,10 @@ module.exports = (db) => {
}, },
}, },
{ {
// 与库表名一致:单数 biz_user与模型名一致避免部分环境下 tableName 未生效时落到默认表名 biz_user
tableName: "biz_user", tableName: "biz_user",
freezeTableName: true, freezeTableName: true,
timestamps: false, timestamps: false,
underscored: true, underscored: true,
comment: "业务用户",
} }
); );
// biz_user.sync({ alter: true }); // biz_user.sync({ alter: true });

View File

@@ -6,19 +6,16 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "控件名称",
}, },
module_key: { module_key: {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "组件key",
}, },
data_lenght: { data_lenght: {
type: Sequelize.INTEGER(11), type: Sequelize.INTEGER(11),
allowNull: false, allowNull: false,
defaultValue: "50", defaultValue: "50",
comment: "数据长度",
}, },
}); });
}; };

View File

@@ -7,19 +7,16 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "表名",
}, },
operate: { operate: {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "操作",
}, },
content: { content: {
type: Sequelize.JSON, type: Sequelize.JSON,
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "内容",
set(value) { set(value) {
this.setDataValue("content", { value }); this.setDataValue("content", { value });
}, },

View File

@@ -8,27 +8,23 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "菜单名称",
}, },
// 父id // 父id
parent_id: { parent_id: {
type: Sequelize.INTEGER(11).UNSIGNED, type: Sequelize.INTEGER(11).UNSIGNED,
allowNull: true, allowNull: true,
defaultValue: 0, defaultValue: 0,
comment: "父id",
}, },
// 图标 // 图标
icon: { icon: {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "图标",
}, },
path: { path: {
type: Sequelize.STRING(255), type: Sequelize.STRING(255),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "路径",
}, },
// 菜单类型 "菜单", "页面", "外链", "功能" // 菜单类型 "菜单", "页面", "外链", "功能"
@@ -36,14 +32,12 @@ module.exports = (db) => {
type: Sequelize.STRING(255), type: Sequelize.STRING(255),
allowNull: false, allowNull: false,
defaultValue: "页面", defaultValue: "页面",
comment: "菜单类型",
}, },
//模型id //模型id
model_id: { model_id: {
type: Sequelize.INTEGER(11).UNSIGNED, type: Sequelize.INTEGER(11).UNSIGNED,
allowNull: true, allowNull: true,
defaultValue: 0, defaultValue: 0,
comment: "模型id",
}, },
//表单id //表单id
@@ -51,7 +45,6 @@ module.exports = (db) => {
type: Sequelize.INTEGER(11).UNSIGNED, type: Sequelize.INTEGER(11).UNSIGNED,
allowNull: true, allowNull: true,
defaultValue: 0, defaultValue: 0,
comment: "表单id",
}, },
// 组件地址 // 组件地址
@@ -59,7 +52,6 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "组件地址",
}, },
// api地址 // api地址
@@ -67,20 +59,17 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "api地址",
}, },
// 是否显示在菜单中 // 是否显示在菜单中
is_show_menu: { is_show_menu: {
type: Sequelize.INTEGER(1), type: Sequelize.INTEGER(1),
allowNull: false, allowNull: false,
defaultValue: true, defaultValue: true,
comment: "是否显示在菜单中",
}, },
is_show: { is_show: {
type: Sequelize.INTEGER(1), type: Sequelize.INTEGER(1),
allowNull: false, allowNull: false,
defaultValue: true, defaultValue: true,
comment: "是否展示",
}, },
// 菜单类型 // 菜单类型
@@ -88,7 +77,6 @@ module.exports = (db) => {
type: Sequelize.INTEGER(11), type: Sequelize.INTEGER(11),
allowNull: false, allowNull: false,
defaultValue: "0", defaultValue: "0",
comment: "菜单类型",
}, },
}); });
}; };

View File

@@ -7,21 +7,18 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "字典key",
}, },
value: { value: {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "值",
}, },
remark: { remark: {
type: Sequelize.STRING(500), type: Sequelize.STRING(500),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "备注",
}, },
// 是否允许修改 0 允许1 不允许 // 是否允许修改 0 允许1 不允许
@@ -29,7 +26,6 @@ module.exports = (db) => {
type: Sequelize.INTEGER(2), type: Sequelize.INTEGER(2),
allowNull: false, allowNull: false,
defaultValue: 0, defaultValue: 0,
comment: "是否允许修改",
}, },
}); });
}; };

View File

@@ -7,20 +7,17 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "角色名称",
}, },
// 0 普通角色 1 系统角色 // 0 普通角色 1 系统角色
type: { type: {
type: Sequelize.INTEGER(1), type: Sequelize.INTEGER(1),
allowNull: false, allowNull: false,
defaultValue: "0", defaultValue: "0",
comment: "角色类型",
}, },
menus: { menus: {
type: Sequelize.JSON, type: Sequelize.JSON,
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "权限菜单",
set(value) { set(value) {
this.setDataValue('menus', { value }); this.setDataValue('menus', { value });
}, },

View File

@@ -7,18 +7,15 @@ module.exports = (db) => {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "名称",
}, },
password: { password: {
type: Sequelize.STRING(100), type: Sequelize.STRING(100),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
comment: "密码",
}, },
roleId: { roleId: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
allowNull: false, allowNull: false,
comment: "角色id",
}, },
}); });
}; };