rentease-backend-new/models/User.js

98 lines
2.1 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 User = sequelize.define('User', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '用户ID'
},
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: '昵称'
},
avatar: {
type: DataTypes.STRING(255),
allowNull: true,
comment: '头像URL'
},
roleId: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '角色ID'
},
tenantId: {
type: DataTypes.INTEGER,
allowNull: false,
comment: '租户ID'
},
userType: {
type: DataTypes.ENUM('super_admin', 'tenant_admin', 'user'),
allowNull: false,
defaultValue: 'user',
comment: '用户类型super_admin-系统管理员tenant_admin-租户管理员user-普通用户'
},
status: {
type: DataTypes.ENUM('active', 'inactive'),
defaultValue: 'active',
comment: '状态active-启用inactive-禁用'
},
lastLoginTime: {
type: DataTypes.DATE,
allowNull: true,
comment: '最后登录时间'
},
lastLoginIp: {
type: DataTypes.STRING(50),
allowNull: true,
comment: '最后登录IP'
},
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: 'users',
timestamps: false,
comment: '用户表'
});
module.exports = User;