import { Column, Entity, PrimaryColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import {
  decodeBigNumberKey,
  encodeBigNumberKey,
} from '../utils/big-number-key';

@Entity('notification_assets', { schema: 'public' })
export class NotificationAssetEntity {
  @PrimaryColumn('uuid', {
    name: 'notification_id',
    nullable: false,
  })
  notificationId: string;

  @PrimaryColumn({
    name: 'project_id',
    nullable: false,
    transformer: {
      from: (x) => encodeBigNumberKey(x),
      to: (x) => decodeBigNumberKey(x),
    },
  })
  projectId: string;

  @PrimaryColumn('uuid', {
    name: 'asset_id',
    nullable: false,
  })
  assetId: string;

  @PrimaryColumn('integer', {
    name: 'user_id',
    nullable: false,
  })
  userId: number;

  @Column('timestamp with time zone', {
    name: 'viewed_at',
    nullable: true,
  })
  viewedAt: Date | null;
}
