@chevre/domain 21.2.0-alpha.143 → 21.2.0-alpha.145
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 +4 -3
- package/example/src/chevre/searchScreeningRooms.ts +16 -4
- package/example/src/chevre/syncScreeningRoomsAll.ts +1 -1
- package/lib/chevre/repo/place.d.ts +25 -13
- package/lib/chevre/repo/place.js +498 -368
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +12 -6
- package/lib/chevre/service/assetTransaction/reserve.js +1 -1
- package/lib/chevre/service/event.js +2 -1
- package/lib/chevre/service/offer.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -6
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +3 -1
- package/package.json +1 -1
package/lib/chevre/repo/place.js
CHANGED
|
@@ -414,211 +414,256 @@ class MongoRepository {
|
|
|
414
414
|
});
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
|
-
createScreeningRoom(screeningRoom) {
|
|
417
|
+
createScreeningRoom(screeningRoom, useScreeningRoomType) {
|
|
418
418
|
return __awaiter(this, void 0, void 0, function* () {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
branchCode: screeningRoom.containedInPlace.branchCode
|
|
424
|
-
}, {
|
|
425
|
-
_id: 1
|
|
426
|
-
})
|
|
427
|
-
.exec();
|
|
428
|
-
if (doc === null) {
|
|
429
|
-
throw new factory.errors.NotFound('containedInPlace');
|
|
419
|
+
if (useScreeningRoomType === true) {
|
|
420
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
421
|
+
// TODO implement
|
|
422
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
430
423
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
424
|
+
else {
|
|
425
|
+
// 施設存在確認
|
|
426
|
+
let doc = yield this.placeModel.findOne({
|
|
427
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
428
|
+
'project.id': { $eq: screeningRoom.project.id },
|
|
429
|
+
branchCode: screeningRoom.containedInPlace.branchCode
|
|
430
|
+
}, {
|
|
431
|
+
_id: 1
|
|
432
|
+
})
|
|
433
|
+
.exec();
|
|
434
|
+
if (doc === null) {
|
|
435
|
+
throw new factory.errors.NotFound('containedInPlace');
|
|
436
|
+
}
|
|
437
|
+
// ルームコードが存在しなければ追加する
|
|
438
|
+
doc = yield this.placeModel.findOneAndUpdate({
|
|
439
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
440
|
+
'project.id': { $eq: screeningRoom.project.id },
|
|
441
|
+
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
442
|
+
'containsPlace.branchCode': { $ne: screeningRoom.branchCode }
|
|
443
|
+
}, {
|
|
444
|
+
$push: {
|
|
445
|
+
containsPlace: {
|
|
446
|
+
typeOf: screeningRoom.typeOf,
|
|
447
|
+
branchCode: screeningRoom.branchCode,
|
|
448
|
+
name: screeningRoom.name,
|
|
449
|
+
address: screeningRoom.address,
|
|
450
|
+
additionalProperty: screeningRoom.additionalProperty
|
|
451
|
+
}
|
|
445
452
|
}
|
|
453
|
+
}, {
|
|
454
|
+
new: true,
|
|
455
|
+
projection: {
|
|
456
|
+
_id: 1,
|
|
457
|
+
// 'project.id': 1,
|
|
458
|
+
branchCode: 1,
|
|
459
|
+
typeOf: 1
|
|
460
|
+
}
|
|
461
|
+
})
|
|
462
|
+
.exec();
|
|
463
|
+
// 存在しなければコード重複
|
|
464
|
+
if (doc === null) {
|
|
465
|
+
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
|
|
446
466
|
}
|
|
447
|
-
|
|
448
|
-
new: true,
|
|
449
|
-
projection: {
|
|
450
|
-
_id: 1,
|
|
451
|
-
// 'project.id': 1,
|
|
452
|
-
branchCode: 1,
|
|
453
|
-
typeOf: 1
|
|
454
|
-
}
|
|
455
|
-
})
|
|
456
|
-
.exec();
|
|
457
|
-
// 存在しなければコード重複
|
|
458
|
-
if (doc === null) {
|
|
459
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
|
|
467
|
+
return doc.toObject();
|
|
460
468
|
}
|
|
461
|
-
return doc.toObject();
|
|
462
469
|
});
|
|
463
470
|
}
|
|
464
|
-
updateScreeningRoom(screeningRoom, $unset) {
|
|
471
|
+
updateScreeningRoom(screeningRoom, $unset, useScreeningRoomType) {
|
|
465
472
|
return __awaiter(this, void 0, void 0, function* () {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
:
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
{ 'screeningRoom.
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
473
|
+
if (useScreeningRoomType === true) {
|
|
474
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
475
|
+
// TODO implement
|
|
476
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
480
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
481
|
+
'project.id': { $eq: screeningRoom.project.id },
|
|
482
|
+
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
483
|
+
'containsPlace.branchCode': screeningRoom.branchCode
|
|
484
|
+
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].name': screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
|
|
485
|
+
? { 'containsPlace.$[screeningRoom].address': screeningRoom.address }
|
|
486
|
+
: undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
|
|
487
|
+
? { 'containsPlace.$[screeningRoom].openSeatingAllowed': screeningRoom.openSeatingAllowed }
|
|
488
|
+
: undefined), (Array.isArray(screeningRoom.additionalProperty))
|
|
489
|
+
? { 'containsPlace.$[screeningRoom].additionalProperty': screeningRoom.additionalProperty }
|
|
490
|
+
: undefined), ($unset !== undefined && $unset !== null)
|
|
491
|
+
? { $unset }
|
|
492
|
+
: undefined), {
|
|
493
|
+
new: true,
|
|
494
|
+
arrayFilters: [
|
|
495
|
+
{ 'screeningRoom.branchCode': screeningRoom.branchCode }
|
|
496
|
+
],
|
|
497
|
+
projection: {
|
|
498
|
+
_id: 1,
|
|
499
|
+
// 'project.id': 1,
|
|
500
|
+
branchCode: 1,
|
|
501
|
+
typeOf: 1
|
|
502
|
+
}
|
|
503
|
+
})
|
|
504
|
+
.exec();
|
|
505
|
+
if (doc === null) {
|
|
506
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
489
507
|
}
|
|
490
|
-
|
|
491
|
-
.exec();
|
|
492
|
-
if (doc === null) {
|
|
493
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
508
|
+
return doc.toObject();
|
|
494
509
|
}
|
|
495
|
-
return doc.toObject();
|
|
496
510
|
});
|
|
497
511
|
}
|
|
498
|
-
deleteScreeningRoom(screeningRoom) {
|
|
512
|
+
deleteScreeningRoom(screeningRoom, useScreeningRoomType) {
|
|
499
513
|
return __awaiter(this, void 0, void 0, function* () {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
514
|
+
if (useScreeningRoomType === true) {
|
|
515
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
516
|
+
// TODO implement
|
|
517
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
521
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
522
|
+
'project.id': { $eq: screeningRoom.project.id },
|
|
523
|
+
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
524
|
+
'containsPlace.branchCode': screeningRoom.branchCode
|
|
525
|
+
}, {
|
|
526
|
+
$pull: {
|
|
527
|
+
containsPlace: { branchCode: screeningRoom.branchCode }
|
|
528
|
+
}
|
|
529
|
+
}, {
|
|
530
|
+
projection: {
|
|
531
|
+
_id: 1,
|
|
532
|
+
typeOf: 1
|
|
533
|
+
}
|
|
534
|
+
})
|
|
535
|
+
.exec();
|
|
536
|
+
if (doc === null) {
|
|
537
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
513
538
|
}
|
|
514
|
-
|
|
515
|
-
.exec();
|
|
516
|
-
if (doc === null) {
|
|
517
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
539
|
+
return doc.toObject();
|
|
518
540
|
}
|
|
519
|
-
return doc.toObject();
|
|
520
541
|
});
|
|
521
542
|
}
|
|
522
|
-
|
|
543
|
+
deleteScreeningRoomsByMovieTheaterId(params) {
|
|
523
544
|
return __awaiter(this, void 0, void 0, function* () {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
530
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
531
|
-
}
|
|
532
|
-
// 施設存在確認
|
|
533
|
-
let doc = yield this.placeModel.findOne({
|
|
534
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
535
|
-
'project.id': { $eq: screeningRoomSection.project.id },
|
|
536
|
-
branchCode: movieTheater.branchCode,
|
|
537
|
-
'containsPlace.branchCode': screeningRoom.branchCode
|
|
538
|
-
}, { _id: 1 })
|
|
545
|
+
yield this.placeModel.deleteMany({
|
|
546
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
547
|
+
'project.id': { $eq: params.project.id },
|
|
548
|
+
'containedInPlace.id': { $exists: true, $eq: params.containedInPlace.id }
|
|
549
|
+
})
|
|
539
550
|
.exec();
|
|
540
|
-
|
|
541
|
-
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
createScreeningRoomSection(screeningRoomSection, useScreeningRoomType) {
|
|
554
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
555
|
+
if (useScreeningRoomType === true) {
|
|
556
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
557
|
+
// TODO implement
|
|
558
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
542
559
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
560
|
+
else {
|
|
561
|
+
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
562
|
+
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
563
|
+
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
564
|
+
}
|
|
565
|
+
const movieTheater = screeningRoom.containedInPlace;
|
|
566
|
+
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
567
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
568
|
+
}
|
|
569
|
+
// 施設存在確認
|
|
570
|
+
let doc = yield this.placeModel.findOne({
|
|
571
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
572
|
+
'project.id': { $eq: screeningRoomSection.project.id },
|
|
573
|
+
branchCode: movieTheater.branchCode,
|
|
574
|
+
'containsPlace.branchCode': screeningRoom.branchCode
|
|
575
|
+
}, { _id: 1 })
|
|
576
|
+
.exec();
|
|
577
|
+
if (doc === null) {
|
|
578
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
579
|
+
}
|
|
580
|
+
doc = yield this.placeModel.findOneAndUpdate({
|
|
581
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
582
|
+
'project.id': { $eq: screeningRoomSection.project.id },
|
|
583
|
+
branchCode: movieTheater.branchCode,
|
|
584
|
+
'containsPlace.branchCode': screeningRoom.branchCode
|
|
585
|
+
// 'containsPlace.containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
|
|
586
|
+
}, {
|
|
587
|
+
$push: {
|
|
588
|
+
'containsPlace.$[screeningRoom].containsPlace': Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
|
|
589
|
+
? { additionalProperty: screeningRoomSection.additionalProperty }
|
|
590
|
+
: undefined)
|
|
591
|
+
}
|
|
592
|
+
}, {
|
|
593
|
+
new: true,
|
|
594
|
+
arrayFilters: [
|
|
595
|
+
{
|
|
596
|
+
'screeningRoom.branchCode': screeningRoom.branchCode,
|
|
597
|
+
'screeningRoom.containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
|
|
598
|
+
}
|
|
599
|
+
],
|
|
600
|
+
projection: {
|
|
601
|
+
_id: 1,
|
|
602
|
+
typeOf: 1
|
|
561
603
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
604
|
+
})
|
|
605
|
+
.exec();
|
|
606
|
+
// 存在しなければコード重複
|
|
607
|
+
if (doc === null) {
|
|
608
|
+
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
|
|
566
609
|
}
|
|
567
|
-
|
|
568
|
-
.exec();
|
|
569
|
-
// 存在しなければコード重複
|
|
570
|
-
if (doc === null) {
|
|
571
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
|
|
610
|
+
return doc.toObject();
|
|
572
611
|
}
|
|
573
|
-
return doc.toObject();
|
|
574
612
|
});
|
|
575
613
|
}
|
|
576
|
-
updateScreeningRoomSection(screeningRoomSection, $unset) {
|
|
614
|
+
updateScreeningRoomSection(screeningRoomSection, $unset, useScreeningRoomType) {
|
|
577
615
|
return __awaiter(this, void 0, void 0, function* () {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
583
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
584
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
616
|
+
if (useScreeningRoomType === true) {
|
|
617
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
618
|
+
// TODO implement
|
|
619
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
585
620
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
{
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
621
|
+
else {
|
|
622
|
+
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
623
|
+
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
624
|
+
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
625
|
+
}
|
|
626
|
+
const movieTheater = screeningRoom.containedInPlace;
|
|
627
|
+
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
628
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
629
|
+
}
|
|
630
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
631
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
632
|
+
'project.id': { $eq: screeningRoomSection.project.id },
|
|
633
|
+
branchCode: movieTheater.branchCode,
|
|
634
|
+
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
635
|
+
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
|
|
636
|
+
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
|
|
637
|
+
? {
|
|
638
|
+
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
|
|
639
|
+
}
|
|
640
|
+
: undefined), (Array.isArray(screeningRoomSection.additionalProperty))
|
|
641
|
+
? {
|
|
642
|
+
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
|
|
643
|
+
}
|
|
644
|
+
: undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
|
|
645
|
+
? {
|
|
646
|
+
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
|
|
647
|
+
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);
|
|
648
|
+
})
|
|
649
|
+
}
|
|
650
|
+
: undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
|
|
651
|
+
new: true,
|
|
652
|
+
arrayFilters: [
|
|
653
|
+
{ 'screeningRoom.branchCode': screeningRoom.branchCode },
|
|
654
|
+
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
|
|
655
|
+
],
|
|
656
|
+
projection: {
|
|
657
|
+
_id: 1,
|
|
658
|
+
typeOf: 1
|
|
659
|
+
}
|
|
660
|
+
})
|
|
661
|
+
.exec();
|
|
662
|
+
if (doc === null) {
|
|
663
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
615
664
|
}
|
|
616
|
-
|
|
617
|
-
.exec();
|
|
618
|
-
if (doc === null) {
|
|
619
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
665
|
+
return doc.toObject();
|
|
620
666
|
}
|
|
621
|
-
return doc.toObject();
|
|
622
667
|
});
|
|
623
668
|
}
|
|
624
669
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
@@ -844,7 +889,8 @@ class MongoRepository {
|
|
|
844
889
|
branchCode: '$containsPlace.branchCode',
|
|
845
890
|
name: '$containsPlace.name',
|
|
846
891
|
containedInPlace: {
|
|
847
|
-
id: '$_id',
|
|
892
|
+
id: { $toString: '$_id' },
|
|
893
|
+
// id: '$_id',
|
|
848
894
|
typeOf: '$typeOf',
|
|
849
895
|
branchCode: '$branchCode',
|
|
850
896
|
name: '$name'
|
|
@@ -873,35 +919,42 @@ class MongoRepository {
|
|
|
873
919
|
}
|
|
874
920
|
});
|
|
875
921
|
}
|
|
876
|
-
deleteScreeningRoomSection(screeningRoomSection) {
|
|
922
|
+
deleteScreeningRoomSection(screeningRoomSection, useScreeningRoomType) {
|
|
877
923
|
return __awaiter(this, void 0, void 0, function* () {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
'
|
|
887
|
-
|
|
924
|
+
if (useScreeningRoomType === true) {
|
|
925
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
926
|
+
// TODO implement
|
|
927
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
928
|
+
}
|
|
929
|
+
else {
|
|
930
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
931
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
932
|
+
'project.id': { $eq: screeningRoomSection.project.id },
|
|
933
|
+
branchCode: screeningRoomSection.containedInPlace.containedInPlace.branchCode,
|
|
934
|
+
'containsPlace.branchCode': screeningRoomSection.containedInPlace.branchCode,
|
|
935
|
+
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
|
|
936
|
+
}, {
|
|
937
|
+
$pull: {
|
|
938
|
+
'containsPlace.$[screeningRoom].containsPlace': {
|
|
939
|
+
branchCode: screeningRoomSection.branchCode
|
|
940
|
+
}
|
|
888
941
|
}
|
|
942
|
+
}, {
|
|
943
|
+
new: true,
|
|
944
|
+
arrayFilters: [
|
|
945
|
+
{ 'screeningRoom.branchCode': screeningRoomSection.containedInPlace.branchCode }
|
|
946
|
+
],
|
|
947
|
+
projection: {
|
|
948
|
+
_id: 1,
|
|
949
|
+
typeOf: 1
|
|
950
|
+
}
|
|
951
|
+
})
|
|
952
|
+
.exec();
|
|
953
|
+
if (doc === null) {
|
|
954
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
889
955
|
}
|
|
890
|
-
|
|
891
|
-
new: true,
|
|
892
|
-
arrayFilters: [
|
|
893
|
-
{ 'screeningRoom.branchCode': screeningRoomSection.containedInPlace.branchCode }
|
|
894
|
-
],
|
|
895
|
-
projection: {
|
|
896
|
-
_id: 1,
|
|
897
|
-
typeOf: 1
|
|
898
|
-
}
|
|
899
|
-
})
|
|
900
|
-
.exec();
|
|
901
|
-
if (doc === null) {
|
|
902
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
956
|
+
return doc.toObject();
|
|
903
957
|
}
|
|
904
|
-
return doc.toObject();
|
|
905
958
|
});
|
|
906
959
|
}
|
|
907
960
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
@@ -1013,6 +1066,7 @@ class MongoRepository {
|
|
|
1013
1066
|
});
|
|
1014
1067
|
}
|
|
1015
1068
|
const aggregate = this.placeModel.aggregate([
|
|
1069
|
+
{ $sort: { branchCode: factory.sortType.Ascending } },
|
|
1016
1070
|
// { $unwind: '$containsPlace' },
|
|
1017
1071
|
...matchStages,
|
|
1018
1072
|
{
|
|
@@ -1167,7 +1221,8 @@ class MongoRepository {
|
|
|
1167
1221
|
...matchStages,
|
|
1168
1222
|
{
|
|
1169
1223
|
$project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', address: '$containsPlace.address', containedInPlace: {
|
|
1170
|
-
id: '$_id',
|
|
1224
|
+
id: { $toString: '$_id' },
|
|
1225
|
+
// id: '$_id',
|
|
1171
1226
|
typeOf: '$typeOf',
|
|
1172
1227
|
branchCode: '$branchCode',
|
|
1173
1228
|
name: '$name'
|
|
@@ -1214,161 +1269,228 @@ class MongoRepository {
|
|
|
1214
1269
|
}
|
|
1215
1270
|
findScreeningRoomsByBranchCode(params) {
|
|
1216
1271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
$
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1272
|
+
if (params.useScreeningRoomType === true) {
|
|
1273
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
1274
|
+
// TODO implement
|
|
1275
|
+
const matchStages = [
|
|
1276
|
+
{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } },
|
|
1277
|
+
{
|
|
1278
|
+
$match: { 'containedInPlace.id': { $exists: true, $eq: params.containedInPlace.id.$eq } }
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
$match: { branchCode: { $eq: params.branchCode.$eq } }
|
|
1282
|
+
}
|
|
1283
|
+
];
|
|
1284
|
+
const aggregate = this.placeModel.aggregate([
|
|
1285
|
+
// { $unwind: '$containsPlace' },
|
|
1286
|
+
...matchStages,
|
|
1287
|
+
{
|
|
1288
|
+
$project: {
|
|
1289
|
+
_id: 0,
|
|
1290
|
+
typeOf: '$typeOf',
|
|
1291
|
+
branchCode: '$branchCode',
|
|
1292
|
+
name: '$name',
|
|
1293
|
+
containsPlace: '$containsPlace',
|
|
1294
|
+
seatCount: {
|
|
1295
|
+
$sum: {
|
|
1296
|
+
$map: {
|
|
1297
|
+
input: '$containsPlace',
|
|
1298
|
+
in: {
|
|
1299
|
+
$cond: {
|
|
1300
|
+
if: { $isArray: '$$this.containsPlace' },
|
|
1301
|
+
then: { $size: '$$this.containsPlace' },
|
|
1302
|
+
else: 0
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1245
1309
|
}
|
|
1310
|
+
]);
|
|
1311
|
+
const docs = yield aggregate.limit(1)
|
|
1312
|
+
.exec();
|
|
1313
|
+
if (docs.length < 1) {
|
|
1314
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
1246
1315
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1316
|
+
return docs[0];
|
|
1317
|
+
}
|
|
1318
|
+
else {
|
|
1319
|
+
const matchStages = [
|
|
1320
|
+
{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } },
|
|
1321
|
+
{
|
|
1322
|
+
$match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.containedInPlace.id.$eq) } }
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
$match: { 'containsPlace.branchCode': { $exists: true, $eq: params.branchCode.$eq } }
|
|
1326
|
+
}
|
|
1327
|
+
];
|
|
1328
|
+
const aggregate = this.placeModel.aggregate([
|
|
1329
|
+
{ $unwind: '$containsPlace' },
|
|
1330
|
+
...matchStages,
|
|
1331
|
+
{
|
|
1332
|
+
$project: {
|
|
1333
|
+
_id: 0,
|
|
1334
|
+
typeOf: '$containsPlace.typeOf',
|
|
1335
|
+
branchCode: '$containsPlace.branchCode',
|
|
1336
|
+
name: '$containsPlace.name',
|
|
1337
|
+
containsPlace: '$containsPlace.containsPlace',
|
|
1338
|
+
seatCount: {
|
|
1339
|
+
$sum: {
|
|
1340
|
+
$map: {
|
|
1341
|
+
input: '$containsPlace.containsPlace',
|
|
1342
|
+
in: {
|
|
1343
|
+
$cond: {
|
|
1344
|
+
if: { $isArray: '$$this.containsPlace' },
|
|
1345
|
+
then: { $size: '$$this.containsPlace' },
|
|
1346
|
+
else: 0
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
]);
|
|
1355
|
+
const docs = yield aggregate.limit(1)
|
|
1356
|
+
.exec();
|
|
1357
|
+
if (docs.length < 1) {
|
|
1358
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
1359
|
+
}
|
|
1360
|
+
return docs[0];
|
|
1252
1361
|
}
|
|
1253
|
-
return docs[0];
|
|
1254
1362
|
});
|
|
1255
1363
|
}
|
|
1256
|
-
createSeat(seat) {
|
|
1364
|
+
createSeat(seat, useScreeningRoomType) {
|
|
1257
1365
|
var _a, _b;
|
|
1258
1366
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
1264
|
-
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
1265
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
1266
|
-
}
|
|
1267
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
1268
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
1269
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
1270
|
-
}
|
|
1271
|
-
// 施設存在確認
|
|
1272
|
-
let doc = yield this.placeModel.findOne({
|
|
1273
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1274
|
-
'project.id': { $eq: seat.project.id },
|
|
1275
|
-
branchCode: movieTheater.branchCode,
|
|
1276
|
-
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
1277
|
-
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
|
|
1278
|
-
}, {
|
|
1279
|
-
_id: 1
|
|
1280
|
-
})
|
|
1281
|
-
.exec();
|
|
1282
|
-
if (doc === null) {
|
|
1283
|
-
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
1367
|
+
if (useScreeningRoomType === true) {
|
|
1368
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
1369
|
+
// TODO implement
|
|
1370
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
1284
1371
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1372
|
+
else {
|
|
1373
|
+
const screeningRoomSection = seat.containedInPlace;
|
|
1374
|
+
if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
|
|
1375
|
+
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
1376
|
+
}
|
|
1377
|
+
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
1378
|
+
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
1379
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
1380
|
+
}
|
|
1381
|
+
const movieTheater = screeningRoom.containedInPlace;
|
|
1382
|
+
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
1383
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
1384
|
+
}
|
|
1385
|
+
// 施設存在確認
|
|
1386
|
+
let doc = yield this.placeModel.findOne({
|
|
1387
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1388
|
+
'project.id': { $eq: seat.project.id },
|
|
1389
|
+
branchCode: movieTheater.branchCode,
|
|
1390
|
+
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
1391
|
+
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
|
|
1392
|
+
}, {
|
|
1393
|
+
_id: 1
|
|
1394
|
+
})
|
|
1395
|
+
.exec();
|
|
1396
|
+
if (doc === null) {
|
|
1397
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
1398
|
+
}
|
|
1399
|
+
doc = yield this.placeModel.findOneAndUpdate({
|
|
1400
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1401
|
+
'project.id': { $eq: seat.project.id },
|
|
1402
|
+
branchCode: movieTheater.branchCode,
|
|
1403
|
+
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
1404
|
+
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
|
|
1405
|
+
}, {
|
|
1406
|
+
$push: {
|
|
1407
|
+
'containsPlace.$[screeningRoom].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)
|
|
1302
1408
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1409
|
+
}, {
|
|
1410
|
+
new: true,
|
|
1411
|
+
arrayFilters: [
|
|
1412
|
+
{ 'screeningRoom.branchCode': screeningRoom.branchCode },
|
|
1413
|
+
{
|
|
1414
|
+
'screeningRoomSection.branchCode': screeningRoomSection.branchCode,
|
|
1415
|
+
'screeningRoomSection.containsPlace.branchCode': { $ne: seat.branchCode }
|
|
1416
|
+
}
|
|
1417
|
+
],
|
|
1418
|
+
projection: {
|
|
1419
|
+
_id: 1,
|
|
1420
|
+
// 'project.id': 1,
|
|
1421
|
+
branchCode: 1,
|
|
1422
|
+
typeOf: 1
|
|
1423
|
+
}
|
|
1424
|
+
})
|
|
1425
|
+
.exec();
|
|
1426
|
+
// 存在しなければコード重複
|
|
1427
|
+
if (doc === null) {
|
|
1428
|
+
throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
|
|
1309
1429
|
}
|
|
1310
|
-
|
|
1311
|
-
.exec();
|
|
1312
|
-
// 存在しなければコード重複
|
|
1313
|
-
if (doc === null) {
|
|
1314
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
|
|
1430
|
+
return doc.toObject();
|
|
1315
1431
|
}
|
|
1316
|
-
return doc.toObject();
|
|
1317
1432
|
});
|
|
1318
1433
|
}
|
|
1319
|
-
updateSeat(seat, $unset) {
|
|
1434
|
+
updateSeat(seat, $unset, useScreeningRoomType) {
|
|
1320
1435
|
var _a, _b;
|
|
1321
1436
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
1327
|
-
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
1328
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
1329
|
-
}
|
|
1330
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
1331
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
1332
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
1437
|
+
if (useScreeningRoomType === true) {
|
|
1438
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
1439
|
+
// TODO implement
|
|
1440
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
1333
1441
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
'containsPlace
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1442
|
+
else {
|
|
1443
|
+
const screeningRoomSection = seat.containedInPlace;
|
|
1444
|
+
if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
|
|
1445
|
+
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
1446
|
+
}
|
|
1447
|
+
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
1448
|
+
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
1449
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
1450
|
+
}
|
|
1451
|
+
const movieTheater = screeningRoom.containedInPlace;
|
|
1452
|
+
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
1453
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
1454
|
+
}
|
|
1455
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1456
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1457
|
+
'project.id': { $eq: seat.project.id },
|
|
1458
|
+
branchCode: movieTheater.branchCode,
|
|
1459
|
+
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
1460
|
+
'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode,
|
|
1461
|
+
'containsPlace.containsPlace.containsPlace.branchCode': seat.branchCode
|
|
1462
|
+
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].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')
|
|
1463
|
+
? {
|
|
1464
|
+
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
|
|
1465
|
+
}
|
|
1466
|
+
: undefined), (Array.isArray(seat.seatingType))
|
|
1467
|
+
? {
|
|
1468
|
+
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': seat.seatingType
|
|
1469
|
+
}
|
|
1470
|
+
: undefined), (Array.isArray(seat.additionalProperty))
|
|
1471
|
+
? {
|
|
1472
|
+
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].additionalProperty': seat.additionalProperty
|
|
1473
|
+
}
|
|
1474
|
+
: undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
|
|
1475
|
+
new: true,
|
|
1476
|
+
arrayFilters: [
|
|
1477
|
+
{ 'screeningRoom.branchCode': screeningRoom.branchCode },
|
|
1478
|
+
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode },
|
|
1479
|
+
{ 'seat.branchCode': seat.branchCode }
|
|
1480
|
+
],
|
|
1481
|
+
projection: {
|
|
1482
|
+
_id: 1,
|
|
1483
|
+
// 'project.id': 1,
|
|
1484
|
+
branchCode: 1,
|
|
1485
|
+
typeOf: 1
|
|
1486
|
+
}
|
|
1487
|
+
})
|
|
1488
|
+
.exec();
|
|
1489
|
+
if (doc === null) {
|
|
1490
|
+
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
1365
1491
|
}
|
|
1366
|
-
|
|
1367
|
-
.exec();
|
|
1368
|
-
if (doc === null) {
|
|
1369
|
-
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
1492
|
+
return doc.toObject();
|
|
1370
1493
|
}
|
|
1371
|
-
return doc.toObject();
|
|
1372
1494
|
});
|
|
1373
1495
|
}
|
|
1374
1496
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
@@ -1717,7 +1839,8 @@ class MongoRepository {
|
|
|
1717
1839
|
branchCode: '$containsPlace.branchCode',
|
|
1718
1840
|
name: '$containsPlace.name',
|
|
1719
1841
|
containedInPlace: {
|
|
1720
|
-
id: '$_id',
|
|
1842
|
+
id: { $toString: '$_id' },
|
|
1843
|
+
// id: '$_id',
|
|
1721
1844
|
typeOf: '$typeOf',
|
|
1722
1845
|
branchCode: '$branchCode',
|
|
1723
1846
|
name: '$name'
|
|
@@ -1738,37 +1861,44 @@ class MongoRepository {
|
|
|
1738
1861
|
}
|
|
1739
1862
|
});
|
|
1740
1863
|
}
|
|
1741
|
-
deleteSeat(seat) {
|
|
1864
|
+
deleteSeat(seat, useScreeningRoomType) {
|
|
1742
1865
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1866
|
+
if (useScreeningRoomType === true) {
|
|
1867
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
1868
|
+
// TODO implement
|
|
1869
|
+
throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
|
|
1870
|
+
}
|
|
1871
|
+
else {
|
|
1872
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1873
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1874
|
+
'project.id': { $eq: seat.project.id },
|
|
1875
|
+
branchCode: seat.containedInPlace.containedInPlace.containedInPlace.branchCode,
|
|
1876
|
+
'containsPlace.branchCode': seat.containedInPlace.containedInPlace.branchCode,
|
|
1877
|
+
'containsPlace.containsPlace.branchCode': seat.containedInPlace.branchCode,
|
|
1878
|
+
'containsPlace.containsPlace.containsPlace.branchCode': seat.branchCode
|
|
1879
|
+
}, {
|
|
1880
|
+
$pull: {
|
|
1881
|
+
'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace': {
|
|
1882
|
+
branchCode: seat.branchCode
|
|
1883
|
+
}
|
|
1754
1884
|
}
|
|
1885
|
+
}, {
|
|
1886
|
+
new: true,
|
|
1887
|
+
arrayFilters: [
|
|
1888
|
+
{ 'screeningRoom.branchCode': seat.containedInPlace.containedInPlace.branchCode },
|
|
1889
|
+
{ 'screeningRoomSection.branchCode': seat.containedInPlace.branchCode }
|
|
1890
|
+
],
|
|
1891
|
+
projection: {
|
|
1892
|
+
_id: 1,
|
|
1893
|
+
typeOf: 1
|
|
1894
|
+
}
|
|
1895
|
+
})
|
|
1896
|
+
.exec();
|
|
1897
|
+
if (doc === null) {
|
|
1898
|
+
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
1755
1899
|
}
|
|
1756
|
-
|
|
1757
|
-
new: true,
|
|
1758
|
-
arrayFilters: [
|
|
1759
|
-
{ 'screeningRoom.branchCode': seat.containedInPlace.containedInPlace.branchCode },
|
|
1760
|
-
{ 'screeningRoomSection.branchCode': seat.containedInPlace.branchCode }
|
|
1761
|
-
],
|
|
1762
|
-
projection: {
|
|
1763
|
-
_id: 1,
|
|
1764
|
-
typeOf: 1
|
|
1765
|
-
}
|
|
1766
|
-
})
|
|
1767
|
-
.exec();
|
|
1768
|
-
if (doc === null) {
|
|
1769
|
-
throw new factory.errors.NotFound(factory.placeType.Seat);
|
|
1900
|
+
return doc.toObject();
|
|
1770
1901
|
}
|
|
1771
|
-
return doc.toObject();
|
|
1772
1902
|
});
|
|
1773
1903
|
}
|
|
1774
1904
|
syncScreeningRooms(params) {
|