Skip to content

Commit f5eb44c

Browse files
committed
WIP ticket schema ok
1 parent 0997671 commit f5eb44c

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2+
import { IdnamePart } from '~/_common/schemas/parts/idname.part.schema'
3+
import { UserPart, UserPartSchema } from '~/_common/schemas/parts/user.part.schema'
4+
import { UserType } from '~/_common/enum/user-type.enum'
5+
6+
@Schema({ _id: false })
7+
export class EnvelopePart extends IdnamePart {
8+
@Prop({
9+
type: [UserPartSchema],
10+
required: true,
11+
})
12+
public senders: UserPart[]
13+
14+
@Prop({
15+
type: [UserPartSchema],
16+
required: true,
17+
})
18+
public observers: UserPart[]
19+
20+
@Prop({
21+
type: [UserPartSchema],
22+
validate: (v: UserPart[]) => {
23+
for (const user of v) {
24+
if (user.type !== UserType.AGENT) {
25+
return false
26+
}
27+
}
28+
return true
29+
},
30+
required: true,
31+
})
32+
public assigned: UserPart[]
33+
}
34+
35+
export const EnvelopePartSchema = SchemaFactory.createForClass(EnvelopePart)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2+
import { IdnamePart } from '~/_common/schemas/parts/idname.part.schema'
3+
4+
@Schema({ _id: false })
5+
export class TagPart extends IdnamePart {
6+
@Prop({
7+
type: Boolean,
8+
required: true,
9+
default: false,
10+
})
11+
public manual: boolean
12+
13+
@Prop({
14+
type: Object,
15+
})
16+
public metadata: object
17+
}
18+
19+
export const TagPartSchema = SchemaFactory.createForClass(TagPart)

service/src/tickets/ticket/_schemas/ticket.schema.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { TicketTypeList } from '~/tickets/ticket/_enum/ticket-type.enum'
77
import { TicketLifestepList } from '~/tickets/ticket/_enum/ticket-lifestep.enum'
88
import { Types } from 'mongoose'
99
import { SlaPart, SlaPartSchema } from '~/tickets/ticket/_schemas/parts/sla.part.schema'
10+
import { TagPart, TagPartSchema } from '~/tickets/ticket/_schemas/parts/tag.part.schema'
11+
import { EnvelopePart, EnvelopePartSchema } from '~/tickets/ticket/_schemas/parts/envelope.part.schema'
1012

1113
@Schema({
1214
collection: 'tickets',
@@ -20,6 +22,12 @@ export class Ticket extends AbstractSchema {
2022
})
2123
public sequence: string
2224

25+
@Prop({
26+
type: EnvelopePartSchema,
27+
required: true,
28+
})
29+
public envelope: EnvelopePart
30+
2331
@Prop({
2432
required: true,
2533
type: String,
@@ -33,7 +41,11 @@ export class Ticket extends AbstractSchema {
3341
})
3442
public type: number
3543

36-
public envelope
44+
@Prop({
45+
type: [TagPartSchema],
46+
required: true,
47+
})
48+
public tags: TagPart[]
3749

3850
@Prop({
3951
type: Number,
@@ -87,6 +99,11 @@ export class Ticket extends AbstractSchema {
8799
default: [],
88100
})
89101
public readFlags: string[]
102+
103+
@Prop({
104+
type: Object,
105+
})
106+
public customFields: object
90107
}
91108

92109
export const TicketSchema = SchemaFactory.createForClass(Ticket)

0 commit comments

Comments
 (0)