@chevre/domain 21.2.0-alpha.147 → 21.2.0-alpha.149

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.
@@ -61,10 +61,12 @@ export declare class MongoRepository {
61
61
  id: string;
62
62
  typeOf: factory.placeType.MovieTheater;
63
63
  } | {
64
- /**
65
- * ルームID
66
- */
67
- id: string;
64
+ containedInPlace: {
65
+ /**
66
+ * 施設ID
67
+ */
68
+ id: string;
69
+ };
68
70
  typeOf: factory.placeType.ScreeningRoom;
69
71
  }>;
70
72
  updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace'> & {
@@ -78,10 +80,12 @@ export declare class MongoRepository {
78
80
  id: string;
79
81
  typeOf: factory.placeType.MovieTheater;
80
82
  } | {
81
- /**
82
- * ルームコード
83
- */
84
- branchCode: string;
83
+ containedInPlace: {
84
+ /**
85
+ * 施設ID
86
+ */
87
+ id: string;
88
+ };
85
89
  typeOf: factory.placeType.ScreeningRoom;
86
90
  }>;
87
91
  deleteScreeningRoom(screeningRoom: {
@@ -105,6 +109,12 @@ export declare class MongoRepository {
105
109
  id: string;
106
110
  typeOf: factory.placeType.MovieTheater;
107
111
  } | {
112
+ containedInPlace: {
113
+ /**
114
+ * 施設ID
115
+ */
116
+ id: string;
117
+ };
108
118
  typeOf: factory.placeType.ScreeningRoom;
109
119
  }>;
110
120
  deleteScreeningRoomsByMovieTheaterId(params: {
@@ -118,12 +128,20 @@ export declare class MongoRepository {
118
128
  id: string;
119
129
  };
120
130
  }): Promise<void>;
121
- createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace, useScreeningRoomType?: boolean): Promise<{
131
+ createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace, useScreeningRoomType: boolean): Promise<{
122
132
  /**
123
133
  * 施設ID
124
134
  */
125
135
  id: string;
126
136
  typeOf: factory.placeType.MovieTheater;
137
+ } | {
138
+ containedInPlace: {
139
+ /**
140
+ * 施設ID
141
+ */
142
+ id: string;
143
+ };
144
+ typeOf: factory.placeType.ScreeningRoom;
127
145
  }>;
128
146
  updateScreeningRoomSection(screeningRoomSection: Omit<factory.place.screeningRoomSection.IPlace, 'containedInPlace'> & {
129
147
  containedInPlace: {
@@ -132,12 +150,20 @@ export declare class MongoRepository {
132
150
  branchCode: string;
133
151
  };
134
152
  };
135
- }, $unset: any, useScreeningRoomType?: boolean): Promise<{
153
+ }, $unset: any, useScreeningRoomType: boolean): Promise<{
136
154
  /**
137
155
  * 施設ID
138
156
  */
139
157
  id: string;
140
158
  typeOf: factory.placeType.MovieTheater;
159
+ } | {
160
+ containedInPlace: {
161
+ /**
162
+ * 施設ID
163
+ */
164
+ id: string;
165
+ };
166
+ typeOf: factory.placeType.ScreeningRoom;
141
167
  }>;
142
168
  searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions & {
143
169
  $projection?: {
@@ -164,12 +190,20 @@ export declare class MongoRepository {
164
190
  branchCode: string;
165
191
  };
166
192
  };
167
- }, useScreeningRoomType?: boolean): Promise<{
193
+ }, useScreeningRoomType: boolean): Promise<{
168
194
  /**
169
195
  * 施設ID
170
196
  */
171
197
  id: string;
172
198
  typeOf: factory.placeType.MovieTheater;
199
+ } | {
200
+ containedInPlace: {
201
+ /**
202
+ * 施設ID
203
+ */
204
+ id: string;
205
+ };
206
+ typeOf: factory.placeType.ScreeningRoom;
173
207
  }>;
174
208
  searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions, useScreeningRoomType: boolean): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>[]>;
175
209
  findScreeningRoomsByBranchCode(params: {
@@ -183,12 +217,20 @@ export declare class MongoRepository {
183
217
  };
184
218
  useScreeningRoomType: boolean;
185
219
  }): Promise<IScreeningRoomFoundByBranchCode>;
186
- createSeat(seat: factory.place.seat.IPlace, useScreeningRoomType?: boolean): Promise<{
220
+ createSeat(seat: factory.place.seat.IPlace, useScreeningRoomType: boolean): Promise<{
187
221
  /**
188
222
  * 施設ID
189
223
  */
190
224
  id: string;
191
225
  typeOf: factory.placeType.MovieTheater;
226
+ } | {
227
+ containedInPlace: {
228
+ /**
229
+ * 施設ID
230
+ */
231
+ id: string;
232
+ };
233
+ typeOf: factory.placeType.ScreeningRoom;
192
234
  }>;
193
235
  updateSeat(seat: Omit<factory.place.seat.IPlace, 'containedInPlace'> & {
194
236
  containedInPlace: {
@@ -200,12 +242,20 @@ export declare class MongoRepository {
200
242
  };
201
243
  };
202
244
  };
203
- }, $unset: any, useScreeningRoomType?: boolean): Promise<{
245
+ }, $unset: any, useScreeningRoomType: boolean): Promise<{
204
246
  /**
205
247
  * 施設ID
206
248
  */
207
249
  id: string;
208
250
  typeOf: factory.placeType.MovieTheater;
251
+ } | {
252
+ containedInPlace: {
253
+ /**
254
+ * 施設ID
255
+ */
256
+ id: string;
257
+ };
258
+ typeOf: factory.placeType.ScreeningRoom;
209
259
  }>;
210
260
  searchSeats(params: factory.place.seat.ISearchConditions, useScreeningRoomType: boolean): Promise<factory.place.seat.IPlace[]>;
211
261
  deleteSeat(seat: {
@@ -234,12 +284,20 @@ export declare class MongoRepository {
234
284
  };
235
285
  };
236
286
  };
237
- }, useScreeningRoomType?: boolean): Promise<{
287
+ }, useScreeningRoomType: boolean): Promise<{
238
288
  /**
239
289
  * 施設ID
240
290
  */
241
291
  id: string;
242
292
  typeOf: factory.placeType.MovieTheater;
293
+ } | {
294
+ containedInPlace: {
295
+ /**
296
+ * 施設ID
297
+ */
298
+ id: string;
299
+ };
300
+ typeOf: factory.placeType.ScreeningRoom;
243
301
  }>;
244
302
  syncScreeningRooms(params: {
245
303
  /**
@@ -450,7 +450,7 @@ class MongoRepository {
450
450
  throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
451
451
  }
452
452
  return {
453
- id: upsertScreeningRoomResult.upsertedId.toString(),
453
+ containedInPlace: { id: creatingScreeningRoom.containedInPlace.id },
454
454
  typeOf: factory.placeType.ScreeningRoom
455
455
  };
456
456
  }
@@ -511,16 +511,13 @@ class MongoRepository {
511
511
  }
512
512
  : undefined), {
513
513
  new: true,
514
- projection: { _id: 1 }
514
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
515
515
  })
516
516
  .exec();
517
517
  if (doc === null) {
518
518
  throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
519
519
  }
520
- return {
521
- branchCode: screeningRoom.branchCode,
522
- typeOf: factory.placeType.ScreeningRoom
523
- };
520
+ return doc.toObject();
524
521
  }
525
522
  else {
526
523
  const doc = yield this.placeModel.findOneAndUpdate({
@@ -563,12 +560,14 @@ class MongoRepository {
563
560
  'project.id': { $eq: screeningRoom.project.id },
564
561
  'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
565
562
  branchCode: screeningRoom.branchCode
566
- }, { projection: { _id: 1 } })
563
+ }, {
564
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
565
+ })
567
566
  .exec();
568
567
  if (doc === null) {
569
568
  throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
570
569
  }
571
- return { typeOf: factory.placeType.ScreeningRoom };
570
+ return doc.toObject();
572
571
  }
573
572
  else {
574
573
  const doc = yield this.placeModel.findOneAndUpdate({
@@ -604,39 +603,59 @@ class MongoRepository {
604
603
  .exec();
605
604
  });
606
605
  }
606
+ // tslint:disable-next-line:max-func-body-length
607
607
  createScreeningRoomSection(screeningRoomSection, useScreeningRoomType) {
608
608
  return __awaiter(this, void 0, void 0, function* () {
609
- if (useScreeningRoomType === true) {
610
- // tslint:disable-next-line:no-suspicious-comment
611
- // TODO implement
612
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
609
+ const screeningRoom = screeningRoomSection.containedInPlace;
610
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
611
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
613
612
  }
614
- else {
615
- const screeningRoom = screeningRoomSection.containedInPlace;
616
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
617
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
618
- }
619
- const movieTheater = screeningRoom.containedInPlace;
620
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
621
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
622
- }
623
- // 施設存在確認
624
- let doc = yield this.placeModel.findOne({
625
- typeOf: { $eq: factory.placeType.MovieTheater },
613
+ const movieTheater = screeningRoom.containedInPlace;
614
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
615
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
616
+ }
617
+ // 施設存在確認
618
+ let doc = yield this.placeModel.findOne({
619
+ typeOf: { $eq: factory.placeType.MovieTheater },
620
+ 'project.id': { $eq: screeningRoomSection.project.id },
621
+ branchCode: movieTheater.branchCode,
622
+ 'containsPlace.branchCode': screeningRoom.branchCode
623
+ }, { _id: 1 })
624
+ .exec();
625
+ if (doc === null) {
626
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
627
+ }
628
+ if (useScreeningRoomType === true) {
629
+ // セクションコードが存在しなければ追加する
630
+ doc = yield this.placeModel.findOneAndUpdate({
631
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
626
632
  'project.id': { $eq: screeningRoomSection.project.id },
627
- branchCode: movieTheater.branchCode,
628
- 'containsPlace.branchCode': screeningRoom.branchCode
629
- }, { _id: 1 })
633
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
634
+ branchCode: { $eq: screeningRoom.branchCode },
635
+ 'containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
636
+ }, {
637
+ $push: {
638
+ containsPlace: Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
639
+ ? { additionalProperty: screeningRoomSection.additionalProperty }
640
+ : undefined)
641
+ }
642
+ }, {
643
+ new: true,
644
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
645
+ })
630
646
  .exec();
647
+ // 存在しなければコード重複
631
648
  if (doc === null) {
632
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
649
+ throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
633
650
  }
651
+ return doc.toObject();
652
+ }
653
+ else {
634
654
  doc = yield this.placeModel.findOneAndUpdate({
635
655
  typeOf: { $eq: factory.placeType.MovieTheater },
636
656
  'project.id': { $eq: screeningRoomSection.project.id },
637
657
  branchCode: movieTheater.branchCode,
638
658
  'containsPlace.branchCode': screeningRoom.branchCode
639
- // 'containsPlace.containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
640
659
  }, {
641
660
  $push: {
642
661
  'containsPlace.$[screeningRoom].containsPlace': Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
@@ -665,22 +684,52 @@ class MongoRepository {
665
684
  }
666
685
  });
667
686
  }
687
+ // tslint:disable-next-line:max-func-body-length
668
688
  updateScreeningRoomSection(screeningRoomSection, $unset, useScreeningRoomType) {
669
689
  return __awaiter(this, void 0, void 0, function* () {
690
+ const screeningRoom = screeningRoomSection.containedInPlace;
691
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
692
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
693
+ }
694
+ const movieTheater = screeningRoom.containedInPlace;
695
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
696
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
697
+ }
670
698
  if (useScreeningRoomType === true) {
671
- // tslint:disable-next-line:no-suspicious-comment
672
- // TODO implement
673
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
699
+ const doc = yield this.placeModel.findOneAndUpdate({
700
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
701
+ 'project.id': { $eq: screeningRoomSection.project.id },
702
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
703
+ branchCode: { $eq: screeningRoom.branchCode },
704
+ 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
705
+ }, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
706
+ ? {
707
+ 'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
708
+ }
709
+ : undefined), (Array.isArray(screeningRoomSection.additionalProperty))
710
+ ? {
711
+ 'containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
712
+ }
713
+ : undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
714
+ ? {
715
+ 'containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
716
+ 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);
717
+ })
718
+ }
719
+ : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
720
+ new: true,
721
+ arrayFilters: [
722
+ { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
723
+ ],
724
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
725
+ })
726
+ .exec();
727
+ if (doc === null) {
728
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
729
+ }
730
+ return doc.toObject();
674
731
  }
675
732
  else {
676
- const screeningRoom = screeningRoomSection.containedInPlace;
677
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
678
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
679
- }
680
- const movieTheater = screeningRoom.containedInPlace;
681
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
682
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
683
- }
684
733
  const doc = yield this.placeModel.findOneAndUpdate({
685
734
  typeOf: { $eq: factory.placeType.MovieTheater },
686
735
  'project.id': { $eq: screeningRoomSection.project.id },
@@ -976,9 +1025,30 @@ class MongoRepository {
976
1025
  deleteScreeningRoomSection(screeningRoomSection, useScreeningRoomType) {
977
1026
  return __awaiter(this, void 0, void 0, function* () {
978
1027
  if (useScreeningRoomType === true) {
979
- // tslint:disable-next-line:no-suspicious-comment
980
- // TODO implement
981
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
1028
+ const doc = yield this.placeModel.findOneAndUpdate({
1029
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
1030
+ 'project.id': { $eq: screeningRoomSection.project.id },
1031
+ 'containedInPlace.branchCode': {
1032
+ $exists: true,
1033
+ $eq: screeningRoomSection.containedInPlace.containedInPlace.branchCode
1034
+ },
1035
+ branchCode: { $eq: screeningRoomSection.containedInPlace.branchCode },
1036
+ 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
1037
+ }, {
1038
+ $pull: {
1039
+ containsPlace: {
1040
+ branchCode: screeningRoomSection.branchCode
1041
+ }
1042
+ }
1043
+ }, {
1044
+ new: true,
1045
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
1046
+ })
1047
+ .exec();
1048
+ if (doc === null) {
1049
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
1050
+ }
1051
+ return doc.toObject();
982
1052
  }
983
1053
  else {
984
1054
  const doc = yield this.placeModel.findOneAndUpdate({
@@ -1413,41 +1483,65 @@ class MongoRepository {
1413
1483
  }
1414
1484
  });
1415
1485
  }
1486
+ // tslint:disable-next-line:max-func-body-length
1416
1487
  createSeat(seat, useScreeningRoomType) {
1417
- var _a, _b;
1488
+ var _a, _b, _c, _d;
1418
1489
  return __awaiter(this, void 0, void 0, function* () {
1419
- if (useScreeningRoomType === true) {
1420
- // tslint:disable-next-line:no-suspicious-comment
1421
- // TODO implement
1422
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
1490
+ const screeningRoomSection = seat.containedInPlace;
1491
+ if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
1492
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
1423
1493
  }
1424
- else {
1425
- const screeningRoomSection = seat.containedInPlace;
1426
- if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
1427
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
1428
- }
1429
- const screeningRoom = screeningRoomSection.containedInPlace;
1430
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
1431
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
1432
- }
1433
- const movieTheater = screeningRoom.containedInPlace;
1434
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
1435
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
1436
- }
1437
- // 施設存在確認
1438
- let doc = yield this.placeModel.findOne({
1439
- typeOf: { $eq: factory.placeType.MovieTheater },
1494
+ const screeningRoom = screeningRoomSection.containedInPlace;
1495
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
1496
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
1497
+ }
1498
+ const movieTheater = screeningRoom.containedInPlace;
1499
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
1500
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
1501
+ }
1502
+ // 施設存在確認
1503
+ let doc = yield this.placeModel.findOne({
1504
+ typeOf: { $eq: factory.placeType.MovieTheater },
1505
+ 'project.id': { $eq: seat.project.id },
1506
+ branchCode: movieTheater.branchCode,
1507
+ 'containsPlace.branchCode': screeningRoom.branchCode,
1508
+ 'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
1509
+ }, {
1510
+ _id: 1
1511
+ })
1512
+ .exec();
1513
+ if (doc === null) {
1514
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
1515
+ }
1516
+ if (useScreeningRoomType === true) {
1517
+ doc = yield this.placeModel.findOneAndUpdate({
1518
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
1440
1519
  'project.id': { $eq: seat.project.id },
1441
- branchCode: movieTheater.branchCode,
1442
- 'containsPlace.branchCode': screeningRoom.branchCode,
1443
- 'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
1520
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
1521
+ branchCode: { $eq: screeningRoom.branchCode },
1522
+ 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
1523
+ }, {
1524
+ $push: {
1525
+ '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)
1526
+ }
1444
1527
  }, {
1445
- _id: 1
1528
+ new: true,
1529
+ arrayFilters: [
1530
+ {
1531
+ 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode },
1532
+ 'screeningRoomSection.containsPlace.branchCode': { $ne: seat.branchCode }
1533
+ }
1534
+ ],
1535
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
1446
1536
  })
1447
1537
  .exec();
1538
+ // 存在しなければコード重複
1448
1539
  if (doc === null) {
1449
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
1540
+ throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
1450
1541
  }
1542
+ return doc.toObject();
1543
+ }
1544
+ else {
1451
1545
  doc = yield this.placeModel.findOneAndUpdate({
1452
1546
  typeOf: { $eq: factory.placeType.MovieTheater },
1453
1547
  'project.id': { $eq: seat.project.id },
@@ -1456,7 +1550,7 @@ class MongoRepository {
1456
1550
  'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode
1457
1551
  }, {
1458
1552
  $push: {
1459
- '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)
1553
+ 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace': Object.assign(Object.assign({ typeOf: seat.typeOf, branchCode: seat.branchCode, additionalProperty: seat.additionalProperty }, (typeof ((_c = seat.name) === null || _c === void 0 ? void 0 : _c.ja) === 'string' || typeof ((_d = seat.name) === null || _d === void 0 ? void 0 : _d.en) === 'string') ? { name: seat.name } : undefined), (Array.isArray(seat.seatingType)) ? { seatingType: seat.seatingType } : undefined)
1460
1554
  }
1461
1555
  }, {
1462
1556
  new: true,
@@ -1469,7 +1563,6 @@ class MongoRepository {
1469
1563
  ],
1470
1564
  projection: {
1471
1565
  _id: 1,
1472
- // 'project.id': 1,
1473
1566
  branchCode: 1,
1474
1567
  typeOf: 1
1475
1568
  }
@@ -1483,27 +1576,69 @@ class MongoRepository {
1483
1576
  }
1484
1577
  });
1485
1578
  }
1579
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
1486
1580
  updateSeat(seat, $unset, useScreeningRoomType) {
1487
- var _a, _b;
1581
+ var _a, _b, _c, _d;
1488
1582
  return __awaiter(this, void 0, void 0, function* () {
1583
+ const screeningRoomSection = seat.containedInPlace;
1584
+ if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
1585
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
1586
+ }
1587
+ const screeningRoom = screeningRoomSection.containedInPlace;
1588
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
1589
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
1590
+ }
1591
+ const movieTheater = screeningRoom.containedInPlace;
1592
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
1593
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
1594
+ }
1489
1595
  if (useScreeningRoomType === true) {
1490
- // tslint:disable-next-line:no-suspicious-comment
1491
- // TODO implement
1492
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
1596
+ const doc = yield this.placeModel.findOneAndUpdate({
1597
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
1598
+ 'project.id': { $eq: seat.project.id },
1599
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
1600
+ branchCode: { $eq: screeningRoom.branchCode },
1601
+ 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode },
1602
+ 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode }
1603
+ }, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_a = seat.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.en) === 'string')
1604
+ ? {
1605
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
1606
+ }
1607
+ : undefined), (Array.isArray(seat.seatingType))
1608
+ ? {
1609
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': seat.seatingType
1610
+ }
1611
+ : undefined), (Array.isArray(seat.additionalProperty))
1612
+ ? {
1613
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].additionalProperty': seat.additionalProperty
1614
+ }
1615
+ : undefined), { $unset: Object.assign(Object.assign({ noExistingAttributeName: 1 }, (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].name'])
1616
+ === 1
1617
+ || ($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoomSection].containsPlace.$[seat].name']) === 1)
1618
+ ? {
1619
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': 1
1620
+ }
1621
+ : undefined), (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType'])
1622
+ === 1
1623
+ || ($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType']) === 1)
1624
+ ? {
1625
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': 1
1626
+ }
1627
+ : undefined) }), {
1628
+ new: true,
1629
+ arrayFilters: [
1630
+ { 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode } },
1631
+ { 'seat.branchCode': { $eq: seat.branchCode } }
1632
+ ],
1633
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
1634
+ })
1635
+ .exec();
1636
+ if (doc === null) {
1637
+ throw new factory.errors.NotFound(factory.placeType.Seat);
1638
+ }
1639
+ return doc.toObject();
1493
1640
  }
1494
1641
  else {
1495
- const screeningRoomSection = seat.containedInPlace;
1496
- if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
1497
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
1498
- }
1499
- const screeningRoom = screeningRoomSection.containedInPlace;
1500
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
1501
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
1502
- }
1503
- const movieTheater = screeningRoom.containedInPlace;
1504
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
1505
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
1506
- }
1507
1642
  const doc = yield this.placeModel.findOneAndUpdate({
1508
1643
  typeOf: { $eq: factory.placeType.MovieTheater },
1509
1644
  'project.id': { $eq: seat.project.id },
@@ -1511,7 +1646,7 @@ class MongoRepository {
1511
1646
  'containsPlace.branchCode': screeningRoom.branchCode,
1512
1647
  'containsPlace.containsPlace.branchCode': screeningRoomSection.branchCode,
1513
1648
  'containsPlace.containsPlace.containsPlace.branchCode': seat.branchCode
1514
- }, 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')
1649
+ }, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_c = seat.name) === null || _c === void 0 ? void 0 : _c.ja) === 'string' || typeof ((_d = seat.name) === null || _d === void 0 ? void 0 : _d.en) === 'string')
1515
1650
  ? {
1516
1651
  'containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
1517
1652
  }
@@ -1916,9 +2051,34 @@ class MongoRepository {
1916
2051
  deleteSeat(seat, useScreeningRoomType) {
1917
2052
  return __awaiter(this, void 0, void 0, function* () {
1918
2053
  if (useScreeningRoomType === true) {
1919
- // tslint:disable-next-line:no-suspicious-comment
1920
- // TODO implement
1921
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
2054
+ const doc = yield this.placeModel.findOneAndUpdate({
2055
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
2056
+ 'project.id': { $eq: seat.project.id },
2057
+ 'containedInPlace.branchCode': {
2058
+ $exists: true,
2059
+ $eq: seat.containedInPlace.containedInPlace.containedInPlace.branchCode
2060
+ },
2061
+ branchCode: { $eq: seat.containedInPlace.containedInPlace.branchCode },
2062
+ 'containsPlace.branchCode': { $eq: seat.containedInPlace.branchCode },
2063
+ 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode }
2064
+ }, {
2065
+ $pull: {
2066
+ 'containsPlace.$[screeningRoomSection].containsPlace': {
2067
+ branchCode: seat.branchCode
2068
+ }
2069
+ }
2070
+ }, {
2071
+ new: true,
2072
+ arrayFilters: [
2073
+ { 'screeningRoomSection.branchCode': { $eq: seat.containedInPlace.branchCode } }
2074
+ ],
2075
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
2076
+ })
2077
+ .exec();
2078
+ if (doc === null) {
2079
+ throw new factory.errors.NotFound(factory.placeType.Seat);
2080
+ }
2081
+ return doc.toObject();
1922
2082
  }
1923
2083
  else {
1924
2084
  const doc = yield this.placeModel.findOneAndUpdate({
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.147"
120
+ "version": "21.2.0-alpha.149"
121
121
  }