1
This commit is contained in:
68
api/model/biz_api_call_log.js
Normal file
68
api/model/biz_api_call_log.js
Normal file
@@ -0,0 +1,68 @@
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
module.exports = (db) => {
|
||||
const biz_api_call_log = db.define(
|
||||
"biz_api_call_log",
|
||||
{
|
||||
id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
user_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
comment: "业务用户ID",
|
||||
},
|
||||
token_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
comment: "使用的Token ID",
|
||||
},
|
||||
api_path: {
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: false,
|
||||
comment: "接口路径,如 /user/GetProfile",
|
||||
},
|
||||
http_method: {
|
||||
type: Sequelize.STRING(10),
|
||||
allowNull: false,
|
||||
defaultValue: "POST",
|
||||
},
|
||||
status_code: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: "上游返回的HTTP状态码",
|
||||
},
|
||||
response_time: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: "上游响应耗时ms",
|
||||
},
|
||||
call_date: {
|
||||
type: Sequelize.DATEONLY,
|
||||
allowNull: false,
|
||||
comment: "调用日期,方便按天统计",
|
||||
},
|
||||
created_at: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: false,
|
||||
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;
|
||||
};
|
||||
@@ -40,6 +40,17 @@ module.exports = (db) => {
|
||||
allowNull: true,
|
||||
comment: "JSON 功能点白名单",
|
||||
},
|
||||
allowed_apis: {
|
||||
type: Sequelize.JSON,
|
||||
allowNull: true,
|
||||
comment: "可访问的接口路径列表,如 [\"/user/GetProfile\",\"/message/SendText\"],null 表示不限制",
|
||||
},
|
||||
api_call_quota: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: "每月 API 总调用次数上限,0=不限制",
|
||||
},
|
||||
status: {
|
||||
type: Sequelize.ENUM("active", "inactive"),
|
||||
allowNull: false,
|
||||
|
||||
Reference in New Issue
Block a user