@chevre/domain 28.0.0-alpha.6 → 28.0.0-alpha.7

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.
@@ -84,7 +84,23 @@ export declare class ScreeningRoomRepo {
84
84
  id: string;
85
85
  };
86
86
  }): Promise<mongo.DeleteResult>;
87
- searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
87
+ /**
88
+ * ルーム検索
89
+ * sectionCount,seatCountのprojectが可能
90
+ * sortはbranchCode: factory.sortType.Ascendingで固定
91
+ */
92
+ projectRoomFields(params: Pick<factory.place.screeningRoom.ISearchConditions, '$projection' | 'branchCode' | 'containedInPlace' | 'parentOrganization'> & {
93
+ /**
94
+ * プロジェクト指定は必須
95
+ */
96
+ project: {
97
+ id: {
98
+ $eq: string;
99
+ };
100
+ };
101
+ limit: number;
102
+ page: number;
103
+ }): Promise<Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'containedInPlace' | 'maximumAttendeeCapacity' | 'name' | 'openSeatingAllowed' | 'typeOf' | 'seatCount' | 'sectionCount'>[]>;
88
104
  findRooms(params: Omit<factory.place.screeningRoom.ISearchConditions, '$projection'>): Promise<Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed' | 'maximumAttendeeCapacity'>[]>;
89
105
  /**
90
106
  * セクションと座席も含めたひとつのルームを取得する
@@ -379,10 +379,14 @@ class ScreeningRoomRepo {
379
379
  })
380
380
  .exec();
381
381
  }
382
- async searchScreeningRooms(searchConditions) {
382
+ /**
383
+ * ルーム検索
384
+ * sectionCount,seatCountのprojectが可能
385
+ * sortはbranchCode: factory.sortType.Ascendingで固定
386
+ */
387
+ async projectRoomFields(params) {
383
388
  const aggregate = this.placeModel.aggregate([
384
- { $sort: { branchCode: factory_1.factory.sortType.Ascending } },
385
- ...ScreeningRoomRepo.CREATE_ROOM_MONGO_CONDITIONS(searchConditions),
389
+ ...ScreeningRoomRepo.CREATE_ROOM_MONGO_CONDITIONS(params),
386
390
  {
387
391
  $project: {
388
392
  _id: 0,
@@ -399,7 +403,7 @@ class ScreeningRoomRepo {
399
403
  openSeatingAllowed: '$openSeatingAllowed',
400
404
  additionalProperty: '$additionalProperty',
401
405
  maximumAttendeeCapacity: '$maximumAttendeeCapacity',
402
- ...(searchConditions.$projection?.sectionCount === 1)
406
+ ...(params.$projection?.sectionCount === 1)
403
407
  ? {
404
408
  sectionCount: {
405
409
  $cond: {
@@ -410,7 +414,7 @@ class ScreeningRoomRepo {
410
414
  }
411
415
  }
412
416
  : undefined,
413
- ...(searchConditions.$projection?.seatCount === 1)
417
+ ...(params.$projection?.seatCount === 1)
414
418
  ? {
415
419
  seatCount: {
416
420
  $sum: {
@@ -429,14 +433,16 @@ class ScreeningRoomRepo {
429
433
  }
430
434
  : undefined
431
435
  }
432
- }
436
+ },
437
+ { $sort: { branchCode: factory_1.factory.sortType.Ascending } }
433
438
  ]);
434
- /* istanbul ignore else */
435
- if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
436
- const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
437
- aggregate.limit(searchConditions.limit * page)
438
- .skip(searchConditions.limit * (page - 1));
439
+ const { limit, page } = params;
440
+ if (typeof limit !== 'number' || limit === 0) {
441
+ throw new factory_1.factory.errors.ArgumentNull('limit', 'must be number > 0');
439
442
  }
443
+ const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
444
+ aggregate.skip(limit * (pageMustBePositive - 1))
445
+ .limit(limit);
440
446
  return aggregate
441
447
  .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
442
448
  .exec();
package/package.json CHANGED
@@ -88,5 +88,5 @@
88
88
  "postversion": "git push origin --tags",
89
89
  "prepublishOnly": "npm run clean && npm run build"
90
90
  },
91
- "version": "28.0.0-alpha.6"
91
+ "version": "28.0.0-alpha.7"
92
92
  }