@chevre/domain 20.2.0-alpha.10 → 20.2.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
- package/lib/chevre/repo/event.js +101 -13
- package/lib/chevre/repo/place.d.ts +15 -1
- package/lib/chevre/repo/place.js +175 -10
- package/lib/chevre/repo/reservation.js +39 -30
- package/lib/chevre/repo/trip.js +33 -27
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +12 -6
- package/package.json +2 -2
- package/CHANGELOG.md +0 -2030
- package/example/.gitignore +0 -1
- package/example/src/chevre/.gitignore +0 -1
|
@@ -21,7 +21,8 @@ async function main() {
|
|
|
21
21
|
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
22
22
|
startDate: {
|
|
23
23
|
$gte: moment()
|
|
24
|
-
|
|
24
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
25
|
+
.add(-6, 'months')
|
|
25
26
|
.toDate()
|
|
26
27
|
}
|
|
27
28
|
// _id: { $eq: 'al6aff83w' }
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -34,7 +34,7 @@ class MongoRepository {
|
|
|
34
34
|
}
|
|
35
35
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
36
36
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
37
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26;
|
|
38
38
|
const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
|
|
39
39
|
const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
40
40
|
if (typeof projectIdEq === 'string') {
|
|
@@ -131,8 +131,96 @@ class MongoRepository {
|
|
|
131
131
|
let params;
|
|
132
132
|
switch (conditions.typeOf) {
|
|
133
133
|
case factory.eventType.Event:
|
|
134
|
-
|
|
135
|
-
//
|
|
134
|
+
params = conditions;
|
|
135
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
136
|
+
/* istanbul ignore else */
|
|
137
|
+
if (params.offers !== undefined) {
|
|
138
|
+
const itemOfferedIdIn = (_k = (_j = params.offers.itemOffered) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$in;
|
|
139
|
+
if (Array.isArray(itemOfferedIdIn)) {
|
|
140
|
+
andConditions.push({
|
|
141
|
+
'offers.itemOffered.id': {
|
|
142
|
+
$exists: true,
|
|
143
|
+
$in: itemOfferedIdIn
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
148
|
+
/* istanbul ignore else */
|
|
149
|
+
if (params.offers.itemOffered !== undefined) {
|
|
150
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
151
|
+
/* istanbul ignore else */
|
|
152
|
+
if (params.offers.itemOffered.serviceOutput !== undefined) {
|
|
153
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
154
|
+
/* istanbul ignore else */
|
|
155
|
+
if (params.offers.itemOffered.serviceOutput.reservedTicket !== undefined) {
|
|
156
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
157
|
+
/* istanbul ignore else */
|
|
158
|
+
if (params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat !== undefined) {
|
|
159
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
160
|
+
/* istanbul ignore else */
|
|
161
|
+
if (Array.isArray(params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOfs)) {
|
|
162
|
+
andConditions.push({
|
|
163
|
+
'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
|
|
164
|
+
$exists: true,
|
|
165
|
+
$in: params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOfs
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
173
|
+
/* istanbul ignore else */
|
|
174
|
+
if (params.offers.itemOffered.serviceType !== undefined) {
|
|
175
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
176
|
+
/* istanbul ignore else */
|
|
177
|
+
if (Array.isArray(params.offers.itemOffered.serviceType.ids)) {
|
|
178
|
+
andConditions.push({
|
|
179
|
+
'offers.itemOffered.serviceType.id': {
|
|
180
|
+
$exists: true,
|
|
181
|
+
$in: params.offers.itemOffered.serviceType.ids
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const sellerMakesOfferElemMatch4event = (_o = (_m = (_l = params.offers) === null || _l === void 0 ? void 0 : _l.seller) === null || _m === void 0 ? void 0 : _m.makesOffer) === null || _o === void 0 ? void 0 : _o.$elemMatch;
|
|
189
|
+
if (typeof ((_p = sellerMakesOfferElemMatch4event === null || sellerMakesOfferElemMatch4event === void 0 ? void 0 : sellerMakesOfferElemMatch4event['availableAtOrFrom.id']) === null || _p === void 0 ? void 0 : _p.$eq) === 'string') {
|
|
190
|
+
andConditions.push({
|
|
191
|
+
'offers.seller.makesOffer': {
|
|
192
|
+
$exists: true,
|
|
193
|
+
$elemMatch: sellerMakesOfferElemMatch4event
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const reservationForIdentifierEq = (_u = (_t = (_s = (_r = (_q = params.offers) === null || _q === void 0 ? void 0 : _q.itemOffered) === null || _r === void 0 ? void 0 : _r.serviceOutput) === null || _s === void 0 ? void 0 : _s.reservationFor) === null || _t === void 0 ? void 0 : _t.identifier) === null || _u === void 0 ? void 0 : _u.$eq;
|
|
198
|
+
if (typeof reservationForIdentifierEq === 'string') {
|
|
199
|
+
andConditions.push({
|
|
200
|
+
'offers.itemOffered.serviceOutput.reservationFor.identifier': {
|
|
201
|
+
$exists: true,
|
|
202
|
+
$eq: reservationForIdentifierEq
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
const reservationForArrivalBusStopBranchCodeEq = (_0 = (_z = (_y = (_x = (_w = (_v = params.offers) === null || _v === void 0 ? void 0 : _v.itemOffered) === null || _w === void 0 ? void 0 : _w.serviceOutput) === null || _x === void 0 ? void 0 : _x.reservationFor) === null || _y === void 0 ? void 0 : _y.arrivalBusStop) === null || _z === void 0 ? void 0 : _z.branchCode) === null || _0 === void 0 ? void 0 : _0.$eq;
|
|
207
|
+
if (typeof reservationForArrivalBusStopBranchCodeEq === 'string') {
|
|
208
|
+
andConditions.push({
|
|
209
|
+
'offers.itemOffered.serviceOutput.reservationFor.arrivalBusStop.branchCode': {
|
|
210
|
+
$exists: true,
|
|
211
|
+
$eq: reservationForArrivalBusStopBranchCodeEq
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const reservationForDepartureBusStopBranchCodeEq = (_6 = (_5 = (_4 = (_3 = (_2 = (_1 = params.offers) === null || _1 === void 0 ? void 0 : _1.itemOffered) === null || _2 === void 0 ? void 0 : _2.serviceOutput) === null || _3 === void 0 ? void 0 : _3.reservationFor) === null || _4 === void 0 ? void 0 : _4.departureBusStop) === null || _5 === void 0 ? void 0 : _5.branchCode) === null || _6 === void 0 ? void 0 : _6.$eq;
|
|
216
|
+
if (typeof reservationForDepartureBusStopBranchCodeEq === 'string') {
|
|
217
|
+
andConditions.push({
|
|
218
|
+
'offers.itemOffered.serviceOutput.reservationFor.departureBusStop.branchCode': {
|
|
219
|
+
$exists: true,
|
|
220
|
+
$eq: reservationForDepartureBusStopBranchCodeEq
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
136
224
|
break;
|
|
137
225
|
case factory.eventType.ScreeningEvent:
|
|
138
226
|
params = conditions;
|
|
@@ -158,7 +246,7 @@ class MongoRepository {
|
|
|
158
246
|
}
|
|
159
247
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
160
248
|
/* istanbul ignore else */
|
|
161
|
-
const superEventLocationIdEq = (
|
|
249
|
+
const superEventLocationIdEq = (_9 = (_8 = (_7 = params.superEvent) === null || _7 === void 0 ? void 0 : _7.location) === null || _8 === void 0 ? void 0 : _8.id) === null || _9 === void 0 ? void 0 : _9.$eq;
|
|
162
250
|
if (typeof superEventLocationIdEq === 'string') {
|
|
163
251
|
andConditions.push({
|
|
164
252
|
'superEvent.location.id': {
|
|
@@ -246,7 +334,7 @@ class MongoRepository {
|
|
|
246
334
|
});
|
|
247
335
|
}
|
|
248
336
|
}
|
|
249
|
-
const itemOfferedIdIn = (
|
|
337
|
+
const itemOfferedIdIn = (_11 = (_10 = params.offers.itemOffered) === null || _10 === void 0 ? void 0 : _10.id) === null || _11 === void 0 ? void 0 : _11.$in;
|
|
250
338
|
if (Array.isArray(itemOfferedIdIn)) {
|
|
251
339
|
andConditions.push({
|
|
252
340
|
'offers.itemOffered.id': {
|
|
@@ -296,8 +384,8 @@ class MongoRepository {
|
|
|
296
384
|
}
|
|
297
385
|
}
|
|
298
386
|
}
|
|
299
|
-
const sellerMakesOfferElemMatch = (
|
|
300
|
-
if (typeof ((
|
|
387
|
+
const sellerMakesOfferElemMatch = (_14 = (_13 = (_12 = params.offers) === null || _12 === void 0 ? void 0 : _12.seller) === null || _13 === void 0 ? void 0 : _13.makesOffer) === null || _14 === void 0 ? void 0 : _14.$elemMatch;
|
|
388
|
+
if (typeof ((_15 = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _15 === void 0 ? void 0 : _15.$eq) === 'string') {
|
|
301
389
|
andConditions.push({
|
|
302
390
|
'offers.seller.makesOffer': {
|
|
303
391
|
$exists: true,
|
|
@@ -334,7 +422,7 @@ class MongoRepository {
|
|
|
334
422
|
]
|
|
335
423
|
});
|
|
336
424
|
}
|
|
337
|
-
const locationIdEq = (
|
|
425
|
+
const locationIdEq = (_17 = (_16 = params.location) === null || _16 === void 0 ? void 0 : _16.id) === null || _17 === void 0 ? void 0 : _17.$eq;
|
|
338
426
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
339
427
|
/* istanbul ignore else */
|
|
340
428
|
if (typeof locationIdEq === 'string') {
|
|
@@ -356,7 +444,7 @@ class MongoRepository {
|
|
|
356
444
|
});
|
|
357
445
|
}
|
|
358
446
|
}
|
|
359
|
-
const workPerformedIdentifierIn = (
|
|
447
|
+
const workPerformedIdentifierIn = (_18 = params.workPerformed) === null || _18 === void 0 ? void 0 : _18.identifiers;
|
|
360
448
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
361
449
|
/* istanbul ignore else */
|
|
362
450
|
if (Array.isArray(workPerformedIdentifierIn)) {
|
|
@@ -367,7 +455,7 @@ class MongoRepository {
|
|
|
367
455
|
}
|
|
368
456
|
});
|
|
369
457
|
}
|
|
370
|
-
const videoFormatTypeOfEq = (
|
|
458
|
+
const videoFormatTypeOfEq = (_20 = (_19 = params.videoFormat) === null || _19 === void 0 ? void 0 : _19.typeOf) === null || _20 === void 0 ? void 0 : _20.$eq;
|
|
371
459
|
if (typeof videoFormatTypeOfEq === 'string') {
|
|
372
460
|
andConditions.push({
|
|
373
461
|
'videoFormat.typeOf': {
|
|
@@ -376,7 +464,7 @@ class MongoRepository {
|
|
|
376
464
|
}
|
|
377
465
|
});
|
|
378
466
|
}
|
|
379
|
-
const videoFormatTypeOfIn = (
|
|
467
|
+
const videoFormatTypeOfIn = (_22 = (_21 = params.videoFormat) === null || _21 === void 0 ? void 0 : _21.typeOf) === null || _22 === void 0 ? void 0 : _22.$in;
|
|
380
468
|
if (Array.isArray(videoFormatTypeOfIn)) {
|
|
381
469
|
andConditions.push({
|
|
382
470
|
'videoFormat.typeOf': {
|
|
@@ -385,7 +473,7 @@ class MongoRepository {
|
|
|
385
473
|
}
|
|
386
474
|
});
|
|
387
475
|
}
|
|
388
|
-
const soundFormatTypeOfEq = (
|
|
476
|
+
const soundFormatTypeOfEq = (_24 = (_23 = params.soundFormat) === null || _23 === void 0 ? void 0 : _23.typeOf) === null || _24 === void 0 ? void 0 : _24.$eq;
|
|
389
477
|
if (typeof soundFormatTypeOfEq === 'string') {
|
|
390
478
|
andConditions.push({
|
|
391
479
|
'soundFormat.typeOf': {
|
|
@@ -394,7 +482,7 @@ class MongoRepository {
|
|
|
394
482
|
}
|
|
395
483
|
});
|
|
396
484
|
}
|
|
397
|
-
const soundFormatTypeOfIn = (
|
|
485
|
+
const soundFormatTypeOfIn = (_26 = (_25 = params.soundFormat) === null || _25 === void 0 ? void 0 : _25.typeOf) === null || _26 === void 0 ? void 0 : _26.$in;
|
|
398
486
|
if (Array.isArray(soundFormatTypeOfIn)) {
|
|
399
487
|
andConditions.push({
|
|
400
488
|
'soundFormat.typeOf': {
|
|
@@ -7,6 +7,7 @@ declare type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.scre
|
|
|
7
7
|
export declare class MongoRepository {
|
|
8
8
|
private readonly placeModel;
|
|
9
9
|
constructor(connection: Connection);
|
|
10
|
+
static CREATE_BUS_STOP_MONGO_CONDITIONS(params: factory.place.busStop.ISearchConditions): any[];
|
|
10
11
|
static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions): any[];
|
|
11
12
|
/**
|
|
12
13
|
* 施設を保管する
|
|
@@ -19,7 +20,6 @@ export declare class MongoRepository {
|
|
|
19
20
|
};
|
|
20
21
|
branchCode: string;
|
|
21
22
|
}): Promise<factory.place.movieTheater.IPlace>;
|
|
22
|
-
countMovieTheaters(params: factory.place.movieTheater.ISearchConditions): Promise<number>;
|
|
23
23
|
/**
|
|
24
24
|
* 施設検索
|
|
25
25
|
*/
|
|
@@ -114,6 +114,20 @@ export declare class MongoRepository {
|
|
|
114
114
|
id: string;
|
|
115
115
|
};
|
|
116
116
|
}): Promise<void>;
|
|
117
|
+
saveBusStop(params: factory.place.busStop.IPlace): Promise<factory.place.busStop.IPlace>;
|
|
118
|
+
findBusStopByBranchCode(params: {
|
|
119
|
+
project: {
|
|
120
|
+
id: string;
|
|
121
|
+
};
|
|
122
|
+
branchCode: string;
|
|
123
|
+
}): Promise<factory.place.movieTheater.IPlace>;
|
|
124
|
+
searchBusStops(params: factory.place.busStop.ISearchConditions): Promise<factory.place.busStop.IPlace[]>;
|
|
125
|
+
findBusStopById(params: {
|
|
126
|
+
id: string;
|
|
127
|
+
}, projection?: any): Promise<factory.place.busStop.IPlace>;
|
|
128
|
+
deleteBusStopById(params: {
|
|
129
|
+
id: string;
|
|
130
|
+
}): Promise<void>;
|
|
117
131
|
getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
|
|
118
132
|
}
|
|
119
133
|
export {};
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -32,6 +32,82 @@ class MongoRepository {
|
|
|
32
32
|
this.placeModel = connection.model(place_1.modelName);
|
|
33
33
|
}
|
|
34
34
|
// tslint:disable-next-line:max-func-body-length
|
|
35
|
+
static CREATE_BUS_STOP_MONGO_CONDITIONS(params) {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
37
|
+
const andConditions = [{ typeOf: { $eq: factory.placeType.BusStop } }];
|
|
38
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
|
+
if (typeof projectIdEq === 'string') {
|
|
40
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
41
|
+
}
|
|
42
|
+
const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
43
|
+
if (typeof branchCodeEq === 'string') {
|
|
44
|
+
andConditions.push({
|
|
45
|
+
branchCode: {
|
|
46
|
+
$exists: true,
|
|
47
|
+
$eq: branchCodeEq
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
|
|
52
|
+
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
53
|
+
andConditions.push({
|
|
54
|
+
branchCode: {
|
|
55
|
+
$exists: true,
|
|
56
|
+
$regex: new RegExp(branchCodeRegex)
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const branchCodeIn = (_e = params.branchCode) === null || _e === void 0 ? void 0 : _e.$in;
|
|
61
|
+
if (Array.isArray(branchCodeIn)) {
|
|
62
|
+
andConditions.push({
|
|
63
|
+
branchCode: {
|
|
64
|
+
$exists: true,
|
|
65
|
+
$in: branchCodeIn
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
70
|
+
/* istanbul ignore else */
|
|
71
|
+
const idEq = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
72
|
+
if (typeof idEq === 'string') {
|
|
73
|
+
andConditions.push({
|
|
74
|
+
_id: {
|
|
75
|
+
$eq: idEq
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const idIn = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$in;
|
|
80
|
+
if (Array.isArray(idIn)) {
|
|
81
|
+
andConditions.push({
|
|
82
|
+
_id: {
|
|
83
|
+
$in: idIn
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const nameRegex = (_h = params.name) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
88
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
89
|
+
/* istanbul ignore else */
|
|
90
|
+
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
91
|
+
andConditions.push({
|
|
92
|
+
$or: [
|
|
93
|
+
{
|
|
94
|
+
'name.ja': {
|
|
95
|
+
$exists: true,
|
|
96
|
+
$regex: new RegExp(nameRegex)
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
'name.en': {
|
|
101
|
+
$exists: true,
|
|
102
|
+
$regex: new RegExp(nameRegex)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return andConditions;
|
|
109
|
+
}
|
|
110
|
+
// tslint:disable-next-line:max-func-body-length
|
|
35
111
|
static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params) {
|
|
36
112
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
37
113
|
// MongoDB検索条件
|
|
@@ -171,6 +247,7 @@ class MongoRepository {
|
|
|
171
247
|
findMovieTheaterByBranchCode(params) {
|
|
172
248
|
return __awaiter(this, void 0, void 0, function* () {
|
|
173
249
|
return this.placeModel.findOne({
|
|
250
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
174
251
|
'project.id': { $eq: params.project.id },
|
|
175
252
|
branchCode: { $eq: params.branchCode }
|
|
176
253
|
})
|
|
@@ -183,14 +260,12 @@ class MongoRepository {
|
|
|
183
260
|
});
|
|
184
261
|
});
|
|
185
262
|
}
|
|
186
|
-
countMovieTheaters(params) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
});
|
|
193
|
-
}
|
|
263
|
+
// public async countMovieTheaters(params: factory.place.movieTheater.ISearchConditions): Promise<number> {
|
|
264
|
+
// const conditions = MongoRepository.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
|
|
265
|
+
// return this.placeModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
|
|
266
|
+
// .setOptions({ maxTimeMS: 10000 })
|
|
267
|
+
// .exec();
|
|
268
|
+
// }
|
|
194
269
|
/**
|
|
195
270
|
* 施設検索
|
|
196
271
|
*/
|
|
@@ -224,7 +299,10 @@ class MongoRepository {
|
|
|
224
299
|
*/
|
|
225
300
|
findById(params, projection) {
|
|
226
301
|
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
-
const doc = yield this.placeModel.findOne({
|
|
302
|
+
const doc = yield this.placeModel.findOne({
|
|
303
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
304
|
+
_id: { $eq: params.id }
|
|
305
|
+
}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
|
|
228
306
|
.exec();
|
|
229
307
|
if (doc === null) {
|
|
230
308
|
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
@@ -235,7 +313,8 @@ class MongoRepository {
|
|
|
235
313
|
deleteMovieTheaterById(params) {
|
|
236
314
|
return __awaiter(this, void 0, void 0, function* () {
|
|
237
315
|
yield this.placeModel.findOneAndDelete({
|
|
238
|
-
|
|
316
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
317
|
+
_id: { $eq: params.id }
|
|
239
318
|
})
|
|
240
319
|
.exec()
|
|
241
320
|
.then((doc) => {
|
|
@@ -1066,6 +1145,92 @@ class MongoRepository {
|
|
|
1066
1145
|
.exec();
|
|
1067
1146
|
});
|
|
1068
1147
|
}
|
|
1148
|
+
saveBusStop(params) {
|
|
1149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1150
|
+
let doc;
|
|
1151
|
+
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
1152
|
+
doc = yield this.placeModel.create(params);
|
|
1153
|
+
}
|
|
1154
|
+
else {
|
|
1155
|
+
// 上書き禁止属性を除外(2022-08-24~)
|
|
1156
|
+
const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
|
|
1157
|
+
doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
|
|
1158
|
+
.exec();
|
|
1159
|
+
}
|
|
1160
|
+
if (doc === null) {
|
|
1161
|
+
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
1162
|
+
}
|
|
1163
|
+
return doc.toObject();
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
findBusStopByBranchCode(params) {
|
|
1167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1168
|
+
return this.placeModel.findOne({
|
|
1169
|
+
typeOf: { $eq: factory.placeType.BusStop },
|
|
1170
|
+
'project.id': { $eq: params.project.id },
|
|
1171
|
+
branchCode: { $eq: params.branchCode }
|
|
1172
|
+
})
|
|
1173
|
+
.exec()
|
|
1174
|
+
.then((doc) => {
|
|
1175
|
+
if (doc === null) {
|
|
1176
|
+
throw new factory.errors.NotFound(`${factory.placeType.BusStop} ${params.branchCode}`);
|
|
1177
|
+
}
|
|
1178
|
+
return doc.toObject();
|
|
1179
|
+
});
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
searchBusStops(params) {
|
|
1183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1184
|
+
const conditions = MongoRepository.CREATE_BUS_STOP_MONGO_CONDITIONS(params);
|
|
1185
|
+
// containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
|
|
1186
|
+
const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
|
|
1187
|
+
__v: 0,
|
|
1188
|
+
createdAt: 0,
|
|
1189
|
+
updatedAt: 0,
|
|
1190
|
+
containsPlace: 0
|
|
1191
|
+
});
|
|
1192
|
+
if (typeof params.limit === 'number') {
|
|
1193
|
+
const page = (typeof params.page === 'number') ? params.page : 1;
|
|
1194
|
+
query.limit(params.limit)
|
|
1195
|
+
.skip(params.limit * (page - 1));
|
|
1196
|
+
}
|
|
1197
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
1198
|
+
/* istanbul ignore else */
|
|
1199
|
+
if (params.sort !== undefined) {
|
|
1200
|
+
query.sort(params.sort);
|
|
1201
|
+
}
|
|
1202
|
+
return query.setOptions({ maxTimeMS: 10000 })
|
|
1203
|
+
.exec()
|
|
1204
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
findBusStopById(params, projection) {
|
|
1208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1209
|
+
const doc = yield this.placeModel.findOne({
|
|
1210
|
+
typeOf: { $eq: factory.placeType.BusStop },
|
|
1211
|
+
_id: { $eq: params.id }
|
|
1212
|
+
}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
|
|
1213
|
+
.exec();
|
|
1214
|
+
if (doc === null) {
|
|
1215
|
+
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
1216
|
+
}
|
|
1217
|
+
return doc.toObject();
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
deleteBusStopById(params) {
|
|
1221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1222
|
+
yield this.placeModel.findOneAndDelete({
|
|
1223
|
+
typeOf: { $eq: factory.placeType.BusStop },
|
|
1224
|
+
_id: { $eq: params.id }
|
|
1225
|
+
})
|
|
1226
|
+
.exec()
|
|
1227
|
+
.then((doc) => {
|
|
1228
|
+
if (doc === null) {
|
|
1229
|
+
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1069
1234
|
getCursor(conditions, projection) {
|
|
1070
1235
|
return this.placeModel.find(conditions, projection)
|
|
1071
1236
|
.sort({ branchCode: factory.sortType.Ascending })
|