init
This commit is contained in:
46
api/model/biz_api_token.js
Normal file
46
api/model/biz_api_token.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
module.exports = (db) => {
|
||||
return db.define(
|
||||
"biz_api_token",
|
||||
{
|
||||
id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
user_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
},
|
||||
plan_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: true,
|
||||
comment: "冗余:鉴权时少联表",
|
||||
},
|
||||
token_name: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
token_hash: {
|
||||
type: Sequelize.STRING(64),
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
status: {
|
||||
type: Sequelize.ENUM("active", "revoked", "expired"),
|
||||
allowNull: false,
|
||||
defaultValue: "active",
|
||||
},
|
||||
expire_at: { type: Sequelize.DATE, allowNull: false },
|
||||
last_used_at: { type: Sequelize.DATE, allowNull: true },
|
||||
},
|
||||
{
|
||||
tableName: "biz_api_tokens",
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
comment: "API Token",
|
||||
}
|
||||
);
|
||||
};
|
||||
54
api/model/biz_audit_log.js
Normal file
54
api/model/biz_audit_log.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
module.exports = (db) => {
|
||||
return db.define(
|
||||
"biz_audit_log",
|
||||
{
|
||||
id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
admin_user_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: true,
|
||||
},
|
||||
biz_user_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: true,
|
||||
},
|
||||
action: {
|
||||
type: Sequelize.STRING(64),
|
||||
allowNull: false,
|
||||
},
|
||||
resource_type: {
|
||||
type: Sequelize.STRING(64),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
resource_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: true,
|
||||
},
|
||||
detail: {
|
||||
type: Sequelize.JSON,
|
||||
allowNull: true,
|
||||
},
|
||||
created_at: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
tableName: "biz_audit_log",
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
comment: "审计日志",
|
||||
hooks: {
|
||||
beforeCreate(row) {
|
||||
if (!row.created_at) row.created_at = new Date();
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
56
api/model/biz_plan.js
Normal file
56
api/model/biz_plan.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
module.exports = (db) => {
|
||||
return db.define(
|
||||
"biz_plan",
|
||||
{
|
||||
id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
plan_code: {
|
||||
type: Sequelize.STRING(64),
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
plan_name: {
|
||||
type: Sequelize.STRING(128),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
monthly_price: {
|
||||
type: Sequelize.DECIMAL(12, 2),
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
auth_fee: {
|
||||
type: Sequelize.DECIMAL(12, 2),
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
account_limit: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
active_user_limit: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
msg_quota: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
mass_quota: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
friend_quota: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
sns_quota: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
enabled_features: {
|
||||
type: Sequelize.JSON,
|
||||
allowNull: true,
|
||||
comment: "JSON 功能点白名单",
|
||||
},
|
||||
status: {
|
||||
type: Sequelize.ENUM("active", "inactive"),
|
||||
allowNull: false,
|
||||
defaultValue: "active",
|
||||
},
|
||||
},
|
||||
{
|
||||
tableName: "biz_plans",
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
comment: "套餐",
|
||||
}
|
||||
);
|
||||
};
|
||||
48
api/model/biz_subscription.js
Normal file
48
api/model/biz_subscription.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
module.exports = (db) => {
|
||||
return db.define(
|
||||
"biz_subscription",
|
||||
{
|
||||
id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
user_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
},
|
||||
plan_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
},
|
||||
status: {
|
||||
type: Sequelize.ENUM("pending", "active", "expired", "cancelled"),
|
||||
allowNull: false,
|
||||
defaultValue: "pending",
|
||||
},
|
||||
start_time: { type: Sequelize.DATE, allowNull: false },
|
||||
end_time: { type: Sequelize.DATE, allowNull: false },
|
||||
renew_mode: {
|
||||
type: Sequelize.ENUM("manual", "auto"),
|
||||
allowNull: false,
|
||||
defaultValue: "manual",
|
||||
},
|
||||
payment_channel: {
|
||||
type: Sequelize.ENUM("offline", "pay_link"),
|
||||
allowNull: true,
|
||||
},
|
||||
payment_ref: {
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
tableName: "biz_subscriptions",
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
comment: "订阅",
|
||||
}
|
||||
);
|
||||
};
|
||||
38
api/model/biz_usage_monthly.js
Normal file
38
api/model/biz_usage_monthly.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
module.exports = (db) => {
|
||||
return db.define(
|
||||
"biz_usage_monthly",
|
||||
{
|
||||
id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
user_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
},
|
||||
plan_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
},
|
||||
stat_month: {
|
||||
type: Sequelize.STRING(7),
|
||||
allowNull: false,
|
||||
comment: "YYYY-MM",
|
||||
},
|
||||
msg_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
mass_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
friend_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
sns_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
active_user_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
},
|
||||
{
|
||||
tableName: "biz_usage_monthly",
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
comment: "月用量",
|
||||
}
|
||||
);
|
||||
};
|
||||
45
api/model/biz_user.js
Normal file
45
api/model/biz_user.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
module.exports = (db) => {
|
||||
return db.define(
|
||||
"biz_user",
|
||||
{
|
||||
id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
name: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "姓名/称呼",
|
||||
},
|
||||
mobile: {
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
comment: "手机号",
|
||||
},
|
||||
email: {
|
||||
type: Sequelize.STRING(120),
|
||||
allowNull: true,
|
||||
},
|
||||
company_name: {
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
comment: "公司名",
|
||||
},
|
||||
status: {
|
||||
type: Sequelize.ENUM("active", "disabled"),
|
||||
allowNull: false,
|
||||
defaultValue: "active",
|
||||
},
|
||||
},
|
||||
{
|
||||
tableName: "biz_users",
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
comment: "业务用户",
|
||||
}
|
||||
);
|
||||
};
|
||||
26
api/model/sys_control_type.js
Normal file
26
api/model/sys_control_type.js
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
const Sequelize = require("sequelize");
|
||||
module.exports = (db) => {
|
||||
return db.define("sys_control_type", {
|
||||
name: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "控件名称",
|
||||
},
|
||||
module_key: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "组件key",
|
||||
},
|
||||
data_lenght: {
|
||||
type: Sequelize.INTEGER(11),
|
||||
allowNull: false,
|
||||
defaultValue: "50",
|
||||
comment: "数据长度",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
37
api/model/sys_log.js
Normal file
37
api/model/sys_log.js
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
const Sequelize = require("sequelize");
|
||||
// db日志管理
|
||||
module.exports = (db) => {
|
||||
return db.define("sys_log", {
|
||||
table_name: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "表名",
|
||||
},
|
||||
operate: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "操作",
|
||||
},
|
||||
content: {
|
||||
type: Sequelize.JSON,
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "内容",
|
||||
set(value) {
|
||||
this.setDataValue("content", { value });
|
||||
},
|
||||
get() {
|
||||
let jsonValue = this.getDataValue("content");
|
||||
if (jsonValue && jsonValue.value !== undefined) {
|
||||
return jsonValue.value;
|
||||
} else {
|
||||
return jsonValue;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
96
api/model/sys_menu.js
Normal file
96
api/model/sys_menu.js
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
const Sequelize = require("sequelize");
|
||||
// 菜单表
|
||||
module.exports = (db) => {
|
||||
return db.define("sys_menu", {
|
||||
// 菜单名称
|
||||
name: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "菜单名称",
|
||||
},
|
||||
// 父id
|
||||
parent_id: {
|
||||
type: Sequelize.INTEGER(11).UNSIGNED,
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
comment: "父id",
|
||||
},
|
||||
// 图标
|
||||
icon: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "图标",
|
||||
},
|
||||
path: {
|
||||
type: Sequelize.STRING(255),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "路径",
|
||||
},
|
||||
|
||||
// 菜单类型 "菜单", "页面", "外链", "功能"
|
||||
type: {
|
||||
type: Sequelize.STRING(255),
|
||||
allowNull: false,
|
||||
defaultValue: "页面",
|
||||
comment: "菜单类型",
|
||||
},
|
||||
//模型id
|
||||
model_id: {
|
||||
type: Sequelize.INTEGER(11).UNSIGNED,
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
comment: "模型id",
|
||||
},
|
||||
|
||||
//表单id
|
||||
form_id: {
|
||||
type: Sequelize.INTEGER(11).UNSIGNED,
|
||||
allowNull: true,
|
||||
defaultValue: 0,
|
||||
comment: "表单id",
|
||||
},
|
||||
|
||||
// 组件地址
|
||||
component: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "组件地址",
|
||||
},
|
||||
|
||||
// api地址
|
||||
api_path: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "api地址",
|
||||
},
|
||||
// 是否显示在菜单中
|
||||
is_show_menu: {
|
||||
type: Sequelize.INTEGER(1),
|
||||
allowNull: false,
|
||||
defaultValue: true,
|
||||
comment: "是否显示在菜单中",
|
||||
},
|
||||
is_show: {
|
||||
type: Sequelize.INTEGER(1),
|
||||
allowNull: false,
|
||||
defaultValue: true,
|
||||
comment: "是否展示",
|
||||
},
|
||||
|
||||
// 菜单类型
|
||||
sort: {
|
||||
type: Sequelize.INTEGER(11),
|
||||
allowNull: false,
|
||||
defaultValue: "0",
|
||||
comment: "菜单类型",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
37
api/model/sys_parameter.js
Normal file
37
api/model/sys_parameter.js
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
const Sequelize = require("sequelize");
|
||||
// 字典表
|
||||
module.exports = (db) => {
|
||||
return db.define("sys_parameter", {
|
||||
key: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "字典key",
|
||||
},
|
||||
|
||||
value: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "值",
|
||||
},
|
||||
|
||||
remark: {
|
||||
type: Sequelize.STRING(500),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "备注",
|
||||
},
|
||||
|
||||
// 是否允许修改 0 允许,1 不允许
|
||||
is_modified: {
|
||||
type: Sequelize.INTEGER(2),
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: "是否允许修改",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
41
api/model/sys_role.js
Normal file
41
api/model/sys_role.js
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
const Sequelize = require("sequelize");
|
||||
//角色表
|
||||
module.exports = (db) => {
|
||||
return db.define("sys_role", {
|
||||
name: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "角色名称",
|
||||
},
|
||||
// 0 普通角色 1 系统角色
|
||||
type: {
|
||||
type: Sequelize.INTEGER(1),
|
||||
allowNull: false,
|
||||
defaultValue: "0",
|
||||
comment: "角色类型",
|
||||
},
|
||||
menus: {
|
||||
type: Sequelize.JSON,
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "权限菜单",
|
||||
set(value) {
|
||||
this.setDataValue('menus', { value });
|
||||
},
|
||||
get() {
|
||||
let jsonValue = this.getDataValue("menus")
|
||||
if (jsonValue && jsonValue.value !== undefined) {
|
||||
|
||||
return jsonValue.value;
|
||||
}
|
||||
else {
|
||||
return jsonValue
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
26
api/model/sys_user.js
Normal file
26
api/model/sys_user.js
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
const Sequelize = require("sequelize");
|
||||
// 系统用户表
|
||||
module.exports = (db) => {
|
||||
return db.define("sys_user", {
|
||||
name: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "名称",
|
||||
},
|
||||
password: {
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: false,
|
||||
defaultValue: "",
|
||||
comment: "密码",
|
||||
},
|
||||
roleId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
comment: "角色id",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user