@chevre/domain 23.2.0-alpha.6 → 23.2.0-alpha.60
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.
- package/example/src/chevre/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +25 -17
- package/example/src/chevre/confirmationNumber/testRandomness.ts +49 -0
- package/example/src/chevre/emailMessage/createEmailMessageText.ts +63 -0
- package/example/src/chevre/event/importEventsFromCOAByTitle.ts +2 -2
- package/example/src/chevre/event/unsetSuperEventVideoFormat.ts +30 -0
- package/example/src/chevre/eventSeries/unsetVideoFormat.ts +31 -0
- package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -43
- package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +6 -3
- package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +8 -3
- package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts} +5 -3
- package/example/src/chevre/orderNumber/decryptOrderNumber.ts +14 -0
- package/example/src/chevre/orderNumber/testRandomness.ts +54 -0
- package/example/src/chevre/place/adminEntranceGates.ts +69 -0
- package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
- package/example/src/chevre/place/findRooms.ts +24 -0
- package/example/src/chevre/place/findSections.ts +28 -0
- package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
- package/example/src/chevre/place/seatsJson2csv.ts +63 -0
- package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
- package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
- package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
- package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
- package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
- package/example/src/chevre/settings/addOrderNumberSetting.ts +44 -0
- package/example/src/chevre/settings/addTransactionNumberSetting.ts +40 -0
- package/example/src/chevre/transactionNumber/publishByTimestamp.ts +23 -0
- package/example/src/chevre/transactionNumber/testRandomness.ts +42 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
- package/lib/chevre/emailMessageBuilder.js +1 -0
- package/lib/chevre/factory/event.d.ts +1 -1
- package/lib/chevre/factory/event.js +11 -5
- package/lib/chevre/factory/transactionNumber.d.ts +19 -0
- package/lib/chevre/factory/transactionNumber.js +54 -0
- package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -8
- package/lib/chevre/repo/acceptedPaymentMethod.js +72 -27
- package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
- package/lib/chevre/repo/aggregateOffer.js +11 -3
- package/lib/chevre/repo/aggregateOrder.js +0 -93
- package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
- package/lib/chevre/repo/aggregateReservation.js +0 -2
- package/lib/chevre/repo/confirmationNumber.d.ts +1 -0
- package/lib/chevre/repo/confirmationNumber.js +32 -25
- package/lib/chevre/repo/event.d.ts +3 -3
- package/lib/chevre/repo/event.js +20 -8
- package/lib/chevre/repo/eventOffer.d.ts +8 -0
- package/lib/chevre/repo/eventOffer.js +11 -0
- package/lib/chevre/repo/eventSeries.d.ts +18 -25
- package/lib/chevre/repo/eventSeries.js +155 -101
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +13 -25
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +2 -8
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +28 -2
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +40 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +3 -0
- package/lib/chevre/repo/offerCatalog.d.ts +14 -1
- package/lib/chevre/repo/offerCatalog.js +41 -19
- package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
- package/lib/chevre/repo/offerCatalogItem.js +32 -17
- package/lib/chevre/repo/orderNumber.d.ts +7 -0
- package/lib/chevre/repo/orderNumber.js +110 -34
- package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
- package/lib/chevre/repo/place/entranceGate.js +172 -0
- package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
- package/lib/chevre/repo/place/movieTheater.js +77 -6
- package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
- package/lib/chevre/repo/place/screeningRoom.js +227 -135
- package/lib/chevre/repo/place/seat.d.ts +47 -45
- package/lib/chevre/repo/place/seat.js +175 -45
- package/lib/chevre/repo/place/section.d.ts +60 -30
- package/lib/chevre/repo/place/section.js +337 -127
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +3 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +42 -27
- package/lib/chevre/repo/setting.d.ts +1 -1
- package/lib/chevre/repo/setting.js +2 -2
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/transactionNumber.d.ts +5 -0
- package/lib/chevre/repo/transactionNumber.js +63 -27
- package/lib/chevre/repository.d.ts +8 -0
- package/lib/chevre/repository.js +16 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +10 -2
- package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
- package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
- package/lib/chevre/service/event/saveScreeningEventSeries.js +4 -5
- package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -2
- package/lib/chevre/service/event/saveScreeningEvents.js +16 -12
- package/lib/chevre/service/offer/event/authorize/factory.js +9 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
- package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +7 -1
- package/lib/chevre/service/offer/onEventChanged.js +10 -6
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/offer.d.ts +5 -0
- package/lib/chevre/service/offer.js +34 -9
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +2 -2
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +13 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +53 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +13 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +56 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +15 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +58 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +17 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +75 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +19 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +60 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +20 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +51 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +27 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +100 -0
- package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
- package/lib/chevre/service/task/onResourceDeleted.js +168 -0
- package/lib/chevre/service/task/onResourceUpdated.js +205 -42
- package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
- package/lib/chevre/service/taskHandler.js +1 -0
- package/package.json +10 -8
- package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
- package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +0 -93
- package/example/src/chevre/offers/createSampleOffers.ts +0 -154
- package/example/src/chevre/settings/addSettings.ts +0 -46
- package/lib/chevre/service/eventOld.d.ts +0 -60
- package/lib/chevre/service/eventOld.js +0 -864
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -45
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +0 -447
|
@@ -33,6 +33,120 @@ class ScreeningRoomRepo {
|
|
|
33
33
|
this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
34
34
|
this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
35
35
|
}
|
|
36
|
+
// tslint:disable-next-line:max-func-body-length
|
|
37
|
+
static CREATE_ROOM_MONGO_CONDITIONS(searchConditions) {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
39
|
+
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
|
|
40
|
+
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
41
|
+
if (typeof projectIdEq === 'string') {
|
|
42
|
+
matchStages.push({
|
|
43
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
47
|
+
if (typeof parentOrganizationIdEq === 'string') {
|
|
48
|
+
matchStages.push({
|
|
49
|
+
$match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// 施設ID
|
|
53
|
+
const containedInPlaceIdEq = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
54
|
+
if (typeof containedInPlaceIdEq === 'string') {
|
|
55
|
+
matchStages.push({
|
|
56
|
+
$match: {
|
|
57
|
+
'containedInPlace.id': {
|
|
58
|
+
$exists: true,
|
|
59
|
+
$eq: containedInPlaceIdEq
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (searchConditions.containedInPlace !== undefined) {
|
|
65
|
+
// 施設コード
|
|
66
|
+
if (searchConditions.containedInPlace.branchCode !== undefined) {
|
|
67
|
+
if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
|
|
68
|
+
matchStages.push({
|
|
69
|
+
$match: {
|
|
70
|
+
'containedInPlace.branchCode': {
|
|
71
|
+
$exists: true,
|
|
72
|
+
$eq: searchConditions.containedInPlace.branchCode.$eq
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const branchCodeEq = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
80
|
+
if (typeof branchCodeEq === 'string') {
|
|
81
|
+
matchStages.push({
|
|
82
|
+
$match: {
|
|
83
|
+
branchCode: { $eq: branchCodeEq }
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const branchCodeIn = (_h = searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$in;
|
|
88
|
+
if (Array.isArray(branchCodeIn)) {
|
|
89
|
+
matchStages.push({
|
|
90
|
+
$match: {
|
|
91
|
+
branchCode: { $in: branchCodeIn }
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const branchCodeRegex = (_j = searchConditions.branchCode) === null || _j === void 0 ? void 0 : _j.$regex;
|
|
96
|
+
if (typeof branchCodeRegex === 'string') {
|
|
97
|
+
matchStages.push({
|
|
98
|
+
$match: {
|
|
99
|
+
branchCode: {
|
|
100
|
+
$regex: new RegExp(branchCodeRegex)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const nameCodeRegex = (_k = searchConditions.name) === null || _k === void 0 ? void 0 : _k.$regex;
|
|
106
|
+
if (typeof nameCodeRegex === 'string') {
|
|
107
|
+
matchStages.push({
|
|
108
|
+
$match: {
|
|
109
|
+
$or: [
|
|
110
|
+
{
|
|
111
|
+
'name.ja': {
|
|
112
|
+
$exists: true,
|
|
113
|
+
$regex: new RegExp(nameCodeRegex)
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
'name.en': {
|
|
118
|
+
$exists: true,
|
|
119
|
+
$regex: new RegExp(nameCodeRegex)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const openSeatingAllowed = searchConditions.openSeatingAllowed;
|
|
127
|
+
if (typeof openSeatingAllowed === 'boolean') {
|
|
128
|
+
matchStages.push({
|
|
129
|
+
$match: {
|
|
130
|
+
openSeatingAllowed: {
|
|
131
|
+
$exists: true,
|
|
132
|
+
$eq: openSeatingAllowed
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
138
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
139
|
+
matchStages.push({
|
|
140
|
+
$match: {
|
|
141
|
+
additionalProperty: {
|
|
142
|
+
$exists: true,
|
|
143
|
+
$elemMatch: additionalPropertyElemMatch
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return matchStages;
|
|
149
|
+
}
|
|
36
150
|
saveScreeningRooms4coa(params) {
|
|
37
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
152
|
const { containsPlace } = params, movieTheater4update = __rest(params, ["containsPlace"]);
|
|
@@ -79,29 +193,24 @@ class ScreeningRoomRepo {
|
|
|
79
193
|
})));
|
|
80
194
|
});
|
|
81
195
|
}
|
|
82
|
-
|
|
196
|
+
createRoom(screeningRoom, options) {
|
|
83
197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
|
|
198
|
+
const { project, parentOrganization, movieTheaterCode } = options;
|
|
85
199
|
// 施設存在確認
|
|
86
|
-
const
|
|
87
|
-
? { 'parentOrganization.id': { $exists: true, $eq:
|
|
200
|
+
const movieTheater = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: project.id }, branchCode: { $eq: movieTheaterCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
|
|
201
|
+
? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
|
|
88
202
|
: undefined), { _id: 0, id: { $toString: '$_id' }, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
|
|
89
203
|
.lean()
|
|
90
204
|
.exec();
|
|
91
|
-
if (
|
|
205
|
+
if (movieTheater === null) {
|
|
92
206
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
93
207
|
}
|
|
94
|
-
|
|
95
|
-
// factory.place.movieTheater.IPlace,
|
|
96
|
-
// 'id' | 'typeOf' | 'branchCode' | 'name' | 'parentOrganization'
|
|
97
|
-
// >>movieTheaterDoc.toObject();
|
|
98
|
-
const movieTheater = movieTheaterDoc;
|
|
99
|
-
const creatingScreeningRoom = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
|
|
208
|
+
const creatingScreeningRoom = Object.assign({ typeOf: factory.placeType.ScreeningRoom, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
|
|
100
209
|
id: movieTheater.id,
|
|
101
210
|
typeOf: movieTheater.typeOf,
|
|
102
211
|
branchCode: movieTheater.branchCode,
|
|
103
212
|
name: movieTheater.name
|
|
104
|
-
}, containsPlace: [], project:
|
|
213
|
+
}, containsPlace: [], project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
105
214
|
// 必須化(2023-07-14~)
|
|
106
215
|
parentOrganization: movieTheater.parentOrganization }, (typeof screeningRoom.openSeatingAllowed === 'boolean')
|
|
107
216
|
? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
|
|
@@ -125,11 +234,11 @@ class ScreeningRoomRepo {
|
|
|
125
234
|
};
|
|
126
235
|
});
|
|
127
236
|
}
|
|
128
|
-
|
|
237
|
+
updateRoomByBranchCode(screeningRoom, $unset, options) {
|
|
129
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
|
|
131
|
-
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq:
|
|
132
|
-
? { 'parentOrganization.id': { $exists: true, $eq:
|
|
239
|
+
const { project, parentOrganization, movieTheaterCode } = options;
|
|
240
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: screeningRoom.branchCode }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
|
|
241
|
+
? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
|
|
133
242
|
: undefined), Object.assign(Object.assign(Object.assign(Object.assign({ name: screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
|
|
134
243
|
? { address: screeningRoom.address }
|
|
135
244
|
: undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
|
|
@@ -169,11 +278,72 @@ class ScreeningRoomRepo {
|
|
|
169
278
|
}
|
|
170
279
|
});
|
|
171
280
|
}
|
|
172
|
-
|
|
281
|
+
/**
|
|
282
|
+
* コードをキーにして冪等作成
|
|
283
|
+
* 2026-01-12~
|
|
284
|
+
*/
|
|
285
|
+
upsertRoomsByBranchCode(params, options) {
|
|
173
286
|
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
287
|
+
const { project, parentOrganization, movieTheaterId } = options;
|
|
288
|
+
// 施設存在確認
|
|
289
|
+
const movieTheater = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: project.id }, _id: { $eq: movieTheaterId } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
|
|
290
|
+
? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
|
|
291
|
+
: undefined), { _id: 0, id: { $toString: '$_id' }, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
|
|
292
|
+
.lean()
|
|
293
|
+
.exec();
|
|
294
|
+
if (movieTheater === null) {
|
|
295
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
296
|
+
}
|
|
297
|
+
const containedInPlace = {
|
|
298
|
+
id: movieTheater.id,
|
|
299
|
+
typeOf: movieTheater.typeOf,
|
|
300
|
+
branchCode: movieTheater.branchCode,
|
|
301
|
+
name: movieTheater.name
|
|
302
|
+
};
|
|
303
|
+
const bulkWriteOps = [];
|
|
304
|
+
if (Array.isArray(params)) {
|
|
305
|
+
params.forEach(({ $set, $unset }) => {
|
|
306
|
+
const { branchCode } = $set, setFields = __rest($set, ["branchCode"]);
|
|
307
|
+
if (typeof branchCode !== 'string' || branchCode === '') {
|
|
308
|
+
throw new factory.errors.ArgumentNull('branchCode');
|
|
309
|
+
}
|
|
310
|
+
// リソースのユニークネスを保証するfilter
|
|
311
|
+
const filter = {
|
|
312
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
313
|
+
'project.id': { $eq: project.id },
|
|
314
|
+
'containedInPlace.id': { $eq: movieTheaterId },
|
|
315
|
+
branchCode: { $eq: branchCode }
|
|
316
|
+
};
|
|
317
|
+
const initialRoom = {
|
|
318
|
+
typeOf: factory.placeType.ScreeningRoom,
|
|
319
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
320
|
+
branchCode,
|
|
321
|
+
containedInPlace,
|
|
322
|
+
containsPlace: [],
|
|
323
|
+
parentOrganization: movieTheater.parentOrganization
|
|
324
|
+
};
|
|
325
|
+
const setOnInsert = initialRoom;
|
|
326
|
+
const update = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
327
|
+
const updateOne = {
|
|
328
|
+
filter,
|
|
329
|
+
update,
|
|
330
|
+
upsert: true
|
|
331
|
+
};
|
|
332
|
+
bulkWriteOps.push({ updateOne });
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
if (bulkWriteOps.length > 0) {
|
|
336
|
+
const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
337
|
+
return { bulkWriteResult };
|
|
338
|
+
}
|
|
339
|
+
return {};
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
deleteRoomByBranchCode(screeningRoom, options) {
|
|
343
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
344
|
+
const { project, parentOrganization, movieTheaterCode } = options;
|
|
345
|
+
const doc = yield this.placeModel.findOneAndDelete(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: screeningRoom.branchCode }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
|
|
346
|
+
? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
|
|
177
347
|
: undefined), {
|
|
178
348
|
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
179
349
|
})
|
|
@@ -194,130 +364,19 @@ class ScreeningRoomRepo {
|
|
|
194
364
|
.exec();
|
|
195
365
|
});
|
|
196
366
|
}
|
|
197
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
198
367
|
searchScreeningRooms(searchConditions) {
|
|
199
368
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
var _a, _b
|
|
201
|
-
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
|
|
202
|
-
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
203
|
-
if (typeof projectIdEq === 'string') {
|
|
204
|
-
matchStages.push({
|
|
205
|
-
$match: { 'project.id': { $eq: projectIdEq } }
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
209
|
-
if (typeof parentOrganizationIdEq === 'string') {
|
|
210
|
-
matchStages.push({
|
|
211
|
-
$match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
// 施設ID
|
|
215
|
-
const containedInPlaceIdEq = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
216
|
-
if (typeof containedInPlaceIdEq === 'string') {
|
|
217
|
-
matchStages.push({
|
|
218
|
-
$match: {
|
|
219
|
-
'containedInPlace.id': {
|
|
220
|
-
$exists: true,
|
|
221
|
-
$eq: containedInPlaceIdEq
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
if (searchConditions.containedInPlace !== undefined) {
|
|
227
|
-
// 施設コード
|
|
228
|
-
if (searchConditions.containedInPlace.branchCode !== undefined) {
|
|
229
|
-
if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
|
|
230
|
-
matchStages.push({
|
|
231
|
-
$match: {
|
|
232
|
-
'containedInPlace.branchCode': {
|
|
233
|
-
$exists: true,
|
|
234
|
-
$eq: searchConditions.containedInPlace.branchCode.$eq
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
const branchCodeEq = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
242
|
-
if (typeof branchCodeEq === 'string') {
|
|
243
|
-
matchStages.push({
|
|
244
|
-
$match: {
|
|
245
|
-
branchCode: { $eq: branchCodeEq }
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
const branchCodeIn = (_h = searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$in;
|
|
250
|
-
if (Array.isArray(branchCodeIn)) {
|
|
251
|
-
matchStages.push({
|
|
252
|
-
$match: {
|
|
253
|
-
branchCode: { $in: branchCodeIn }
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
const branchCodeRegex = (_j = searchConditions.branchCode) === null || _j === void 0 ? void 0 : _j.$regex;
|
|
258
|
-
if (typeof branchCodeRegex === 'string') {
|
|
259
|
-
matchStages.push({
|
|
260
|
-
$match: {
|
|
261
|
-
branchCode: {
|
|
262
|
-
$regex: new RegExp(branchCodeRegex)
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
const nameCodeRegex = (_k = searchConditions.name) === null || _k === void 0 ? void 0 : _k.$regex;
|
|
268
|
-
if (typeof nameCodeRegex === 'string') {
|
|
269
|
-
matchStages.push({
|
|
270
|
-
$match: {
|
|
271
|
-
$or: [
|
|
272
|
-
{
|
|
273
|
-
'name.ja': {
|
|
274
|
-
$exists: true,
|
|
275
|
-
$regex: new RegExp(nameCodeRegex)
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
'name.en': {
|
|
280
|
-
$exists: true,
|
|
281
|
-
$regex: new RegExp(nameCodeRegex)
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
const openSeatingAllowed = searchConditions.openSeatingAllowed;
|
|
289
|
-
if (typeof openSeatingAllowed === 'boolean') {
|
|
290
|
-
matchStages.push({
|
|
291
|
-
$match: {
|
|
292
|
-
openSeatingAllowed: {
|
|
293
|
-
$exists: true,
|
|
294
|
-
$eq: openSeatingAllowed
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
300
|
-
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
301
|
-
matchStages.push({
|
|
302
|
-
$match: {
|
|
303
|
-
additionalProperty: {
|
|
304
|
-
$exists: true,
|
|
305
|
-
$elemMatch: additionalPropertyElemMatch
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
}
|
|
369
|
+
var _a, _b;
|
|
310
370
|
const aggregate = this.placeModel.aggregate([
|
|
311
371
|
{ $sort: { branchCode: factory.sortType.Ascending } },
|
|
312
|
-
|
|
313
|
-
...matchStages,
|
|
372
|
+
...ScreeningRoomRepo.CREATE_ROOM_MONGO_CONDITIONS(searchConditions),
|
|
314
373
|
{
|
|
315
374
|
$project: Object.assign(Object.assign({ _id: 0, typeOf: '$typeOf', branchCode: '$branchCode', name: '$name', address: '$address', containedInPlace: {
|
|
316
375
|
id: '$containedInPlace.id',
|
|
317
376
|
typeOf: '$containedInPlace.typeOf',
|
|
318
377
|
branchCode: '$containedInPlace.branchCode',
|
|
319
378
|
name: '$containedInPlace.name'
|
|
320
|
-
}, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((
|
|
379
|
+
}, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((_a = searchConditions.$projection) === null || _a === void 0 ? void 0 : _a.sectionCount) === 1)
|
|
321
380
|
? {
|
|
322
381
|
sectionCount: {
|
|
323
382
|
$cond: {
|
|
@@ -327,7 +386,7 @@ class ScreeningRoomRepo {
|
|
|
327
386
|
}
|
|
328
387
|
}
|
|
329
388
|
}
|
|
330
|
-
: undefined), (((
|
|
389
|
+
: undefined), (((_b = searchConditions.$projection) === null || _b === void 0 ? void 0 : _b.seatCount) === 1)
|
|
331
390
|
? {
|
|
332
391
|
seatCount: {
|
|
333
392
|
$sum: {
|
|
@@ -359,6 +418,34 @@ class ScreeningRoomRepo {
|
|
|
359
418
|
.exec();
|
|
360
419
|
});
|
|
361
420
|
}
|
|
421
|
+
findRooms(params) {
|
|
422
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
423
|
+
const aggregate = this.placeModel.aggregate([
|
|
424
|
+
...ScreeningRoomRepo.CREATE_ROOM_MONGO_CONDITIONS(params),
|
|
425
|
+
{
|
|
426
|
+
$project: {
|
|
427
|
+
_id: 0,
|
|
428
|
+
branchCode: '$branchCode',
|
|
429
|
+
name: '$name',
|
|
430
|
+
address: '$address',
|
|
431
|
+
openSeatingAllowed: '$openSeatingAllowed',
|
|
432
|
+
additionalProperty: '$additionalProperty',
|
|
433
|
+
maximumAttendeeCapacity: '$maximumAttendeeCapacity'
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
{ $sort: { branchCode: factory.sortType.Ascending } }
|
|
437
|
+
]);
|
|
438
|
+
const { limit, page } = params;
|
|
439
|
+
if (typeof limit === 'number' && limit > 0) {
|
|
440
|
+
const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
|
|
441
|
+
aggregate.skip(limit * (pageMustBePositive - 1))
|
|
442
|
+
.limit(limit);
|
|
443
|
+
}
|
|
444
|
+
return aggregate
|
|
445
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
446
|
+
.exec();
|
|
447
|
+
});
|
|
448
|
+
}
|
|
362
449
|
/**
|
|
363
450
|
* セクションと座席も含めたひとつのルームを取得する
|
|
364
451
|
*/
|
|
@@ -430,5 +517,10 @@ class ScreeningRoomRepo {
|
|
|
430
517
|
.exec();
|
|
431
518
|
});
|
|
432
519
|
}
|
|
520
|
+
getCursor(conditions, projection) {
|
|
521
|
+
return this.placeModel.find(conditions, projection)
|
|
522
|
+
.sort({ branchCode: factory.sortType.Ascending })
|
|
523
|
+
.cursor();
|
|
524
|
+
}
|
|
433
525
|
}
|
|
434
526
|
exports.ScreeningRoomRepo = ScreeningRoomRepo;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
+
import { AnyExpression, Connection, PipelineStage } from 'mongoose';
|
|
2
3
|
import * as factory from '../../factory';
|
|
3
4
|
type IMatchStage = PipelineStage.Match;
|
|
5
|
+
type ICreatingSeat = Pick<factory.place.seat.IPlace, 'additionalProperty' | 'branchCode' | 'name' | 'maximumAttendeeCapacity' | 'seatingType'>;
|
|
6
|
+
interface IUpdateOptions {
|
|
7
|
+
project: {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
parentOrganization?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
movieTheaterCode: string;
|
|
14
|
+
roomCode: string;
|
|
15
|
+
sectionCode: string;
|
|
16
|
+
}
|
|
4
17
|
/**
|
|
5
18
|
* 座席編集時レスポンス
|
|
6
19
|
*/
|
|
@@ -27,25 +40,27 @@ export declare class SeatRepo {
|
|
|
27
40
|
static CREATE_MATCH_STAGES(params: factory.place.seat.ISearchConditions, options: {
|
|
28
41
|
filterTypeOf: boolean;
|
|
29
42
|
}): IMatchStage[];
|
|
30
|
-
createSeat(seat:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
id?: string;
|
|
43
|
+
createSeat(seat: ICreatingSeat, options: IUpdateOptions): Promise<IUpdateSeatResult>;
|
|
44
|
+
/**
|
|
45
|
+
* コードをキーにして冪等追加
|
|
46
|
+
*/
|
|
47
|
+
addSeatsByBranchCodeIfNotExist(params: {
|
|
48
|
+
$set: ICreatingSeat;
|
|
49
|
+
}[], options: IUpdateOptions): Promise<{
|
|
50
|
+
bulkWriteResult: BulkWriteResult;
|
|
51
|
+
} | void>;
|
|
52
|
+
/**
|
|
53
|
+
* コードをキーにして冪等編集
|
|
54
|
+
*/
|
|
55
|
+
updateSeatsByBranchCode(params: {
|
|
56
|
+
$set: ICreatingSeat;
|
|
57
|
+
$unset?: {
|
|
58
|
+
[key in keyof ICreatingSeat]?: 1;
|
|
47
59
|
};
|
|
48
|
-
},
|
|
60
|
+
}[], options: IUpdateOptions): Promise<{
|
|
61
|
+
bulkWriteResult: BulkWriteResult;
|
|
62
|
+
} | void>;
|
|
63
|
+
updateSeatByBranchCode(seat: ICreatingSeat, $unset: any, options: IUpdateOptions): Promise<IUpdateSeatResult>;
|
|
49
64
|
searchSeats(params: factory.place.seat.ISearchConditions): Promise<factory.place.seat.IPlace[]>;
|
|
50
65
|
projectSeatsByScreeningRoom(params: Pick<factory.place.seat.ISearchConditions, '$projection' | 'additionalProperty' | 'branchCode' | 'seatingType' | 'name' | 'limit' | 'page'> & {
|
|
51
66
|
project: {
|
|
@@ -137,35 +152,22 @@ export declare class SeatRepo {
|
|
|
137
152
|
};
|
|
138
153
|
};
|
|
139
154
|
}): Promise<string[]>;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
parentOrganization?: {
|
|
145
|
-
id?: string;
|
|
146
|
-
};
|
|
155
|
+
/**
|
|
156
|
+
* コードをキーにして冪等削除
|
|
157
|
+
*/
|
|
158
|
+
deleteSeatsByBranchCode(params: {
|
|
147
159
|
/**
|
|
148
160
|
* 座席コード
|
|
149
161
|
*/
|
|
150
162
|
branchCode: string;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
branchCode: string;
|
|
161
|
-
containedInPlace: {
|
|
162
|
-
/**
|
|
163
|
-
* 施設コード
|
|
164
|
-
*/
|
|
165
|
-
branchCode: string;
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
}): Promise<IUpdateSeatResult>;
|
|
163
|
+
}[], options: IUpdateOptions): Promise<{
|
|
164
|
+
bulkWriteResult: BulkWriteResult;
|
|
165
|
+
} | void>;
|
|
166
|
+
deleteSeatByBranchCode(seat: {
|
|
167
|
+
/**
|
|
168
|
+
* 座席コード
|
|
169
|
+
*/
|
|
170
|
+
branchCode: string;
|
|
171
|
+
}, options: IUpdateOptions): Promise<IUpdateSeatResult>;
|
|
170
172
|
}
|
|
171
173
|
export {};
|