rentease-backend/models/Role.js

61 lines
1.2 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 Role = sequelize.define('Role', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: DataTypes.STRING(50),
allowNull: false,
unique: true,
comment: '角色名称'
},
code: {
type: DataTypes.STRING(50),
allowNull: false,
unique: true,
comment: '角色编码'
},
description: {
type: DataTypes.TEXT,
allowNull: true,
comment: '角色描述'
},
permissions: {
type: DataTypes.JSON,
allowNull: true,
defaultValue: [],
comment: '角色权限'
},
status: {
type: DataTypes.ENUM('active', 'disabled'),
defaultValue: 'active',
comment: '状态active-启用disabled-禁用'
},
createBy: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '创建人ID'
},
updateBy: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '修改人ID'
},
isDeleted: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '删除状态0未删除1已删除'
}
}, {
tableName: 'roles',
timestamps: true,
comment: '角色表'
});
module.exports = Role;