feat(#194): module Cartes SYSTEM
Closes #194 Co-authored-by: Julien Martin <julien.martin@ptits-pas.fr>
This commit was merged in pull request #203.
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { AmChildren } from './am_children.entity';
|
||||
import { AbsencesGarde } from './absences_garde.entity';
|
||||
import { Users } from './users.entity';
|
||||
import { CardType } from './card_types.entity';
|
||||
import { CardAudienceMember } from './card_audience_members.entity';
|
||||
import { CardResponse } from './card_responses.entity';
|
||||
|
||||
export enum CardInstanceStatutType {
|
||||
OUVERTE = 'ouverte',
|
||||
REFUSEE = 'refusee',
|
||||
TRAITEE = 'traitee',
|
||||
}
|
||||
|
||||
export enum CardOperationType {
|
||||
CREATE = 'create',
|
||||
UPDATE = 'update',
|
||||
}
|
||||
|
||||
@Entity('card_instances', { schema: 'public' })
|
||||
export class CardInstance {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ name: 'type_code', type: 'varchar', length: 64 })
|
||||
type_code: string;
|
||||
|
||||
@ManyToOne(() => CardType, { onDelete: 'RESTRICT' })
|
||||
@JoinColumn({ name: 'type_code', referencedColumnName: 'code' })
|
||||
type: CardType;
|
||||
|
||||
@Column({ name: 'id_placement', type: 'uuid' })
|
||||
id_placement: string;
|
||||
|
||||
@ManyToOne(() => AmChildren, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'id_placement', referencedColumnName: 'id' })
|
||||
placement: AmChildren;
|
||||
|
||||
@Column({ name: 'id_absence', type: 'uuid', nullable: true })
|
||||
id_absence?: string;
|
||||
|
||||
@ManyToOne(() => AbsencesGarde, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'id_absence', referencedColumnName: 'id' })
|
||||
absence?: AbsencesGarde;
|
||||
|
||||
@Column({ name: 'cree_par', type: 'uuid', nullable: true })
|
||||
cree_par?: string;
|
||||
|
||||
@ManyToOne(() => Users, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'cree_par', referencedColumnName: 'id' })
|
||||
createdBy?: Users;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: CardOperationType,
|
||||
enumName: 'card_operation_type',
|
||||
name: 'operation',
|
||||
default: CardOperationType.CREATE,
|
||||
})
|
||||
operation: CardOperationType;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: CardInstanceStatutType,
|
||||
enumName: 'card_instance_statut_type',
|
||||
name: 'statut',
|
||||
default: CardInstanceStatutType.OUVERTE,
|
||||
})
|
||||
statut: CardInstanceStatutType;
|
||||
|
||||
@Column({ name: 'payload', type: 'jsonb', default: {} })
|
||||
payload: Record<string, unknown>;
|
||||
|
||||
@Column({ name: 'purge_at', type: 'timestamptz' })
|
||||
purge_at: Date;
|
||||
|
||||
@OneToMany(() => CardAudienceMember, (m) => m.card)
|
||||
audience: CardAudienceMember[];
|
||||
|
||||
@OneToMany(() => CardResponse, (r) => r.card)
|
||||
responses: CardResponse[];
|
||||
|
||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||
cree_le: Date;
|
||||
|
||||
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
||||
modifie_le: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user