Files
MemeMind-Server/src/modules/auth/entities/user.entity.ts
2026-04-19 13:27:10 +08:00

43 lines
1.1 KiB
TypeScript
Raw 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.
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
} from 'typeorm';
import { MAX_STAMINA } from '../../../common/constants/game.constants';
@Entity('wx_users')
export class User {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Index('idx_user_openid', { unique: true })
@Column({ type: 'varchar', length: 128 })
openid!: string;
@Column({ type: 'varchar', length: 255, name: 'session_key', nullable: true })
sessionKey!: string | null;
@Column({ type: 'varchar', length: 100, nullable: true })
nickname!: string | null;
@Column({ type: 'text', name: 'avatar_url', nullable: true })
avatarUrl!: string | null;
/** 体力值(默认 MAX_STAMINA上限 MAX_STAMINA */
@Column({ type: 'int', default: MAX_STAMINA })
stamina!: number;
/** 体力值最后更新时间(用于计算恢复) */
@Column({ type: 'timestamp', name: 'stamina_updated_at', nullable: true })
staminaUpdatedAt!: Date | null;
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt!: Date;
}