import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { EntityHelper } from 'src/utils/entity-helper';
import { LOGEVENT, LOGLEVEL } from '../model/logging-event.type';

@Entity()
export class LogEntry extends EntityHelper {
  @ApiProperty({ example: 1 })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ example: 'error' })
  @Column()
  level: LOGLEVEL;

  @ApiProperty({ example: 'created new user' })
  @Column()
  event: LOGEVENT;

  @ApiProperty({ example: 'created new user max mustermann' })
  @Column()
  details: string;

  @ApiProperty({ example: 5 })
  @Column()
  userId: number;

  @ApiProperty({ example: 5 })
  @Column({ nullable: true })
  duration?: number;

  @CreateDateColumn()
  createdAt: Date;
}
