27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 菜单模型,对应 menus 表(通用菜单,不区分主体)
|
||
* @param {Egg.Application} app egg application
|
||
* @return {object} menu model
|
||
*/
|
||
module.exports = app => {
|
||
const { BIGINT, STRING, TINYINT, INTEGER, DATE } = app.Sequelize;
|
||
|
||
const Menu = app.model.define('menu', {
|
||
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
|
||
parent_id: { type: BIGINT.UNSIGNED, allowNull: false, defaultValue: 0, comment: '父菜单ID,0 为根节点' },
|
||
name: { type: STRING(50), allowNull: false, comment: '菜单名称' },
|
||
type: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '类型:1目录 2菜单 3按钮' },
|
||
path: { type: STRING(200), comment: '前端路由/地址' },
|
||
icon: { type: STRING(100), comment: '图标' },
|
||
permission: { type: STRING(100), comment: '权限标识,如 order:create' },
|
||
sort: { type: INTEGER, allowNull: false, defaultValue: 0, comment: '排序' },
|
||
status: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' },
|
||
created_at: { type: DATE, comment: '创建时间' },
|
||
updated_at: { type: DATE, comment: '更新时间' },
|
||
});
|
||
|
||
return Menu;
|
||
};
|