@chevre/domain 21.2.0-alpha.144 → 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.
@@ -8,7 +8,7 @@ async function main() {
8
8
 
9
9
  const placeRepo = new chevre.repository.Place(mongoose.connection);
10
10
 
11
- const event = await placeRepo.findScreeningRoomsByBranchCode({
11
+ const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
12
12
  branchCode: {
13
13
  $eq: '20'
14
14
  },
@@ -16,9 +16,10 @@ async function main() {
16
16
  id: {
17
17
  $eq: '5bfb841d5a78d7948369979a'
18
18
  }
19
- }
19
+ },
20
+ useScreeningRoomType: true
20
21
  });
21
- console.log('room found', event);
22
+ console.log('room found', screeningRoom);
22
23
 
23
24
  }
24
25
 
@@ -24,7 +24,8 @@ async function main() {
24
24
 
25
25
  const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
26
26
  branchCode: { $eq: rooms[0].branchCode },
27
- containedInPlace: { id: { $eq: String(rooms[0].containedInPlace?.id) } }
27
+ containedInPlace: { id: { $eq: String(rooms[0].containedInPlace?.id) } },
28
+ useScreeningRoomType: true
28
29
  });
29
30
  console.log('screeningRoom found', screeningRoom);
30
31
  }
@@ -30,7 +30,7 @@ async function main() {
30
30
  doc.toObject();
31
31
 
32
32
  console.log('syncing...', project.id, typeOf, id, name.ja, i);
33
- // await placeRepo.syncScreeningRooms({ id });
33
+ await placeRepo.syncScreeningRooms({ id });
34
34
  console.log('synced.', project.id, typeOf, id, name.ja, i);
35
35
  });
36
36
 
@@ -50,7 +50,7 @@ export declare class MongoRepository {
50
50
  deleteMovieTheaterById(params: {
51
51
  id: string;
52
52
  }): Promise<void>;
53
- createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>): Promise<{
53
+ createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>, useScreeningRoomType?: boolean): Promise<{
54
54
  /**
55
55
  * 施設ID
56
56
  */
@@ -61,7 +61,7 @@ export declare class MongoRepository {
61
61
  containedInPlace: {
62
62
  branchCode: string;
63
63
  };
64
- }, $unset: any): Promise<{
64
+ }, $unset: any, useScreeningRoomType?: boolean): Promise<{
65
65
  /**
66
66
  * 施設ID
67
67
  */
@@ -82,7 +82,7 @@ export declare class MongoRepository {
82
82
  */
83
83
  branchCode: string;
84
84
  };
85
- }): Promise<{
85
+ }, useScreeningRoomType?: boolean): Promise<{
86
86
  /**
87
87
  * 施設ID
88
88
  */
@@ -100,7 +100,7 @@ export declare class MongoRepository {
100
100
  id: string;
101
101
  };
102
102
  }): Promise<void>;
103
- createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace): Promise<{
103
+ createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace, useScreeningRoomType?: boolean): Promise<{
104
104
  /**
105
105
  * 施設ID
106
106
  */
@@ -114,7 +114,7 @@ export declare class MongoRepository {
114
114
  branchCode: string;
115
115
  };
116
116
  };
117
- }, $unset: any): Promise<{
117
+ }, $unset: any, useScreeningRoomType?: boolean): Promise<{
118
118
  /**
119
119
  * 施設ID
120
120
  */
@@ -125,7 +125,7 @@ export declare class MongoRepository {
125
125
  $projection?: {
126
126
  [key: string]: number;
127
127
  };
128
- }, useScreeningRoomType?: boolean): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
128
+ }, useScreeningRoomType: boolean): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
129
129
  deleteScreeningRoomSection(screeningRoomSection: {
130
130
  project: {
131
131
  id: string;
@@ -146,14 +146,14 @@ export declare class MongoRepository {
146
146
  branchCode: string;
147
147
  };
148
148
  };
149
- }): Promise<{
149
+ }, useScreeningRoomType?: boolean): Promise<{
150
150
  /**
151
151
  * 施設ID
152
152
  */
153
153
  id: string;
154
154
  typeOf: factory.placeType.MovieTheater;
155
155
  }>;
156
- searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions, useScreeningRoomType?: boolean): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>[]>;
156
+ searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions, useScreeningRoomType: boolean): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>[]>;
157
157
  findScreeningRoomsByBranchCode(params: {
158
158
  branchCode: {
159
159
  $eq: string;
@@ -163,8 +163,9 @@ export declare class MongoRepository {
163
163
  $eq: string;
164
164
  };
165
165
  };
166
+ useScreeningRoomType: boolean;
166
167
  }): Promise<IScreeningRoomFoundByBranchCode>;
167
- createSeat(seat: factory.place.seat.IPlace): Promise<{
168
+ createSeat(seat: factory.place.seat.IPlace, useScreeningRoomType?: boolean): Promise<{
168
169
  /**
169
170
  * 施設ID
170
171
  */
@@ -181,14 +182,14 @@ export declare class MongoRepository {
181
182
  };
182
183
  };
183
184
  };
184
- }, $unset: any): Promise<{
185
+ }, $unset: any, useScreeningRoomType?: boolean): Promise<{
185
186
  /**
186
187
  * 施設ID
187
188
  */
188
189
  id: string;
189
190
  typeOf: factory.placeType.MovieTheater;
190
191
  }>;
191
- searchSeats(params: factory.place.seat.ISearchConditions, useScreeningRoomType?: boolean): Promise<factory.place.seat.IPlace[]>;
192
+ searchSeats(params: factory.place.seat.ISearchConditions, useScreeningRoomType: boolean): Promise<factory.place.seat.IPlace[]>;
192
193
  deleteSeat(seat: {
193
194
  project: {
194
195
  id: string;
@@ -215,7 +216,7 @@ export declare class MongoRepository {
215
216
  };
216
217
  };
217
218
  };
218
- }): Promise<{
219
+ }, useScreeningRoomType?: boolean): Promise<{
219
220
  /**
220
221
  * 施設ID
221
222
  */
@@ -414,109 +414,130 @@ 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
- let doc = yield this.placeModel.findOne({
421
- typeOf: { $eq: factory.placeType.MovieTheater },
422
- 'project.id': { $eq: screeningRoom.project.id },
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
- doc = yield this.placeModel.findOneAndUpdate({
433
- typeOf: { $eq: factory.placeType.MovieTheater },
434
- 'project.id': { $eq: screeningRoom.project.id },
435
- branchCode: screeningRoom.containedInPlace.branchCode,
436
- 'containsPlace.branchCode': { $ne: screeningRoom.branchCode }
437
- }, {
438
- $push: {
439
- containsPlace: {
440
- typeOf: screeningRoom.typeOf,
441
- branchCode: screeningRoom.branchCode,
442
- name: screeningRoom.name,
443
- address: screeningRoom.address,
444
- additionalProperty: screeningRoom.additionalProperty
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
- const doc = yield this.placeModel.findOneAndUpdate({
467
- typeOf: { $eq: factory.placeType.MovieTheater },
468
- 'project.id': { $eq: screeningRoom.project.id },
469
- branchCode: screeningRoom.containedInPlace.branchCode,
470
- 'containsPlace.branchCode': screeningRoom.branchCode
471
- }, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].name': screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
472
- ? { 'containsPlace.$[screeningRoom].address': screeningRoom.address }
473
- : undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
474
- ? { 'containsPlace.$[screeningRoom].openSeatingAllowed': screeningRoom.openSeatingAllowed }
475
- : undefined), (Array.isArray(screeningRoom.additionalProperty))
476
- ? { 'containsPlace.$[screeningRoom].additionalProperty': screeningRoom.additionalProperty }
477
- : undefined), ($unset !== undefined && $unset !== null)
478
- ? { $unset }
479
- : undefined), {
480
- new: true,
481
- arrayFilters: [
482
- { 'screeningRoom.branchCode': screeningRoom.branchCode }
483
- ],
484
- projection: {
485
- _id: 1,
486
- // 'project.id': 1,
487
- branchCode: 1,
488
- typeOf: 1
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
- const doc = yield this.placeModel.findOneAndUpdate({
501
- typeOf: { $eq: factory.placeType.MovieTheater },
502
- 'project.id': { $eq: screeningRoom.project.id },
503
- branchCode: screeningRoom.containedInPlace.branchCode,
504
- 'containsPlace.branchCode': screeningRoom.branchCode
505
- }, {
506
- $pull: {
507
- containsPlace: { branchCode: screeningRoom.branchCode }
508
- }
509
- }, {
510
- projection: {
511
- _id: 1,
512
- typeOf: 1
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) {
@@ -529,106 +550,120 @@ class MongoRepository {
529
550
  .exec();
530
551
  });
531
552
  }
532
- createScreeningRoomSection(screeningRoomSection) {
553
+ createScreeningRoomSection(screeningRoomSection, useScreeningRoomType) {
533
554
  return __awaiter(this, void 0, void 0, function* () {
534
- const screeningRoom = screeningRoomSection.containedInPlace;
535
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
536
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
537
- }
538
- const movieTheater = screeningRoom.containedInPlace;
539
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
540
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
541
- }
542
- // 施設存在確認
543
- let doc = yield this.placeModel.findOne({
544
- typeOf: { $eq: factory.placeType.MovieTheater },
545
- 'project.id': { $eq: screeningRoomSection.project.id },
546
- branchCode: movieTheater.branchCode,
547
- 'containsPlace.branchCode': screeningRoom.branchCode
548
- }, { _id: 1 })
549
- .exec();
550
- if (doc === null) {
551
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
555
+ if (useScreeningRoomType === true) {
556
+ // tslint:disable-next-line:no-suspicious-comment
557
+ // TODO implement
558
+ throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
552
559
  }
553
- doc = yield this.placeModel.findOneAndUpdate({
554
- typeOf: { $eq: factory.placeType.MovieTheater },
555
- 'project.id': { $eq: screeningRoomSection.project.id },
556
- branchCode: movieTheater.branchCode,
557
- 'containsPlace.branchCode': screeningRoom.branchCode
558
- // 'containsPlace.containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
559
- }, {
560
- $push: {
561
- 'containsPlace.$[screeningRoom].containsPlace': Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
562
- ? { additionalProperty: screeningRoomSection.additionalProperty }
563
- : undefined)
564
- }
565
- }, {
566
- new: true,
567
- arrayFilters: [
568
- {
569
- 'screeningRoom.branchCode': screeningRoom.branchCode,
570
- 'screeningRoom.containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
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)
571
591
  }
572
- ],
573
- projection: {
574
- _id: 1,
575
- typeOf: 1
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
603
+ }
604
+ })
605
+ .exec();
606
+ // 存在しなければコード重複
607
+ if (doc === null) {
608
+ throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
576
609
  }
577
- })
578
- .exec();
579
- // 存在しなければコード重複
580
- if (doc === null) {
581
- throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
610
+ return doc.toObject();
582
611
  }
583
- return doc.toObject();
584
612
  });
585
613
  }
586
- updateScreeningRoomSection(screeningRoomSection, $unset) {
614
+ updateScreeningRoomSection(screeningRoomSection, $unset, useScreeningRoomType) {
587
615
  return __awaiter(this, void 0, void 0, function* () {
588
- const screeningRoom = screeningRoomSection.containedInPlace;
589
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
590
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
591
- }
592
- const movieTheater = screeningRoom.containedInPlace;
593
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
594
- 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');
595
620
  }
596
- const doc = yield this.placeModel.findOneAndUpdate({
597
- typeOf: { $eq: factory.placeType.MovieTheater },
598
- 'project.id': { $eq: screeningRoomSection.project.id },
599
- branchCode: movieTheater.branchCode,
600
- 'containsPlace.branchCode': screeningRoom.branchCode,
601
- 'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
602
- }, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
603
- ? {
604
- 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
605
- }
606
- : undefined), (Array.isArray(screeningRoomSection.additionalProperty))
607
- ? {
608
- 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
609
- }
610
- : undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
611
- ? {
612
- 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
613
- 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);
614
- })
615
- }
616
- : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
617
- new: true,
618
- arrayFilters: [
619
- { 'screeningRoom.branchCode': screeningRoom.branchCode },
620
- { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
621
- ],
622
- projection: {
623
- _id: 1,
624
- typeOf: 1
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);
625
664
  }
626
- })
627
- .exec();
628
- if (doc === null) {
629
- throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
665
+ return doc.toObject();
630
666
  }
631
- return doc.toObject();
632
667
  });
633
668
  }
634
669
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
@@ -884,35 +919,42 @@ class MongoRepository {
884
919
  }
885
920
  });
886
921
  }
887
- deleteScreeningRoomSection(screeningRoomSection) {
922
+ deleteScreeningRoomSection(screeningRoomSection, useScreeningRoomType) {
888
923
  return __awaiter(this, void 0, void 0, function* () {
889
- const doc = yield this.placeModel.findOneAndUpdate({
890
- typeOf: { $eq: factory.placeType.MovieTheater },
891
- 'project.id': { $eq: screeningRoomSection.project.id },
892
- branchCode: screeningRoomSection.containedInPlace.containedInPlace.branchCode,
893
- 'containsPlace.branchCode': screeningRoomSection.containedInPlace.branchCode,
894
- 'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
895
- }, {
896
- $pull: {
897
- 'containsPlace.$[screeningRoom].containsPlace': {
898
- branchCode: screeningRoomSection.branchCode
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
+ }
899
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);
900
955
  }
901
- }, {
902
- new: true,
903
- arrayFilters: [
904
- { 'screeningRoom.branchCode': screeningRoomSection.containedInPlace.branchCode }
905
- ],
906
- projection: {
907
- _id: 1,
908
- typeOf: 1
909
- }
910
- })
911
- .exec();
912
- if (doc === null) {
913
- throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
956
+ return doc.toObject();
914
957
  }
915
- return doc.toObject();
916
958
  });
917
959
  }
918
960
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
@@ -1227,166 +1269,228 @@ class MongoRepository {
1227
1269
  }
1228
1270
  findScreeningRoomsByBranchCode(params) {
1229
1271
  return __awaiter(this, void 0, void 0, function* () {
1230
- const matchStages = [
1231
- { $match: { typeOf: { $eq: factory.placeType.MovieTheater } } },
1232
- {
1233
- $match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.containedInPlace.id.$eq) } }
1234
- },
1235
- {
1236
- $match: { 'containsPlace.branchCode': { $exists: true, $eq: params.branchCode.$eq } }
1237
- }
1238
- ];
1239
- const aggregate = this.placeModel.aggregate([
1240
- { $unwind: '$containsPlace' },
1241
- ...matchStages,
1242
- {
1243
- $project: {
1244
- _id: 0,
1245
- typeOf: '$containsPlace.typeOf',
1246
- branchCode: '$containsPlace.branchCode',
1247
- name: '$containsPlace.name',
1248
- containsPlace: '$containsPlace.containsPlace',
1249
- seatCount: {
1250
- $sum: {
1251
- $map: {
1252
- input: '$containsPlace.containsPlace',
1253
- in: {
1254
- $cond: {
1255
- if: { $isArray: '$$this.containsPlace' },
1256
- then: { $size: '$$this.containsPlace' },
1257
- else: 0
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
+ }
1258
1304
  }
1259
1305
  }
1260
1306
  }
1261
1307
  }
1262
1308
  }
1263
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);
1264
1315
  }
1265
- ]);
1266
- const docs = yield aggregate.limit(1)
1267
- .exec();
1268
- if (docs.length < 1) {
1269
- throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
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];
1270
1361
  }
1271
- return docs[0];
1272
1362
  });
1273
1363
  }
1274
- createSeat(seat) {
1364
+ createSeat(seat, useScreeningRoomType) {
1275
1365
  var _a, _b;
1276
1366
  return __awaiter(this, void 0, void 0, function* () {
1277
- const screeningRoomSection = seat.containedInPlace;
1278
- if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
1279
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
1280
- }
1281
- const screeningRoom = screeningRoomSection.containedInPlace;
1282
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
1283
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
1284
- }
1285
- const movieTheater = screeningRoom.containedInPlace;
1286
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
1287
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
1288
- }
1289
- // 施設存在確認
1290
- let doc = yield this.placeModel.findOne({
1291
- typeOf: { $eq: factory.placeType.MovieTheater },
1292
- 'project.id': { $eq: seat.project.id },
1293
- branchCode: movieTheater.branchCode,
1294
- 'containsPlace.branchCode': screeningRoom.branchCode,
1295
- 'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
1296
- }, {
1297
- _id: 1
1298
- })
1299
- .exec();
1300
- if (doc === null) {
1301
- 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');
1302
1371
  }
1303
- doc = yield this.placeModel.findOneAndUpdate({
1304
- typeOf: { $eq: factory.placeType.MovieTheater },
1305
- 'project.id': { $eq: seat.project.id },
1306
- branchCode: movieTheater.branchCode,
1307
- 'containsPlace.branchCode': screeningRoom.branchCode,
1308
- 'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
1309
- }, {
1310
- $push: {
1311
- '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)
1312
- }
1313
- }, {
1314
- new: true,
1315
- arrayFilters: [
1316
- { 'screeningRoom.branchCode': screeningRoom.branchCode },
1317
- {
1318
- 'screeningRoomSection.branchCode': screeningRoomSection.branchCode,
1319
- 'screeningRoomSection.containsPlace.branchCode': { $ne: seat.branchCode }
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)
1408
+ }
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
1320
1423
  }
1321
- ],
1322
- projection: {
1323
- _id: 1,
1324
- // 'project.id': 1,
1325
- branchCode: 1,
1326
- typeOf: 1
1424
+ })
1425
+ .exec();
1426
+ // 存在しなければコード重複
1427
+ if (doc === null) {
1428
+ throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
1327
1429
  }
1328
- })
1329
- .exec();
1330
- // 存在しなければコード重複
1331
- if (doc === null) {
1332
- throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
1430
+ return doc.toObject();
1333
1431
  }
1334
- return doc.toObject();
1335
1432
  });
1336
1433
  }
1337
- updateSeat(seat, $unset) {
1434
+ updateSeat(seat, $unset, useScreeningRoomType) {
1338
1435
  var _a, _b;
1339
1436
  return __awaiter(this, void 0, void 0, function* () {
1340
- const screeningRoomSection = seat.containedInPlace;
1341
- if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
1342
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
1343
- }
1344
- const screeningRoom = screeningRoomSection.containedInPlace;
1345
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
1346
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
1347
- }
1348
- const movieTheater = screeningRoom.containedInPlace;
1349
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
1350
- 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');
1351
1441
  }
1352
- const doc = yield this.placeModel.findOneAndUpdate({
1353
- typeOf: { $eq: factory.placeType.MovieTheater },
1354
- 'project.id': { $eq: seat.project.id },
1355
- branchCode: movieTheater.branchCode,
1356
- 'containsPlace.branchCode': screeningRoom.branchCode,
1357
- 'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode,
1358
- 'containsPlace.containsPlace.containsPlace.branchCode': seat.branchCode
1359
- }, 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')
1360
- ? {
1361
- 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
1362
- }
1363
- : undefined), (Array.isArray(seat.seatingType))
1364
- ? {
1365
- 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': seat.seatingType
1366
- }
1367
- : undefined), (Array.isArray(seat.additionalProperty))
1368
- ? {
1369
- 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].additionalProperty': seat.additionalProperty
1370
- }
1371
- : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
1372
- new: true,
1373
- arrayFilters: [
1374
- { 'screeningRoom.branchCode': screeningRoom.branchCode },
1375
- { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode },
1376
- { 'seat.branchCode': seat.branchCode }
1377
- ],
1378
- projection: {
1379
- _id: 1,
1380
- // 'project.id': 1,
1381
- branchCode: 1,
1382
- typeOf: 1
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);
1383
1491
  }
1384
- })
1385
- .exec();
1386
- if (doc === null) {
1387
- throw new factory.errors.NotFound(factory.placeType.Seat);
1492
+ return doc.toObject();
1388
1493
  }
1389
- return doc.toObject();
1390
1494
  });
1391
1495
  }
1392
1496
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
@@ -1757,37 +1861,44 @@ class MongoRepository {
1757
1861
  }
1758
1862
  });
1759
1863
  }
1760
- deleteSeat(seat) {
1864
+ deleteSeat(seat, useScreeningRoomType) {
1761
1865
  return __awaiter(this, void 0, void 0, function* () {
1762
- const doc = yield this.placeModel.findOneAndUpdate({
1763
- typeOf: { $eq: factory.placeType.MovieTheater },
1764
- 'project.id': { $eq: seat.project.id },
1765
- branchCode: seat.containedInPlace.containedInPlace.containedInPlace.branchCode,
1766
- 'containsPlace.branchCode': seat.containedInPlace.containedInPlace.branchCode,
1767
- 'containsPlace.containsPlace.branchCode': seat.containedInPlace.branchCode,
1768
- 'containsPlace.containsPlace.containsPlace.branchCode': seat.branchCode
1769
- }, {
1770
- $pull: {
1771
- 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace': {
1772
- branchCode: seat.branchCode
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
+ }
1773
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);
1774
1899
  }
1775
- }, {
1776
- new: true,
1777
- arrayFilters: [
1778
- { 'screeningRoom.branchCode': seat.containedInPlace.containedInPlace.branchCode },
1779
- { 'screeningRoomSection.branchCode': seat.containedInPlace.branchCode }
1780
- ],
1781
- projection: {
1782
- _id: 1,
1783
- typeOf: 1
1784
- }
1785
- })
1786
- .exec();
1787
- if (doc === null) {
1788
- throw new factory.errors.NotFound(factory.placeType.Seat);
1900
+ return doc.toObject();
1789
1901
  }
1790
- return doc.toObject();
1791
1902
  });
1792
1903
  }
1793
1904
  syncScreeningRooms(params) {
@@ -81,7 +81,8 @@ function aggregateByEvent(params) {
81
81
  }
82
82
  const screeningRoom = yield repos.place.findScreeningRoomsByBranchCode({
83
83
  branchCode: { $eq: event.location.branchCode },
84
- containedInPlace: { id: { $eq: movieTheaterId } }
84
+ containedInPlace: { id: { $eq: movieTheaterId } },
85
+ useScreeningRoomType: settings_1.USE_READ_SCREENING_ROOM_TYPE
85
86
  });
86
87
  // 予約集計
87
88
  const { maximumAttendeeCapacity, remainingAttendeeCapacity, aggregateReservation } = yield aggregateReservationByEvent({
@@ -236,7 +236,7 @@ function searchEventSeatOffers(params) {
236
236
  }
237
237
  },
238
238
  $projection: params.$projection
239
- });
239
+ }, settings_1.USE_READ_SCREENING_ROOM_TYPE);
240
240
  if (seats.length > 0) {
241
241
  const availabilities = yield repos.stockHolder.searchHolders({
242
242
  project: { id: params.event.project.id },
@@ -21,6 +21,7 @@ const difference = require("lodash.difference");
21
21
  const moment = require("moment-timezone");
22
22
  const credentials_1 = require("../credentials");
23
23
  const factory = require("../factory");
24
+ const settings_1 = require("../settings");
24
25
  const offer_1 = require("./offer");
25
26
  const debug = createDebug('chevre-domain:service:event');
26
27
  const coaAuthClient = new COA.auth.RefreshToken({
@@ -120,7 +121,7 @@ function importFromCOA(params) {
120
121
  }
121
122
  const screeningRooms = yield repos.place.searchScreeningRooms({
122
123
  containedInPlace: { branchCode: { $eq: movieTheater.branchCode } }
123
- });
124
+ }, settings_1.USE_READ_SCREENING_ROOM_TYPE);
124
125
  const targetImportFrom = moment(`${moment(params.importFrom)
125
126
  .tz('Asia/Tokyo')
126
127
  .format('YYYY-MM-DD')}T00:00:00+09:00`);
@@ -88,7 +88,7 @@ function searchEventSeatOffersWithPaging(params) {
88
88
  branchCode: { $eq: movieTheaterBranchCode }
89
89
  }
90
90
  }
91
- } }));
91
+ } }), settings_1.USE_READ_SCREENING_ROOM_TYPE);
92
92
  if (seats.length > 0) {
93
93
  const availabilities = yield repos.stockHolder.searchHolders({
94
94
  project: { id: event.project.id },
@@ -252,11 +252,6 @@ function createInformMovieTheaterTasks(params) {
252
252
  'telephone',
253
253
  'url',
254
254
  'typeOf'
255
- // 'containsPlace.branchCode',
256
- // 'containsPlace.name',
257
- // 'containsPlace.typeOf',
258
- // 'containsPlace.additionalProperty',
259
- // 'containsPlace.address'
260
255
  ], []);
261
256
  const movieTheater = movieTheaters.shift();
262
257
  if (movieTheater === undefined) {
@@ -265,7 +260,7 @@ function createInformMovieTheaterTasks(params) {
265
260
  // ルームを検索
266
261
  const screeningRooms = yield repos.place.searchScreeningRooms({
267
262
  containedInPlace: { id: { $eq: movieTheater.id } }
268
- });
263
+ }, settings_1.USE_READ_SCREENING_ROOM_TYPE);
269
264
  const movieTheaters4inform = [Object.assign(Object.assign({}, movieTheater), { containsPlace: screeningRooms.map((room) => {
270
265
  return {
271
266
  branchCode: room.branchCode,
@@ -41,6 +41,8 @@ export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
41
41
  export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
42
42
  export declare const USE_NEW_STOCK_HOLDER_REPO_FROM: moment.Moment;
43
43
  export declare const USE_NEW_STOCK_HOLDER_REPO_IDS: string[];
44
+ export declare const USE_READ_SCREENING_ROOM_TYPE: boolean;
45
+ export declare const USE_WRITE_SCREENING_ROOM_TYPE: boolean;
44
46
  export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
45
47
  export declare const MONGO_MAX_TIME_MS: number;
46
48
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_STOCK_HOLDER_REPO_FROM = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_WRITE_SCREENING_ROOM_TYPE = exports.USE_READ_SCREENING_ROOM_TYPE = exports.USE_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_STOCK_HOLDER_REPO_FROM = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -71,6 +71,8 @@ exports.USE_NEW_STOCK_HOLDER_REPO_FROM = (typeof process.env.USE_NEW_STOCK_HOLDE
71
71
  exports.USE_NEW_STOCK_HOLDER_REPO_IDS = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
72
72
  ? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
73
73
  : [];
74
+ exports.USE_READ_SCREENING_ROOM_TYPE = process.env.USE_READ_SCREENING_ROOM_TYPE === '1';
75
+ exports.USE_WRITE_SCREENING_ROOM_TYPE = process.env.USE_WRITE_SCREENING_ROOM_TYPE === '1';
74
76
  exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
75
77
  ? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
76
78
  : 0;
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.144"
120
+ "version": "21.2.0-alpha.145"
121
121
  }