55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
|
|
|
@Entity('users')
|
|
export class User {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column({ unique: true, length: 50, nullable: true })
|
|
username: string;
|
|
|
|
@Column({ unique: true, length: 100, nullable: true })
|
|
email: string;
|
|
|
|
@Column({ select: false, nullable: true })
|
|
password: string;
|
|
|
|
@Column({ length: 50, nullable: true })
|
|
realName: string;
|
|
|
|
@Column({ length: 20, nullable: true })
|
|
phone: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
avatar: string;
|
|
|
|
// 微信小程序相关字段
|
|
@Column({ unique: true, length: 50, nullable: true })
|
|
openid: string; // 微信openid
|
|
|
|
@Column({ length: 100, nullable: true })
|
|
unionid: string; // 微信unionid
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
sessionKey: string; // 微信session_key
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: ['admin', 'customer', 'worker'],
|
|
default: 'customer'
|
|
})
|
|
role: string;
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: ['active', 'inactive', 'banned'],
|
|
default: 'active'
|
|
})
|
|
status: string;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
} |