Skip to content

Commit 895bfb9

Browse files
Merge branch '1-schematics' of https://github.com/Libertech-FR/teaket into 1-schematics
2 parents 8db294b + e213ff7 commit 895bfb9

File tree

17 files changed

+279
-28
lines changed

17 files changed

+279
-28
lines changed

service/src/_common/enum/user-type.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export enum UserType {
33
OPERATOR = 1,
44
AGENT = 2,
55
CLIENT = 3,
6+
COMPANY = 4,
67
OTHER = 99,
78
}
89

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Schema, SchemaFactory } from '@nestjs/mongoose'
2+
import { Document } from 'mongoose'
3+
4+
@Schema({ _id: false })
5+
export class RulePart extends Document {
6+
7+
}
8+
9+
export const RulePartSchema = SchemaFactory.createForClass(RulePart)
Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,65 @@
1-
import { Schema, SchemaFactory } from '@nestjs/mongoose'
1+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
22
import { AbstractSchema } from '~/_common/abstracts/schemas/abstract.schema'
3+
import { RulePart, RulePartSchema } from '~/tickets/sla/_schemas/parts/rules.part.schema'
34

4-
@Schema({ versionKey: false })
5+
@Schema({
6+
collection: 'sla',
7+
versionKey: false,
8+
})
59
export class Sla extends AbstractSchema {
10+
@Prop({
11+
type: String,
12+
required: true,
13+
})
14+
public name: string
15+
16+
@Prop({
17+
type: String,
18+
required: true,
19+
})
20+
public description: string
21+
22+
@Prop({
23+
type: String,
24+
required: true,
25+
})
26+
public icon: string
27+
28+
@Prop({
29+
type: String,
30+
required: true,
31+
})
32+
public color: string
33+
34+
@Prop({
35+
type: [RulePartSchema],
36+
required: true,
37+
})
38+
public rules: RulePart[]
39+
40+
@Prop({
41+
type: String,
42+
required: true,
43+
})
44+
public backgroundColor: string
45+
46+
@Prop({
47+
type: Number,
48+
required: true,
49+
})
50+
public order: number
51+
52+
@Prop({
53+
type: Number,
54+
required: true,
55+
validate: (value: number) => value > 0,
56+
})
57+
public timeToExpire: number
58+
59+
@Prop({
60+
type: Object,
61+
})
62+
public customFields: object
663
}
764

865
export const SlaSchema = SchemaFactory.createForClass(Sla)

service/src/tickets/sla/sla.controller.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { DeleteResult } from 'mongodb'
22
import { Test, TestingModule } from '@nestjs/testing'
33
import { SlaController } from './sla.controller'
44
import { SlaService } from './sla.service'
5-
import { SlaDto } from '~/tickets/sla/_dto/sla.dto'
6-
import { Sla } from '~/tickets/sla/_schemas/sla.schema'
5+
import { SlaDto } from './dto/sla.dto'
6+
import { Sla } from './schemas/sla.schema'
77
import { HttpException, HttpStatus } from '@nestjs/common'
88
import { Types } from 'mongoose'
99
import { Response, Request } from 'express'

service/src/tickets/sla/sla.controller.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import { Body, Controller, Delete, Get, HttpStatus, Param, Patch, Post, Req, Res
22
import { SlaService } from './sla.service'
33
import { AbstractController } from '~/_common/abstracts/abstract.controller'
44
import { Request, Response } from 'express'
5+
import { SlaCreateDto, SlaUpdateDto } from '~/tickets/sla/_dto/sla.dto'
56
import { FilterOptions, FilterSchema, SearchFilterOptions, SearchFilterSchema } from '@streamkits/nestjs_module_scrud'
67
import { ApiParam } from '@nestjs/swagger'
78
import { ObjectIdValidationPipe } from '~/_common/pipes/object-id-validation.pipe'
89
import { Types } from 'mongoose'
9-
import { SlaCreateDto, SlaDto, SlaUpdateDto } from '~/tickets/sla/_dto/sla.dto'
10-
import { ApiOkResponse } from '@nestjs/swagger/dist/decorators/api-response.decorator'
11-
import { ApiPaginatedResponse } from '~/_common/decorators/api-paginated-response.decorator'
1210

1311
@Controller('sla')
1412
export class SlaController extends AbstractController {
@@ -32,10 +30,6 @@ export class SlaController extends AbstractController {
3230
}
3331

3432
@Get()
35-
@ApiOkResponse({
36-
description: 'Search sla with pagination',
37-
})
38-
@ApiPaginatedResponse(SlaDto)
3933
public async search(@Res() res: Response, @SearchFilterSchema() searchFilterSchema: FilterSchema, @SearchFilterOptions() searchFilterOptions: FilterOptions) {
4034
const [data, total] = await this._service.findAndCount(searchFilterSchema, this.projection, searchFilterOptions)
4135
return res.status(HttpStatus.OK).json({

service/src/tickets/sla/sla.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Module } from '@nestjs/common'
22
import { MongooseModule } from '@nestjs/mongoose'
3-
import { SlaSchema, Sla } from '~/tickets/sla/_schemas/sla.schema'
3+
import { SlaSchema, Sla } from './_schemas/sla.schema'
44
import { SlaService } from './sla.service'
55
import { SlaController } from './sla.controller'
66

service/src/tickets/sla/sla.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DeleteResult } from 'mongodb'
22
import { Test, TestingModule } from '@nestjs/testing'
33
import { SlaService } from './sla.service'
44
import { getModelToken } from '@nestjs/mongoose'
5-
import { Sla } from '~/tickets/sla/_schemas/sla.schema'
5+
import { Sla } from './schemas/sla.schema'
66
import { Model, Types } from 'mongoose'
77

88
describe('SlaService', () => {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Injectable } from '@nestjs/common'
22
import { InjectModel } from '@nestjs/mongoose'
3+
import { Sla } from './_schemas/sla.schema'
34
import { Model } from 'mongoose'
4-
import { Sla } from '~/tickets/sla/_schemas/sla.schema'
55
import { AbstractServiceSchema } from '~/_common/abstracts/abstract.service.schema'
66

77
@Injectable()
88
export class SlaService extends AbstractServiceSchema {
9-
public constructor(@InjectModel(Sla.name) protected _model: Model<Sla>) {
9+
constructor(@InjectModel(Sla.name) protected _model: Model<Sla>,
10+
) {
1011
super()
1112
}
1213
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Schema, SchemaFactory } from '@nestjs/mongoose'
2+
import { Document } from 'mongoose'
3+
4+
@Schema({ _id: false })
5+
export class RulePart extends Document {
6+
7+
}
8+
9+
export const RulePartSchema = SchemaFactory.createForClass(RulePart)
Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,58 @@
1-
import { Schema, SchemaFactory } from '@nestjs/mongoose'
2-
import { Document } from 'mongoose'
1+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
32
import { AbstractSchema } from '~/_common/abstracts/schemas/abstract.schema'
4-
5-
export type SourceRequestDocument = SourceRequest & Document
3+
import { RulePart, RulePartSchema } from '~/tickets/source-request/_schemas/parts/rules.part.schema'
64

75
@Schema({
86
collection: 'source-requests',
97
versionKey: false,
108
})
11-
export class SourceRequest extends AbstractSchema {}
9+
export class SourceRequest extends AbstractSchema {
10+
@Prop({
11+
type: String,
12+
required: true,
13+
})
14+
public name: string
15+
16+
@Prop({
17+
type: String,
18+
required: true,
19+
})
20+
public description: string
21+
22+
@Prop({
23+
type: String,
24+
required: true,
25+
})
26+
public icon: string
27+
28+
@Prop({
29+
type: String,
30+
required: true,
31+
})
32+
public color: string
33+
34+
@Prop({
35+
type: [RulePartSchema],
36+
required: true,
37+
})
38+
public rules: RulePart[]
39+
40+
@Prop({
41+
type: String,
42+
required: true,
43+
})
44+
public backgroundColor: string
45+
46+
@Prop({
47+
type: Number,
48+
required: true,
49+
})
50+
public order: number
51+
52+
@Prop({
53+
type: Object,
54+
})
55+
public customFields: object
56+
}
1257

1358
export const SourceRequestSchema = SchemaFactory.createForClass(SourceRequest)

0 commit comments

Comments
 (0)