Files
smart_grid_iot/server/src/entity/user.entity.ts
T
andyesfly 3d7eb12103 feat: 初始化智能物联网设备管理系统前后端基础项目
完成项目整体结构搭建,包含:
1. 前端Vue3+TS+Vite+Antd项目基础配置与核心依赖
2. 后端MidwayJS+TypeORM+JWT权限认证框架
3. 完整的用户、角色、权限、日志数据库表结构
4. 核心业务模块API与基础服务实现
5. 全局样式、路由、状态管理配置
2026-05-28 16:23:15 +08:00

93 lines
1.5 KiB
TypeScript

import { Column, Model, Table, DataType, CreatedAt, UpdatedAt, HasMany } from "sequelize-typescript";
import UserRole from "./userRole.entity";
@Table({
tableName: "users",
comment: "用户表",
timestamps: true,
createdAt: "created_at",
updatedAt: "updated_at"
})
export default class User extends Model {
@Column({
type: DataType.BIGINT,
autoIncrement: true,
primaryKey: true
})
id!: number;
@Column({
type: DataType.STRING(50),
allowNull: false,
unique: true,
comment: "用户名"
})
username!: string;
@Column({
type: DataType.STRING(255),
allowNull: false,
comment: "加密密码(bcrypt)"
})
password!: string;
@Column({
type: DataType.STRING(50),
field: "nickname",
comment: "昵称"
})
nickname!: string;
@Column({
type: DataType.STRING(100),
field: "email",
comment: "邮箱"
})
email!: string;
@Column({
type: DataType.STRING(20),
field: "phone",
comment: "手机号"
})
phone!: string;
@Column({
type: DataType.STRING(255),
field: "avatar",
comment: "头像URL"
})
avatar!: string;
@Column({
type: DataType.TINYINT,
allowNull: false,
defaultValue: 1,
comment: "状态: 0-禁用 1-启用"
})
status!: number;
@Column({
type: DataType.DATE,
field: "last_login_at",
comment: "最后登录时间"
})
lastLoginAt!: Date;
@Column({
type: DataType.STRING(45),
field: "last_login_ip",
comment: "最后登录IP(支持IPv6)"
})
lastLoginIp!: string;
@HasMany(() => UserRole)
userRoles!: UserRole[];
@CreatedAt
created_at!: Date;
@UpdatedAt
updated_at!: Date;
}