@@ -5,10 +5,164 @@ import { ToolsQueryDto } from '../dto/query/tools.query.dto';
5
5
import { QueryPipe } from '../pipes/query.pipe' ;
6
6
import { ApiDotNotationQuery } from './api-dot-notation-query.decorator' ;
7
7
8
- export const Paginated = ( entityDto : any , entity ?: any ) => {
8
+ export interface EntityFields {
9
+ allowFieldsFindAll : string [ ] ;
10
+ idKeys : string [ ] ;
11
+ regexSearchKeys : string [ ] ;
12
+ dateSearchKeys : string [ ] ;
13
+ numberSearchKeys : string [ ] ;
14
+ blacklistFields ?: string [ ] ;
15
+ }
16
+
17
+ export interface Entities {
18
+ movie : EntityFields ;
19
+ person : EntityFields ;
20
+ review : EntityFields ;
21
+ season : EntityFields ;
22
+ image : EntityFields ;
23
+ }
24
+
25
+ const entitiesField : Entities = {
26
+ movie : {
27
+ allowFieldsFindAll : [
28
+ 'id' ,
29
+ 'externalId' ,
30
+ 'name' ,
31
+ 'logo' ,
32
+ 'color' ,
33
+ 'shortDescription' ,
34
+ 'horizontalPoster' ,
35
+ 'alternativeName' ,
36
+ 'enName' ,
37
+ 'names' ,
38
+ 'type' ,
39
+ 'movieLength' ,
40
+ 'description' ,
41
+ 'year' ,
42
+ 'poster' ,
43
+ 'votes' ,
44
+ 'rating' ,
45
+ 'watchability' ,
46
+ 'releaseYears' ,
47
+ ] ,
48
+ idKeys : [ 'id' , 'externalId.imdb' ] ,
49
+ regexSearchKeys : [
50
+ 'name' ,
51
+ 'alternativeName' ,
52
+ 'enName' ,
53
+ 'names.name' ,
54
+ 'tagline' ,
55
+ 'slogan' ,
56
+ 'description' ,
57
+ 'persons.name' ,
58
+ 'persons.enName' ,
59
+ 'persons.description' ,
60
+ ] ,
61
+ dateSearchKeys : [ 'premiere.world' , 'premiere.russia' , 'premiere.digital' , 'premiere.bluray' , 'premiere.dvd' ] ,
62
+ numberSearchKeys : [
63
+ 'id' ,
64
+ 'externalId.imdb' ,
65
+ 'externalId.tmdb' ,
66
+ 'typeNumber' ,
67
+ 'movieLength' ,
68
+ 'year' ,
69
+ 'rating.kp' ,
70
+ 'rating.imdb' ,
71
+ 'rating.tmdb' ,
72
+ 'votes.kp' ,
73
+ 'votes.imdb' ,
74
+ 'votes.tmdb' ,
75
+ 'ratingAgeLimits' ,
76
+ 'persons.id' ,
77
+ 'budget.value' ,
78
+ 'fees.world' ,
79
+ 'fees.usa' ,
80
+ 'fees.russia' ,
81
+ 'image.postersCount' ,
82
+ 'image.backdropsCount' ,
83
+ 'image.framesCount' ,
84
+ 'reviewInfo.count' ,
85
+ 'reviewInfo.positiveCount' ,
86
+ 'seasonsInfo.number' ,
87
+ 'seasonsInfo.episodesCount' ,
88
+ 'videos.trailers.size' ,
89
+ 'videos.teasers.size' ,
90
+ ] ,
91
+ } ,
92
+ person : {
93
+ blacklistFields : [
94
+ '-_id' ,
95
+ '-profession._id' ,
96
+ '-birthPlace._id' ,
97
+ '-deathPlace._id' ,
98
+ '-facts._id' ,
99
+ '-movies._id' ,
100
+ '-isParse' ,
101
+ ] ,
102
+ allowFieldsFindAll : [ 'id' , 'name' , 'enName' , 'photo' , 'age' , 'sex' ] ,
103
+ idKeys : [ 'id' ] ,
104
+ regexSearchKeys : [
105
+ 'name' ,
106
+ 'enName' ,
107
+ 'movies.name' ,
108
+ 'slogan' ,
109
+ 'description' ,
110
+ 'persons.name' ,
111
+ 'persons.enName' ,
112
+ 'persons.description' ,
113
+ ] ,
114
+ dateSearchKeys : [ 'birthday' , 'death' ] ,
115
+ numberSearchKeys : [
116
+ 'id' ,
117
+ 'movies.id' ,
118
+ 'movies.rating' ,
119
+ 'age' ,
120
+ 'countAwards' ,
121
+ 'growth' ,
122
+ 'spouses.id' ,
123
+ 'spouses.children' ,
124
+ 'spouses.name' ,
125
+ ] ,
126
+ } ,
127
+ review : {
128
+ blacklistFields : [ '-_id' , '-episodes._id' ] ,
129
+ allowFieldsFindAll : [ 'movieId' , 'id' , 'title' , 'type' , 'review' , 'author' , 'date' ] ,
130
+ idKeys : [ 'id' ] ,
131
+ regexSearchKeys : [ ] ,
132
+ dateSearchKeys : [ 'date' ] ,
133
+ numberSearchKeys : [ 'movieId' , 'id' ] ,
134
+ } ,
135
+ season : {
136
+ blacklistFields : [ '-_id' , '-episodes._id' ] ,
137
+ allowFieldsFindAll : [
138
+ 'movieId' ,
139
+ 'number' ,
140
+ 'episodesCount' ,
141
+ 'episodes.number' ,
142
+ 'episodes.name' ,
143
+ 'episodes.enName' ,
144
+ 'episodes.date' ,
145
+ 'episodes.description' ,
146
+ ] ,
147
+ idKeys : [ 'id' ] ,
148
+ regexSearchKeys : [ ] ,
149
+ dateSearchKeys : [ 'episodes.date' ] ,
150
+ numberSearchKeys : [ 'movieId' , 'number' , 'episodesCount' , 'episodes.number' ] ,
151
+ } ,
152
+ image : {
153
+ blacklistFields : [ '-_id' ] ,
154
+ allowFieldsFindAll : [ 'url' , 'previewUrl' , 'width' , 'language' , 'height' , 'type' , 'movieId' ] ,
155
+ idKeys : [ 'id' ] ,
156
+ regexSearchKeys : [ ] ,
157
+ dateSearchKeys : [ ] ,
158
+ numberSearchKeys : [ 'movieId' , 'height' , 'width' ] ,
159
+ } ,
160
+ } ;
161
+
162
+ export const Paginated = ( entityDto : any , entity : any , findForAllProperties ?: boolean ) => {
9
163
return applyDecorators (
10
- UsePipes ( new QueryPipe ( ) ) ,
11
- entity
164
+ UsePipes ( new QueryPipe ( entitiesField [ entity . name . toLowerCase ( ) ] ) ) ,
165
+ findForAllProperties
12
166
? ApiDotNotationQuery ( ToolsQueryDto , PaginatedQueryDto , entity )
13
167
: ApiDotNotationQuery ( ToolsQueryDto , PaginatedQueryDto ) ,
14
168
ApiResponse ( { type : entityDto , isArray : true } ) ,
0 commit comments