miinventario-v2/apps/backend/src/modules/notifications/entities/notification.entity.ts
rckrdmrd 1a53b5c4d3 [MIINVENTARIO] feat: Initial commit - Sistema de inventario con análisis de video IA
- Backend NestJS con módulos de autenticación, inventario, créditos
- Frontend React con dashboard y componentes UI
- Base de datos PostgreSQL con migraciones
- Tests E2E configurados
- Configuración de Docker y deployment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 02:25:48 -06:00

58 lines
1.2 KiB
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
Index,
} from 'typeorm';
import { User } from '../../users/entities/user.entity';
export enum NotificationType {
VIDEO_PROCESSING_COMPLETE = 'VIDEO_PROCESSING_COMPLETE',
VIDEO_PROCESSING_FAILED = 'VIDEO_PROCESSING_FAILED',
LOW_CREDITS = 'LOW_CREDITS',
PAYMENT_COMPLETE = 'PAYMENT_COMPLETE',
PAYMENT_FAILED = 'PAYMENT_FAILED',
REFERRAL_BONUS = 'REFERRAL_BONUS',
PROMO = 'PROMO',
SYSTEM = 'SYSTEM',
}
@Entity('notifications')
@Index(['userId', 'createdAt'])
@Index(['userId', 'isRead'])
export class Notification {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'uuid' })
userId: string;
@ManyToOne(() => User)
@JoinColumn({ name: 'userId' })
user: User;
@Column({ type: 'enum', enum: NotificationType })
type: NotificationType;
@Column({ type: 'varchar', length: 255 })
title: string;
@Column({ type: 'text', nullable: true })
body: string;
@Column({ type: 'boolean', default: false })
isRead: boolean;
@Column({ type: 'boolean', default: false })
isPushSent: boolean;
@Column({ type: 'jsonb', nullable: true })
data: Record<string, unknown>;
@CreateDateColumn()
createdAt: Date;
}