rentease-backend/models/User.js

65 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-03-08 16:28:33 +00:00
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: '是否超级管理员01'
},
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;