rentease-backend-new/models/Role.js

78 lines
1.6 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 { 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-禁用'
},
tenantId: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '租户IDnull为系统默认角色'
},
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已删除'
},
createTime: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
comment: '创建时间'
},
updateTime: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
comment: '更新时间'
}
}, {
tableName: 'roles',
timestamps: false,
comment: '角色表'
});
module.exports = Role;