2025-12-25 10:48:35 +08:00
|
|
|
const { DataTypes } = require('sequelize');
|
|
|
|
|
const { sequelize } = require('../db');
|
|
|
|
|
|
2026-03-27 19:12:16 +08:00
|
|
|
const Permission = sequelize.define(
|
|
|
|
|
'Permission',
|
|
|
|
|
{
|
|
|
|
|
permissionId: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
primaryKey: true,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
},
|
|
|
|
|
permissionName: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
},
|
|
|
|
|
permissionCode: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
unique: true,
|
|
|
|
|
},
|
|
|
|
|
parentId: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
type: {
|
|
|
|
|
type: DataTypes.ENUM('menu', 'button'),
|
|
|
|
|
defaultValue: 'button',
|
|
|
|
|
},
|
|
|
|
|
path: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
icon: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
},
|
|
|
|
|
sort: {
|
|
|
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
defaultValue: 0,
|
|
|
|
|
},
|
|
|
|
|
status: {
|
|
|
|
|
type: DataTypes.ENUM('active', 'inactive'),
|
|
|
|
|
defaultValue: 'active',
|
|
|
|
|
},
|
2025-12-25 10:48:35 +08:00
|
|
|
},
|
2026-03-27 19:12:16 +08:00
|
|
|
{
|
|
|
|
|
tableName: 'permissions',
|
|
|
|
|
timestamps: true,
|
2025-12-25 10:48:35 +08:00
|
|
|
}
|
2026-03-27 19:12:16 +08:00
|
|
|
);
|
2025-12-25 10:48:35 +08:00
|
|
|
|
|
|
|
|
module.exports = Permission;
|