65 lines
1.3 KiB
JavaScript
65 lines
1.3 KiB
JavaScript
|
|
const { DataTypes } = require('sequelize');
|
|||
|
|
const sequelize = require('../config/db');
|
|||
|
|
|
|||
|
|
const User = sequelize.define('User', {
|
|||
|
|
id: {
|
|||
|
|
type: DataTypes.INTEGER,
|
|||
|
|
primaryKey: true,
|
|||
|
|
autoIncrement: true
|
|||
|
|
},
|
|||
|
|
username: {
|
|||
|
|
type: DataTypes.STRING(50),
|
|||
|
|
allowNull: false,
|
|||
|
|
unique: true,
|
|||
|
|
comment: '用户名'
|
|||
|
|
},
|
|||
|
|
password: {
|
|||
|
|
type: DataTypes.STRING(255),
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '密码(加密存储)'
|
|||
|
|
},
|
|||
|
|
nickname: {
|
|||
|
|
type: DataTypes.STRING(50),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '昵称'
|
|||
|
|
},
|
|||
|
|
roleId: {
|
|||
|
|
type: DataTypes.INTEGER,
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '角色ID'
|
|||
|
|
},
|
|||
|
|
isSuperAdmin: {
|
|||
|
|
type: DataTypes.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 0,
|
|||
|
|
comment: '是否超级管理员(0:否,1:是)'
|
|||
|
|
},
|
|||
|
|
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: 'users',
|
|||
|
|
timestamps: true,
|
|||
|
|
comment: '用户表'
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
module.exports = User;
|