初始化游戏小组管理系统后端项目
- 基于 NestJS + TypeScript + MySQL + Redis 架构 - 完整的模块化设计(认证、用户、小组、游戏、预约等) - JWT 认证和 RBAC 权限控制系统 - Docker 容器化部署支持 - 添加 CLAUDE.md 项目开发指南 - 配置 .gitignore 忽略文件 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
60
src/entities/asset.entity.ts
Normal file
60
src/entities/asset.entity.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
OneToMany,
|
||||
} from 'typeorm';
|
||||
import { AssetType, AssetStatus } from '../common/enums';
|
||||
import { Group } from './group.entity';
|
||||
import { AssetLog } from './asset-log.entity';
|
||||
|
||||
@Entity('assets')
|
||||
export class Asset {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column()
|
||||
groupId: string;
|
||||
|
||||
@ManyToOne(() => Group, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'groupId' })
|
||||
group: Group;
|
||||
|
||||
@Column({ type: 'enum', enum: AssetType })
|
||||
type: AssetType;
|
||||
|
||||
@Column({ length: 100 })
|
||||
name: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true, comment: '描述' })
|
||||
description: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true, comment: '加密的账号凭据' })
|
||||
accountCredentials?: string | null;
|
||||
|
||||
@Column({ default: 1, comment: '数量(用于物品)' })
|
||||
quantity: number;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: AssetStatus,
|
||||
default: AssetStatus.AVAILABLE,
|
||||
})
|
||||
status: AssetStatus;
|
||||
|
||||
@Column({ type: 'varchar', nullable: true, comment: '当前借用人ID' })
|
||||
currentBorrowerId?: string | null;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
|
||||
@OneToMany(() => AssetLog, (log) => log.asset)
|
||||
logs: AssetLog[];
|
||||
}
|
||||
Reference in New Issue
Block a user