@chevre/domain 21.2.0-alpha.141 → 21.2.0-alpha.143

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.
@@ -268,24 +268,26 @@ class MongoRepository {
268
268
  });
269
269
  yield Promise.all(creatingScreeningRooms.map((createScreeningRoom) => __awaiter(this, void 0, void 0, function* () {
270
270
  const { typeOf, project, branchCode } = createScreeningRoom, setFields = __rest(createScreeningRoom, ["typeOf", "project", "branchCode"]);
271
- yield this.placeModel.findOneAndUpdate({
272
- typeOf: { $eq: factory.placeType.ScreeningRoom },
273
- 'project.id': { $eq: createScreeningRoom.project.id },
274
- 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
275
- branchCode: { $eq: createScreeningRoom.branchCode }
276
- }, {
277
- $setOnInsert: {
278
- typeOf: createScreeningRoom.typeOf,
279
- project: createScreeningRoom.project,
280
- branchCode: createScreeningRoom.branchCode
281
- },
282
- $set: setFields
283
- }, {
284
- upsert: true,
285
- new: true,
286
- projection: { _id: 1 }
287
- })
288
- .exec();
271
+ if (typeof branchCode === 'string' && branchCode.length > 0) {
272
+ yield this.placeModel.findOneAndUpdate({
273
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
274
+ 'project.id': { $eq: createScreeningRoom.project.id },
275
+ 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
276
+ branchCode: { $eq: createScreeningRoom.branchCode }
277
+ }, {
278
+ $setOnInsert: {
279
+ typeOf: createScreeningRoom.typeOf,
280
+ project: createScreeningRoom.project,
281
+ branchCode: createScreeningRoom.branchCode
282
+ },
283
+ $set: setFields
284
+ }, {
285
+ upsert: true,
286
+ new: true,
287
+ projection: { _id: 1 }
288
+ })
289
+ .exec();
290
+ }
289
291
  })));
290
292
  });
291
293
  }
@@ -619,132 +621,256 @@ class MongoRepository {
619
621
  return doc.toObject();
620
622
  });
621
623
  }
622
- // tslint:disable-next-line:max-func-body-length
623
- searchScreeningRoomSections(searchConditions) {
624
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
624
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
625
+ searchScreeningRoomSections(searchConditions, useScreeningRoomType) {
626
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
625
627
  return __awaiter(this, void 0, void 0, function* () {
626
- const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
627
- const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
628
- if (typeof projectIdEq === 'string') {
629
- matchStages.push({
630
- $match: { 'project.id': { $eq: projectIdEq } }
631
- });
632
- }
633
- // 施設コード
634
- 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;
635
- if (typeof movieTheaterBranchCodeEq === 'string') {
636
- matchStages.push({
637
- $match: {
638
- branchCode: {
639
- $exists: true,
640
- $eq: movieTheaterBranchCodeEq
628
+ if (useScreeningRoomType === true) {
629
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoomSection } } }];
630
+ const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
631
+ if (typeof projectIdEq === 'string') {
632
+ matchStages.push({
633
+ $match: { 'project.id': { $eq: projectIdEq } }
634
+ });
635
+ }
636
+ // 施設コード
637
+ 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;
638
+ if (typeof movieTheaterBranchCodeEq === 'string') {
639
+ matchStages.push({
640
+ $match: {
641
+ 'containedInPlace.branchCode': {
642
+ $exists: true,
643
+ $eq: movieTheaterBranchCodeEq
644
+ }
641
645
  }
642
- }
643
- });
644
- }
645
- // ルームコード
646
- const containedInPlaceBranchCodeEq = (_g = (_f = searchConditions.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
647
- if (typeof containedInPlaceBranchCodeEq === 'string') {
648
- matchStages.push({
649
- $match: {
650
- 'containsPlace.branchCode': {
651
- $exists: true,
652
- $eq: containedInPlaceBranchCodeEq
646
+ });
647
+ }
648
+ // ルームコード
649
+ const containedInPlaceBranchCodeEq = (_g = (_f = searchConditions.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
650
+ if (typeof containedInPlaceBranchCodeEq === 'string') {
651
+ matchStages.push({
652
+ $match: {
653
+ branchCode: {
654
+ $eq: containedInPlaceBranchCodeEq
655
+ }
653
656
  }
654
- }
655
- });
656
- }
657
- // セクションコード
658
- const sectionBranchCodeEq = (_h = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$eq;
659
- if (typeof sectionBranchCodeEq === 'string') {
660
- matchStages.push({
661
- $match: {
662
- 'containsPlace.containsPlace.branchCode': {
663
- $exists: true,
664
- $eq: sectionBranchCodeEq
657
+ });
658
+ }
659
+ // セクションコード
660
+ const sectionBranchCodeEq = (_h = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$eq;
661
+ if (typeof sectionBranchCodeEq === 'string') {
662
+ matchStages.push({
663
+ $match: {
664
+ 'containsPlace.branchCode': {
665
+ $exists: true,
666
+ $eq: sectionBranchCodeEq
667
+ }
665
668
  }
666
- }
667
- });
668
- }
669
- const nameCodeRegex = (_j = searchConditions.name) === null || _j === void 0 ? void 0 : _j.$regex;
670
- if (typeof nameCodeRegex === 'string') {
671
- matchStages.push({
672
- $match: {
673
- $or: [
674
- {
675
- 'containsPlace.containsPlace.name.ja': {
676
- $exists: true,
677
- $regex: new RegExp(nameCodeRegex)
669
+ });
670
+ }
671
+ const nameCodeRegex = (_j = searchConditions.name) === null || _j === void 0 ? void 0 : _j.$regex;
672
+ if (typeof nameCodeRegex === 'string') {
673
+ matchStages.push({
674
+ $match: {
675
+ $or: [
676
+ {
677
+ 'containsPlace.name.ja': {
678
+ $exists: true,
679
+ $regex: new RegExp(nameCodeRegex)
680
+ }
681
+ },
682
+ {
683
+ 'containsPlace.name.en': {
684
+ $exists: true,
685
+ $regex: new RegExp(nameCodeRegex)
686
+ }
678
687
  }
679
- },
680
- {
681
- 'containsPlace.containsPlace.name.en': {
682
- $exists: true,
683
- $regex: new RegExp(nameCodeRegex)
688
+ ]
689
+ }
690
+ });
691
+ }
692
+ const branchCodeRegex = (_k = searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
693
+ if (typeof branchCodeRegex === 'string') {
694
+ matchStages.push({
695
+ $match: {
696
+ 'containsPlace.branchCode': {
697
+ $exists: true,
698
+ $regex: new RegExp(branchCodeRegex)
699
+ }
700
+ }
701
+ });
702
+ }
703
+ const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
704
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
705
+ matchStages.push({
706
+ $match: {
707
+ 'containsPlace.additionalProperty': {
708
+ $exists: true,
709
+ $elemMatch: additionalPropertyElemMatch
710
+ }
711
+ }
712
+ });
713
+ }
714
+ const aggregate = this.placeModel.aggregate([
715
+ { $unwind: '$containsPlace' },
716
+ ...matchStages,
717
+ {
718
+ $project: Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', containedInPlace: {
719
+ typeOf: '$typeOf',
720
+ branchCode: '$branchCode',
721
+ name: '$name',
722
+ containedInPlace: {
723
+ id: '$containedInPlace.id',
724
+ typeOf: '$containedInPlace.typeOf',
725
+ branchCode: '$containedInPlace.branchCode',
726
+ name: '$containedInPlace.name'
727
+ }
728
+ }, additionalProperty: '$containsPlace.additionalProperty' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.seatCount) === 1)
729
+ ? {
730
+ seatCount: {
731
+ $cond: {
732
+ if: { $isArray: '$containsPlace.containsPlace' },
733
+ then: { $size: '$containsPlace.containsPlace' },
734
+ else: 0
735
+ }
684
736
  }
685
737
  }
686
- ]
738
+ : undefined)
687
739
  }
688
- });
740
+ ]);
741
+ // tslint:disable-next-line:no-single-line-block-comment
742
+ /* istanbul ignore else */
743
+ if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
744
+ const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
745
+ aggregate.limit(searchConditions.limit * page)
746
+ .skip(searchConditions.limit * (page - 1));
747
+ }
748
+ return aggregate.exec();
689
749
  }
690
- const branchCodeRegex = (_k = searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
691
- if (typeof branchCodeRegex === 'string') {
692
- matchStages.push({
693
- $match: {
694
- 'containsPlace.containsPlace.branchCode': {
695
- $exists: true,
696
- $regex: new RegExp(branchCodeRegex)
750
+ else {
751
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
752
+ const projectIdEq = (_p = (_o = searchConditions.project) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$eq;
753
+ if (typeof projectIdEq === 'string') {
754
+ matchStages.push({
755
+ $match: { 'project.id': { $eq: projectIdEq } }
756
+ });
757
+ }
758
+ // 施設コード
759
+ const movieTheaterBranchCodeEq = (_s = (_r = (_q = searchConditions.containedInPlace) === null || _q === void 0 ? void 0 : _q.containedInPlace) === null || _r === void 0 ? void 0 : _r.branchCode) === null || _s === void 0 ? void 0 : _s.$eq;
760
+ if (typeof movieTheaterBranchCodeEq === 'string') {
761
+ matchStages.push({
762
+ $match: {
763
+ branchCode: {
764
+ $exists: true,
765
+ $eq: movieTheaterBranchCodeEq
766
+ }
697
767
  }
698
- }
699
- });
700
- }
701
- const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
702
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
703
- matchStages.push({
704
- $match: {
705
- 'containsPlace.containsPlace.additionalProperty': {
706
- $exists: true,
707
- $elemMatch: additionalPropertyElemMatch
768
+ });
769
+ }
770
+ // ルームコード
771
+ const containedInPlaceBranchCodeEq = (_u = (_t = searchConditions.containedInPlace) === null || _t === void 0 ? void 0 : _t.branchCode) === null || _u === void 0 ? void 0 : _u.$eq;
772
+ if (typeof containedInPlaceBranchCodeEq === 'string') {
773
+ matchStages.push({
774
+ $match: {
775
+ 'containsPlace.branchCode': {
776
+ $exists: true,
777
+ $eq: containedInPlaceBranchCodeEq
778
+ }
708
779
  }
709
- }
710
- });
711
- }
712
- const aggregate = this.placeModel.aggregate([
713
- { $unwind: '$containsPlace' },
714
- { $unwind: '$containsPlace.containsPlace' },
715
- ...matchStages,
716
- {
717
- $project: Object.assign({ _id: 0, typeOf: '$containsPlace.containsPlace.typeOf', branchCode: '$containsPlace.containsPlace.branchCode', name: '$containsPlace.containsPlace.name', containedInPlace: {
718
- typeOf: '$containsPlace.typeOf',
719
- branchCode: '$containsPlace.branchCode',
720
- name: '$containsPlace.name',
721
- containedInPlace: {
722
- id: '$_id',
723
- typeOf: '$typeOf',
724
- branchCode: '$branchCode',
725
- name: '$name'
780
+ });
781
+ }
782
+ // セクションコード
783
+ const sectionBranchCodeEq = (_v = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _v === void 0 ? void 0 : _v.$eq;
784
+ if (typeof sectionBranchCodeEq === 'string') {
785
+ matchStages.push({
786
+ $match: {
787
+ 'containsPlace.containsPlace.branchCode': {
788
+ $exists: true,
789
+ $eq: sectionBranchCodeEq
726
790
  }
727
- }, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.seatCount) === 1)
728
- ? {
729
- seatCount: {
730
- $cond: {
731
- if: { $isArray: '$containsPlace.containsPlace.containsPlace' },
732
- then: { $size: '$containsPlace.containsPlace.containsPlace' },
733
- else: 0
791
+ }
792
+ });
793
+ }
794
+ const nameCodeRegex = (_w = searchConditions.name) === null || _w === void 0 ? void 0 : _w.$regex;
795
+ if (typeof nameCodeRegex === 'string') {
796
+ matchStages.push({
797
+ $match: {
798
+ $or: [
799
+ {
800
+ 'containsPlace.containsPlace.name.ja': {
801
+ $exists: true,
802
+ $regex: new RegExp(nameCodeRegex)
803
+ }
804
+ },
805
+ {
806
+ 'containsPlace.containsPlace.name.en': {
807
+ $exists: true,
808
+ $regex: new RegExp(nameCodeRegex)
809
+ }
734
810
  }
811
+ ]
812
+ }
813
+ });
814
+ }
815
+ const branchCodeRegex = (_x = searchConditions.branchCode) === null || _x === void 0 ? void 0 : _x.$regex;
816
+ if (typeof branchCodeRegex === 'string') {
817
+ matchStages.push({
818
+ $match: {
819
+ 'containsPlace.containsPlace.branchCode': {
820
+ $exists: true,
821
+ $regex: new RegExp(branchCodeRegex)
735
822
  }
736
823
  }
737
- : undefined)
824
+ });
738
825
  }
739
- ]);
740
- // tslint:disable-next-line:no-single-line-block-comment
741
- /* istanbul ignore else */
742
- if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
743
- const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
744
- aggregate.limit(searchConditions.limit * page)
745
- .skip(searchConditions.limit * (page - 1));
826
+ const additionalPropertyElemMatch = (_y = searchConditions.additionalProperty) === null || _y === void 0 ? void 0 : _y.$elemMatch;
827
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
828
+ matchStages.push({
829
+ $match: {
830
+ 'containsPlace.containsPlace.additionalProperty': {
831
+ $exists: true,
832
+ $elemMatch: additionalPropertyElemMatch
833
+ }
834
+ }
835
+ });
836
+ }
837
+ const aggregate = this.placeModel.aggregate([
838
+ { $unwind: '$containsPlace' },
839
+ { $unwind: '$containsPlace.containsPlace' },
840
+ ...matchStages,
841
+ {
842
+ $project: Object.assign({ _id: 0, typeOf: '$containsPlace.containsPlace.typeOf', branchCode: '$containsPlace.containsPlace.branchCode', name: '$containsPlace.containsPlace.name', containedInPlace: {
843
+ typeOf: '$containsPlace.typeOf',
844
+ branchCode: '$containsPlace.branchCode',
845
+ name: '$containsPlace.name',
846
+ containedInPlace: {
847
+ id: '$_id',
848
+ typeOf: '$typeOf',
849
+ branchCode: '$branchCode',
850
+ name: '$name'
851
+ }
852
+ }, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((_z = searchConditions.$projection) === null || _z === void 0 ? void 0 : _z.seatCount) === 1)
853
+ ? {
854
+ seatCount: {
855
+ $cond: {
856
+ if: { $isArray: '$containsPlace.containsPlace.containsPlace' },
857
+ then: { $size: '$containsPlace.containsPlace.containsPlace' },
858
+ else: 0
859
+ }
860
+ }
861
+ }
862
+ : undefined)
863
+ }
864
+ ]);
865
+ // tslint:disable-next-line:no-single-line-block-comment
866
+ /* istanbul ignore else */
867
+ if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
868
+ const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
869
+ aggregate.limit(searchConditions.limit * page)
870
+ .skip(searchConditions.limit * (page - 1));
871
+ }
872
+ return aggregate.exec();
746
873
  }
747
- return aggregate.exec();
748
874
  });
749
875
  }
750
876
  deleteScreeningRoomSection(screeningRoomSection) {
@@ -778,161 +904,315 @@ class MongoRepository {
778
904
  return doc.toObject();
779
905
  });
780
906
  }
781
- // tslint:disable-next-line:max-func-body-length
782
- searchScreeningRooms(searchConditions) {
783
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
907
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
908
+ searchScreeningRooms(searchConditions, useScreeningRoomType) {
909
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
784
910
  return __awaiter(this, void 0, void 0, function* () {
785
- const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
786
- const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
787
- if (typeof projectIdEq === 'string') {
788
- matchStages.push({
789
- $match: { 'project.id': { $eq: projectIdEq } }
790
- });
791
- }
792
- // 施設ID
793
- const containedInPlaceIdEq = (_d = (_c = searchConditions.containedInPlace) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
794
- if (typeof containedInPlaceIdEq === 'string') {
795
- matchStages.push({
796
- $match: {
797
- _id: { $eq: new mongoose_1.Types.ObjectId(containedInPlaceIdEq) }
798
- }
799
- });
800
- }
801
- if (searchConditions.containedInPlace !== undefined) {
802
- // 施設コード
803
- if (searchConditions.containedInPlace.branchCode !== undefined) {
804
- if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
805
- matchStages.push({
806
- $match: {
807
- branchCode: {
808
- $exists: true,
809
- $eq: searchConditions.containedInPlace.branchCode.$eq
810
- }
911
+ if (useScreeningRoomType === true) {
912
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
913
+ const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
914
+ if (typeof projectIdEq === 'string') {
915
+ matchStages.push({
916
+ $match: { 'project.id': { $eq: projectIdEq } }
917
+ });
918
+ }
919
+ // 施設ID
920
+ const containedInPlaceIdEq = (_d = (_c = searchConditions.containedInPlace) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
921
+ if (typeof containedInPlaceIdEq === 'string') {
922
+ matchStages.push({
923
+ $match: {
924
+ 'containedInPlace.id': {
925
+ $exists: true,
926
+ $eq: containedInPlaceIdEq
811
927
  }
812
- });
813
- }
928
+ }
929
+ });
814
930
  }
815
- }
816
- const branchCodeEq = (_e = searchConditions.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
817
- if (typeof branchCodeEq === 'string') {
818
- matchStages.push({
819
- $match: {
820
- 'containsPlace.branchCode': { $exists: true, $eq: branchCodeEq }
821
- }
822
- });
823
- }
824
- const branchCodeIn = (_f = searchConditions.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
825
- if (Array.isArray(branchCodeIn)) {
826
- matchStages.push({
827
- $match: {
828
- 'containsPlace.branchCode': { $exists: true, $in: branchCodeIn }
829
- }
830
- });
831
- }
832
- const branchCodeRegex = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$regex;
833
- if (typeof branchCodeRegex === 'string') {
834
- matchStages.push({
835
- $match: {
836
- 'containsPlace.branchCode': {
837
- $exists: true,
838
- $regex: new RegExp(branchCodeRegex)
931
+ if (searchConditions.containedInPlace !== undefined) {
932
+ // 施設コード
933
+ if (searchConditions.containedInPlace.branchCode !== undefined) {
934
+ if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
935
+ matchStages.push({
936
+ $match: {
937
+ 'containedInPlace.branchCode': {
938
+ $exists: true,
939
+ $eq: searchConditions.containedInPlace.branchCode.$eq
940
+ }
941
+ }
942
+ });
839
943
  }
840
944
  }
841
- });
842
- }
843
- const nameCodeRegex = (_h = searchConditions.name) === null || _h === void 0 ? void 0 : _h.$regex;
844
- if (typeof nameCodeRegex === 'string') {
845
- matchStages.push({
846
- $match: {
847
- $or: [
848
- {
849
- 'containsPlace.name.ja': {
850
- $exists: true,
851
- $regex: new RegExp(nameCodeRegex)
852
- }
853
- },
854
- {
855
- 'containsPlace.name.en': {
856
- $exists: true,
857
- $regex: new RegExp(nameCodeRegex)
945
+ }
946
+ const branchCodeEq = (_e = searchConditions.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
947
+ if (typeof branchCodeEq === 'string') {
948
+ matchStages.push({
949
+ $match: {
950
+ branchCode: { $eq: branchCodeEq }
951
+ }
952
+ });
953
+ }
954
+ const branchCodeIn = (_f = searchConditions.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
955
+ if (Array.isArray(branchCodeIn)) {
956
+ matchStages.push({
957
+ $match: {
958
+ branchCode: { $in: branchCodeIn }
959
+ }
960
+ });
961
+ }
962
+ const branchCodeRegex = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$regex;
963
+ if (typeof branchCodeRegex === 'string') {
964
+ matchStages.push({
965
+ $match: {
966
+ branchCode: {
967
+ $regex: new RegExp(branchCodeRegex)
968
+ }
969
+ }
970
+ });
971
+ }
972
+ const nameCodeRegex = (_h = searchConditions.name) === null || _h === void 0 ? void 0 : _h.$regex;
973
+ if (typeof nameCodeRegex === 'string') {
974
+ matchStages.push({
975
+ $match: {
976
+ $or: [
977
+ {
978
+ 'name.ja': {
979
+ $exists: true,
980
+ $regex: new RegExp(nameCodeRegex)
981
+ }
982
+ },
983
+ {
984
+ 'name.en': {
985
+ $exists: true,
986
+ $regex: new RegExp(nameCodeRegex)
987
+ }
858
988
  }
989
+ ]
990
+ }
991
+ });
992
+ }
993
+ const openSeatingAllowed = searchConditions.openSeatingAllowed;
994
+ if (typeof openSeatingAllowed === 'boolean') {
995
+ matchStages.push({
996
+ $match: {
997
+ openSeatingAllowed: {
998
+ $exists: true,
999
+ $eq: openSeatingAllowed
859
1000
  }
860
- ]
861
- }
862
- });
863
- }
864
- const openSeatingAllowed = searchConditions.openSeatingAllowed;
865
- if (typeof openSeatingAllowed === 'boolean') {
866
- matchStages.push({
867
- $match: {
868
- 'containsPlace.openSeatingAllowed': {
869
- $exists: true,
870
- $eq: openSeatingAllowed
871
1001
  }
872
- }
873
- });
874
- }
875
- const additionalPropertyElemMatch = (_j = searchConditions.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
876
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
877
- matchStages.push({
878
- $match: {
879
- 'containsPlace.additionalProperty': {
880
- $exists: true,
881
- $elemMatch: additionalPropertyElemMatch
1002
+ });
1003
+ }
1004
+ const additionalPropertyElemMatch = (_j = searchConditions.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
1005
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
1006
+ matchStages.push({
1007
+ $match: {
1008
+ additionalProperty: {
1009
+ $exists: true,
1010
+ $elemMatch: additionalPropertyElemMatch
1011
+ }
882
1012
  }
883
- }
884
- });
885
- }
886
- const aggregate = this.placeModel.aggregate([
887
- { $unwind: '$containsPlace' },
888
- ...matchStages,
889
- {
890
- $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', address: '$containsPlace.address', containedInPlace: {
891
- id: '$_id',
892
- typeOf: '$typeOf',
893
- branchCode: '$branchCode',
894
- name: '$name'
895
- }, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty', maximumAttendeeCapacity: '$containsPlace.maximumAttendeeCapacity' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.sectionCount) === 1)
896
- ? {
897
- sectionCount: {
898
- $cond: {
899
- if: { $isArray: '$containsPlace.containsPlace' },
900
- then: { $size: '$containsPlace.containsPlace' },
901
- else: 0
1013
+ });
1014
+ }
1015
+ const aggregate = this.placeModel.aggregate([
1016
+ // { $unwind: '$containsPlace' },
1017
+ ...matchStages,
1018
+ {
1019
+ $project: Object.assign(Object.assign({ _id: 0, typeOf: '$typeOf', branchCode: '$branchCode', name: '$name', address: '$address', containedInPlace: {
1020
+ id: '$containedInPlace.id',
1021
+ typeOf: '$containedInPlace.typeOf',
1022
+ branchCode: '$containedInPlace.branchCode',
1023
+ name: '$containedInPlace.name'
1024
+ }, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.sectionCount) === 1)
1025
+ ? {
1026
+ sectionCount: {
1027
+ $cond: {
1028
+ if: { $isArray: '$containsPlace' },
1029
+ then: { $size: '$containsPlace' },
1030
+ else: 0
1031
+ }
902
1032
  }
903
1033
  }
904
- }
905
- : undefined), (((_l = searchConditions.$projection) === null || _l === void 0 ? void 0 : _l.seatCount) === 1)
906
- ? {
907
- seatCount: {
908
- $sum: {
909
- $map: {
910
- input: '$containsPlace.containsPlace',
911
- in: {
912
- $cond: {
913
- if: { $isArray: '$$this.containsPlace' },
914
- then: { $size: '$$this.containsPlace' },
915
- else: 0
1034
+ : undefined), (((_l = searchConditions.$projection) === null || _l === void 0 ? void 0 : _l.seatCount) === 1)
1035
+ ? {
1036
+ seatCount: {
1037
+ $sum: {
1038
+ $map: {
1039
+ input: '$containsPlace',
1040
+ in: {
1041
+ $cond: {
1042
+ if: { $isArray: '$$this.containsPlace' },
1043
+ then: { $size: '$$this.containsPlace' },
1044
+ else: 0
1045
+ }
916
1046
  }
917
1047
  }
918
1048
  }
919
1049
  }
920
1050
  }
921
- }
922
- : undefined)
1051
+ : undefined)
1052
+ }
1053
+ ]);
1054
+ // tslint:disable-next-line:no-single-line-block-comment
1055
+ /* istanbul ignore else */
1056
+ if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
1057
+ const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
1058
+ aggregate.limit(searchConditions.limit * page)
1059
+ .skip(searchConditions.limit * (page - 1));
923
1060
  }
924
- ]);
925
- // tslint:disable-next-line:no-single-line-block-comment
926
- /* istanbul ignore else */
927
- if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
928
- const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
929
- aggregate.limit(searchConditions.limit * page)
930
- .skip(searchConditions.limit * (page - 1));
1061
+ return aggregate.exec();
931
1062
  }
932
- return aggregate.exec();
933
- });
934
- }
935
- findScreeningRoomsByBranchCode(params) {
1063
+ else {
1064
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
1065
+ const projectIdEq = (_o = (_m = searchConditions.project) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
1066
+ if (typeof projectIdEq === 'string') {
1067
+ matchStages.push({
1068
+ $match: { 'project.id': { $eq: projectIdEq } }
1069
+ });
1070
+ }
1071
+ // 施設ID
1072
+ const containedInPlaceIdEq = (_q = (_p = searchConditions.containedInPlace) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
1073
+ if (typeof containedInPlaceIdEq === 'string') {
1074
+ matchStages.push({
1075
+ $match: {
1076
+ _id: { $eq: new mongoose_1.Types.ObjectId(containedInPlaceIdEq) }
1077
+ }
1078
+ });
1079
+ }
1080
+ if (searchConditions.containedInPlace !== undefined) {
1081
+ // 施設コード
1082
+ if (searchConditions.containedInPlace.branchCode !== undefined) {
1083
+ if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
1084
+ matchStages.push({
1085
+ $match: {
1086
+ branchCode: {
1087
+ $exists: true,
1088
+ $eq: searchConditions.containedInPlace.branchCode.$eq
1089
+ }
1090
+ }
1091
+ });
1092
+ }
1093
+ }
1094
+ }
1095
+ const branchCodeEq = (_r = searchConditions.branchCode) === null || _r === void 0 ? void 0 : _r.$eq;
1096
+ if (typeof branchCodeEq === 'string') {
1097
+ matchStages.push({
1098
+ $match: {
1099
+ 'containsPlace.branchCode': { $exists: true, $eq: branchCodeEq }
1100
+ }
1101
+ });
1102
+ }
1103
+ const branchCodeIn = (_s = searchConditions.branchCode) === null || _s === void 0 ? void 0 : _s.$in;
1104
+ if (Array.isArray(branchCodeIn)) {
1105
+ matchStages.push({
1106
+ $match: {
1107
+ 'containsPlace.branchCode': { $exists: true, $in: branchCodeIn }
1108
+ }
1109
+ });
1110
+ }
1111
+ const branchCodeRegex = (_t = searchConditions.branchCode) === null || _t === void 0 ? void 0 : _t.$regex;
1112
+ if (typeof branchCodeRegex === 'string') {
1113
+ matchStages.push({
1114
+ $match: {
1115
+ 'containsPlace.branchCode': {
1116
+ $exists: true,
1117
+ $regex: new RegExp(branchCodeRegex)
1118
+ }
1119
+ }
1120
+ });
1121
+ }
1122
+ const nameCodeRegex = (_u = searchConditions.name) === null || _u === void 0 ? void 0 : _u.$regex;
1123
+ if (typeof nameCodeRegex === 'string') {
1124
+ matchStages.push({
1125
+ $match: {
1126
+ $or: [
1127
+ {
1128
+ 'containsPlace.name.ja': {
1129
+ $exists: true,
1130
+ $regex: new RegExp(nameCodeRegex)
1131
+ }
1132
+ },
1133
+ {
1134
+ 'containsPlace.name.en': {
1135
+ $exists: true,
1136
+ $regex: new RegExp(nameCodeRegex)
1137
+ }
1138
+ }
1139
+ ]
1140
+ }
1141
+ });
1142
+ }
1143
+ const openSeatingAllowed = searchConditions.openSeatingAllowed;
1144
+ if (typeof openSeatingAllowed === 'boolean') {
1145
+ matchStages.push({
1146
+ $match: {
1147
+ 'containsPlace.openSeatingAllowed': {
1148
+ $exists: true,
1149
+ $eq: openSeatingAllowed
1150
+ }
1151
+ }
1152
+ });
1153
+ }
1154
+ const additionalPropertyElemMatch = (_v = searchConditions.additionalProperty) === null || _v === void 0 ? void 0 : _v.$elemMatch;
1155
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
1156
+ matchStages.push({
1157
+ $match: {
1158
+ 'containsPlace.additionalProperty': {
1159
+ $exists: true,
1160
+ $elemMatch: additionalPropertyElemMatch
1161
+ }
1162
+ }
1163
+ });
1164
+ }
1165
+ const aggregate = this.placeModel.aggregate([
1166
+ { $unwind: '$containsPlace' },
1167
+ ...matchStages,
1168
+ {
1169
+ $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', address: '$containsPlace.address', containedInPlace: {
1170
+ id: '$_id',
1171
+ typeOf: '$typeOf',
1172
+ branchCode: '$branchCode',
1173
+ name: '$name'
1174
+ }, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty', maximumAttendeeCapacity: '$containsPlace.maximumAttendeeCapacity' }, (((_w = searchConditions.$projection) === null || _w === void 0 ? void 0 : _w.sectionCount) === 1)
1175
+ ? {
1176
+ sectionCount: {
1177
+ $cond: {
1178
+ if: { $isArray: '$containsPlace.containsPlace' },
1179
+ then: { $size: '$containsPlace.containsPlace' },
1180
+ else: 0
1181
+ }
1182
+ }
1183
+ }
1184
+ : undefined), (((_x = searchConditions.$projection) === null || _x === void 0 ? void 0 : _x.seatCount) === 1)
1185
+ ? {
1186
+ seatCount: {
1187
+ $sum: {
1188
+ $map: {
1189
+ input: '$containsPlace.containsPlace',
1190
+ in: {
1191
+ $cond: {
1192
+ if: { $isArray: '$$this.containsPlace' },
1193
+ then: { $size: '$$this.containsPlace' },
1194
+ else: 0
1195
+ }
1196
+ }
1197
+ }
1198
+ }
1199
+ }
1200
+ }
1201
+ : undefined)
1202
+ }
1203
+ ]);
1204
+ // tslint:disable-next-line:no-single-line-block-comment
1205
+ /* istanbul ignore else */
1206
+ if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
1207
+ const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
1208
+ aggregate.limit(searchConditions.limit * page)
1209
+ .skip(searchConditions.limit * (page - 1));
1210
+ }
1211
+ return aggregate.exec();
1212
+ }
1213
+ });
1214
+ }
1215
+ findScreeningRoomsByBranchCode(params) {
936
1216
  return __awaiter(this, void 0, void 0, function* () {
937
1217
  const matchStages = [
938
1218
  { $match: { typeOf: { $eq: factory.placeType.MovieTheater } } },
@@ -1092,188 +1372,370 @@ class MongoRepository {
1092
1372
  });
1093
1373
  }
1094
1374
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
1095
- searchSeats(params) {
1096
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1375
+ searchSeats(params, useScreeningRoomType) {
1376
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
1097
1377
  return __awaiter(this, void 0, void 0, function* () {
1098
- const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
1099
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
1100
- if (typeof projectIdEq === 'string') {
1101
- matchStages.push({
1102
- $match: { 'project.id': { $eq: projectIdEq } }
1103
- });
1104
- }
1105
- const containedInPlaceBranchCodeEq = (_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.branchCode) === null || _d === void 0 ? void 0 : _d.$eq;
1106
- if (typeof containedInPlaceBranchCodeEq === 'string') {
1107
- matchStages.push({
1108
- $match: {
1109
- 'containsPlace.containsPlace.branchCode': {
1110
- $exists: true,
1111
- $eq: containedInPlaceBranchCodeEq
1378
+ if (useScreeningRoomType === true) {
1379
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
1380
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
1381
+ if (typeof projectIdEq === 'string') {
1382
+ matchStages.push({
1383
+ $match: { 'project.id': { $eq: projectIdEq } }
1384
+ });
1385
+ }
1386
+ const containedInPlaceBranchCodeEq = (_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.branchCode) === null || _d === void 0 ? void 0 : _d.$eq;
1387
+ if (typeof containedInPlaceBranchCodeEq === 'string') {
1388
+ matchStages.push({
1389
+ $match: {
1390
+ 'containsPlace.branchCode': {
1391
+ $exists: true,
1392
+ $eq: containedInPlaceBranchCodeEq
1393
+ }
1112
1394
  }
1113
- }
1114
- });
1115
- }
1116
- const containedInPlaceBranchCodeIn = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
1117
- if (Array.isArray(containedInPlaceBranchCodeIn)) {
1118
- matchStages.push({
1119
- $match: {
1120
- 'containsPlace.containsPlace.branchCode': {
1121
- $exists: true,
1122
- $in: containedInPlaceBranchCodeIn
1395
+ });
1396
+ }
1397
+ const containedInPlaceBranchCodeIn = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
1398
+ if (Array.isArray(containedInPlaceBranchCodeIn)) {
1399
+ matchStages.push({
1400
+ $match: {
1401
+ 'containsPlace.branchCode': {
1402
+ $exists: true,
1403
+ $in: containedInPlaceBranchCodeIn
1404
+ }
1405
+ }
1406
+ });
1407
+ }
1408
+ if (params.containedInPlace !== undefined) {
1409
+ if (params.containedInPlace.containedInPlace !== undefined) {
1410
+ if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
1411
+ if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
1412
+ matchStages.push({
1413
+ $match: {
1414
+ branchCode: {
1415
+ $eq: params.containedInPlace.containedInPlace.branchCode.$eq
1416
+ }
1417
+ }
1418
+ });
1419
+ }
1420
+ }
1421
+ if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
1422
+ if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
1423
+ if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
1424
+ matchStages.push({
1425
+ $match: {
1426
+ 'containedInPlace.branchCode': {
1427
+ $exists: true,
1428
+ $eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
1429
+ }
1430
+ }
1431
+ });
1432
+ }
1433
+ }
1123
1434
  }
1124
1435
  }
1125
- });
1126
- }
1127
- if (params.containedInPlace !== undefined) {
1128
- if (params.containedInPlace.containedInPlace !== undefined) {
1129
- if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
1130
- if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
1131
- matchStages.push({
1132
- $match: {
1133
- 'containsPlace.branchCode': {
1436
+ }
1437
+ // 座席コード
1438
+ if (params.branchCode !== undefined) {
1439
+ if (typeof params.branchCode.$eq === 'string') {
1440
+ matchStages.push({
1441
+ $match: {
1442
+ 'containsPlace.containsPlace.branchCode': {
1443
+ $exists: true,
1444
+ $eq: params.branchCode.$eq
1445
+ }
1446
+ }
1447
+ });
1448
+ }
1449
+ }
1450
+ const branchCodeIn = (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$in;
1451
+ if (Array.isArray(branchCodeIn)) {
1452
+ matchStages.push({
1453
+ $match: {
1454
+ 'containsPlace.containsPlace.branchCode': {
1455
+ $exists: true,
1456
+ $in: branchCodeIn
1457
+ }
1458
+ }
1459
+ });
1460
+ }
1461
+ const branchCodeRegex = (_h = params.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
1462
+ if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
1463
+ matchStages.push({
1464
+ $match: {
1465
+ 'containsPlace.containsPlace.branchCode': {
1466
+ $exists: true,
1467
+ $regex: new RegExp(branchCodeRegex)
1468
+ }
1469
+ }
1470
+ });
1471
+ }
1472
+ const nameRegex = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$regex;
1473
+ if (typeof nameRegex === 'string' && nameRegex.length > 0) {
1474
+ matchStages.push({
1475
+ $match: {
1476
+ $or: [
1477
+ {
1478
+ 'containsPlace.containsPlace.name.ja': {
1134
1479
  $exists: true,
1135
- $eq: params.containedInPlace.containedInPlace.branchCode.$eq
1480
+ $regex: new RegExp(nameRegex)
1481
+ }
1482
+ },
1483
+ {
1484
+ 'containsPlace.containsPlace.name.en': {
1485
+ $exists: true,
1486
+ $regex: new RegExp(nameRegex)
1136
1487
  }
1137
1488
  }
1138
- });
1489
+ ]
1490
+ }
1491
+ });
1492
+ }
1493
+ const seatingTypeEq = (_k = params.seatingType) === null || _k === void 0 ? void 0 : _k.$eq;
1494
+ if (typeof seatingTypeEq === 'string') {
1495
+ matchStages.push({
1496
+ $match: {
1497
+ 'containsPlace.containsPlace.seatingType': {
1498
+ $exists: true,
1499
+ $eq: seatingTypeEq
1500
+ }
1501
+ }
1502
+ });
1503
+ }
1504
+ let includeScreeningRooms = true;
1505
+ if (params.$projection !== undefined && params.$projection !== null
1506
+ && params.$projection['containedInPlace.containedInPlace'] === 0) {
1507
+ includeScreeningRooms = false;
1508
+ }
1509
+ const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
1510
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
1511
+ matchStages.push({
1512
+ $match: {
1513
+ 'containsPlace.containsPlace.additionalProperty': {
1514
+ $exists: true,
1515
+ $elemMatch: additionalPropertyElemMatch
1516
+ }
1517
+ }
1518
+ });
1519
+ }
1520
+ const aggregate = this.placeModel.aggregate([
1521
+ { $unwind: '$containsPlace' },
1522
+ { $unwind: '$containsPlace.containsPlace' },
1523
+ // { $unwind: '$containsPlace.containsPlace.containsPlace' },
1524
+ ...matchStages,
1525
+ {
1526
+ $project: {
1527
+ _id: 0,
1528
+ typeOf: '$containsPlace.containsPlace.typeOf',
1529
+ branchCode: '$containsPlace.containsPlace.branchCode',
1530
+ name: '$containsPlace.containsPlace.name',
1531
+ seatingType: '$containsPlace.containsPlace.seatingType',
1532
+ containedInPlace: Object.assign({ typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name' }, (includeScreeningRooms)
1533
+ ? {
1534
+ containedInPlace: {
1535
+ typeOf: '$typeOf',
1536
+ branchCode: '$branchCode',
1537
+ name: '$name',
1538
+ containedInPlace: {
1539
+ id: '$containedInPlace.id',
1540
+ typeOf: '$containedInPlace.typeOf',
1541
+ branchCode: '$containedInPlace.branchCode',
1542
+ name: '$containedInPlace.name'
1543
+ }
1544
+ }
1545
+ }
1546
+ : undefined),
1547
+ additionalProperty: '$containsPlace.containsPlace.additionalProperty'
1139
1548
  }
1140
1549
  }
1141
- if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
1142
- if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
1143
- if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
1550
+ ]);
1551
+ if (typeof params.limit === 'number' && params.limit > 0) {
1552
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1553
+ aggregate.limit(params.limit * page)
1554
+ .skip(params.limit * (page - 1));
1555
+ }
1556
+ return aggregate.exec();
1557
+ }
1558
+ else {
1559
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
1560
+ const projectIdEq = (_o = (_m = params.project) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
1561
+ if (typeof projectIdEq === 'string') {
1562
+ matchStages.push({
1563
+ $match: { 'project.id': { $eq: projectIdEq } }
1564
+ });
1565
+ }
1566
+ const containedInPlaceBranchCodeEq = (_q = (_p = params.containedInPlace) === null || _p === void 0 ? void 0 : _p.branchCode) === null || _q === void 0 ? void 0 : _q.$eq;
1567
+ if (typeof containedInPlaceBranchCodeEq === 'string') {
1568
+ matchStages.push({
1569
+ $match: {
1570
+ 'containsPlace.containsPlace.branchCode': {
1571
+ $exists: true,
1572
+ $eq: containedInPlaceBranchCodeEq
1573
+ }
1574
+ }
1575
+ });
1576
+ }
1577
+ const containedInPlaceBranchCodeIn = (_s = (_r = params.containedInPlace) === null || _r === void 0 ? void 0 : _r.branchCode) === null || _s === void 0 ? void 0 : _s.$in;
1578
+ if (Array.isArray(containedInPlaceBranchCodeIn)) {
1579
+ matchStages.push({
1580
+ $match: {
1581
+ 'containsPlace.containsPlace.branchCode': {
1582
+ $exists: true,
1583
+ $in: containedInPlaceBranchCodeIn
1584
+ }
1585
+ }
1586
+ });
1587
+ }
1588
+ if (params.containedInPlace !== undefined) {
1589
+ if (params.containedInPlace.containedInPlace !== undefined) {
1590
+ if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
1591
+ if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
1144
1592
  matchStages.push({
1145
1593
  $match: {
1146
- branchCode: {
1594
+ 'containsPlace.branchCode': {
1147
1595
  $exists: true,
1148
- $eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
1596
+ $eq: params.containedInPlace.containedInPlace.branchCode.$eq
1149
1597
  }
1150
1598
  }
1151
1599
  });
1152
1600
  }
1153
1601
  }
1602
+ if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
1603
+ if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
1604
+ if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
1605
+ matchStages.push({
1606
+ $match: {
1607
+ branchCode: {
1608
+ $exists: true,
1609
+ $eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
1610
+ }
1611
+ }
1612
+ });
1613
+ }
1614
+ }
1615
+ }
1154
1616
  }
1155
1617
  }
1156
- }
1157
- // 座席コード
1158
- if (params.branchCode !== undefined) {
1159
- if (typeof params.branchCode.$eq === 'string') {
1618
+ // 座席コード
1619
+ if (params.branchCode !== undefined) {
1620
+ if (typeof params.branchCode.$eq === 'string') {
1621
+ matchStages.push({
1622
+ $match: {
1623
+ 'containsPlace.containsPlace.containsPlace.branchCode': {
1624
+ $exists: true,
1625
+ $eq: params.branchCode.$eq
1626
+ }
1627
+ }
1628
+ });
1629
+ }
1630
+ }
1631
+ const branchCodeIn = (_t = params.branchCode) === null || _t === void 0 ? void 0 : _t.$in;
1632
+ if (Array.isArray(branchCodeIn)) {
1160
1633
  matchStages.push({
1161
1634
  $match: {
1162
1635
  'containsPlace.containsPlace.containsPlace.branchCode': {
1163
1636
  $exists: true,
1164
- $eq: params.branchCode.$eq
1637
+ $in: branchCodeIn
1165
1638
  }
1166
1639
  }
1167
1640
  });
1168
1641
  }
1169
- }
1170
- const branchCodeIn = (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$in;
1171
- if (Array.isArray(branchCodeIn)) {
1172
- matchStages.push({
1173
- $match: {
1174
- 'containsPlace.containsPlace.containsPlace.branchCode': {
1175
- $exists: true,
1176
- $in: branchCodeIn
1177
- }
1178
- }
1179
- });
1180
- }
1181
- const branchCodeRegex = (_h = params.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
1182
- if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
1183
- matchStages.push({
1184
- $match: {
1185
- 'containsPlace.containsPlace.containsPlace.branchCode': {
1186
- $exists: true,
1187
- $regex: new RegExp(branchCodeRegex)
1642
+ const branchCodeRegex = (_u = params.branchCode) === null || _u === void 0 ? void 0 : _u.$regex;
1643
+ if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
1644
+ matchStages.push({
1645
+ $match: {
1646
+ 'containsPlace.containsPlace.containsPlace.branchCode': {
1647
+ $exists: true,
1648
+ $regex: new RegExp(branchCodeRegex)
1649
+ }
1188
1650
  }
1189
- }
1190
- });
1191
- }
1192
- const nameRegex = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$regex;
1193
- if (typeof nameRegex === 'string' && nameRegex.length > 0) {
1194
- matchStages.push({
1195
- $match: {
1196
- $or: [
1197
- {
1198
- 'containsPlace.containsPlace.containsPlace.name.ja': {
1199
- $exists: true,
1200
- $regex: new RegExp(nameRegex)
1201
- }
1202
- },
1203
- {
1204
- 'containsPlace.containsPlace.containsPlace.name.en': {
1205
- $exists: true,
1206
- $regex: new RegExp(nameRegex)
1651
+ });
1652
+ }
1653
+ const nameRegex = (_v = params.name) === null || _v === void 0 ? void 0 : _v.$regex;
1654
+ if (typeof nameRegex === 'string' && nameRegex.length > 0) {
1655
+ matchStages.push({
1656
+ $match: {
1657
+ $or: [
1658
+ {
1659
+ 'containsPlace.containsPlace.containsPlace.name.ja': {
1660
+ $exists: true,
1661
+ $regex: new RegExp(nameRegex)
1662
+ }
1663
+ },
1664
+ {
1665
+ 'containsPlace.containsPlace.containsPlace.name.en': {
1666
+ $exists: true,
1667
+ $regex: new RegExp(nameRegex)
1668
+ }
1207
1669
  }
1670
+ ]
1671
+ }
1672
+ });
1673
+ }
1674
+ const seatingTypeEq = (_w = params.seatingType) === null || _w === void 0 ? void 0 : _w.$eq;
1675
+ if (typeof seatingTypeEq === 'string') {
1676
+ matchStages.push({
1677
+ $match: {
1678
+ 'containsPlace.containsPlace.containsPlace.seatingType': {
1679
+ $exists: true,
1680
+ $eq: seatingTypeEq
1208
1681
  }
1209
- ]
1210
- }
1211
- });
1212
- }
1213
- const seatingTypeEq = (_k = params.seatingType) === null || _k === void 0 ? void 0 : _k.$eq;
1214
- if (typeof seatingTypeEq === 'string') {
1215
- matchStages.push({
1216
- $match: {
1217
- 'containsPlace.containsPlace.containsPlace.seatingType': {
1218
- $exists: true,
1219
- $eq: seatingTypeEq
1220
1682
  }
1221
- }
1222
- });
1223
- }
1224
- let includeScreeningRooms = true;
1225
- if (params.$projection !== undefined && params.$projection !== null
1226
- && params.$projection['containedInPlace.containedInPlace'] === 0) {
1227
- includeScreeningRooms = false;
1228
- }
1229
- const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
1230
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
1231
- matchStages.push({
1232
- $match: {
1233
- 'containsPlace.containsPlace.containsPlace.additionalProperty': {
1234
- $exists: true,
1235
- $elemMatch: additionalPropertyElemMatch
1683
+ });
1684
+ }
1685
+ let includeScreeningRooms = true;
1686
+ if (params.$projection !== undefined && params.$projection !== null
1687
+ && params.$projection['containedInPlace.containedInPlace'] === 0) {
1688
+ includeScreeningRooms = false;
1689
+ }
1690
+ const additionalPropertyElemMatch = (_x = params.additionalProperty) === null || _x === void 0 ? void 0 : _x.$elemMatch;
1691
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
1692
+ matchStages.push({
1693
+ $match: {
1694
+ 'containsPlace.containsPlace.containsPlace.additionalProperty': {
1695
+ $exists: true,
1696
+ $elemMatch: additionalPropertyElemMatch
1697
+ }
1236
1698
  }
1237
- }
1238
- });
1239
- }
1240
- const aggregate = this.placeModel.aggregate([
1241
- { $unwind: '$containsPlace' },
1242
- { $unwind: '$containsPlace.containsPlace' },
1243
- { $unwind: '$containsPlace.containsPlace.containsPlace' },
1244
- ...matchStages,
1245
- {
1246
- $project: {
1247
- _id: 0,
1248
- typeOf: '$containsPlace.containsPlace.containsPlace.typeOf',
1249
- branchCode: '$containsPlace.containsPlace.containsPlace.branchCode',
1250
- name: '$containsPlace.containsPlace.containsPlace.name',
1251
- seatingType: '$containsPlace.containsPlace.containsPlace.seatingType',
1252
- containedInPlace: Object.assign({ typeOf: '$containsPlace.containsPlace.typeOf', branchCode: '$containsPlace.containsPlace.branchCode', name: '$containsPlace.containsPlace.name' }, (includeScreeningRooms)
1253
- ? {
1254
- containedInPlace: {
1255
- typeOf: '$containsPlace.typeOf',
1256
- branchCode: '$containsPlace.branchCode',
1257
- name: '$containsPlace.name',
1699
+ });
1700
+ }
1701
+ const aggregate = this.placeModel.aggregate([
1702
+ { $unwind: '$containsPlace' },
1703
+ { $unwind: '$containsPlace.containsPlace' },
1704
+ { $unwind: '$containsPlace.containsPlace.containsPlace' },
1705
+ ...matchStages,
1706
+ {
1707
+ $project: {
1708
+ _id: 0,
1709
+ typeOf: '$containsPlace.containsPlace.containsPlace.typeOf',
1710
+ branchCode: '$containsPlace.containsPlace.containsPlace.branchCode',
1711
+ name: '$containsPlace.containsPlace.containsPlace.name',
1712
+ seatingType: '$containsPlace.containsPlace.containsPlace.seatingType',
1713
+ containedInPlace: Object.assign({ typeOf: '$containsPlace.containsPlace.typeOf', branchCode: '$containsPlace.containsPlace.branchCode', name: '$containsPlace.containsPlace.name' }, (includeScreeningRooms)
1714
+ ? {
1258
1715
  containedInPlace: {
1259
- id: '$_id',
1260
- typeOf: '$typeOf',
1261
- branchCode: '$branchCode',
1262
- name: '$name'
1716
+ typeOf: '$containsPlace.typeOf',
1717
+ branchCode: '$containsPlace.branchCode',
1718
+ name: '$containsPlace.name',
1719
+ containedInPlace: {
1720
+ id: '$_id',
1721
+ typeOf: '$typeOf',
1722
+ branchCode: '$branchCode',
1723
+ name: '$name'
1724
+ }
1263
1725
  }
1264
1726
  }
1265
- }
1266
- : undefined),
1267
- additionalProperty: '$containsPlace.containsPlace.containsPlace.additionalProperty'
1727
+ : undefined),
1728
+ additionalProperty: '$containsPlace.containsPlace.containsPlace.additionalProperty'
1729
+ }
1268
1730
  }
1731
+ ]);
1732
+ if (typeof params.limit === 'number' && params.limit > 0) {
1733
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1734
+ aggregate.limit(params.limit * page)
1735
+ .skip(params.limit * (page - 1));
1269
1736
  }
1270
- ]);
1271
- if (typeof params.limit === 'number' && params.limit > 0) {
1272
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1273
- aggregate.limit(params.limit * page)
1274
- .skip(params.limit * (page - 1));
1737
+ return aggregate.exec();
1275
1738
  }
1276
- return aggregate.exec();
1277
1739
  });
1278
1740
  }
1279
1741
  deleteSeat(seat) {
@@ -1340,25 +1802,27 @@ class MongoRepository {
1340
1802
  debug('sync processing', creatingScreeningRooms.length, 'screeningRooms...', creatingScreeningRooms);
1341
1803
  yield Promise.all(creatingScreeningRooms.map((createScreeningRoom) => __awaiter(this, void 0, void 0, function* () {
1342
1804
  const { typeOf, project, branchCode } = createScreeningRoom, setFields = __rest(createScreeningRoom, ["typeOf", "project", "branchCode"]);
1343
- const upsertScreeningRoomResult = yield this.placeModel.findOneAndUpdate({
1344
- typeOf: { $eq: factory.placeType.ScreeningRoom },
1345
- 'project.id': { $eq: createScreeningRoom.project.id },
1346
- 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
1347
- branchCode: { $eq: createScreeningRoom.branchCode }
1348
- }, {
1349
- $setOnInsert: {
1350
- typeOf: createScreeningRoom.typeOf,
1351
- project: createScreeningRoom.project,
1352
- branchCode: createScreeningRoom.branchCode
1353
- },
1354
- $set: setFields
1355
- }, {
1356
- upsert: true,
1357
- new: true,
1358
- projection: { _id: 1 }
1359
- })
1360
- .exec();
1361
- debug('screeningRoom upserted. upsertScreeningRoomResult:', upsertScreeningRoomResult);
1805
+ if (typeof branchCode === 'string' && branchCode.length > 0) {
1806
+ const upsertScreeningRoomResult = yield this.placeModel.findOneAndUpdate({
1807
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
1808
+ 'project.id': { $eq: createScreeningRoom.project.id },
1809
+ 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
1810
+ branchCode: { $eq: createScreeningRoom.branchCode }
1811
+ }, {
1812
+ $setOnInsert: {
1813
+ typeOf: createScreeningRoom.typeOf,
1814
+ project: createScreeningRoom.project,
1815
+ branchCode: createScreeningRoom.branchCode
1816
+ },
1817
+ $set: setFields
1818
+ }, {
1819
+ upsert: true,
1820
+ new: true,
1821
+ projection: { _id: 1 }
1822
+ })
1823
+ .exec();
1824
+ debug('screeningRoom upserted. upsertScreeningRoomResult:', upsertScreeningRoomResult);
1825
+ }
1362
1826
  })));
1363
1827
  });
1364
1828
  }