@@ -2,7 +2,11 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
22import { AbstractSchema } from '~/_common/abstracts/schemas/abstract.schema'
33import { AutoIncrementPlugin } from '~/_common/plugins/mongoose/auto-increment.plugin'
44import { AutoIncrementPluginOptions } from '~/_common/plugins/mongoose/auto-increment.interface'
5- import { IdnamePart } from '~/_common/schemas/parts/idname.part.schema'
5+ import { IdnamePart , IdnamePartSchema } from '~/_common/schemas/parts/idname.part.schema'
6+ import { TicketTypeList } from '~/tickets/ticket/_enum/ticket-type.enum'
7+ import { TicketLifestepList } from '~/tickets/ticket/_enum/ticket-lifestep.enum'
8+ import { Types } from 'mongoose'
9+ import { SlaPart , SlaPartSchema } from '~/tickets/ticket/_schemas/parts/sla.part.schema'
610
711@Schema ( {
812 collection : 'tickets' ,
@@ -23,28 +27,66 @@ export class Ticket extends AbstractSchema {
2327 public subject : string
2428
2529 @Prop ( {
26- type : IdnamePart ,
27- required : [ true , 'Le status du ticket doit être spécifié' ] ,
30+ type : Number ,
31+ enum : TicketTypeList ,
32+ required : true ,
33+ } )
34+ public type : number
35+
36+ public envelope
37+
38+ @Prop ( {
39+ type : Number ,
40+ enum : TicketLifestepList ,
41+ required : true ,
42+ } )
43+ public lifestep : number
44+
45+ @Prop ( { type : Types . ObjectId } )
46+ public parent ?: Types . ObjectId
47+
48+ @Prop ( {
49+ type : IdnamePartSchema ,
50+ required : true ,
2851 } )
2952 public state : IdnamePart
3053
3154 @Prop ( {
32- type : IdnamePart ,
33- required : [ true , 'Le projet du ticket doit être spécifié' ] ,
55+ type : IdnamePartSchema ,
56+ required : true ,
3457 } )
3558 public project : IdnamePart
3659
3760 @Prop ( {
38- type : IdnamePart ,
39- required : [ true , 'La priorité du ticket doit être spécifié' ] ,
61+ type : IdnamePartSchema ,
62+ required : true ,
4063 } )
4164 public priority : IdnamePart
4265
4366 @Prop ( {
44- type : IdnamePart ,
45- required : [ true , 'L\'impact du ticket doit être spécifié' ] ,
67+ type : IdnamePartSchema ,
68+ required : true ,
4669 } )
4770 public impact : IdnamePart
71+
72+ @Prop ( {
73+ type : SlaPartSchema ,
74+ required : true ,
75+ } )
76+ public sla : SlaPart
77+
78+ @Prop ( {
79+ type : Number ,
80+ required : true ,
81+ default : 0 ,
82+ } )
83+ public totalTime : number
84+
85+ @Prop ( {
86+ type : [ String ] ,
87+ default : [ ] ,
88+ } )
89+ public readFlags : string [ ]
4890}
4991
5092export const TicketSchema = SchemaFactory . createForClass ( Ticket )
@@ -55,7 +97,7 @@ export const TicketSchema = SchemaFactory.createForClass(Ticket)
5597 } )
5698 . pre ( 'save' , function ( next ) {
5799 if ( this . isNew ) {
58- this . sequence = 'LT' + this . sequence . padStart ( 6 , '0' )
100+ this . sequence = 'LT' + this . sequence . padStart ( 6 , '0' ) //TODO: get prefix from config
59101 }
60102 next ( )
61103 } )
0 commit comments