@chevre/domain 21.2.0 → 21.3.0
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/findScreeningRoomsByBranchCode.ts +1 -2
- package/example/src/chevre/ownershipInfosCsv2peopleJson.ts +1 -1
- package/example/src/chevre/searchScreeningRooms.ts +2 -4
- package/example/src/chevre/syncScreeningRooms.ts +1 -2
- package/example/src/chevre/syncScreeningRoomsAll.ts +1 -4
- package/lib/chevre/repo/place.d.ts +13 -73
- package/lib/chevre/repo/place.js +769 -1638
- package/lib/chevre/repo/seller.d.ts +1 -1
- package/lib/chevre/repo/seller.js +23 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -2
- package/lib/chevre/service/assetTransaction/reserve.js +1 -1
- package/lib/chevre/service/event.js +2 -3
- package/lib/chevre/service/offer.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/lib/chevre/service/task/syncScreeningRooms.js +1 -2
- package/lib/chevre/settings.d.ts +0 -2
- package/lib/chevre/settings.js +1 -3
- package/package.json +1 -1
package/lib/chevre/repo/place.js
CHANGED
|
@@ -21,12 +21,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
|
-
const createDebug = require("debug");
|
|
25
|
-
const mongoose_1 = require("mongoose");
|
|
26
24
|
const place_1 = require("./mongoose/schemas/place");
|
|
27
25
|
const factory = require("../factory");
|
|
28
26
|
const settings_1 = require("../settings");
|
|
29
|
-
const debug = createDebug('chevre-domain:repo:place');
|
|
27
|
+
// const debug = createDebug('chevre-domain:repo:place');
|
|
30
28
|
/**
|
|
31
29
|
* 施設リポジトリ
|
|
32
30
|
*/
|
|
@@ -295,31 +293,6 @@ class MongoRepository {
|
|
|
295
293
|
})));
|
|
296
294
|
});
|
|
297
295
|
}
|
|
298
|
-
// 廃止(2023-06-23~)
|
|
299
|
-
// public async findMovieTheaterByBranchCode(params: {
|
|
300
|
-
// project: { id: string };
|
|
301
|
-
// branchCode: string;
|
|
302
|
-
// }): Promise<factory.place.movieTheater.IPlace> {
|
|
303
|
-
// return this.placeModel.findOne(
|
|
304
|
-
// {
|
|
305
|
-
// typeOf: { $eq: factory.placeType.MovieTheater },
|
|
306
|
-
// 'project.id': { $eq: params.project.id },
|
|
307
|
-
// branchCode: { $eq: params.branchCode }
|
|
308
|
-
// },
|
|
309
|
-
// {
|
|
310
|
-
// __v: 0,
|
|
311
|
-
// createdAt: 0,
|
|
312
|
-
// updatedAt: 0
|
|
313
|
-
// }
|
|
314
|
-
// )
|
|
315
|
-
// .exec()
|
|
316
|
-
// .then((doc) => {
|
|
317
|
-
// if (doc === null) {
|
|
318
|
-
// throw new factory.errors.NotFound(`${factory.placeType.MovieTheater} ${params.branchCode}`);
|
|
319
|
-
// }
|
|
320
|
-
// return doc.toObject();
|
|
321
|
-
// });
|
|
322
|
-
// }
|
|
323
296
|
/**
|
|
324
297
|
* 施設検索
|
|
325
298
|
*/
|
|
@@ -365,45 +338,6 @@ class MongoRepository {
|
|
|
365
338
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
366
339
|
});
|
|
367
340
|
}
|
|
368
|
-
/**
|
|
369
|
-
* 施設取得
|
|
370
|
-
* 廃止(2023-06-22~)
|
|
371
|
-
*/
|
|
372
|
-
// public async findById(
|
|
373
|
-
// params: { id: string },
|
|
374
|
-
// inclusion: string[],
|
|
375
|
-
// exclusion: string[]
|
|
376
|
-
// ): Promise<factory.place.movieTheater.IPlace> {
|
|
377
|
-
// let projection: { [key: string]: number } = {};
|
|
378
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
379
|
-
// inclusion.forEach((field) => {
|
|
380
|
-
// projection[field] = 1;
|
|
381
|
-
// });
|
|
382
|
-
// } else {
|
|
383
|
-
// projection = {
|
|
384
|
-
// __v: 0,
|
|
385
|
-
// createdAt: 0,
|
|
386
|
-
// updatedAt: 0
|
|
387
|
-
// };
|
|
388
|
-
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
389
|
-
// exclusion.forEach((field) => {
|
|
390
|
-
// projection[field] = 0;
|
|
391
|
-
// });
|
|
392
|
-
// }
|
|
393
|
-
// }
|
|
394
|
-
// const doc = await this.placeModel.findOne(
|
|
395
|
-
// {
|
|
396
|
-
// typeOf: { $eq: factory.placeType.MovieTheater },
|
|
397
|
-
// _id: { $eq: params.id }
|
|
398
|
-
// },
|
|
399
|
-
// projection
|
|
400
|
-
// )
|
|
401
|
-
// .exec();
|
|
402
|
-
// if (doc === null) {
|
|
403
|
-
// throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
404
|
-
// }
|
|
405
|
-
// return doc.toObject();
|
|
406
|
-
// }
|
|
407
341
|
deleteMovieTheaterById(params) {
|
|
408
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
409
343
|
yield this.placeModel.findOneAndDelete({
|
|
@@ -418,142 +352,75 @@ class MongoRepository {
|
|
|
418
352
|
});
|
|
419
353
|
});
|
|
420
354
|
}
|
|
421
|
-
createScreeningRoom(screeningRoom
|
|
355
|
+
createScreeningRoom(screeningRoom) {
|
|
422
356
|
return __awaiter(this, void 0, void 0, function* () {
|
|
423
357
|
// 施設存在確認
|
|
424
|
-
|
|
358
|
+
const movieTheaterDoc = yield this.placeModel.findOne({
|
|
425
359
|
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
426
360
|
'project.id': { $eq: screeningRoom.project.id },
|
|
427
361
|
branchCode: { $eq: screeningRoom.containedInPlace.branchCode }
|
|
428
362
|
}, { _id: 1, typeOf: 1, branchCode: 1, name: 1 })
|
|
429
363
|
.exec();
|
|
430
|
-
if (
|
|
364
|
+
if (movieTheaterDoc === null) {
|
|
431
365
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
432
366
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
|
|
455
|
-
}
|
|
456
|
-
return {
|
|
457
|
-
containedInPlace: { id: creatingScreeningRoom.containedInPlace.id },
|
|
458
|
-
typeOf: factory.placeType.ScreeningRoom
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
// ルームコードが存在しなければ追加する
|
|
463
|
-
doc = yield this.placeModel.findOneAndUpdate({
|
|
464
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
465
|
-
'project.id': { $eq: screeningRoom.project.id },
|
|
466
|
-
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
467
|
-
'containsPlace.branchCode': { $ne: screeningRoom.branchCode }
|
|
468
|
-
}, {
|
|
469
|
-
$push: {
|
|
470
|
-
containsPlace: {
|
|
471
|
-
typeOf: screeningRoom.typeOf,
|
|
472
|
-
branchCode: screeningRoom.branchCode,
|
|
473
|
-
name: screeningRoom.name,
|
|
474
|
-
address: screeningRoom.address,
|
|
475
|
-
additionalProperty: screeningRoom.additionalProperty
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}, {
|
|
479
|
-
new: true,
|
|
480
|
-
projection: {
|
|
481
|
-
_id: 1,
|
|
482
|
-
branchCode: 1,
|
|
483
|
-
typeOf: 1
|
|
484
|
-
}
|
|
485
|
-
})
|
|
486
|
-
.exec();
|
|
487
|
-
// 存在しなければコード重複
|
|
488
|
-
if (doc === null) {
|
|
489
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
|
|
490
|
-
}
|
|
491
|
-
return doc.toObject();
|
|
367
|
+
const movieTheater = movieTheaterDoc.toObject();
|
|
368
|
+
const creatingScreeningRoom = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
|
|
369
|
+
id: movieTheater.id,
|
|
370
|
+
typeOf: movieTheater.typeOf,
|
|
371
|
+
branchCode: movieTheater.branchCode,
|
|
372
|
+
name: movieTheater.name
|
|
373
|
+
}, containsPlace: [], project: screeningRoom.project }, (typeof screeningRoom.openSeatingAllowed === 'boolean')
|
|
374
|
+
? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
|
|
375
|
+
: undefined);
|
|
376
|
+
const upsertScreeningRoomResult = yield this.placeModel.updateOne({
|
|
377
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
378
|
+
'project.id': { $eq: creatingScreeningRoom.project.id },
|
|
379
|
+
'containedInPlace.id': { $exists: true, $eq: creatingScreeningRoom.containedInPlace.id },
|
|
380
|
+
branchCode: { $eq: creatingScreeningRoom.branchCode }
|
|
381
|
+
},
|
|
382
|
+
// 既存であれば何もしない
|
|
383
|
+
{ $setOnInsert: creatingScreeningRoom }, { upsert: true })
|
|
384
|
+
.exec();
|
|
385
|
+
// 既存であればコード重複
|
|
386
|
+
if (upsertScreeningRoomResult.matchedCount > 0) {
|
|
387
|
+
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
|
|
492
388
|
}
|
|
389
|
+
return {
|
|
390
|
+
containedInPlace: { id: creatingScreeningRoom.containedInPlace.id },
|
|
391
|
+
typeOf: factory.placeType.ScreeningRoom
|
|
392
|
+
};
|
|
493
393
|
});
|
|
494
394
|
}
|
|
495
|
-
updateScreeningRoom(screeningRoom, $unset
|
|
395
|
+
updateScreeningRoom(screeningRoom, $unset) {
|
|
496
396
|
return __awaiter(this, void 0, void 0, function* () {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
openSeatingAllowed: 1
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
: undefined), {
|
|
517
|
-
new: true,
|
|
518
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
519
|
-
})
|
|
520
|
-
.exec();
|
|
521
|
-
if (doc === null) {
|
|
522
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
523
|
-
}
|
|
524
|
-
return doc.toObject();
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
528
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
529
|
-
'project.id': { $eq: screeningRoom.project.id },
|
|
530
|
-
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
531
|
-
'containsPlace.branchCode': screeningRoom.branchCode
|
|
532
|
-
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].name': screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
|
|
533
|
-
? { 'containsPlace.$[screeningRoom].address': screeningRoom.address }
|
|
534
|
-
: undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
|
|
535
|
-
? { 'containsPlace.$[screeningRoom].openSeatingAllowed': screeningRoom.openSeatingAllowed }
|
|
536
|
-
: undefined), (Array.isArray(screeningRoom.additionalProperty))
|
|
537
|
-
? { 'containsPlace.$[screeningRoom].additionalProperty': screeningRoom.additionalProperty }
|
|
538
|
-
: undefined), ($unset !== undefined && $unset !== null)
|
|
539
|
-
? { $unset }
|
|
540
|
-
: undefined), {
|
|
541
|
-
new: true,
|
|
542
|
-
arrayFilters: [
|
|
543
|
-
{ 'screeningRoom.branchCode': screeningRoom.branchCode }
|
|
544
|
-
],
|
|
545
|
-
projection: {
|
|
546
|
-
_id: 1,
|
|
547
|
-
branchCode: 1,
|
|
548
|
-
typeOf: 1
|
|
397
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
398
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
399
|
+
'project.id': { $eq: screeningRoom.project.id },
|
|
400
|
+
'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
|
|
401
|
+
branchCode: screeningRoom.branchCode
|
|
402
|
+
}, Object.assign(Object.assign(Object.assign(Object.assign({ name: screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
|
|
403
|
+
? { address: screeningRoom.address }
|
|
404
|
+
: undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
|
|
405
|
+
? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
|
|
406
|
+
: undefined), (Array.isArray(screeningRoom.additionalProperty))
|
|
407
|
+
? { additionalProperty: screeningRoom.additionalProperty }
|
|
408
|
+
: undefined), (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].openSeatingAllowed']) === 1
|
|
409
|
+
|| $unset.openSeatingAllowed === 1)
|
|
410
|
+
? {
|
|
411
|
+
$unset: {
|
|
412
|
+
openSeatingAllowed: 1
|
|
549
413
|
}
|
|
550
|
-
})
|
|
551
|
-
.exec();
|
|
552
|
-
if (doc === null) {
|
|
553
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
554
414
|
}
|
|
555
|
-
|
|
415
|
+
: undefined), {
|
|
416
|
+
new: true,
|
|
417
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
418
|
+
})
|
|
419
|
+
.exec();
|
|
420
|
+
if (doc === null) {
|
|
421
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
556
422
|
}
|
|
423
|
+
return doc.toObject();
|
|
557
424
|
});
|
|
558
425
|
}
|
|
559
426
|
updateScreeningRoomsByContainedInPlaceId(screeningRoom) {
|
|
@@ -571,45 +438,21 @@ class MongoRepository {
|
|
|
571
438
|
}
|
|
572
439
|
});
|
|
573
440
|
}
|
|
574
|
-
deleteScreeningRoom(screeningRoom
|
|
441
|
+
deleteScreeningRoom(screeningRoom) {
|
|
575
442
|
return __awaiter(this, void 0, void 0, function* () {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
588
|
-
}
|
|
589
|
-
return doc.toObject();
|
|
590
|
-
}
|
|
591
|
-
else {
|
|
592
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
593
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
594
|
-
'project.id': { $eq: screeningRoom.project.id },
|
|
595
|
-
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
596
|
-
'containsPlace.branchCode': screeningRoom.branchCode
|
|
597
|
-
}, {
|
|
598
|
-
$pull: {
|
|
599
|
-
containsPlace: { branchCode: screeningRoom.branchCode }
|
|
600
|
-
}
|
|
601
|
-
}, {
|
|
602
|
-
projection: {
|
|
603
|
-
_id: 1,
|
|
604
|
-
typeOf: 1
|
|
605
|
-
}
|
|
606
|
-
})
|
|
607
|
-
.exec();
|
|
608
|
-
if (doc === null) {
|
|
609
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
610
|
-
}
|
|
611
|
-
return doc.toObject();
|
|
443
|
+
const doc = yield this.placeModel.findOneAndDelete({
|
|
444
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
445
|
+
'project.id': { $eq: screeningRoom.project.id },
|
|
446
|
+
'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
|
|
447
|
+
branchCode: screeningRoom.branchCode
|
|
448
|
+
}, {
|
|
449
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
450
|
+
})
|
|
451
|
+
.exec();
|
|
452
|
+
if (doc === null) {
|
|
453
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
612
454
|
}
|
|
455
|
+
return doc.toObject();
|
|
613
456
|
});
|
|
614
457
|
}
|
|
615
458
|
deleteScreeningRoomsByMovieTheaterId(params) {
|
|
@@ -623,7 +466,7 @@ class MongoRepository {
|
|
|
623
466
|
});
|
|
624
467
|
}
|
|
625
468
|
// tslint:disable-next-line:max-func-body-length
|
|
626
|
-
createScreeningRoomSection(screeningRoomSection
|
|
469
|
+
createScreeningRoomSection(screeningRoomSection) {
|
|
627
470
|
return __awaiter(this, void 0, void 0, function* () {
|
|
628
471
|
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
629
472
|
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
@@ -643,67 +486,33 @@ class MongoRepository {
|
|
|
643
486
|
if (doc === null) {
|
|
644
487
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
645
488
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
: undefined)
|
|
659
|
-
}
|
|
660
|
-
}, {
|
|
661
|
-
new: true,
|
|
662
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
663
|
-
})
|
|
664
|
-
.exec();
|
|
665
|
-
// 存在しなければコード重複
|
|
666
|
-
if (doc === null) {
|
|
667
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
|
|
668
|
-
}
|
|
669
|
-
return doc.toObject();
|
|
670
|
-
}
|
|
671
|
-
else {
|
|
672
|
-
doc = yield this.placeModel.findOneAndUpdate({
|
|
673
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
674
|
-
'project.id': { $eq: screeningRoomSection.project.id },
|
|
675
|
-
branchCode: movieTheater.branchCode,
|
|
676
|
-
'containsPlace.branchCode': screeningRoom.branchCode
|
|
677
|
-
}, {
|
|
678
|
-
$push: {
|
|
679
|
-
'containsPlace.$[screeningRoom].containsPlace': Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
|
|
680
|
-
? { additionalProperty: screeningRoomSection.additionalProperty }
|
|
681
|
-
: undefined)
|
|
682
|
-
}
|
|
683
|
-
}, {
|
|
684
|
-
new: true,
|
|
685
|
-
arrayFilters: [
|
|
686
|
-
{
|
|
687
|
-
'screeningRoom.branchCode': screeningRoom.branchCode,
|
|
688
|
-
'screeningRoom.containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
|
|
689
|
-
}
|
|
690
|
-
],
|
|
691
|
-
projection: {
|
|
692
|
-
_id: 1,
|
|
693
|
-
typeOf: 1
|
|
694
|
-
}
|
|
695
|
-
})
|
|
696
|
-
.exec();
|
|
697
|
-
// 存在しなければコード重複
|
|
698
|
-
if (doc === null) {
|
|
699
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
|
|
489
|
+
// セクションコードが存在しなければ追加する
|
|
490
|
+
doc = yield this.placeModel.findOneAndUpdate({
|
|
491
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
492
|
+
'project.id': { $eq: screeningRoomSection.project.id },
|
|
493
|
+
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
494
|
+
branchCode: { $eq: screeningRoom.branchCode },
|
|
495
|
+
'containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
|
|
496
|
+
}, {
|
|
497
|
+
$push: {
|
|
498
|
+
containsPlace: Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
|
|
499
|
+
? { additionalProperty: screeningRoomSection.additionalProperty }
|
|
500
|
+
: undefined)
|
|
700
501
|
}
|
|
701
|
-
|
|
502
|
+
}, {
|
|
503
|
+
new: true,
|
|
504
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
505
|
+
})
|
|
506
|
+
.exec();
|
|
507
|
+
// 存在しなければコード重複
|
|
508
|
+
if (doc === null) {
|
|
509
|
+
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
|
|
702
510
|
}
|
|
511
|
+
return doc.toObject();
|
|
703
512
|
});
|
|
704
513
|
}
|
|
705
514
|
// tslint:disable-next-line:max-func-body-length
|
|
706
|
-
updateScreeningRoomSection(screeningRoomSection, $unset
|
|
515
|
+
updateScreeningRoomSection(screeningRoomSection, $unset) {
|
|
707
516
|
return __awaiter(this, void 0, void 0, function* () {
|
|
708
517
|
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
709
518
|
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
@@ -713,772 +522,327 @@ class MongoRepository {
|
|
|
713
522
|
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
714
523
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
715
524
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
})
|
|
736
|
-
}
|
|
737
|
-
: undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
|
|
738
|
-
new: true,
|
|
739
|
-
arrayFilters: [
|
|
740
|
-
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
|
|
741
|
-
],
|
|
742
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
743
|
-
})
|
|
744
|
-
.exec();
|
|
745
|
-
if (doc === null) {
|
|
746
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
747
|
-
}
|
|
748
|
-
return doc.toObject();
|
|
749
|
-
}
|
|
750
|
-
else {
|
|
751
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
752
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
753
|
-
'project.id': { $eq: screeningRoomSection.project.id },
|
|
754
|
-
branchCode: movieTheater.branchCode,
|
|
755
|
-
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
756
|
-
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
|
|
757
|
-
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
|
|
758
|
-
? {
|
|
759
|
-
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
|
|
760
|
-
}
|
|
761
|
-
: undefined), (Array.isArray(screeningRoomSection.additionalProperty))
|
|
762
|
-
? {
|
|
763
|
-
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
|
|
764
|
-
}
|
|
765
|
-
: undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
|
|
766
|
-
? {
|
|
767
|
-
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
|
|
768
|
-
return Object.assign(Object.assign(Object.assign({ typeOf: p.typeOf, branchCode: p.branchCode }, (p.name !== undefined && p.name !== null) ? { name: p.name } : undefined), (Array.isArray(p.seatingType)) ? { seatingType: p.seatingType } : undefined), (Array.isArray(p.additionalProperty)) ? { additionalProperty: p.additionalProperty } : undefined);
|
|
769
|
-
})
|
|
770
|
-
}
|
|
771
|
-
: undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
|
|
772
|
-
new: true,
|
|
773
|
-
arrayFilters: [
|
|
774
|
-
{ 'screeningRoom.branchCode': screeningRoom.branchCode },
|
|
775
|
-
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
|
|
776
|
-
],
|
|
777
|
-
projection: {
|
|
778
|
-
_id: 1,
|
|
779
|
-
typeOf: 1
|
|
780
|
-
}
|
|
781
|
-
})
|
|
782
|
-
.exec();
|
|
783
|
-
if (doc === null) {
|
|
784
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
525
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
526
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
527
|
+
'project.id': { $eq: screeningRoomSection.project.id },
|
|
528
|
+
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
529
|
+
branchCode: { $eq: screeningRoom.branchCode },
|
|
530
|
+
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
|
|
531
|
+
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
|
|
532
|
+
? {
|
|
533
|
+
'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
|
|
534
|
+
}
|
|
535
|
+
: undefined), (Array.isArray(screeningRoomSection.additionalProperty))
|
|
536
|
+
? {
|
|
537
|
+
'containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
|
|
538
|
+
}
|
|
539
|
+
: undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
|
|
540
|
+
? {
|
|
541
|
+
'containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
|
|
542
|
+
return Object.assign(Object.assign(Object.assign({ typeOf: p.typeOf, branchCode: p.branchCode }, (p.name !== undefined && p.name !== null) ? { name: p.name } : undefined), (Array.isArray(p.seatingType)) ? { seatingType: p.seatingType } : undefined), (Array.isArray(p.additionalProperty)) ? { additionalProperty: p.additionalProperty } : undefined);
|
|
543
|
+
})
|
|
785
544
|
}
|
|
786
|
-
|
|
545
|
+
: undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
|
|
546
|
+
new: true,
|
|
547
|
+
arrayFilters: [
|
|
548
|
+
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
|
|
549
|
+
],
|
|
550
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
551
|
+
})
|
|
552
|
+
.exec();
|
|
553
|
+
if (doc === null) {
|
|
554
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
787
555
|
}
|
|
556
|
+
return doc.toObject();
|
|
788
557
|
});
|
|
789
558
|
}
|
|
790
559
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
791
|
-
searchScreeningRoomSections(searchConditions
|
|
792
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
560
|
+
searchScreeningRoomSections(searchConditions) {
|
|
561
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
793
562
|
return __awaiter(this, void 0, void 0, function* () {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
$eq: movieTheaterBranchCodeEq
|
|
810
|
-
}
|
|
563
|
+
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
|
|
564
|
+
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
565
|
+
if (typeof projectIdEq === 'string') {
|
|
566
|
+
matchStages.push({
|
|
567
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
// 施設コード
|
|
571
|
+
const movieTheaterBranchCodeEq = (_e = (_d = (_c = searchConditions.containedInPlace) === null || _c === void 0 ? void 0 : _c.containedInPlace) === null || _d === void 0 ? void 0 : _d.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
572
|
+
if (typeof movieTheaterBranchCodeEq === 'string') {
|
|
573
|
+
matchStages.push({
|
|
574
|
+
$match: {
|
|
575
|
+
'containedInPlace.branchCode': {
|
|
576
|
+
$exists: true,
|
|
577
|
+
$eq: movieTheaterBranchCodeEq
|
|
811
578
|
}
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
// ルームコード
|
|
583
|
+
const containedInPlaceBranchCodeEq = (_g = (_f = searchConditions.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
584
|
+
if (typeof containedInPlaceBranchCodeEq === 'string') {
|
|
585
|
+
matchStages.push({
|
|
586
|
+
$match: {
|
|
587
|
+
branchCode: {
|
|
588
|
+
$eq: containedInPlaceBranchCodeEq
|
|
822
589
|
}
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
// セクションコード
|
|
594
|
+
const sectionBranchCodeEq = (_h = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
595
|
+
if (typeof sectionBranchCodeEq === 'string') {
|
|
596
|
+
matchStages.push({
|
|
597
|
+
$match: {
|
|
598
|
+
'containsPlace.branchCode': {
|
|
599
|
+
$exists: true,
|
|
600
|
+
$eq: sectionBranchCodeEq
|
|
834
601
|
}
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
const nameCodeRegex = (_j = searchConditions.name) === null || _j === void 0 ? void 0 : _j.$regex;
|
|
606
|
+
if (typeof nameCodeRegex === 'string') {
|
|
607
|
+
matchStages.push({
|
|
608
|
+
$match: {
|
|
609
|
+
$or: [
|
|
610
|
+
{
|
|
611
|
+
'containsPlace.name.ja': {
|
|
612
|
+
$exists: true,
|
|
613
|
+
$regex: new RegExp(nameCodeRegex)
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
'containsPlace.name.en': {
|
|
618
|
+
$exists: true,
|
|
619
|
+
$regex: new RegExp(nameCodeRegex)
|
|
853
620
|
}
|
|
854
|
-
]
|
|
855
|
-
}
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
const branchCodeRegex = (_k = searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
|
|
859
|
-
if (typeof branchCodeRegex === 'string') {
|
|
860
|
-
matchStages.push({
|
|
861
|
-
$match: {
|
|
862
|
-
'containsPlace.branchCode': {
|
|
863
|
-
$exists: true,
|
|
864
|
-
$regex: new RegExp(branchCodeRegex)
|
|
865
621
|
}
|
|
622
|
+
]
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
const branchCodeRegex = (_k = searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
|
|
627
|
+
if (typeof branchCodeRegex === 'string') {
|
|
628
|
+
matchStages.push({
|
|
629
|
+
$match: {
|
|
630
|
+
'containsPlace.branchCode': {
|
|
631
|
+
$exists: true,
|
|
632
|
+
$regex: new RegExp(branchCodeRegex)
|
|
866
633
|
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
638
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
639
|
+
matchStages.push({
|
|
640
|
+
$match: {
|
|
641
|
+
'containsPlace.additionalProperty': {
|
|
642
|
+
$exists: true,
|
|
643
|
+
$elemMatch: additionalPropertyElemMatch
|
|
877
644
|
}
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
const aggregate = this.placeModel.aggregate([
|
|
881
|
-
{ $unwind: '$containsPlace' },
|
|
882
|
-
...matchStages,
|
|
883
|
-
{
|
|
884
|
-
$project: Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', containedInPlace: {
|
|
885
|
-
typeOf: '$typeOf',
|
|
886
|
-
branchCode: '$branchCode',
|
|
887
|
-
name: '$name',
|
|
888
|
-
containedInPlace: {
|
|
889
|
-
id: '$containedInPlace.id',
|
|
890
|
-
typeOf: '$containedInPlace.typeOf',
|
|
891
|
-
branchCode: '$containedInPlace.branchCode',
|
|
892
|
-
name: '$containedInPlace.name'
|
|
893
|
-
}
|
|
894
|
-
}, additionalProperty: '$containsPlace.additionalProperty' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.seatCount) === 1)
|
|
895
|
-
? {
|
|
896
|
-
seatCount: {
|
|
897
|
-
$cond: {
|
|
898
|
-
if: { $isArray: '$containsPlace.containsPlace' },
|
|
899
|
-
then: { $size: '$containsPlace.containsPlace' },
|
|
900
|
-
else: 0
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
: undefined)
|
|
905
645
|
}
|
|
906
|
-
|
|
907
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
908
|
-
/* istanbul ignore else */
|
|
909
|
-
if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
|
|
910
|
-
const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
|
|
911
|
-
aggregate.limit(searchConditions.limit * page)
|
|
912
|
-
.skip(searchConditions.limit * (page - 1));
|
|
913
|
-
}
|
|
914
|
-
return aggregate.exec();
|
|
646
|
+
});
|
|
915
647
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
branchCode: {
|
|
930
|
-
$exists: true,
|
|
931
|
-
$eq: movieTheaterBranchCodeEq
|
|
648
|
+
const aggregate = this.placeModel.aggregate([
|
|
649
|
+
{ $unwind: '$containsPlace' },
|
|
650
|
+
...matchStages,
|
|
651
|
+
{
|
|
652
|
+
$project: Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', containedInPlace: {
|
|
653
|
+
typeOf: '$typeOf',
|
|
654
|
+
branchCode: '$branchCode',
|
|
655
|
+
name: '$name',
|
|
656
|
+
containedInPlace: {
|
|
657
|
+
id: '$containedInPlace.id',
|
|
658
|
+
typeOf: '$containedInPlace.typeOf',
|
|
659
|
+
branchCode: '$containedInPlace.branchCode',
|
|
660
|
+
name: '$containedInPlace.name'
|
|
932
661
|
}
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
'containsPlace.branchCode': {
|
|
942
|
-
$exists: true,
|
|
943
|
-
$eq: containedInPlaceBranchCodeEq
|
|
662
|
+
}, additionalProperty: '$containsPlace.additionalProperty' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.seatCount) === 1)
|
|
663
|
+
? {
|
|
664
|
+
seatCount: {
|
|
665
|
+
$cond: {
|
|
666
|
+
if: { $isArray: '$containsPlace.containsPlace' },
|
|
667
|
+
then: { $size: '$containsPlace.containsPlace' },
|
|
668
|
+
else: 0
|
|
669
|
+
}
|
|
944
670
|
}
|
|
945
671
|
}
|
|
946
|
-
|
|
672
|
+
: undefined)
|
|
947
673
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
$eq: sectionBranchCodeEq
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
const nameCodeRegex = (_w = searchConditions.name) === null || _w === void 0 ? void 0 : _w.$regex;
|
|
961
|
-
if (typeof nameCodeRegex === 'string') {
|
|
962
|
-
matchStages.push({
|
|
963
|
-
$match: {
|
|
964
|
-
$or: [
|
|
965
|
-
{
|
|
966
|
-
'containsPlace.containsPlace.name.ja': {
|
|
967
|
-
$exists: true,
|
|
968
|
-
$regex: new RegExp(nameCodeRegex)
|
|
969
|
-
}
|
|
970
|
-
},
|
|
971
|
-
{
|
|
972
|
-
'containsPlace.containsPlace.name.en': {
|
|
973
|
-
$exists: true,
|
|
974
|
-
$regex: new RegExp(nameCodeRegex)
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
]
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
const branchCodeRegex = (_x = searchConditions.branchCode) === null || _x === void 0 ? void 0 : _x.$regex;
|
|
982
|
-
if (typeof branchCodeRegex === 'string') {
|
|
983
|
-
matchStages.push({
|
|
984
|
-
$match: {
|
|
985
|
-
'containsPlace.containsPlace.branchCode': {
|
|
986
|
-
$exists: true,
|
|
987
|
-
$regex: new RegExp(branchCodeRegex)
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
const additionalPropertyElemMatch = (_y = searchConditions.additionalProperty) === null || _y === void 0 ? void 0 : _y.$elemMatch;
|
|
993
|
-
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
994
|
-
matchStages.push({
|
|
995
|
-
$match: {
|
|
996
|
-
'containsPlace.containsPlace.additionalProperty': {
|
|
997
|
-
$exists: true,
|
|
998
|
-
$elemMatch: additionalPropertyElemMatch
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
const aggregate = this.placeModel.aggregate([
|
|
1004
|
-
{ $unwind: '$containsPlace' },
|
|
1005
|
-
{ $unwind: '$containsPlace.containsPlace' },
|
|
1006
|
-
...matchStages,
|
|
1007
|
-
{
|
|
1008
|
-
$project: Object.assign({ _id: 0, typeOf: '$containsPlace.containsPlace.typeOf', branchCode: '$containsPlace.containsPlace.branchCode', name: '$containsPlace.containsPlace.name', containedInPlace: {
|
|
1009
|
-
typeOf: '$containsPlace.typeOf',
|
|
1010
|
-
branchCode: '$containsPlace.branchCode',
|
|
1011
|
-
name: '$containsPlace.name',
|
|
1012
|
-
containedInPlace: {
|
|
1013
|
-
id: { $toString: '$_id' },
|
|
1014
|
-
// id: '$_id',
|
|
1015
|
-
typeOf: '$typeOf',
|
|
1016
|
-
branchCode: '$branchCode',
|
|
1017
|
-
name: '$name'
|
|
1018
|
-
}
|
|
1019
|
-
}, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((_z = searchConditions.$projection) === null || _z === void 0 ? void 0 : _z.seatCount) === 1)
|
|
1020
|
-
? {
|
|
1021
|
-
seatCount: {
|
|
1022
|
-
$cond: {
|
|
1023
|
-
if: { $isArray: '$containsPlace.containsPlace.containsPlace' },
|
|
1024
|
-
then: { $size: '$containsPlace.containsPlace.containsPlace' },
|
|
1025
|
-
else: 0
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
: undefined)
|
|
1030
|
-
}
|
|
1031
|
-
]);
|
|
1032
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
1033
|
-
/* istanbul ignore else */
|
|
1034
|
-
if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
|
|
1035
|
-
const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
|
|
1036
|
-
aggregate.limit(searchConditions.limit * page)
|
|
1037
|
-
.skip(searchConditions.limit * (page - 1));
|
|
1038
|
-
}
|
|
1039
|
-
return aggregate.exec();
|
|
674
|
+
]);
|
|
675
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
676
|
+
/* istanbul ignore else */
|
|
677
|
+
if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
|
|
678
|
+
const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
|
|
679
|
+
aggregate.limit(searchConditions.limit * page)
|
|
680
|
+
.skip(searchConditions.limit * (page - 1));
|
|
1040
681
|
}
|
|
682
|
+
return aggregate.exec();
|
|
1041
683
|
});
|
|
1042
684
|
}
|
|
1043
|
-
deleteScreeningRoomSection(screeningRoomSection
|
|
685
|
+
deleteScreeningRoomSection(screeningRoomSection) {
|
|
1044
686
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
branchCode: screeningRoomSection.branchCode
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
}, {
|
|
1062
|
-
new: true,
|
|
1063
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
1064
|
-
})
|
|
1065
|
-
.exec();
|
|
1066
|
-
if (doc === null) {
|
|
1067
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
1068
|
-
}
|
|
1069
|
-
return doc.toObject();
|
|
1070
|
-
}
|
|
1071
|
-
else {
|
|
1072
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1073
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1074
|
-
'project.id': { $eq: screeningRoomSection.project.id },
|
|
1075
|
-
branchCode: screeningRoomSection.containedInPlace.containedInPlace.branchCode,
|
|
1076
|
-
'containsPlace.branchCode': screeningRoomSection.containedInPlace.branchCode,
|
|
1077
|
-
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
|
|
1078
|
-
}, {
|
|
1079
|
-
$pull: {
|
|
1080
|
-
'containsPlace.$[screeningRoom].containsPlace': {
|
|
1081
|
-
branchCode: screeningRoomSection.branchCode
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
}, {
|
|
1085
|
-
new: true,
|
|
1086
|
-
arrayFilters: [
|
|
1087
|
-
{ 'screeningRoom.branchCode': screeningRoomSection.containedInPlace.branchCode }
|
|
1088
|
-
],
|
|
1089
|
-
projection: {
|
|
1090
|
-
_id: 1,
|
|
1091
|
-
typeOf: 1
|
|
687
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
688
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
689
|
+
'project.id': { $eq: screeningRoomSection.project.id },
|
|
690
|
+
'containedInPlace.branchCode': {
|
|
691
|
+
$exists: true,
|
|
692
|
+
$eq: screeningRoomSection.containedInPlace.containedInPlace.branchCode
|
|
693
|
+
},
|
|
694
|
+
branchCode: { $eq: screeningRoomSection.containedInPlace.branchCode },
|
|
695
|
+
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
|
|
696
|
+
}, {
|
|
697
|
+
$pull: {
|
|
698
|
+
containsPlace: {
|
|
699
|
+
branchCode: screeningRoomSection.branchCode
|
|
1092
700
|
}
|
|
1093
|
-
})
|
|
1094
|
-
.exec();
|
|
1095
|
-
if (doc === null) {
|
|
1096
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
1097
701
|
}
|
|
1098
|
-
|
|
702
|
+
}, {
|
|
703
|
+
new: true,
|
|
704
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
705
|
+
})
|
|
706
|
+
.exec();
|
|
707
|
+
if (doc === null) {
|
|
708
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
1099
709
|
}
|
|
710
|
+
return doc.toObject();
|
|
1100
711
|
});
|
|
1101
712
|
}
|
|
1102
713
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
1103
|
-
searchScreeningRooms(searchConditions
|
|
1104
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
714
|
+
searchScreeningRooms(searchConditions) {
|
|
715
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1105
716
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
$eq: containedInPlaceIdEq
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
}
|
|
1126
|
-
if (searchConditions.containedInPlace !== undefined) {
|
|
1127
|
-
// 施設コード
|
|
1128
|
-
if (searchConditions.containedInPlace.branchCode !== undefined) {
|
|
1129
|
-
if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
|
|
1130
|
-
matchStages.push({
|
|
1131
|
-
$match: {
|
|
1132
|
-
'containedInPlace.branchCode': {
|
|
1133
|
-
$exists: true,
|
|
1134
|
-
$eq: searchConditions.containedInPlace.branchCode.$eq
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
717
|
+
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
|
|
718
|
+
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
719
|
+
if (typeof projectIdEq === 'string') {
|
|
720
|
+
matchStages.push({
|
|
721
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
// 施設ID
|
|
725
|
+
const containedInPlaceIdEq = (_d = (_c = searchConditions.containedInPlace) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
726
|
+
if (typeof containedInPlaceIdEq === 'string') {
|
|
727
|
+
matchStages.push({
|
|
728
|
+
$match: {
|
|
729
|
+
'containedInPlace.id': {
|
|
730
|
+
$exists: true,
|
|
731
|
+
$eq: containedInPlaceIdEq
|
|
1138
732
|
}
|
|
1139
733
|
}
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
matchStages.push({
|
|
1152
|
-
$match: {
|
|
1153
|
-
branchCode: { $in: branchCodeIn }
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
const branchCodeRegex = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$regex;
|
|
1158
|
-
if (typeof branchCodeRegex === 'string') {
|
|
1159
|
-
matchStages.push({
|
|
1160
|
-
$match: {
|
|
1161
|
-
branchCode: {
|
|
1162
|
-
$regex: new RegExp(branchCodeRegex)
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
const nameCodeRegex = (_h = searchConditions.name) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
1168
|
-
if (typeof nameCodeRegex === 'string') {
|
|
1169
|
-
matchStages.push({
|
|
1170
|
-
$match: {
|
|
1171
|
-
$or: [
|
|
1172
|
-
{
|
|
1173
|
-
'name.ja': {
|
|
1174
|
-
$exists: true,
|
|
1175
|
-
$regex: new RegExp(nameCodeRegex)
|
|
1176
|
-
}
|
|
1177
|
-
},
|
|
1178
|
-
{
|
|
1179
|
-
'name.en': {
|
|
1180
|
-
$exists: true,
|
|
1181
|
-
$regex: new RegExp(nameCodeRegex)
|
|
1182
|
-
}
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
if (searchConditions.containedInPlace !== undefined) {
|
|
737
|
+
// 施設コード
|
|
738
|
+
if (searchConditions.containedInPlace.branchCode !== undefined) {
|
|
739
|
+
if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
|
|
740
|
+
matchStages.push({
|
|
741
|
+
$match: {
|
|
742
|
+
'containedInPlace.branchCode': {
|
|
743
|
+
$exists: true,
|
|
744
|
+
$eq: searchConditions.containedInPlace.branchCode.$eq
|
|
1183
745
|
}
|
|
1184
|
-
]
|
|
1185
|
-
}
|
|
1186
|
-
});
|
|
1187
|
-
}
|
|
1188
|
-
const openSeatingAllowed = searchConditions.openSeatingAllowed;
|
|
1189
|
-
if (typeof openSeatingAllowed === 'boolean') {
|
|
1190
|
-
matchStages.push({
|
|
1191
|
-
$match: {
|
|
1192
|
-
openSeatingAllowed: {
|
|
1193
|
-
$exists: true,
|
|
1194
|
-
$eq: openSeatingAllowed
|
|
1195
746
|
}
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
747
|
+
});
|
|
748
|
+
}
|
|
1198
749
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
750
|
+
}
|
|
751
|
+
const branchCodeEq = (_e = searchConditions.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
752
|
+
if (typeof branchCodeEq === 'string') {
|
|
753
|
+
matchStages.push({
|
|
754
|
+
$match: {
|
|
755
|
+
branchCode: { $eq: branchCodeEq }
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
const branchCodeIn = (_f = searchConditions.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
|
|
760
|
+
if (Array.isArray(branchCodeIn)) {
|
|
761
|
+
matchStages.push({
|
|
762
|
+
$match: {
|
|
763
|
+
branchCode: { $in: branchCodeIn }
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
const branchCodeRegex = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$regex;
|
|
768
|
+
if (typeof branchCodeRegex === 'string') {
|
|
769
|
+
matchStages.push({
|
|
770
|
+
$match: {
|
|
771
|
+
branchCode: {
|
|
772
|
+
$regex: new RegExp(branchCodeRegex)
|
|
1207
773
|
}
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
{
|
|
1215
|
-
$
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
}, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.sectionCount) === 1)
|
|
1221
|
-
? {
|
|
1222
|
-
sectionCount: {
|
|
1223
|
-
$cond: {
|
|
1224
|
-
if: { $isArray: '$containsPlace' },
|
|
1225
|
-
then: { $size: '$containsPlace' },
|
|
1226
|
-
else: 0
|
|
1227
|
-
}
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
const nameCodeRegex = (_h = searchConditions.name) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
778
|
+
if (typeof nameCodeRegex === 'string') {
|
|
779
|
+
matchStages.push({
|
|
780
|
+
$match: {
|
|
781
|
+
$or: [
|
|
782
|
+
{
|
|
783
|
+
'name.ja': {
|
|
784
|
+
$exists: true,
|
|
785
|
+
$regex: new RegExp(nameCodeRegex)
|
|
1228
786
|
}
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
$
|
|
1234
|
-
$map: {
|
|
1235
|
-
input: '$containsPlace',
|
|
1236
|
-
in: {
|
|
1237
|
-
$cond: {
|
|
1238
|
-
if: { $isArray: '$$this.containsPlace' },
|
|
1239
|
-
then: { $size: '$$this.containsPlace' },
|
|
1240
|
-
else: 0
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
'name.en': {
|
|
790
|
+
$exists: true,
|
|
791
|
+
$regex: new RegExp(nameCodeRegex)
|
|
1245
792
|
}
|
|
1246
793
|
}
|
|
1247
|
-
|
|
794
|
+
]
|
|
1248
795
|
}
|
|
1249
|
-
|
|
1250
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
1251
|
-
/* istanbul ignore else */
|
|
1252
|
-
if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
|
|
1253
|
-
const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
|
|
1254
|
-
aggregate.limit(searchConditions.limit * page)
|
|
1255
|
-
.skip(searchConditions.limit * (page - 1));
|
|
1256
|
-
}
|
|
1257
|
-
return aggregate.exec();
|
|
796
|
+
});
|
|
1258
797
|
}
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
}
|
|
1267
|
-
// 施設ID
|
|
1268
|
-
const containedInPlaceIdEq = (_q = (_p = searchConditions.containedInPlace) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
1269
|
-
if (typeof containedInPlaceIdEq === 'string') {
|
|
1270
|
-
matchStages.push({
|
|
1271
|
-
$match: {
|
|
1272
|
-
_id: { $eq: new mongoose_1.Types.ObjectId(containedInPlaceIdEq) }
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
}
|
|
1276
|
-
if (searchConditions.containedInPlace !== undefined) {
|
|
1277
|
-
// 施設コード
|
|
1278
|
-
if (searchConditions.containedInPlace.branchCode !== undefined) {
|
|
1279
|
-
if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
|
|
1280
|
-
matchStages.push({
|
|
1281
|
-
$match: {
|
|
1282
|
-
branchCode: {
|
|
1283
|
-
$exists: true,
|
|
1284
|
-
$eq: searchConditions.containedInPlace.branchCode.$eq
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
});
|
|
798
|
+
const openSeatingAllowed = searchConditions.openSeatingAllowed;
|
|
799
|
+
if (typeof openSeatingAllowed === 'boolean') {
|
|
800
|
+
matchStages.push({
|
|
801
|
+
$match: {
|
|
802
|
+
openSeatingAllowed: {
|
|
803
|
+
$exists: true,
|
|
804
|
+
$eq: openSeatingAllowed
|
|
1288
805
|
}
|
|
1289
806
|
}
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
const branchCodeIn = (_s = searchConditions.branchCode) === null || _s === void 0 ? void 0 : _s.$in;
|
|
1300
|
-
if (Array.isArray(branchCodeIn)) {
|
|
1301
|
-
matchStages.push({
|
|
1302
|
-
$match: {
|
|
1303
|
-
'containsPlace.branchCode': { $exists: true, $in: branchCodeIn }
|
|
1304
|
-
}
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
const branchCodeRegex = (_t = searchConditions.branchCode) === null || _t === void 0 ? void 0 : _t.$regex;
|
|
1308
|
-
if (typeof branchCodeRegex === 'string') {
|
|
1309
|
-
matchStages.push({
|
|
1310
|
-
$match: {
|
|
1311
|
-
'containsPlace.branchCode': {
|
|
1312
|
-
$exists: true,
|
|
1313
|
-
$regex: new RegExp(branchCodeRegex)
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1317
|
-
}
|
|
1318
|
-
const nameCodeRegex = (_u = searchConditions.name) === null || _u === void 0 ? void 0 : _u.$regex;
|
|
1319
|
-
if (typeof nameCodeRegex === 'string') {
|
|
1320
|
-
matchStages.push({
|
|
1321
|
-
$match: {
|
|
1322
|
-
$or: [
|
|
1323
|
-
{
|
|
1324
|
-
'containsPlace.name.ja': {
|
|
1325
|
-
$exists: true,
|
|
1326
|
-
$regex: new RegExp(nameCodeRegex)
|
|
1327
|
-
}
|
|
1328
|
-
},
|
|
1329
|
-
{
|
|
1330
|
-
'containsPlace.name.en': {
|
|
1331
|
-
$exists: true,
|
|
1332
|
-
$regex: new RegExp(nameCodeRegex)
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
]
|
|
1336
|
-
}
|
|
1337
|
-
});
|
|
1338
|
-
}
|
|
1339
|
-
const openSeatingAllowed = searchConditions.openSeatingAllowed;
|
|
1340
|
-
if (typeof openSeatingAllowed === 'boolean') {
|
|
1341
|
-
matchStages.push({
|
|
1342
|
-
$match: {
|
|
1343
|
-
'containsPlace.openSeatingAllowed': {
|
|
1344
|
-
$exists: true,
|
|
1345
|
-
$eq: openSeatingAllowed
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
});
|
|
1349
|
-
}
|
|
1350
|
-
const additionalPropertyElemMatch = (_v = searchConditions.additionalProperty) === null || _v === void 0 ? void 0 : _v.$elemMatch;
|
|
1351
|
-
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
1352
|
-
matchStages.push({
|
|
1353
|
-
$match: {
|
|
1354
|
-
'containsPlace.additionalProperty': {
|
|
1355
|
-
$exists: true,
|
|
1356
|
-
$elemMatch: additionalPropertyElemMatch
|
|
1357
|
-
}
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
const additionalPropertyElemMatch = (_j = searchConditions.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
|
|
810
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
811
|
+
matchStages.push({
|
|
812
|
+
$match: {
|
|
813
|
+
additionalProperty: {
|
|
814
|
+
$exists: true,
|
|
815
|
+
$elemMatch: additionalPropertyElemMatch
|
|
1358
816
|
}
|
|
1359
|
-
});
|
|
1360
|
-
}
|
|
1361
|
-
const aggregate = this.placeModel.aggregate([
|
|
1362
|
-
{ $unwind: '$containsPlace' },
|
|
1363
|
-
...matchStages,
|
|
1364
|
-
{
|
|
1365
|
-
$project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', address: '$containsPlace.address', containedInPlace: {
|
|
1366
|
-
id: { $toString: '$_id' },
|
|
1367
|
-
// id: '$_id',
|
|
1368
|
-
typeOf: '$typeOf',
|
|
1369
|
-
branchCode: '$branchCode',
|
|
1370
|
-
name: '$name'
|
|
1371
|
-
}, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty', maximumAttendeeCapacity: '$containsPlace.maximumAttendeeCapacity' }, (((_w = searchConditions.$projection) === null || _w === void 0 ? void 0 : _w.sectionCount) === 1)
|
|
1372
|
-
? {
|
|
1373
|
-
sectionCount: {
|
|
1374
|
-
$cond: {
|
|
1375
|
-
if: { $isArray: '$containsPlace.containsPlace' },
|
|
1376
|
-
then: { $size: '$containsPlace.containsPlace' },
|
|
1377
|
-
else: 0
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
: undefined), (((_x = searchConditions.$projection) === null || _x === void 0 ? void 0 : _x.seatCount) === 1)
|
|
1382
|
-
? {
|
|
1383
|
-
seatCount: {
|
|
1384
|
-
$sum: {
|
|
1385
|
-
$map: {
|
|
1386
|
-
input: '$containsPlace.containsPlace',
|
|
1387
|
-
in: {
|
|
1388
|
-
$cond: {
|
|
1389
|
-
if: { $isArray: '$$this.containsPlace' },
|
|
1390
|
-
then: { $size: '$$this.containsPlace' },
|
|
1391
|
-
else: 0
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
: undefined)
|
|
1399
817
|
}
|
|
1400
|
-
|
|
1401
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
1402
|
-
/* istanbul ignore else */
|
|
1403
|
-
if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
|
|
1404
|
-
const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
|
|
1405
|
-
aggregate.limit(searchConditions.limit * page)
|
|
1406
|
-
.skip(searchConditions.limit * (page - 1));
|
|
1407
|
-
}
|
|
1408
|
-
return aggregate.exec();
|
|
818
|
+
});
|
|
1409
819
|
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
{
|
|
1428
|
-
$project: {
|
|
1429
|
-
_id: 0,
|
|
1430
|
-
typeOf: '$typeOf',
|
|
1431
|
-
branchCode: '$branchCode',
|
|
1432
|
-
name: '$name',
|
|
1433
|
-
containsPlace: '$containsPlace',
|
|
1434
|
-
seatCount: {
|
|
1435
|
-
$sum: {
|
|
1436
|
-
$map: {
|
|
1437
|
-
input: '$containsPlace',
|
|
1438
|
-
in: {
|
|
1439
|
-
$cond: {
|
|
1440
|
-
if: { $isArray: '$$this.containsPlace' },
|
|
1441
|
-
then: { $size: '$$this.containsPlace' },
|
|
1442
|
-
else: 0
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
820
|
+
const aggregate = this.placeModel.aggregate([
|
|
821
|
+
{ $sort: { branchCode: factory.sortType.Ascending } },
|
|
822
|
+
// { $unwind: '$containsPlace' },
|
|
823
|
+
...matchStages,
|
|
824
|
+
{
|
|
825
|
+
$project: Object.assign(Object.assign({ _id: 0, typeOf: '$typeOf', branchCode: '$branchCode', name: '$name', address: '$address', containedInPlace: {
|
|
826
|
+
id: '$containedInPlace.id',
|
|
827
|
+
typeOf: '$containedInPlace.typeOf',
|
|
828
|
+
branchCode: '$containedInPlace.branchCode',
|
|
829
|
+
name: '$containedInPlace.name'
|
|
830
|
+
}, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.sectionCount) === 1)
|
|
831
|
+
? {
|
|
832
|
+
sectionCount: {
|
|
833
|
+
$cond: {
|
|
834
|
+
if: { $isArray: '$containsPlace' },
|
|
835
|
+
then: { $size: '$containsPlace' },
|
|
836
|
+
else: 0
|
|
1446
837
|
}
|
|
1447
838
|
}
|
|
1448
839
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
const docs = yield aggregate.limit(1)
|
|
1452
|
-
.exec();
|
|
1453
|
-
if (docs.length < 1) {
|
|
1454
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
1455
|
-
}
|
|
1456
|
-
return docs[0];
|
|
1457
|
-
}
|
|
1458
|
-
else {
|
|
1459
|
-
const matchStages = [
|
|
1460
|
-
{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } },
|
|
1461
|
-
{
|
|
1462
|
-
$match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.containedInPlace.id.$eq) } }
|
|
1463
|
-
},
|
|
1464
|
-
{
|
|
1465
|
-
$match: { 'containsPlace.branchCode': { $exists: true, $eq: params.branchCode.$eq } }
|
|
1466
|
-
}
|
|
1467
|
-
];
|
|
1468
|
-
const aggregate = this.placeModel.aggregate([
|
|
1469
|
-
{ $unwind: '$containsPlace' },
|
|
1470
|
-
...matchStages,
|
|
1471
|
-
{
|
|
1472
|
-
$project: {
|
|
1473
|
-
_id: 0,
|
|
1474
|
-
typeOf: '$containsPlace.typeOf',
|
|
1475
|
-
branchCode: '$containsPlace.branchCode',
|
|
1476
|
-
name: '$containsPlace.name',
|
|
1477
|
-
containsPlace: '$containsPlace.containsPlace',
|
|
840
|
+
: undefined), (((_l = searchConditions.$projection) === null || _l === void 0 ? void 0 : _l.seatCount) === 1)
|
|
841
|
+
? {
|
|
1478
842
|
seatCount: {
|
|
1479
843
|
$sum: {
|
|
1480
844
|
$map: {
|
|
1481
|
-
input: '$containsPlace
|
|
845
|
+
input: '$containsPlace',
|
|
1482
846
|
in: {
|
|
1483
847
|
$cond: {
|
|
1484
848
|
if: { $isArray: '$$this.containsPlace' },
|
|
@@ -1490,699 +854,466 @@ class MongoRepository {
|
|
|
1490
854
|
}
|
|
1491
855
|
}
|
|
1492
856
|
}
|
|
1493
|
-
|
|
1494
|
-
]);
|
|
1495
|
-
const docs = yield aggregate.limit(1)
|
|
1496
|
-
.exec();
|
|
1497
|
-
if (docs.length < 1) {
|
|
1498
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
1499
|
-
}
|
|
1500
|
-
return docs[0];
|
|
1501
|
-
}
|
|
1502
|
-
});
|
|
1503
|
-
}
|
|
1504
|
-
// tslint:disable-next-line:max-func-body-length
|
|
1505
|
-
createSeat(seat, useScreeningRoomType) {
|
|
1506
|
-
var _a, _b, _c, _d;
|
|
1507
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1508
|
-
const screeningRoomSection = seat.containedInPlace;
|
|
1509
|
-
if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
|
|
1510
|
-
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
1511
|
-
}
|
|
1512
|
-
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
1513
|
-
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
1514
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
1515
|
-
}
|
|
1516
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
1517
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
1518
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
1519
|
-
}
|
|
1520
|
-
// 施設存在確認
|
|
1521
|
-
let doc = yield this.placeModel.findOne({
|
|
1522
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1523
|
-
'project.id': { $eq: seat.project.id },
|
|
1524
|
-
branchCode: { $eq: movieTheater.branchCode }
|
|
1525
|
-
}, { _id: 1 })
|
|
1526
|
-
.exec();
|
|
1527
|
-
if (doc === null) {
|
|
1528
|
-
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
1529
|
-
}
|
|
1530
|
-
if (useScreeningRoomType === true) {
|
|
1531
|
-
doc = yield this.placeModel.findOneAndUpdate({
|
|
1532
|
-
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
1533
|
-
'project.id': { $eq: seat.project.id },
|
|
1534
|
-
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
1535
|
-
branchCode: { $eq: screeningRoom.branchCode },
|
|
1536
|
-
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
|
|
1537
|
-
}, {
|
|
1538
|
-
$push: {
|
|
1539
|
-
'containsPlace.$[screeningRoomSection].containsPlace': Object.assign(Object.assign({ typeOf: seat.typeOf, branchCode: seat.branchCode, additionalProperty: seat.additionalProperty }, (typeof ((_a = seat.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.en) === 'string') ? { name: seat.name } : undefined), (Array.isArray(seat.seatingType)) ? { seatingType: seat.seatingType } : undefined)
|
|
1540
|
-
}
|
|
1541
|
-
}, {
|
|
1542
|
-
new: true,
|
|
1543
|
-
arrayFilters: [
|
|
1544
|
-
{
|
|
1545
|
-
'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode },
|
|
1546
|
-
'screeningRoomSection.containsPlace.branchCode': { $ne: seat.branchCode }
|
|
1547
|
-
}
|
|
1548
|
-
],
|
|
1549
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
1550
|
-
})
|
|
1551
|
-
.exec();
|
|
1552
|
-
// 存在しなければコード重複
|
|
1553
|
-
if (doc === null) {
|
|
1554
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
|
|
1555
|
-
}
|
|
1556
|
-
return doc.toObject();
|
|
1557
|
-
}
|
|
1558
|
-
else {
|
|
1559
|
-
doc = yield this.placeModel.findOneAndUpdate({
|
|
1560
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1561
|
-
'project.id': { $eq: seat.project.id },
|
|
1562
|
-
branchCode: movieTheater.branchCode,
|
|
1563
|
-
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
1564
|
-
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
|
|
1565
|
-
}, {
|
|
1566
|
-
$push: {
|
|
1567
|
-
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace': Object.assign(Object.assign({ typeOf: seat.typeOf, branchCode: seat.branchCode, additionalProperty: seat.additionalProperty }, (typeof ((_c = seat.name) === null || _c === void 0 ? void 0 : _c.ja) === 'string' || typeof ((_d = seat.name) === null || _d === void 0 ? void 0 : _d.en) === 'string') ? { name: seat.name } : undefined), (Array.isArray(seat.seatingType)) ? { seatingType: seat.seatingType } : undefined)
|
|
1568
|
-
}
|
|
1569
|
-
}, {
|
|
1570
|
-
new: true,
|
|
1571
|
-
arrayFilters: [
|
|
1572
|
-
{ 'screeningRoom.branchCode': screeningRoom.branchCode },
|
|
1573
|
-
{
|
|
1574
|
-
'screeningRoomSection.branchCode': screeningRoomSection.branchCode,
|
|
1575
|
-
'screeningRoomSection.containsPlace.branchCode': { $ne: seat.branchCode }
|
|
1576
|
-
}
|
|
1577
|
-
],
|
|
1578
|
-
projection: {
|
|
1579
|
-
_id: 1,
|
|
1580
|
-
branchCode: 1,
|
|
1581
|
-
typeOf: 1
|
|
1582
|
-
}
|
|
1583
|
-
})
|
|
1584
|
-
.exec();
|
|
1585
|
-
// 存在しなければコード重複
|
|
1586
|
-
if (doc === null) {
|
|
1587
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
|
|
1588
|
-
}
|
|
1589
|
-
return doc.toObject();
|
|
1590
|
-
}
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
1594
|
-
updateSeat(seat, $unset, useScreeningRoomType) {
|
|
1595
|
-
var _a, _b, _c, _d;
|
|
1596
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1597
|
-
const screeningRoomSection = seat.containedInPlace;
|
|
1598
|
-
if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
|
|
1599
|
-
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
1600
|
-
}
|
|
1601
|
-
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
1602
|
-
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
1603
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
1604
|
-
}
|
|
1605
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
1606
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
1607
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
1608
|
-
}
|
|
1609
|
-
if (useScreeningRoomType === true) {
|
|
1610
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1611
|
-
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
1612
|
-
'project.id': { $eq: seat.project.id },
|
|
1613
|
-
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
1614
|
-
branchCode: { $eq: screeningRoom.branchCode },
|
|
1615
|
-
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode },
|
|
1616
|
-
'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode }
|
|
1617
|
-
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_a = seat.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.en) === 'string')
|
|
1618
|
-
? {
|
|
1619
|
-
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
|
|
1620
|
-
}
|
|
1621
|
-
: undefined), (Array.isArray(seat.seatingType))
|
|
1622
|
-
? {
|
|
1623
|
-
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': seat.seatingType
|
|
1624
|
-
}
|
|
1625
|
-
: undefined), (Array.isArray(seat.additionalProperty))
|
|
1626
|
-
? {
|
|
1627
|
-
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].additionalProperty': seat.additionalProperty
|
|
1628
|
-
}
|
|
1629
|
-
: undefined), { $unset: Object.assign(Object.assign({ noExistingAttributeName: 1 }, (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].name'])
|
|
1630
|
-
=== 1
|
|
1631
|
-
|| ($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoomSection].containsPlace.$[seat].name']) === 1)
|
|
1632
|
-
? {
|
|
1633
|
-
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': 1
|
|
1634
|
-
}
|
|
1635
|
-
: undefined), (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType'])
|
|
1636
|
-
=== 1
|
|
1637
|
-
|| ($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType']) === 1)
|
|
1638
|
-
? {
|
|
1639
|
-
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': 1
|
|
1640
|
-
}
|
|
1641
|
-
: undefined) }), {
|
|
1642
|
-
new: true,
|
|
1643
|
-
arrayFilters: [
|
|
1644
|
-
{ 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode } },
|
|
1645
|
-
{ 'seat.branchCode': { $eq: seat.branchCode } }
|
|
1646
|
-
],
|
|
1647
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
1648
|
-
})
|
|
1649
|
-
.exec();
|
|
1650
|
-
if (doc === null) {
|
|
1651
|
-
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
1652
|
-
}
|
|
1653
|
-
return doc.toObject();
|
|
1654
|
-
}
|
|
1655
|
-
else {
|
|
1656
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1657
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1658
|
-
'project.id': { $eq: seat.project.id },
|
|
1659
|
-
branchCode: movieTheater.branchCode,
|
|
1660
|
-
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
1661
|
-
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode,
|
|
1662
|
-
'containsPlace.containsPlace.containsPlace.branchCode': seat.branchCode
|
|
1663
|
-
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_c = seat.name) === null || _c === void 0 ? void 0 : _c.ja) === 'string' || typeof ((_d = seat.name) === null || _d === void 0 ? void 0 : _d.en) === 'string')
|
|
1664
|
-
? {
|
|
1665
|
-
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
|
|
1666
|
-
}
|
|
1667
|
-
: undefined), (Array.isArray(seat.seatingType))
|
|
1668
|
-
? {
|
|
1669
|
-
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': seat.seatingType
|
|
1670
|
-
}
|
|
1671
|
-
: undefined), (Array.isArray(seat.additionalProperty))
|
|
1672
|
-
? {
|
|
1673
|
-
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].additionalProperty': seat.additionalProperty
|
|
1674
|
-
}
|
|
1675
|
-
: undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
|
|
1676
|
-
new: true,
|
|
1677
|
-
arrayFilters: [
|
|
1678
|
-
{ 'screeningRoom.branchCode': screeningRoom.branchCode },
|
|
1679
|
-
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode },
|
|
1680
|
-
{ 'seat.branchCode': seat.branchCode }
|
|
1681
|
-
],
|
|
1682
|
-
projection: {
|
|
1683
|
-
_id: 1,
|
|
1684
|
-
// 'project.id': 1,
|
|
1685
|
-
branchCode: 1,
|
|
1686
|
-
typeOf: 1
|
|
1687
|
-
}
|
|
1688
|
-
})
|
|
1689
|
-
.exec();
|
|
1690
|
-
if (doc === null) {
|
|
1691
|
-
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
857
|
+
: undefined)
|
|
1692
858
|
}
|
|
1693
|
-
|
|
859
|
+
]);
|
|
860
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
861
|
+
/* istanbul ignore else */
|
|
862
|
+
if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
|
|
863
|
+
const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
|
|
864
|
+
aggregate.limit(searchConditions.limit * page)
|
|
865
|
+
.skip(searchConditions.limit * (page - 1));
|
|
1694
866
|
}
|
|
867
|
+
return aggregate.exec();
|
|
1695
868
|
});
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
});
|
|
1730
|
-
}
|
|
1731
|
-
if (params.containedInPlace !== undefined) {
|
|
1732
|
-
if (params.containedInPlace.containedInPlace !== undefined) {
|
|
1733
|
-
if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
1734
|
-
if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
1735
|
-
matchStages.push({
|
|
1736
|
-
$match: {
|
|
1737
|
-
branchCode: {
|
|
1738
|
-
$eq: params.containedInPlace.containedInPlace.branchCode.$eq
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
});
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
|
|
1745
|
-
if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
1746
|
-
if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
1747
|
-
matchStages.push({
|
|
1748
|
-
$match: {
|
|
1749
|
-
'containedInPlace.branchCode': {
|
|
1750
|
-
$exists: true,
|
|
1751
|
-
$eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
// 座席コード
|
|
1761
|
-
if (params.branchCode !== undefined) {
|
|
1762
|
-
if (typeof params.branchCode.$eq === 'string') {
|
|
1763
|
-
matchStages.push({
|
|
1764
|
-
$match: {
|
|
1765
|
-
'containsPlace.containsPlace.branchCode': {
|
|
1766
|
-
$exists: true,
|
|
1767
|
-
$eq: params.branchCode.$eq
|
|
1768
|
-
}
|
|
1769
|
-
}
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
const branchCodeIn = (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$in;
|
|
1774
|
-
if (Array.isArray(branchCodeIn)) {
|
|
1775
|
-
matchStages.push({
|
|
1776
|
-
$match: {
|
|
1777
|
-
'containsPlace.containsPlace.branchCode': {
|
|
1778
|
-
$exists: true,
|
|
1779
|
-
$in: branchCodeIn
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
});
|
|
1783
|
-
}
|
|
1784
|
-
const branchCodeRegex = (_h = params.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
1785
|
-
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
1786
|
-
matchStages.push({
|
|
1787
|
-
$match: {
|
|
1788
|
-
'containsPlace.containsPlace.branchCode': {
|
|
1789
|
-
$exists: true,
|
|
1790
|
-
$regex: new RegExp(branchCodeRegex)
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
});
|
|
1794
|
-
}
|
|
1795
|
-
const nameRegex = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$regex;
|
|
1796
|
-
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
1797
|
-
matchStages.push({
|
|
1798
|
-
$match: {
|
|
1799
|
-
$or: [
|
|
1800
|
-
{
|
|
1801
|
-
'containsPlace.containsPlace.name.ja': {
|
|
1802
|
-
$exists: true,
|
|
1803
|
-
$regex: new RegExp(nameRegex)
|
|
1804
|
-
}
|
|
1805
|
-
},
|
|
1806
|
-
{
|
|
1807
|
-
'containsPlace.containsPlace.name.en': {
|
|
1808
|
-
$exists: true,
|
|
1809
|
-
$regex: new RegExp(nameRegex)
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
]
|
|
1813
|
-
}
|
|
1814
|
-
});
|
|
1815
|
-
}
|
|
1816
|
-
const seatingTypeEq = (_k = params.seatingType) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
1817
|
-
if (typeof seatingTypeEq === 'string') {
|
|
1818
|
-
matchStages.push({
|
|
1819
|
-
$match: {
|
|
1820
|
-
'containsPlace.containsPlace.seatingType': {
|
|
1821
|
-
$exists: true,
|
|
1822
|
-
$eq: seatingTypeEq
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
});
|
|
1826
|
-
}
|
|
1827
|
-
let includeScreeningRooms = true;
|
|
1828
|
-
if (params.$projection !== undefined && params.$projection !== null
|
|
1829
|
-
&& params.$projection['containedInPlace.containedInPlace'] === 0) {
|
|
1830
|
-
includeScreeningRooms = false;
|
|
1831
|
-
}
|
|
1832
|
-
const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
1833
|
-
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
1834
|
-
matchStages.push({
|
|
1835
|
-
$match: {
|
|
1836
|
-
'containsPlace.containsPlace.additionalProperty': {
|
|
1837
|
-
$exists: true,
|
|
1838
|
-
$elemMatch: additionalPropertyElemMatch
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
});
|
|
1842
|
-
}
|
|
1843
|
-
const aggregate = this.placeModel.aggregate([
|
|
1844
|
-
{ $unwind: '$containsPlace' },
|
|
1845
|
-
{ $unwind: '$containsPlace.containsPlace' },
|
|
1846
|
-
// { $unwind: '$containsPlace.containsPlace.containsPlace' },
|
|
1847
|
-
...matchStages,
|
|
1848
|
-
{
|
|
1849
|
-
$project: {
|
|
1850
|
-
_id: 0,
|
|
1851
|
-
typeOf: '$containsPlace.containsPlace.typeOf',
|
|
1852
|
-
branchCode: '$containsPlace.containsPlace.branchCode',
|
|
1853
|
-
name: '$containsPlace.containsPlace.name',
|
|
1854
|
-
seatingType: '$containsPlace.containsPlace.seatingType',
|
|
1855
|
-
containedInPlace: Object.assign({ typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name' }, (includeScreeningRooms)
|
|
1856
|
-
? {
|
|
1857
|
-
containedInPlace: {
|
|
1858
|
-
typeOf: '$typeOf',
|
|
1859
|
-
branchCode: '$branchCode',
|
|
1860
|
-
name: '$name',
|
|
1861
|
-
containedInPlace: {
|
|
1862
|
-
id: '$containedInPlace.id',
|
|
1863
|
-
typeOf: '$containedInPlace.typeOf',
|
|
1864
|
-
branchCode: '$containedInPlace.branchCode',
|
|
1865
|
-
name: '$containedInPlace.name'
|
|
869
|
+
}
|
|
870
|
+
findScreeningRoomsByBranchCode(params) {
|
|
871
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
872
|
+
const matchStages = [
|
|
873
|
+
{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } },
|
|
874
|
+
{
|
|
875
|
+
$match: { 'containedInPlace.id': { $exists: true, $eq: params.containedInPlace.id.$eq } }
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
$match: { branchCode: { $eq: params.branchCode.$eq } }
|
|
879
|
+
}
|
|
880
|
+
];
|
|
881
|
+
const aggregate = this.placeModel.aggregate([
|
|
882
|
+
// { $unwind: '$containsPlace' },
|
|
883
|
+
...matchStages,
|
|
884
|
+
{
|
|
885
|
+
$project: {
|
|
886
|
+
_id: 0,
|
|
887
|
+
typeOf: '$typeOf',
|
|
888
|
+
branchCode: '$branchCode',
|
|
889
|
+
name: '$name',
|
|
890
|
+
containsPlace: '$containsPlace',
|
|
891
|
+
seatCount: {
|
|
892
|
+
$sum: {
|
|
893
|
+
$map: {
|
|
894
|
+
input: '$containsPlace',
|
|
895
|
+
in: {
|
|
896
|
+
$cond: {
|
|
897
|
+
if: { $isArray: '$$this.containsPlace' },
|
|
898
|
+
then: { $size: '$$this.containsPlace' },
|
|
899
|
+
else: 0
|
|
1866
900
|
}
|
|
1867
901
|
}
|
|
1868
902
|
}
|
|
1869
|
-
|
|
1870
|
-
additionalProperty: '$containsPlace.containsPlace.additionalProperty'
|
|
903
|
+
}
|
|
1871
904
|
}
|
|
1872
905
|
}
|
|
1873
|
-
]);
|
|
1874
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
1875
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
1876
|
-
aggregate.limit(params.limit * page)
|
|
1877
|
-
.skip(params.limit * (page - 1));
|
|
1878
906
|
}
|
|
1879
|
-
|
|
907
|
+
]);
|
|
908
|
+
const docs = yield aggregate.limit(1)
|
|
909
|
+
.exec();
|
|
910
|
+
if (docs.length < 1) {
|
|
911
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
1880
912
|
}
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
913
|
+
return docs[0];
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
// tslint:disable-next-line:max-func-body-length
|
|
917
|
+
createSeat(seat) {
|
|
918
|
+
var _a, _b;
|
|
919
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
920
|
+
const screeningRoomSection = seat.containedInPlace;
|
|
921
|
+
if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
|
|
922
|
+
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
923
|
+
}
|
|
924
|
+
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
925
|
+
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
926
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
927
|
+
}
|
|
928
|
+
const movieTheater = screeningRoom.containedInPlace;
|
|
929
|
+
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
930
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
931
|
+
}
|
|
932
|
+
// 施設存在確認
|
|
933
|
+
let doc = yield this.placeModel.findOne({
|
|
934
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
935
|
+
'project.id': { $eq: seat.project.id },
|
|
936
|
+
branchCode: { $eq: movieTheater.branchCode }
|
|
937
|
+
}, { _id: 1 })
|
|
938
|
+
.exec();
|
|
939
|
+
if (doc === null) {
|
|
940
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
941
|
+
}
|
|
942
|
+
doc = yield this.placeModel.findOneAndUpdate({
|
|
943
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
944
|
+
'project.id': { $eq: seat.project.id },
|
|
945
|
+
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
946
|
+
branchCode: { $eq: screeningRoom.branchCode },
|
|
947
|
+
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
|
|
948
|
+
}, {
|
|
949
|
+
$push: {
|
|
950
|
+
'containsPlace.$[screeningRoomSection].containsPlace': Object.assign(Object.assign({ typeOf: seat.typeOf, branchCode: seat.branchCode, additionalProperty: seat.additionalProperty }, (typeof ((_a = seat.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.en) === 'string') ? { name: seat.name } : undefined), (Array.isArray(seat.seatingType)) ? { seatingType: seat.seatingType } : undefined)
|
|
1888
951
|
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
952
|
+
}, {
|
|
953
|
+
new: true,
|
|
954
|
+
arrayFilters: [
|
|
955
|
+
{
|
|
956
|
+
'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode },
|
|
957
|
+
'screeningRoomSection.containsPlace.branchCode': { $ne: seat.branchCode }
|
|
958
|
+
}
|
|
959
|
+
],
|
|
960
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
961
|
+
})
|
|
962
|
+
.exec();
|
|
963
|
+
// 存在しなければコード重複
|
|
964
|
+
if (doc === null) {
|
|
965
|
+
throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
|
|
966
|
+
}
|
|
967
|
+
return doc.toObject();
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
971
|
+
updateSeat(seat, $unset) {
|
|
972
|
+
var _a, _b;
|
|
973
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
974
|
+
const screeningRoomSection = seat.containedInPlace;
|
|
975
|
+
if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
|
|
976
|
+
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
977
|
+
}
|
|
978
|
+
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
979
|
+
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
980
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
981
|
+
}
|
|
982
|
+
const movieTheater = screeningRoom.containedInPlace;
|
|
983
|
+
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
984
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
985
|
+
}
|
|
986
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
987
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
988
|
+
'project.id': { $eq: seat.project.id },
|
|
989
|
+
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
990
|
+
branchCode: { $eq: screeningRoom.branchCode },
|
|
991
|
+
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode },
|
|
992
|
+
'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode }
|
|
993
|
+
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_a = seat.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.en) === 'string')
|
|
994
|
+
? {
|
|
995
|
+
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
|
|
996
|
+
}
|
|
997
|
+
: undefined), (Array.isArray(seat.seatingType))
|
|
998
|
+
? {
|
|
999
|
+
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': seat.seatingType
|
|
1000
|
+
}
|
|
1001
|
+
: undefined), (Array.isArray(seat.additionalProperty))
|
|
1002
|
+
? {
|
|
1003
|
+
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].additionalProperty': seat.additionalProperty
|
|
1004
|
+
}
|
|
1005
|
+
: undefined), { $unset: Object.assign(Object.assign({ noExistingAttributeName: 1 }, (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].name'])
|
|
1006
|
+
=== 1
|
|
1007
|
+
|| ($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoomSection].containsPlace.$[seat].name']) === 1)
|
|
1008
|
+
? {
|
|
1009
|
+
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': 1
|
|
1010
|
+
}
|
|
1011
|
+
: undefined), (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType'])
|
|
1012
|
+
=== 1
|
|
1013
|
+
|| ($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType']) === 1)
|
|
1014
|
+
? {
|
|
1015
|
+
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': 1
|
|
1016
|
+
}
|
|
1017
|
+
: undefined) }), {
|
|
1018
|
+
new: true,
|
|
1019
|
+
arrayFilters: [
|
|
1020
|
+
{ 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode } },
|
|
1021
|
+
{ 'seat.branchCode': { $eq: seat.branchCode } }
|
|
1022
|
+
],
|
|
1023
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
1024
|
+
})
|
|
1025
|
+
.exec();
|
|
1026
|
+
if (doc === null) {
|
|
1027
|
+
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
1028
|
+
}
|
|
1029
|
+
return doc.toObject();
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
1033
|
+
searchSeats(params) {
|
|
1034
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1035
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1036
|
+
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
|
|
1037
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
1038
|
+
if (typeof projectIdEq === 'string') {
|
|
1039
|
+
matchStages.push({
|
|
1040
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
const containedInPlaceBranchCodeEq = (_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.branchCode) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
1044
|
+
if (typeof containedInPlaceBranchCodeEq === 'string') {
|
|
1045
|
+
matchStages.push({
|
|
1046
|
+
$match: {
|
|
1047
|
+
'containsPlace.branchCode': {
|
|
1048
|
+
$exists: true,
|
|
1049
|
+
$eq: containedInPlaceBranchCodeEq
|
|
1897
1050
|
}
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
const containedInPlaceBranchCodeIn = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
|
|
1055
|
+
if (Array.isArray(containedInPlaceBranchCodeIn)) {
|
|
1056
|
+
matchStages.push({
|
|
1057
|
+
$match: {
|
|
1058
|
+
'containsPlace.branchCode': {
|
|
1059
|
+
$exists: true,
|
|
1060
|
+
$in: containedInPlaceBranchCodeIn
|
|
1908
1061
|
}
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
if (params.containedInPlace !== undefined) {
|
|
1066
|
+
if (params.containedInPlace.containedInPlace !== undefined) {
|
|
1067
|
+
if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
1068
|
+
if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
1069
|
+
matchStages.push({
|
|
1070
|
+
$match: {
|
|
1071
|
+
branchCode: {
|
|
1072
|
+
$eq: params.containedInPlace.containedInPlace.branchCode.$eq
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
|
|
1079
|
+
if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
1080
|
+
if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
1915
1081
|
matchStages.push({
|
|
1916
1082
|
$match: {
|
|
1917
|
-
'
|
|
1083
|
+
'containedInPlace.branchCode': {
|
|
1918
1084
|
$exists: true,
|
|
1919
|
-
$eq: params.containedInPlace.containedInPlace.branchCode.$eq
|
|
1085
|
+
$eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
|
|
1920
1086
|
}
|
|
1921
1087
|
}
|
|
1922
1088
|
});
|
|
1923
1089
|
}
|
|
1924
1090
|
}
|
|
1925
|
-
if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
|
|
1926
|
-
if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
1927
|
-
if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
1928
|
-
matchStages.push({
|
|
1929
|
-
$match: {
|
|
1930
|
-
branchCode: {
|
|
1931
|
-
$exists: true,
|
|
1932
|
-
$eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
});
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
// 座席コード
|
|
1942
|
-
if (params.branchCode !== undefined) {
|
|
1943
|
-
if (typeof params.branchCode.$eq === 'string') {
|
|
1944
|
-
matchStages.push({
|
|
1945
|
-
$match: {
|
|
1946
|
-
'containsPlace.containsPlace.containsPlace.branchCode': {
|
|
1947
|
-
$exists: true,
|
|
1948
|
-
$eq: params.branchCode.$eq
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
});
|
|
1952
1091
|
}
|
|
1953
1092
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1093
|
+
}
|
|
1094
|
+
// 座席コード
|
|
1095
|
+
if (params.branchCode !== undefined) {
|
|
1096
|
+
if (typeof params.branchCode.$eq === 'string') {
|
|
1956
1097
|
matchStages.push({
|
|
1957
1098
|
$match: {
|
|
1958
|
-
'containsPlace.containsPlace.
|
|
1099
|
+
'containsPlace.containsPlace.branchCode': {
|
|
1959
1100
|
$exists: true,
|
|
1960
|
-
$
|
|
1101
|
+
$eq: params.branchCode.$eq
|
|
1961
1102
|
}
|
|
1962
1103
|
}
|
|
1963
1104
|
});
|
|
1964
1105
|
}
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1106
|
+
}
|
|
1107
|
+
const branchCodeIn = (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$in;
|
|
1108
|
+
if (Array.isArray(branchCodeIn)) {
|
|
1109
|
+
matchStages.push({
|
|
1110
|
+
$match: {
|
|
1111
|
+
'containsPlace.containsPlace.branchCode': {
|
|
1112
|
+
$exists: true,
|
|
1113
|
+
$in: branchCodeIn
|
|
1973
1114
|
}
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
$regex: new RegExp(nameRegex)
|
|
1985
|
-
}
|
|
1986
|
-
},
|
|
1987
|
-
{
|
|
1988
|
-
'containsPlace.containsPlace.containsPlace.name.en': {
|
|
1989
|
-
$exists: true,
|
|
1990
|
-
$regex: new RegExp(nameRegex)
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
]
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
const branchCodeRegex = (_h = params.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
1119
|
+
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
1120
|
+
matchStages.push({
|
|
1121
|
+
$match: {
|
|
1122
|
+
'containsPlace.containsPlace.branchCode': {
|
|
1123
|
+
$exists: true,
|
|
1124
|
+
$regex: new RegExp(branchCodeRegex)
|
|
1994
1125
|
}
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
const nameRegex = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$regex;
|
|
1130
|
+
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
1131
|
+
matchStages.push({
|
|
1132
|
+
$match: {
|
|
1133
|
+
$or: [
|
|
1134
|
+
{
|
|
1135
|
+
'containsPlace.containsPlace.name.ja': {
|
|
1136
|
+
$exists: true,
|
|
1137
|
+
$regex: new RegExp(nameRegex)
|
|
1138
|
+
}
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
'containsPlace.containsPlace.name.en': {
|
|
1142
|
+
$exists: true,
|
|
1143
|
+
$regex: new RegExp(nameRegex)
|
|
1144
|
+
}
|
|
2004
1145
|
}
|
|
1146
|
+
]
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
const seatingTypeEq = (_k = params.seatingType) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
1151
|
+
if (typeof seatingTypeEq === 'string') {
|
|
1152
|
+
matchStages.push({
|
|
1153
|
+
$match: {
|
|
1154
|
+
'containsPlace.containsPlace.seatingType': {
|
|
1155
|
+
$exists: true,
|
|
1156
|
+
$eq: seatingTypeEq
|
|
2005
1157
|
}
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
let includeScreeningRooms = true;
|
|
1162
|
+
if (params.$projection !== undefined && params.$projection !== null
|
|
1163
|
+
&& params.$projection['containedInPlace.containedInPlace'] === 0) {
|
|
1164
|
+
includeScreeningRooms = false;
|
|
1165
|
+
}
|
|
1166
|
+
const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
1167
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
1168
|
+
matchStages.push({
|
|
1169
|
+
$match: {
|
|
1170
|
+
'containsPlace.containsPlace.additionalProperty': {
|
|
1171
|
+
$exists: true,
|
|
1172
|
+
$elemMatch: additionalPropertyElemMatch
|
|
2021
1173
|
}
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
const aggregate = this.placeModel.aggregate([
|
|
1178
|
+
{ $unwind: '$containsPlace' },
|
|
1179
|
+
{ $unwind: '$containsPlace.containsPlace' },
|
|
1180
|
+
// { $unwind: '$containsPlace.containsPlace.containsPlace' },
|
|
1181
|
+
...matchStages,
|
|
1182
|
+
{
|
|
1183
|
+
$project: {
|
|
1184
|
+
_id: 0,
|
|
1185
|
+
typeOf: '$containsPlace.containsPlace.typeOf',
|
|
1186
|
+
branchCode: '$containsPlace.containsPlace.branchCode',
|
|
1187
|
+
name: '$containsPlace.containsPlace.name',
|
|
1188
|
+
seatingType: '$containsPlace.containsPlace.seatingType',
|
|
1189
|
+
containedInPlace: Object.assign({ typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name' }, (includeScreeningRooms)
|
|
1190
|
+
? {
|
|
1191
|
+
containedInPlace: {
|
|
1192
|
+
typeOf: '$typeOf',
|
|
1193
|
+
branchCode: '$branchCode',
|
|
1194
|
+
name: '$name',
|
|
2038
1195
|
containedInPlace: {
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
id: { $toString: '$_id' },
|
|
2044
|
-
// id: '$_id',
|
|
2045
|
-
typeOf: '$typeOf',
|
|
2046
|
-
branchCode: '$branchCode',
|
|
2047
|
-
name: '$name'
|
|
2048
|
-
}
|
|
1196
|
+
id: '$containedInPlace.id',
|
|
1197
|
+
typeOf: '$containedInPlace.typeOf',
|
|
1198
|
+
branchCode: '$containedInPlace.branchCode',
|
|
1199
|
+
name: '$containedInPlace.name'
|
|
2049
1200
|
}
|
|
2050
1201
|
}
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
1202
|
+
}
|
|
1203
|
+
: undefined),
|
|
1204
|
+
additionalProperty: '$containsPlace.containsPlace.additionalProperty'
|
|
2054
1205
|
}
|
|
2055
|
-
]);
|
|
2056
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
2057
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
2058
|
-
aggregate.limit(params.limit * page)
|
|
2059
|
-
.skip(params.limit * (page - 1));
|
|
2060
1206
|
}
|
|
2061
|
-
|
|
1207
|
+
]);
|
|
1208
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
1209
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
1210
|
+
aggregate.limit(params.limit * page)
|
|
1211
|
+
.skip(params.limit * (page - 1));
|
|
2062
1212
|
}
|
|
1213
|
+
return aggregate.exec();
|
|
2063
1214
|
});
|
|
2064
1215
|
}
|
|
2065
|
-
deleteSeat(seat
|
|
1216
|
+
deleteSeat(seat) {
|
|
2066
1217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
branchCode: seat.branchCode
|
|
2082
|
-
}
|
|
2083
|
-
}
|
|
2084
|
-
}, {
|
|
2085
|
-
new: true,
|
|
2086
|
-
arrayFilters: [
|
|
2087
|
-
{ 'screeningRoomSection.branchCode': { $eq: seat.containedInPlace.branchCode } }
|
|
2088
|
-
],
|
|
2089
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
2090
|
-
})
|
|
2091
|
-
.exec();
|
|
2092
|
-
if (doc === null) {
|
|
2093
|
-
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
2094
|
-
}
|
|
2095
|
-
return doc.toObject();
|
|
2096
|
-
}
|
|
2097
|
-
else {
|
|
2098
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
2099
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
2100
|
-
'project.id': { $eq: seat.project.id },
|
|
2101
|
-
branchCode: seat.containedInPlace.containedInPlace.containedInPlace.branchCode,
|
|
2102
|
-
'containsPlace.branchCode': seat.containedInPlace.containedInPlace.branchCode,
|
|
2103
|
-
'containsPlace.containsPlace.branchCode': seat.containedInPlace.branchCode,
|
|
2104
|
-
'containsPlace.containsPlace.containsPlace.branchCode': seat.branchCode
|
|
2105
|
-
}, {
|
|
2106
|
-
$pull: {
|
|
2107
|
-
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace': {
|
|
2108
|
-
branchCode: seat.branchCode
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
}, {
|
|
2112
|
-
new: true,
|
|
2113
|
-
arrayFilters: [
|
|
2114
|
-
{ 'screeningRoom.branchCode': seat.containedInPlace.containedInPlace.branchCode },
|
|
2115
|
-
{ 'screeningRoomSection.branchCode': seat.containedInPlace.branchCode }
|
|
2116
|
-
],
|
|
2117
|
-
projection: {
|
|
2118
|
-
_id: 1,
|
|
2119
|
-
typeOf: 1
|
|
1218
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1219
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
1220
|
+
'project.id': { $eq: seat.project.id },
|
|
1221
|
+
'containedInPlace.branchCode': {
|
|
1222
|
+
$exists: true,
|
|
1223
|
+
$eq: seat.containedInPlace.containedInPlace.containedInPlace.branchCode
|
|
1224
|
+
},
|
|
1225
|
+
branchCode: { $eq: seat.containedInPlace.containedInPlace.branchCode },
|
|
1226
|
+
'containsPlace.branchCode': { $eq: seat.containedInPlace.branchCode },
|
|
1227
|
+
'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode }
|
|
1228
|
+
}, {
|
|
1229
|
+
$pull: {
|
|
1230
|
+
'containsPlace.$[screeningRoomSection].containsPlace': {
|
|
1231
|
+
branchCode: seat.branchCode
|
|
2120
1232
|
}
|
|
2121
|
-
})
|
|
2122
|
-
.exec();
|
|
2123
|
-
if (doc === null) {
|
|
2124
|
-
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
2125
1233
|
}
|
|
2126
|
-
|
|
1234
|
+
}, {
|
|
1235
|
+
new: true,
|
|
1236
|
+
arrayFilters: [
|
|
1237
|
+
{ 'screeningRoomSection.branchCode': { $eq: seat.containedInPlace.branchCode } }
|
|
1238
|
+
],
|
|
1239
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
1240
|
+
})
|
|
1241
|
+
.exec();
|
|
1242
|
+
if (doc === null) {
|
|
1243
|
+
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
2127
1244
|
}
|
|
1245
|
+
return doc.toObject();
|
|
2128
1246
|
});
|
|
2129
1247
|
}
|
|
2130
|
-
|
|
1248
|
+
// tslint:disable-next-line:prefer-function-over-method
|
|
1249
|
+
syncScreeningRooms(__) {
|
|
2131
1250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
}
|
|
1251
|
+
return;
|
|
1252
|
+
// const movieTheater = <Pick<
|
|
1253
|
+
// factory.place.movieTheater.IPlace,
|
|
1254
|
+
// 'id' | 'branchCode' | 'name' | 'project' | 'typeOf' | 'containsPlace'
|
|
1255
|
+
// >>await this.placeModel.findOne({
|
|
1256
|
+
// _id: { $eq: params.id },
|
|
1257
|
+
// typeOf: { $eq: factory.placeType.MovieTheater }
|
|
1258
|
+
// })
|
|
1259
|
+
// .select({
|
|
1260
|
+
// _id: 1, branchCode: 1, name: 1, project: 1, typeOf: 1, containsPlace: 1
|
|
1261
|
+
// })
|
|
1262
|
+
// .exec()
|
|
1263
|
+
// .then((doc) => {
|
|
1264
|
+
// if (doc === null) {
|
|
1265
|
+
// throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
1266
|
+
// }
|
|
1267
|
+
// return doc.toObject();
|
|
1268
|
+
// });
|
|
1269
|
+
// let screeningRoomsFromMovieTheater = movieTheater.containsPlace;
|
|
1270
|
+
// if (typeof params.screeningRoomBranchCode === 'string' && params.screeningRoomBranchCode.length > 0) {
|
|
1271
|
+
// screeningRoomsFromMovieTheater = screeningRoomsFromMovieTheater.filter(
|
|
1272
|
+
// (place) => place.branchCode === params.screeningRoomBranchCode
|
|
1273
|
+
// );
|
|
1274
|
+
// }
|
|
1275
|
+
// const creatingScreeningRooms: ICreatingScreeningRoom[] = screeningRoomsFromMovieTheater.map((place) => {
|
|
1276
|
+
// return {
|
|
1277
|
+
// ...place,
|
|
1278
|
+
// containedInPlace: {
|
|
1279
|
+
// id: movieTheater.id,
|
|
1280
|
+
// typeOf: movieTheater.typeOf,
|
|
1281
|
+
// branchCode: movieTheater.branchCode,
|
|
1282
|
+
// name: movieTheater.name
|
|
1283
|
+
// },
|
|
1284
|
+
// containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [],
|
|
1285
|
+
// project: movieTheater.project
|
|
1286
|
+
// };
|
|
1287
|
+
// });
|
|
1288
|
+
// debug('sync processing', creatingScreeningRooms.length, 'screeningRooms...', creatingScreeningRooms);
|
|
1289
|
+
// await Promise.all(creatingScreeningRooms.map(async (createScreeningRoom) => {
|
|
1290
|
+
// const { typeOf, project, branchCode, ...setFields } = createScreeningRoom;
|
|
1291
|
+
// if (typeof branchCode === 'string' && branchCode.length > 0) {
|
|
1292
|
+
// const upsertScreeningRoomResult = await this.placeModel.findOneAndUpdate(
|
|
1293
|
+
// {
|
|
1294
|
+
// typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
1295
|
+
// 'project.id': { $eq: createScreeningRoom.project.id },
|
|
1296
|
+
// 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
|
|
1297
|
+
// branchCode: { $eq: createScreeningRoom.branchCode }
|
|
1298
|
+
// },
|
|
1299
|
+
// {
|
|
1300
|
+
// $setOnInsert: {
|
|
1301
|
+
// typeOf: createScreeningRoom.typeOf,
|
|
1302
|
+
// project: createScreeningRoom.project,
|
|
1303
|
+
// branchCode: createScreeningRoom.branchCode
|
|
1304
|
+
// },
|
|
1305
|
+
// $set: setFields
|
|
1306
|
+
// },
|
|
1307
|
+
// {
|
|
1308
|
+
// upsert: true,
|
|
1309
|
+
// new: true,
|
|
1310
|
+
// projection: { _id: 1 }
|
|
1311
|
+
// }
|
|
1312
|
+
// )
|
|
1313
|
+
// .exec();
|
|
1314
|
+
// debug('screeningRoom upserted. upsertScreeningRoomResult:', upsertScreeningRoomResult);
|
|
1315
|
+
// }
|
|
1316
|
+
// }));
|
|
2186
1317
|
});
|
|
2187
1318
|
}
|
|
2188
1319
|
unsetContainsPlaceFromMovieTheater(params) {
|