Files
wechatWeb/api/model/biz_api_token.js
张成 50bb0bc6ad 1
2026-04-01 15:02:45 +08:00

57 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const Sequelize = require("sequelize");
/**
* 业务 API Token管理端页面admin/src/views/subscription/tokens.vue
* 动态路由 component 与 admin/src/router/component-map.js 中
* subscription/token 或 subscription/biz_api_token 对应。
*/
module.exports = (db) => {
const biz_api_token = db.define(
"biz_api_token",
{
user_id: {
type: Sequelize.BIGINT.UNSIGNED,
allowNull: false,
},
plan_id: {
type: Sequelize.BIGINT.UNSIGNED,
allowNull: true,
},
token_name: {
type: Sequelize.STRING(100),
allowNull: false,
defaultValue: "",
},
key: {
type: Sequelize.STRING(128),
allowNull: true,
},
token_hash: {
type: Sequelize.STRING(64),
allowNull: false,
unique: true,
},
secret_cipher: {
type: Sequelize.TEXT,
allowNull: 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_token",
freezeTableName: true,
timestamps: false,
underscored: true,
}
);
//biz_api_token.sync({ force: true });
return biz_api_token;
};