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

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.
@@ -50,23 +50,39 @@ 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'>, useScreeningRoomType?: boolean): Promise<{
53
+ createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace'> & {
54
+ containedInPlace: {
55
+ branchCode: string;
56
+ };
57
+ }, useScreeningRoomType: boolean): Promise<{
54
58
  /**
55
59
  * 施設ID
56
60
  */
57
61
  id: string;
58
62
  typeOf: factory.placeType.MovieTheater;
63
+ } | {
64
+ /**
65
+ * ルームID
66
+ */
67
+ id: string;
68
+ typeOf: factory.placeType.ScreeningRoom;
59
69
  }>;
60
70
  updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace'> & {
61
71
  containedInPlace: {
62
72
  branchCode: string;
63
73
  };
64
- }, $unset: any, useScreeningRoomType?: boolean): Promise<{
74
+ }, $unset: any, useScreeningRoomType: boolean): Promise<{
65
75
  /**
66
76
  * 施設ID
67
77
  */
68
78
  id: string;
69
79
  typeOf: factory.placeType.MovieTheater;
80
+ } | {
81
+ /**
82
+ * ルームコード
83
+ */
84
+ branchCode: string;
85
+ typeOf: factory.placeType.ScreeningRoom;
70
86
  }>;
71
87
  deleteScreeningRoom(screeningRoom: {
72
88
  project: {
@@ -82,12 +98,14 @@ export declare class MongoRepository {
82
98
  */
83
99
  branchCode: string;
84
100
  };
85
- }, useScreeningRoomType?: boolean): Promise<{
101
+ }, useScreeningRoomType: boolean): Promise<{
86
102
  /**
87
103
  * 施設ID
88
104
  */
89
105
  id: string;
90
106
  typeOf: factory.placeType.MovieTheater;
107
+ } | {
108
+ typeOf: factory.placeType.ScreeningRoom;
91
109
  }>;
92
110
  deleteScreeningRoomsByMovieTheaterId(params: {
93
111
  project: {
@@ -416,24 +416,45 @@ class MongoRepository {
416
416
  }
417
417
  createScreeningRoom(screeningRoom, useScreeningRoomType) {
418
418
  return __awaiter(this, void 0, void 0, function* () {
419
- if (useScreeningRoomType === true) {
420
- // tslint:disable-next-line:no-suspicious-comment
421
- // TODO implement
422
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
419
+ // 施設存在確認
420
+ let doc = yield this.placeModel.findOne({
421
+ typeOf: { $eq: factory.placeType.MovieTheater },
422
+ 'project.id': { $eq: screeningRoom.project.id },
423
+ branchCode: { $eq: screeningRoom.containedInPlace.branchCode }
424
+ }, { _id: 1, typeOf: 1, branchCode: 1, name: 1 })
425
+ .exec();
426
+ if (doc === null) {
427
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
423
428
  }
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
- })
429
+ if (useScreeningRoomType === true) {
430
+ const movieTheater = doc.toObject();
431
+ const creatingScreeningRoom = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
432
+ id: movieTheater.id,
433
+ typeOf: movieTheater.typeOf,
434
+ branchCode: movieTheater.branchCode,
435
+ name: movieTheater.name
436
+ }, containsPlace: [], project: screeningRoom.project }, (typeof screeningRoom.openSeatingAllowed === 'boolean')
437
+ ? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
438
+ : undefined);
439
+ const upsertScreeningRoomResult = yield this.placeModel.updateOne({
440
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
441
+ 'project.id': { $eq: creatingScreeningRoom.project.id },
442
+ 'containedInPlace.id': { $exists: true, $eq: creatingScreeningRoom.containedInPlace.id },
443
+ branchCode: { $eq: creatingScreeningRoom.branchCode }
444
+ },
445
+ // 既存であれば何もしない
446
+ { $setOnInsert: creatingScreeningRoom }, { upsert: true })
433
447
  .exec();
434
- if (doc === null) {
435
- throw new factory.errors.NotFound('containedInPlace');
448
+ // 既存であればコード重複
449
+ if (upsertScreeningRoomResult.matchedCount > 0) {
450
+ throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
436
451
  }
452
+ return {
453
+ id: upsertScreeningRoomResult.upsertedId.toString(),
454
+ typeOf: factory.placeType.ScreeningRoom
455
+ };
456
+ }
457
+ else {
437
458
  // ルームコードが存在しなければ追加する
438
459
  doc = yield this.placeModel.findOneAndUpdate({
439
460
  typeOf: { $eq: factory.placeType.MovieTheater },
@@ -454,7 +475,6 @@ class MongoRepository {
454
475
  new: true,
455
476
  projection: {
456
477
  _id: 1,
457
- // 'project.id': 1,
458
478
  branchCode: 1,
459
479
  typeOf: 1
460
480
  }
@@ -471,9 +491,36 @@ class MongoRepository {
471
491
  updateScreeningRoom(screeningRoom, $unset, useScreeningRoomType) {
472
492
  return __awaiter(this, void 0, void 0, function* () {
473
493
  if (useScreeningRoomType === true) {
474
- // tslint:disable-next-line:no-suspicious-comment
475
- // TODO implement
476
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
494
+ const doc = yield this.placeModel.findOneAndUpdate({
495
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
496
+ 'project.id': { $eq: screeningRoom.project.id },
497
+ 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
498
+ branchCode: screeningRoom.branchCode
499
+ }, Object.assign(Object.assign(Object.assign(Object.assign({ name: screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
500
+ ? { address: screeningRoom.address }
501
+ : undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
502
+ ? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
503
+ : undefined), (Array.isArray(screeningRoom.additionalProperty))
504
+ ? { additionalProperty: screeningRoom.additionalProperty }
505
+ : undefined), (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].openSeatingAllowed']) === 1
506
+ || $unset.openSeatingAllowed === 1)
507
+ ? {
508
+ $unset: {
509
+ openSeatingAllowed: 1
510
+ }
511
+ }
512
+ : undefined), {
513
+ new: true,
514
+ projection: { _id: 1 }
515
+ })
516
+ .exec();
517
+ if (doc === null) {
518
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
519
+ }
520
+ return {
521
+ branchCode: screeningRoom.branchCode,
522
+ typeOf: factory.placeType.ScreeningRoom
523
+ };
477
524
  }
478
525
  else {
479
526
  const doc = yield this.placeModel.findOneAndUpdate({
@@ -496,7 +543,6 @@ class MongoRepository {
496
543
  ],
497
544
  projection: {
498
545
  _id: 1,
499
- // 'project.id': 1,
500
546
  branchCode: 1,
501
547
  typeOf: 1
502
548
  }
@@ -512,9 +558,17 @@ class MongoRepository {
512
558
  deleteScreeningRoom(screeningRoom, useScreeningRoomType) {
513
559
  return __awaiter(this, void 0, void 0, function* () {
514
560
  if (useScreeningRoomType === true) {
515
- // tslint:disable-next-line:no-suspicious-comment
516
- // TODO implement
517
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
561
+ const doc = yield this.placeModel.findOneAndDelete({
562
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
563
+ 'project.id': { $eq: screeningRoom.project.id },
564
+ 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
565
+ branchCode: screeningRoom.branchCode
566
+ }, { projection: { _id: 1 } })
567
+ .exec();
568
+ if (doc === null) {
569
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
570
+ }
571
+ return { typeOf: factory.placeType.ScreeningRoom };
518
572
  }
519
573
  else {
520
574
  const doc = yield this.placeModel.findOneAndUpdate({
@@ -1270,8 +1324,6 @@ class MongoRepository {
1270
1324
  findScreeningRoomsByBranchCode(params) {
1271
1325
  return __awaiter(this, void 0, void 0, function* () {
1272
1326
  if (params.useScreeningRoomType === true) {
1273
- // tslint:disable-next-line:no-suspicious-comment
1274
- // TODO implement
1275
1327
  const matchStages = [
1276
1328
  { $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } },
1277
1329
  {
@@ -67,7 +67,7 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
67
67
  : moment('2023-08-31T15:00:00Z');
68
68
  exports.USE_NEW_STOCK_HOLDER_REPO_FROM = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_FROM === 'string')
69
69
  ? moment(process.env.USE_NEW_STOCK_HOLDER_REPO_FROM)
70
- : moment('2023-11-30T15:00:00Z');
70
+ : moment('2024-11-30T15:00:00Z');
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
  : [];
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.146"
120
+ "version": "21.2.0-alpha.147"
121
121
  }