import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, OneToMany } from 'typeorm';
import { Users } from './users.entity';

@Entity('relais', { schema: 'public' })
export class Relais {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'nom' })
  nom: string;

  @Column({ name: 'adresse' })
  adresse: string;

  @Column({ type: 'jsonb', name: 'horaires_ouverture', nullable: true })
  horaires_ouverture?: any;

  @Column({ name: 'ligne_fixe', nullable: true })
  ligne_fixe?: string;

  @Column({ default: true, name: 'actif' })
  actif: boolean;

  @Column({ type: 'text', name: 'notes', nullable: true })
  notes?: string;

  @CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
  cree_le: Date;

  @UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
  modifie_le: Date;

  @OneToMany(() => Users, user => user.relais)
  gestionnaires: Users[];
}
