@chevre/domain 21.28.0-alpha.2 → 21.28.0-alpha.4
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/aggregation/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +1 -1
- package/example/src/chevre/importEventsFromCOA.ts +2 -2
- package/example/src/chevre/migrateMovieTheaterAdditionalProperties.ts +1 -1
- package/lib/chevre/repo/place/movieTheater.d.ts +47 -0
- package/lib/chevre/repo/place/movieTheater.js +30 -0
- package/lib/chevre/repo/place/screeningRoom.d.ts +113 -0
- package/lib/chevre/repo/{place.js → place/screeningRoom.js} +17 -262
- package/lib/chevre/repo/place/section.d.ts +64 -0
- package/lib/chevre/repo/place/section.js +274 -0
- package/lib/chevre/repository.d.ts +16 -5
- package/lib/chevre/repository.js +34 -15
- package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/event.d.ts +2 -2
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/project.d.ts +6 -3
- package/lib/chevre/service/project.js +2 -2
- package/lib/chevre/service/task/aggregateOffers.js +2 -2
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -2
- package/lib/chevre/service/task/importEventsFromCOA.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +8 -3
- package/lib/chevre/service/task/onResourceUpdated.js +4 -4
- package/package.json +3 -3
- package/lib/chevre/repo/place.d.ts +0 -207
|
@@ -26,7 +26,7 @@ async function main() {
|
|
|
26
26
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
27
27
|
offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
|
|
28
28
|
offerRateLimit: await chevre.repository.rateLimit.Offer.createInstance(client),
|
|
29
|
-
|
|
29
|
+
screeningRoom: await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection),
|
|
30
30
|
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
31
31
|
reservation: await chevre.repository.Reservation.createInstance(mongoose.connection),
|
|
32
32
|
task: await chevre.repository.Task.createInstance(mongoose.connection)
|
|
@@ -44,7 +44,7 @@ async function main() {
|
|
|
44
44
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
45
45
|
offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
|
|
46
46
|
offerRateLimit: await chevre.repository.rateLimit.Offer.createInstance(client),
|
|
47
|
-
|
|
47
|
+
screeningRoom: await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection),
|
|
48
48
|
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
49
49
|
reservation: await chevre.repository.Reservation.createInstance(mongoose.connection),
|
|
50
50
|
task: await chevre.repository.Task.createInstance(mongoose.connection)
|
|
@@ -14,7 +14,7 @@ async function main() {
|
|
|
14
14
|
const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
15
15
|
const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
|
|
16
16
|
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
17
|
-
const
|
|
17
|
+
const screeningRoomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
18
18
|
const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
19
19
|
const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
|
|
20
20
|
|
|
@@ -38,7 +38,7 @@ async function main() {
|
|
|
38
38
|
creativeWork: creativeWorkRepo,
|
|
39
39
|
event: eventRepo,
|
|
40
40
|
movieTheater: movieTheaterRepo,
|
|
41
|
-
|
|
41
|
+
screeningRoom: screeningRoomRepo,
|
|
42
42
|
seller: sellerRepo
|
|
43
43
|
});
|
|
44
44
|
console.log('imported');
|
|
@@ -12,7 +12,7 @@ async function main() {
|
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
14
|
const additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
|
|
15
|
-
const placeRepo = await chevre.repository.
|
|
15
|
+
const placeRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
16
16
|
|
|
17
17
|
const cursor = placeRepo.getCursor(
|
|
18
18
|
{
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
1
25
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
26
|
import * as factory from '../../factory';
|
|
3
27
|
export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
|
|
@@ -27,5 +51,28 @@ export declare class MongoRepository {
|
|
|
27
51
|
};
|
|
28
52
|
id: string;
|
|
29
53
|
}): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* 販売者に属する施設を全削除
|
|
56
|
+
*/
|
|
57
|
+
deleteMovieTheatersByParentOrganizationId(params: {
|
|
58
|
+
project: {
|
|
59
|
+
id: string;
|
|
60
|
+
};
|
|
61
|
+
parentOrganization: {
|
|
62
|
+
/**
|
|
63
|
+
* 販売者ID
|
|
64
|
+
*/
|
|
65
|
+
id: string;
|
|
66
|
+
};
|
|
67
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
68
|
+
/**
|
|
69
|
+
* プロジェクトに属する施設を全削除
|
|
70
|
+
*/
|
|
71
|
+
deleteMovieTheatersByProject(params: {
|
|
72
|
+
project: {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
30
77
|
}
|
|
31
78
|
export {};
|
|
@@ -277,5 +277,35 @@ class MongoRepository {
|
|
|
277
277
|
});
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* 販売者に属する施設を全削除
|
|
282
|
+
*/
|
|
283
|
+
deleteMovieTheatersByParentOrganizationId(params) {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
return this.placeModel.deleteMany({
|
|
286
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
287
|
+
'project.id': { $eq: params.project.id },
|
|
288
|
+
'parentOrganization.id': { $exists: true, $eq: params.parentOrganization.id }
|
|
289
|
+
})
|
|
290
|
+
.exec();
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* プロジェクトに属する施設を全削除
|
|
295
|
+
*/
|
|
296
|
+
deleteMovieTheatersByProject(params) {
|
|
297
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
+
yield this.placeModel.deleteMany({
|
|
299
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
300
|
+
'project.id': { $eq: params.project.id }
|
|
301
|
+
})
|
|
302
|
+
.exec();
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
getCursor(conditions, projection) {
|
|
306
|
+
return this.placeModel.find(conditions, projection)
|
|
307
|
+
.sort({ branchCode: factory.sortType.Ascending })
|
|
308
|
+
.cursor();
|
|
309
|
+
}
|
|
280
310
|
}
|
|
281
311
|
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../../factory';
|
|
3
|
+
export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
|
|
4
|
+
/**
|
|
5
|
+
* ルーム編集時レスポンス
|
|
6
|
+
*/
|
|
7
|
+
interface IUpdateScreeningRoomResult {
|
|
8
|
+
containedInPlace: {
|
|
9
|
+
/**
|
|
10
|
+
* 施設ID
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
typeOf: factory.placeType.ScreeningRoom;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ルームリポジトリ
|
|
18
|
+
*/
|
|
19
|
+
export declare class MongoRepository {
|
|
20
|
+
private readonly placeModel;
|
|
21
|
+
constructor(connection: Connection);
|
|
22
|
+
createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
|
|
23
|
+
containedInPlace: {
|
|
24
|
+
branchCode: string;
|
|
25
|
+
};
|
|
26
|
+
parentOrganization?: {
|
|
27
|
+
id?: string;
|
|
28
|
+
};
|
|
29
|
+
}): Promise<IUpdateScreeningRoomResult>;
|
|
30
|
+
updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
|
|
31
|
+
containedInPlace: {
|
|
32
|
+
branchCode: string;
|
|
33
|
+
};
|
|
34
|
+
parentOrganization?: {
|
|
35
|
+
id?: string;
|
|
36
|
+
};
|
|
37
|
+
}, $unset: any): Promise<IUpdateScreeningRoomResult>;
|
|
38
|
+
updateScreeningRoomsByContainedInPlaceId(screeningRoom: {
|
|
39
|
+
project: {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
containedInPlace: Pick<factory.place.screeningRoom.IContainedInPlace, 'id' | 'name'>;
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
deleteScreeningRoom(screeningRoom: {
|
|
45
|
+
project: {
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
parentOrganization?: {
|
|
49
|
+
id?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* ルームコード
|
|
53
|
+
*/
|
|
54
|
+
branchCode: string;
|
|
55
|
+
containedInPlace: {
|
|
56
|
+
/**
|
|
57
|
+
* 施設コード
|
|
58
|
+
*/
|
|
59
|
+
branchCode: string;
|
|
60
|
+
};
|
|
61
|
+
}): Promise<IUpdateScreeningRoomResult>;
|
|
62
|
+
deleteScreeningRoomsByMovieTheaterId(params: {
|
|
63
|
+
project: {
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
66
|
+
containedInPlace: {
|
|
67
|
+
/**
|
|
68
|
+
* 施設ID
|
|
69
|
+
*/
|
|
70
|
+
id: string;
|
|
71
|
+
};
|
|
72
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
73
|
+
searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
|
|
74
|
+
/**
|
|
75
|
+
* セクションと座席も含めたひとつのルームを取得する
|
|
76
|
+
*/
|
|
77
|
+
findScreeningRoomsByBranchCode(params: {
|
|
78
|
+
project: {
|
|
79
|
+
id: string;
|
|
80
|
+
};
|
|
81
|
+
branchCode: {
|
|
82
|
+
$eq: string;
|
|
83
|
+
};
|
|
84
|
+
containedInPlace: {
|
|
85
|
+
id: {
|
|
86
|
+
$eq: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
}): Promise<IScreeningRoomFoundByBranchCode>;
|
|
90
|
+
/**
|
|
91
|
+
* 販売者に属するルームを全削除
|
|
92
|
+
*/
|
|
93
|
+
deleteScreeningRoomsByParentOrganizationId(params: {
|
|
94
|
+
project: {
|
|
95
|
+
id: string;
|
|
96
|
+
};
|
|
97
|
+
parentOrganization: {
|
|
98
|
+
/**
|
|
99
|
+
* 販売者ID
|
|
100
|
+
*/
|
|
101
|
+
id: string;
|
|
102
|
+
};
|
|
103
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
104
|
+
/**
|
|
105
|
+
* プロジェクトに属するルームを全削除
|
|
106
|
+
*/
|
|
107
|
+
deleteScreeningRoomsByProject(params: {
|
|
108
|
+
project: {
|
|
109
|
+
id: string;
|
|
110
|
+
};
|
|
111
|
+
}): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
export {};
|
|
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MongoRepository = void 0;
|
|
13
|
-
const factory = require("
|
|
14
|
-
const settings_1 = require("
|
|
15
|
-
const place_1 = require("
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const settings_1 = require("../../settings");
|
|
15
|
+
const place_1 = require("../mongoose/schemas/place");
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* ルームリポジトリ
|
|
18
18
|
*/
|
|
19
19
|
class MongoRepository {
|
|
20
20
|
constructor(connection) {
|
|
@@ -130,256 +130,6 @@ class MongoRepository {
|
|
|
130
130
|
.exec();
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
// tslint:disable-next-line:max-func-body-length
|
|
134
|
-
createScreeningRoomSection(screeningRoomSection) {
|
|
135
|
-
var _a;
|
|
136
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
138
|
-
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
139
|
-
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
140
|
-
}
|
|
141
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
142
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
143
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
144
|
-
}
|
|
145
|
-
// 施設存在確認
|
|
146
|
-
let doc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoomSection.project.id }, branchCode: { $eq: movieTheater.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
147
|
-
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
|
|
148
|
-
: undefined), { _id: 1 })
|
|
149
|
-
.exec();
|
|
150
|
-
if (doc === null) {
|
|
151
|
-
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
152
|
-
}
|
|
153
|
-
// セクションコードが存在しなければ追加する
|
|
154
|
-
doc = yield this.placeModel.findOneAndUpdate({
|
|
155
|
-
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
156
|
-
'project.id': { $eq: screeningRoomSection.project.id },
|
|
157
|
-
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
158
|
-
branchCode: { $eq: screeningRoom.branchCode },
|
|
159
|
-
'containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
|
|
160
|
-
}, {
|
|
161
|
-
$push: {
|
|
162
|
-
containsPlace: Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
|
|
163
|
-
? { additionalProperty: screeningRoomSection.additionalProperty }
|
|
164
|
-
: undefined)
|
|
165
|
-
}
|
|
166
|
-
}, {
|
|
167
|
-
new: true,
|
|
168
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
169
|
-
})
|
|
170
|
-
.exec();
|
|
171
|
-
// 存在しなければコード重複
|
|
172
|
-
if (doc === null) {
|
|
173
|
-
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
|
|
174
|
-
}
|
|
175
|
-
return doc.toObject();
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
// tslint:disable-next-line:max-func-body-length
|
|
179
|
-
updateScreeningRoomSection(screeningRoomSection, $unset) {
|
|
180
|
-
var _a;
|
|
181
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
183
|
-
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
184
|
-
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
185
|
-
}
|
|
186
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
187
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
188
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
189
|
-
}
|
|
190
|
-
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoomSection.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode }, branchCode: { $eq: screeningRoom.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
191
|
-
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
|
|
192
|
-
: undefined), Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
|
|
193
|
-
? {
|
|
194
|
-
'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
|
|
195
|
-
}
|
|
196
|
-
: undefined), (Array.isArray(screeningRoomSection.additionalProperty))
|
|
197
|
-
? {
|
|
198
|
-
'containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
|
|
199
|
-
}
|
|
200
|
-
: undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
|
|
201
|
-
? {
|
|
202
|
-
'containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
|
|
203
|
-
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);
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
: undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
|
|
207
|
-
new: true,
|
|
208
|
-
arrayFilters: [
|
|
209
|
-
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
|
|
210
|
-
],
|
|
211
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
212
|
-
})
|
|
213
|
-
.exec();
|
|
214
|
-
if (doc === null) {
|
|
215
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
216
|
-
}
|
|
217
|
-
return doc.toObject();
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
221
|
-
searchScreeningRoomSections(searchConditions) {
|
|
222
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
223
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
-
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
|
|
225
|
-
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
226
|
-
if (typeof projectIdEq === 'string') {
|
|
227
|
-
matchStages.push({
|
|
228
|
-
$match: { 'project.id': { $eq: projectIdEq } }
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
232
|
-
if (typeof parentOrganizationIdEq === 'string') {
|
|
233
|
-
matchStages.push({
|
|
234
|
-
$match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
// 施設コード
|
|
238
|
-
const movieTheaterBranchCodeEq = (_g = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
239
|
-
if (typeof movieTheaterBranchCodeEq === 'string') {
|
|
240
|
-
matchStages.push({
|
|
241
|
-
$match: {
|
|
242
|
-
'containedInPlace.branchCode': {
|
|
243
|
-
$exists: true,
|
|
244
|
-
$eq: movieTheaterBranchCodeEq
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
// ルームコード
|
|
250
|
-
const containedInPlaceBranchCodeEq = (_j = (_h = searchConditions.containedInPlace) === null || _h === void 0 ? void 0 : _h.branchCode) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
251
|
-
if (typeof containedInPlaceBranchCodeEq === 'string') {
|
|
252
|
-
matchStages.push({
|
|
253
|
-
$match: {
|
|
254
|
-
branchCode: {
|
|
255
|
-
$eq: containedInPlaceBranchCodeEq
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
// セクションコード
|
|
261
|
-
const sectionBranchCodeEq = (_k = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
262
|
-
if (typeof sectionBranchCodeEq === 'string') {
|
|
263
|
-
matchStages.push({
|
|
264
|
-
$match: {
|
|
265
|
-
'containsPlace.branchCode': {
|
|
266
|
-
$exists: true,
|
|
267
|
-
$eq: sectionBranchCodeEq
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
const nameCodeRegex = (_l = searchConditions.name) === null || _l === void 0 ? void 0 : _l.$regex;
|
|
273
|
-
if (typeof nameCodeRegex === 'string') {
|
|
274
|
-
matchStages.push({
|
|
275
|
-
$match: {
|
|
276
|
-
$or: [
|
|
277
|
-
{
|
|
278
|
-
'containsPlace.name.ja': {
|
|
279
|
-
$exists: true,
|
|
280
|
-
$regex: new RegExp(nameCodeRegex)
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
'containsPlace.name.en': {
|
|
285
|
-
$exists: true,
|
|
286
|
-
$regex: new RegExp(nameCodeRegex)
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
]
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
const branchCodeRegex = (_m = searchConditions.branchCode) === null || _m === void 0 ? void 0 : _m.$regex;
|
|
294
|
-
if (typeof branchCodeRegex === 'string') {
|
|
295
|
-
matchStages.push({
|
|
296
|
-
$match: {
|
|
297
|
-
'containsPlace.branchCode': {
|
|
298
|
-
$exists: true,
|
|
299
|
-
$regex: new RegExp(branchCodeRegex)
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
const additionalPropertyElemMatch = (_o = searchConditions.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
|
|
305
|
-
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
306
|
-
matchStages.push({
|
|
307
|
-
$match: {
|
|
308
|
-
'containsPlace.additionalProperty': {
|
|
309
|
-
$exists: true,
|
|
310
|
-
$elemMatch: additionalPropertyElemMatch
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
const aggregate = this.placeModel.aggregate([
|
|
316
|
-
{ $unwind: '$containsPlace' },
|
|
317
|
-
...matchStages,
|
|
318
|
-
{
|
|
319
|
-
$project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.containedInPlace) === 1)
|
|
320
|
-
? {
|
|
321
|
-
containedInPlace: {
|
|
322
|
-
typeOf: '$typeOf',
|
|
323
|
-
branchCode: '$branchCode',
|
|
324
|
-
name: '$name',
|
|
325
|
-
containedInPlace: {
|
|
326
|
-
id: '$containedInPlace.id',
|
|
327
|
-
typeOf: '$containedInPlace.typeOf',
|
|
328
|
-
branchCode: '$containedInPlace.branchCode',
|
|
329
|
-
name: '$containedInPlace.name'
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
: undefined), (((_q = searchConditions.$projection) === null || _q === void 0 ? void 0 : _q.seatCount) === 1)
|
|
334
|
-
? {
|
|
335
|
-
seatCount: {
|
|
336
|
-
$cond: {
|
|
337
|
-
if: { $isArray: '$containsPlace.containsPlace' },
|
|
338
|
-
then: { $size: '$containsPlace.containsPlace' },
|
|
339
|
-
else: 0
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
: undefined)
|
|
344
|
-
}
|
|
345
|
-
]);
|
|
346
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
347
|
-
/* istanbul ignore else */
|
|
348
|
-
if (typeof searchConditions.limit === 'number' && searchConditions.limit > 0) {
|
|
349
|
-
const page = (typeof searchConditions.page === 'number' && searchConditions.page > 0) ? searchConditions.page : 1;
|
|
350
|
-
aggregate.limit(searchConditions.limit * page)
|
|
351
|
-
.skip(searchConditions.limit * (page - 1));
|
|
352
|
-
}
|
|
353
|
-
return aggregate
|
|
354
|
-
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
355
|
-
.exec();
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
deleteScreeningRoomSection(screeningRoomSection) {
|
|
359
|
-
var _a;
|
|
360
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
361
|
-
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoomSection.project.id }, 'containedInPlace.branchCode': {
|
|
362
|
-
$exists: true,
|
|
363
|
-
$eq: screeningRoomSection.containedInPlace.containedInPlace.branchCode
|
|
364
|
-
}, branchCode: { $eq: screeningRoomSection.containedInPlace.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
365
|
-
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
|
|
366
|
-
: undefined), {
|
|
367
|
-
$pull: {
|
|
368
|
-
containsPlace: {
|
|
369
|
-
branchCode: screeningRoomSection.branchCode
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}, {
|
|
373
|
-
new: true,
|
|
374
|
-
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
375
|
-
})
|
|
376
|
-
.exec();
|
|
377
|
-
if (doc === null) {
|
|
378
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
379
|
-
}
|
|
380
|
-
return doc.toObject();
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
133
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
384
134
|
searchScreeningRooms(searchConditions) {
|
|
385
135
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
@@ -545,6 +295,9 @@ class MongoRepository {
|
|
|
545
295
|
.exec();
|
|
546
296
|
});
|
|
547
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* セクションと座席も含めたひとつのルームを取得する
|
|
300
|
+
*/
|
|
548
301
|
findScreeningRoomsByBranchCode(params) {
|
|
549
302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
550
303
|
const matchStages = [
|
|
@@ -554,7 +307,6 @@ class MongoRepository {
|
|
|
554
307
|
{ $match: { branchCode: { $eq: params.branchCode.$eq } } }
|
|
555
308
|
];
|
|
556
309
|
const aggregate = this.placeModel.aggregate([
|
|
557
|
-
// { $unwind: '$containsPlace' },
|
|
558
310
|
...matchStages,
|
|
559
311
|
{
|
|
560
312
|
$project: {
|
|
@@ -589,27 +341,30 @@ class MongoRepository {
|
|
|
589
341
|
return docs[0];
|
|
590
342
|
});
|
|
591
343
|
}
|
|
592
|
-
|
|
344
|
+
/**
|
|
345
|
+
* 販売者に属するルームを全削除
|
|
346
|
+
*/
|
|
347
|
+
deleteScreeningRoomsByParentOrganizationId(params) {
|
|
593
348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
594
349
|
return this.placeModel.deleteMany({
|
|
350
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
595
351
|
'project.id': { $eq: params.project.id },
|
|
596
352
|
'parentOrganization.id': { $exists: true, $eq: params.parentOrganization.id }
|
|
597
353
|
})
|
|
598
354
|
.exec();
|
|
599
355
|
});
|
|
600
356
|
}
|
|
601
|
-
|
|
357
|
+
/**
|
|
358
|
+
* プロジェクトに属するルームを全削除
|
|
359
|
+
*/
|
|
360
|
+
deleteScreeningRoomsByProject(params) {
|
|
602
361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
603
362
|
yield this.placeModel.deleteMany({
|
|
363
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
604
364
|
'project.id': { $eq: params.project.id }
|
|
605
365
|
})
|
|
606
366
|
.exec();
|
|
607
367
|
});
|
|
608
368
|
}
|
|
609
|
-
getCursor(conditions, projection) {
|
|
610
|
-
return this.placeModel.find(conditions, projection)
|
|
611
|
-
.sort({ branchCode: factory.sortType.Ascending })
|
|
612
|
-
.cursor();
|
|
613
|
-
}
|
|
614
369
|
}
|
|
615
370
|
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../../factory';
|
|
3
|
+
type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
|
|
4
|
+
/**
|
|
5
|
+
* セクション編集時レスポンス
|
|
6
|
+
*/
|
|
7
|
+
interface IUpdateSectionResult {
|
|
8
|
+
containedInPlace: {
|
|
9
|
+
/**
|
|
10
|
+
* 施設ID
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
typeOf: factory.placeType.ScreeningRoom;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* セクションリポジトリ
|
|
18
|
+
*/
|
|
19
|
+
export declare class MongoRepository {
|
|
20
|
+
private readonly placeModel;
|
|
21
|
+
constructor(connection: Connection);
|
|
22
|
+
createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace & {
|
|
23
|
+
parentOrganization?: {
|
|
24
|
+
id?: string;
|
|
25
|
+
};
|
|
26
|
+
}): Promise<IUpdateSectionResult>;
|
|
27
|
+
updateScreeningRoomSection(screeningRoomSection: Omit<factory.place.screeningRoomSection.IPlace, 'containedInPlace'> & {
|
|
28
|
+
containedInPlace: {
|
|
29
|
+
branchCode: string;
|
|
30
|
+
containedInPlace: {
|
|
31
|
+
branchCode: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
parentOrganization?: {
|
|
35
|
+
id?: string;
|
|
36
|
+
};
|
|
37
|
+
}, $unset: any): Promise<IUpdateSectionResult>;
|
|
38
|
+
searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
|
|
39
|
+
deleteScreeningRoomSection(screeningRoomSection: {
|
|
40
|
+
project: {
|
|
41
|
+
id: string;
|
|
42
|
+
};
|
|
43
|
+
parentOrganization?: {
|
|
44
|
+
id?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* セクションコード
|
|
48
|
+
*/
|
|
49
|
+
branchCode: string;
|
|
50
|
+
containedInPlace: {
|
|
51
|
+
/**
|
|
52
|
+
* ルームコード
|
|
53
|
+
*/
|
|
54
|
+
branchCode: string;
|
|
55
|
+
containedInPlace: {
|
|
56
|
+
/**
|
|
57
|
+
* 施設コード
|
|
58
|
+
*/
|
|
59
|
+
branchCode: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}): Promise<IUpdateSectionResult>;
|
|
63
|
+
}
|
|
64
|
+
export {};
|