rentease-backend/models/Menu.js

89 lines
1.9 KiB
JavaScript
Raw Permalink 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 { DataTypes } = require('sequelize');
const sequelize = require('../config/db');
const Menu = sequelize.define('Menu', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
parentId: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
comment: '父菜单IDnull表示顶级菜单'
},
name: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '菜单名称'
},
code: {
type: DataTypes.STRING(50),
allowNull: false,
unique: true,
comment: '菜单编码'
},
type: {
type: DataTypes.ENUM('menu', 'button'),
allowNull: false,
defaultValue: 'menu',
comment: '类型menu-菜单button-按钮'
},
path: {
type: DataTypes.STRING(200),
allowNull: true,
comment: '路由路径'
},
component: {
type: DataTypes.STRING(200),
allowNull: true,
comment: '组件路径'
},
icon: {
type: DataTypes.STRING(50),
allowNull: true,
comment: '菜单图标'
},
sort: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '排序号'
},
visible: {
type: DataTypes.ENUM('show', 'hide'),
allowNull: false,
defaultValue: 'show',
comment: '是否显示show-显示hide-隐藏'
},
status: {
type: DataTypes.ENUM('active', 'disabled'),
allowNull: false,
defaultValue: 'active',
comment: '状态active-启用disabled-禁用'
},
createBy: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '创建人ID'
},
updateBy: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '修改人ID'
},
isDeleted: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
comment: '是否删除true-已删除false-未删除'
}
}, {
tableName: 'menus',
timestamps: true,
comment: '菜单表'
});
module.exports = Menu;