@chevre/domain 21.27.0 → 21.28.0-alpha.1
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/importEventsFromCOA.ts +2 -0
- package/lib/chevre/repo/place/busStop.d.ts +27 -0
- package/lib/chevre/repo/place/busStop.js +199 -0
- package/lib/chevre/repo/place/movieTheater.d.ts +31 -0
- package/lib/chevre/repo/place/movieTheater.js +281 -0
- package/lib/chevre/repo/place/seat.d.ts +75 -0
- package/lib/chevre/repo/place/seat.js +361 -0
- package/lib/chevre/repo/place.d.ts +1 -120
- package/lib/chevre/repo/place.js +8 -801
- package/lib/chevre/repository.d.ts +27 -0
- package/lib/chevre/repository.js +51 -0
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve.d.ts +3 -3
- package/lib/chevre/service/assetTransaction/reserve.js +1 -1
- package/lib/chevre/service/event/createEvent.d.ts +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.d.ts +2 -0
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +2 -2
- package/lib/chevre/service/offer.d.ts +2 -2
- package/lib/chevre/service/offer.js +1 -1
- package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +2 -2
- package/lib/chevre/service/task/createEvent.js +2 -2
- package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated.js +4 -2
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ async function main() {
|
|
|
15
15
|
const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
|
|
16
16
|
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
17
17
|
const placeRepo = await chevre.repository.Place.createInstance(mongoose.connection);
|
|
18
|
+
const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
18
19
|
const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
|
|
19
20
|
|
|
20
21
|
await (await chevre.service.event.createService()).importFromCOA({
|
|
@@ -36,6 +37,7 @@ async function main() {
|
|
|
36
37
|
categoryCode: categoryCodeRepo,
|
|
37
38
|
creativeWork: creativeWorkRepo,
|
|
38
39
|
event: eventRepo,
|
|
40
|
+
movieTheater: movieTheaterRepo,
|
|
39
41
|
place: placeRepo,
|
|
40
42
|
seller: sellerRepo
|
|
41
43
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
|
+
import * as factory from '../../factory';
|
|
3
|
+
/**
|
|
4
|
+
* ターミナルリポジトリ
|
|
5
|
+
*/
|
|
6
|
+
export declare class MongoRepository {
|
|
7
|
+
private readonly placeModel;
|
|
8
|
+
constructor(connection: Connection);
|
|
9
|
+
static CREATE_BUS_STOP_MONGO_CONDITIONS(params: factory.place.busStop.ISearchConditions): FilterQuery<import("@chevre/factory/lib/place/busStop").IPlace>[];
|
|
10
|
+
saveBusStop(params: factory.place.busStop.IPlace): Promise<factory.place.busStop.IPlace>;
|
|
11
|
+
findBusStopByBranchCode(params: {
|
|
12
|
+
project: {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
branchCode: string;
|
|
16
|
+
}): Promise<factory.place.movieTheater.IPlace>;
|
|
17
|
+
searchBusStops(params: factory.place.busStop.ISearchConditions): Promise<factory.place.busStop.IPlace[]>;
|
|
18
|
+
findBusStopById(params: {
|
|
19
|
+
id: string;
|
|
20
|
+
}, projection?: any): Promise<factory.place.busStop.IPlace>;
|
|
21
|
+
deleteBusStopById(params: {
|
|
22
|
+
project: {
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
id: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MongoRepository = void 0;
|
|
24
|
+
const factory = require("../../factory");
|
|
25
|
+
const settings_1 = require("../../settings");
|
|
26
|
+
const place_1 = require("../mongoose/schemas/place");
|
|
27
|
+
/**
|
|
28
|
+
* ターミナルリポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class MongoRepository {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
33
|
+
}
|
|
34
|
+
// tslint:disable-next-line:max-func-body-length
|
|
35
|
+
static CREATE_BUS_STOP_MONGO_CONDITIONS(params) {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
37
|
+
const andConditions = [{ typeOf: { $eq: factory.placeType.BusStop } }];
|
|
38
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
|
+
if (typeof projectIdEq === 'string') {
|
|
40
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
41
|
+
}
|
|
42
|
+
const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
43
|
+
if (typeof branchCodeEq === 'string') {
|
|
44
|
+
andConditions.push({
|
|
45
|
+
branchCode: {
|
|
46
|
+
$exists: true,
|
|
47
|
+
$eq: branchCodeEq
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
|
|
52
|
+
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
53
|
+
andConditions.push({
|
|
54
|
+
branchCode: {
|
|
55
|
+
$exists: true,
|
|
56
|
+
$regex: new RegExp(branchCodeRegex)
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const branchCodeIn = (_e = params.branchCode) === null || _e === void 0 ? void 0 : _e.$in;
|
|
61
|
+
if (Array.isArray(branchCodeIn)) {
|
|
62
|
+
andConditions.push({
|
|
63
|
+
branchCode: {
|
|
64
|
+
$exists: true,
|
|
65
|
+
$in: branchCodeIn
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
70
|
+
/* istanbul ignore else */
|
|
71
|
+
const idEq = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
72
|
+
if (typeof idEq === 'string') {
|
|
73
|
+
andConditions.push({
|
|
74
|
+
_id: {
|
|
75
|
+
$eq: idEq
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const idIn = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$in;
|
|
80
|
+
if (Array.isArray(idIn)) {
|
|
81
|
+
andConditions.push({
|
|
82
|
+
_id: {
|
|
83
|
+
$in: idIn
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const nameRegex = (_h = params.name) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
88
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
89
|
+
/* istanbul ignore else */
|
|
90
|
+
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
91
|
+
andConditions.push({
|
|
92
|
+
$or: [
|
|
93
|
+
{
|
|
94
|
+
'name.ja': {
|
|
95
|
+
$exists: true,
|
|
96
|
+
$regex: new RegExp(nameRegex)
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
'name.en': {
|
|
101
|
+
$exists: true,
|
|
102
|
+
$regex: new RegExp(nameRegex)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return andConditions;
|
|
109
|
+
}
|
|
110
|
+
saveBusStop(params) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
let doc;
|
|
113
|
+
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
114
|
+
doc = yield this.placeModel.create(params);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// 上書き禁止属性を除外(2022-08-24~)
|
|
118
|
+
const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
|
|
119
|
+
doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
|
|
120
|
+
.exec();
|
|
121
|
+
}
|
|
122
|
+
if (doc === null) {
|
|
123
|
+
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
124
|
+
}
|
|
125
|
+
return doc.toObject();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
findBusStopByBranchCode(params) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
return this.placeModel.findOne({
|
|
131
|
+
typeOf: { $eq: factory.placeType.BusStop },
|
|
132
|
+
'project.id': { $eq: params.project.id },
|
|
133
|
+
branchCode: { $eq: params.branchCode }
|
|
134
|
+
})
|
|
135
|
+
.exec()
|
|
136
|
+
.then((doc) => {
|
|
137
|
+
if (doc === null) {
|
|
138
|
+
throw new factory.errors.NotFound(`${factory.placeType.BusStop} ${params.branchCode}`);
|
|
139
|
+
}
|
|
140
|
+
return doc.toObject();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
searchBusStops(params) {
|
|
145
|
+
var _a;
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const conditions = MongoRepository.CREATE_BUS_STOP_MONGO_CONDITIONS(params);
|
|
148
|
+
// containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
|
|
149
|
+
const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
|
|
150
|
+
__v: 0,
|
|
151
|
+
createdAt: 0,
|
|
152
|
+
updatedAt: 0,
|
|
153
|
+
containsPlace: 0
|
|
154
|
+
});
|
|
155
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
156
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
157
|
+
query.limit(params.limit)
|
|
158
|
+
.skip(params.limit * (page - 1));
|
|
159
|
+
}
|
|
160
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
161
|
+
/* istanbul ignore else */
|
|
162
|
+
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.branchCode) !== undefined) {
|
|
163
|
+
query.sort({ branchCode: params.sort.branchCode });
|
|
164
|
+
}
|
|
165
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
166
|
+
.exec()
|
|
167
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
findBusStopById(params, projection) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
const doc = yield this.placeModel.findOne({
|
|
173
|
+
typeOf: { $eq: factory.placeType.BusStop },
|
|
174
|
+
_id: { $eq: params.id }
|
|
175
|
+
}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
|
|
176
|
+
.exec();
|
|
177
|
+
if (doc === null) {
|
|
178
|
+
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
179
|
+
}
|
|
180
|
+
return doc.toObject();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
deleteBusStopById(params) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
yield this.placeModel.findOneAndDelete({
|
|
186
|
+
typeOf: { $eq: factory.placeType.BusStop },
|
|
187
|
+
_id: { $eq: params.id },
|
|
188
|
+
'project.id': { $eq: params.project.id }
|
|
189
|
+
})
|
|
190
|
+
.exec()
|
|
191
|
+
.then((doc) => {
|
|
192
|
+
if (doc === null) {
|
|
193
|
+
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
|
+
import * as factory from '../../factory';
|
|
3
|
+
export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
|
|
4
|
+
export type IMovieTheaterIncludingScreeningRooms = factory.place.movieTheater.IPlace & {
|
|
5
|
+
containsPlace: factory.place.screeningRoom.IPlace[];
|
|
6
|
+
};
|
|
7
|
+
type IKeyOfProjectionMovieTheater = keyof factory.place.movieTheater.IPlace | '_id';
|
|
8
|
+
/**
|
|
9
|
+
* 施設リポジトリ
|
|
10
|
+
*/
|
|
11
|
+
export declare class MongoRepository {
|
|
12
|
+
private readonly placeModel;
|
|
13
|
+
constructor(connection: Connection);
|
|
14
|
+
static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions): FilterQuery<import("@chevre/factory/lib/place/movieTheater").IPlace>[];
|
|
15
|
+
/**
|
|
16
|
+
* 施設を保管する
|
|
17
|
+
*/
|
|
18
|
+
saveMovieTheater(params: factory.place.movieTheater.IPlace): Promise<factory.place.movieTheater.IPlace>;
|
|
19
|
+
saveMovieTheaterByBranchCode4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* 施設検索
|
|
22
|
+
*/
|
|
23
|
+
searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions, inclusion: IKeyOfProjectionMovieTheater[], exclusion: IKeyOfProjectionMovieTheater[]): Promise<factory.place.movieTheater.IPlace[]>;
|
|
24
|
+
deleteMovieTheaterById(params: {
|
|
25
|
+
project: {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
id: string;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MongoRepository = void 0;
|
|
24
|
+
const factory = require("../../factory");
|
|
25
|
+
const settings_1 = require("../../settings");
|
|
26
|
+
const place_1 = require("../mongoose/schemas/place");
|
|
27
|
+
/**
|
|
28
|
+
* 施設リポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class MongoRepository {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
33
|
+
}
|
|
34
|
+
// tslint:disable-next-line:max-func-body-length
|
|
35
|
+
static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params) {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
37
|
+
// MongoDB検索条件
|
|
38
|
+
const andConditions = [{ typeOf: { $eq: factory.placeType.MovieTheater } }];
|
|
39
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
40
|
+
if (typeof projectIdEq === 'string') {
|
|
41
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
42
|
+
}
|
|
43
|
+
const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
44
|
+
if (typeof branchCodeEq === 'string') {
|
|
45
|
+
andConditions.push({
|
|
46
|
+
branchCode: {
|
|
47
|
+
$exists: true,
|
|
48
|
+
$eq: branchCodeEq
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
|
|
53
|
+
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
54
|
+
andConditions.push({
|
|
55
|
+
branchCode: {
|
|
56
|
+
$exists: true,
|
|
57
|
+
$regex: new RegExp(branchCodeRegex)
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
62
|
+
/* istanbul ignore else */
|
|
63
|
+
if (Array.isArray(params.branchCodes)) {
|
|
64
|
+
andConditions.push({
|
|
65
|
+
branchCode: {
|
|
66
|
+
$exists: true,
|
|
67
|
+
$in: params.branchCodes
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
72
|
+
/* istanbul ignore else */
|
|
73
|
+
const idEq = (_e = params.id) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
74
|
+
if (typeof idEq === 'string') {
|
|
75
|
+
andConditions.push({
|
|
76
|
+
_id: {
|
|
77
|
+
$eq: idEq
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const idIn = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$in;
|
|
82
|
+
if (Array.isArray(idIn)) {
|
|
83
|
+
andConditions.push({
|
|
84
|
+
_id: {
|
|
85
|
+
$in: idIn
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
90
|
+
/* istanbul ignore else */
|
|
91
|
+
if (typeof params.name === 'string' && params.name.length > 0) {
|
|
92
|
+
andConditions.push({
|
|
93
|
+
$or: [
|
|
94
|
+
{
|
|
95
|
+
'name.ja': {
|
|
96
|
+
$exists: true,
|
|
97
|
+
$regex: new RegExp(params.name)
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
'name.en': {
|
|
102
|
+
$exists: true,
|
|
103
|
+
$regex: new RegExp(params.name)
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
kanaName: {
|
|
108
|
+
$exists: true,
|
|
109
|
+
$regex: new RegExp(params.name)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const parentOrganizationIdEq = (_h = (_g = params.parentOrganization) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
116
|
+
if (typeof parentOrganizationIdEq === 'string') {
|
|
117
|
+
andConditions.push({
|
|
118
|
+
'parentOrganization.id': {
|
|
119
|
+
$exists: true,
|
|
120
|
+
$eq: parentOrganizationIdEq
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
|
|
125
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
126
|
+
andConditions.push({
|
|
127
|
+
additionalProperty: {
|
|
128
|
+
$exists: true,
|
|
129
|
+
$elemMatch: additionalPropertyElemMatch
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return andConditions;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 施設を保管する
|
|
137
|
+
*/
|
|
138
|
+
saveMovieTheater(params) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
let doc;
|
|
141
|
+
if (params.id === '') {
|
|
142
|
+
doc = yield this.placeModel.create(params);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// 上書き禁止属性を除外(2022-08-24~)
|
|
146
|
+
const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
|
|
147
|
+
doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, {
|
|
148
|
+
upsert: false,
|
|
149
|
+
new: true,
|
|
150
|
+
projection: {
|
|
151
|
+
__v: 0,
|
|
152
|
+
createdAt: 0,
|
|
153
|
+
updatedAt: 0,
|
|
154
|
+
containsPlace: 0
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
.exec();
|
|
158
|
+
}
|
|
159
|
+
if (doc === null) {
|
|
160
|
+
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
161
|
+
}
|
|
162
|
+
return doc.toObject();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// void化(2023-06-23~)
|
|
166
|
+
saveMovieTheaterByBranchCode4coa(params) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const { containsPlace } = params, movieTheater4update = __rest(params, ["containsPlace"]);
|
|
169
|
+
const movieTheaterDoc = yield this.placeModel.findOneAndUpdate({
|
|
170
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
171
|
+
'project.id': { $eq: params.project.id },
|
|
172
|
+
branchCode: { $eq: params.branchCode }
|
|
173
|
+
},
|
|
174
|
+
// containsPlaceの保管を廃止(2023-07-04~)
|
|
175
|
+
// params,
|
|
176
|
+
movieTheater4update, {
|
|
177
|
+
new: true,
|
|
178
|
+
projection: { _id: 1 }
|
|
179
|
+
})
|
|
180
|
+
.exec();
|
|
181
|
+
if (movieTheaterDoc === null) {
|
|
182
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
183
|
+
}
|
|
184
|
+
const movieTheater = movieTheaterDoc.toObject();
|
|
185
|
+
// ScreeningRoomも保管する(2023-06-24~)
|
|
186
|
+
const creatingScreeningRooms = params.containsPlace.map((place) => {
|
|
187
|
+
return Object.assign(Object.assign({}, place), { containedInPlace: {
|
|
188
|
+
id: movieTheater.id,
|
|
189
|
+
typeOf: params.typeOf,
|
|
190
|
+
branchCode: params.branchCode,
|
|
191
|
+
name: params.name
|
|
192
|
+
}, containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [], project: params.project });
|
|
193
|
+
});
|
|
194
|
+
yield Promise.all(creatingScreeningRooms.map((createScreeningRoom) => __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
const { typeOf, project, branchCode } = createScreeningRoom, setFields = __rest(createScreeningRoom, ["typeOf", "project", "branchCode"]);
|
|
196
|
+
if (typeof branchCode === 'string' && branchCode.length > 0) {
|
|
197
|
+
yield this.placeModel.findOneAndUpdate({
|
|
198
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
199
|
+
'project.id': { $eq: createScreeningRoom.project.id },
|
|
200
|
+
'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
|
|
201
|
+
branchCode: { $eq: createScreeningRoom.branchCode }
|
|
202
|
+
}, {
|
|
203
|
+
$setOnInsert: {
|
|
204
|
+
typeOf: createScreeningRoom.typeOf,
|
|
205
|
+
project: createScreeningRoom.project,
|
|
206
|
+
branchCode: createScreeningRoom.branchCode
|
|
207
|
+
},
|
|
208
|
+
$set: setFields
|
|
209
|
+
}, {
|
|
210
|
+
upsert: true,
|
|
211
|
+
new: true,
|
|
212
|
+
projection: { _id: 1 }
|
|
213
|
+
})
|
|
214
|
+
.exec();
|
|
215
|
+
}
|
|
216
|
+
})));
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* 施設検索
|
|
221
|
+
*/
|
|
222
|
+
searchMovieTheaters(params, inclusion, exclusion) {
|
|
223
|
+
var _a;
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
const conditions = MongoRepository.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
|
|
226
|
+
let projection = {};
|
|
227
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
228
|
+
inclusion.forEach((field) => {
|
|
229
|
+
if (String(field) !== 'containsPlace' && String(field) !== 'hasPOS') { // 除外(2023-10-26~)
|
|
230
|
+
projection[field] = 1;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
projection = {
|
|
236
|
+
__v: 0,
|
|
237
|
+
createdAt: 0,
|
|
238
|
+
updatedAt: 0,
|
|
239
|
+
// containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
|
|
240
|
+
containsPlace: 0,
|
|
241
|
+
hasPOS: 0 // 除外(2023-10-26~)
|
|
242
|
+
};
|
|
243
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
244
|
+
exclusion.forEach((field) => {
|
|
245
|
+
projection[field] = 0;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
250
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
251
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
252
|
+
query.limit(params.limit)
|
|
253
|
+
.skip(params.limit * (page - 1));
|
|
254
|
+
}
|
|
255
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
256
|
+
/* istanbul ignore else */
|
|
257
|
+
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.branchCode) !== undefined) {
|
|
258
|
+
query.sort({ branchCode: params.sort.branchCode });
|
|
259
|
+
}
|
|
260
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
261
|
+
.exec()
|
|
262
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
deleteMovieTheaterById(params) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
yield this.placeModel.findOneAndDelete({
|
|
268
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
269
|
+
_id: { $eq: params.id },
|
|
270
|
+
'project.id': { $eq: params.project.id }
|
|
271
|
+
}, { projection: { _id: 1 } })
|
|
272
|
+
.exec()
|
|
273
|
+
.then((doc) => {
|
|
274
|
+
if (doc === null) {
|
|
275
|
+
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { AnyExpression, Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../../factory';
|
|
3
|
+
/**
|
|
4
|
+
* 座席編集時レスポンス
|
|
5
|
+
*/
|
|
6
|
+
interface IUpdateSeatResult {
|
|
7
|
+
containedInPlace: {
|
|
8
|
+
/**
|
|
9
|
+
* 施設ID
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
typeOf: factory.placeType.ScreeningRoom;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 座席リポジトリ
|
|
17
|
+
*/
|
|
18
|
+
export declare class MongoRepository {
|
|
19
|
+
private readonly placeModel;
|
|
20
|
+
constructor(connection: Connection);
|
|
21
|
+
static CREATE_SEARCH_SEATS_PROJECTION(params: factory.place.seat.IProjection): {
|
|
22
|
+
[field: string]: AnyExpression;
|
|
23
|
+
};
|
|
24
|
+
createSeat(seat: factory.place.seat.IPlace & {
|
|
25
|
+
parentOrganization?: {
|
|
26
|
+
id?: string;
|
|
27
|
+
};
|
|
28
|
+
}): Promise<IUpdateSeatResult>;
|
|
29
|
+
updateSeat(seat: Omit<factory.place.seat.IPlace, 'containedInPlace'> & {
|
|
30
|
+
containedInPlace: {
|
|
31
|
+
branchCode: string;
|
|
32
|
+
containedInPlace: {
|
|
33
|
+
branchCode: string;
|
|
34
|
+
containedInPlace: {
|
|
35
|
+
branchCode: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
parentOrganization?: {
|
|
40
|
+
id?: string;
|
|
41
|
+
};
|
|
42
|
+
}, $unset: any): Promise<IUpdateSeatResult>;
|
|
43
|
+
searchSeats(params: factory.place.seat.ISearchConditions): Promise<factory.place.seat.IPlace[]>;
|
|
44
|
+
deleteSeat(seat: {
|
|
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
|
+
containedInPlace: {
|
|
61
|
+
/**
|
|
62
|
+
* ルームコード
|
|
63
|
+
*/
|
|
64
|
+
branchCode: string;
|
|
65
|
+
containedInPlace: {
|
|
66
|
+
/**
|
|
67
|
+
* 施設コード
|
|
68
|
+
*/
|
|
69
|
+
branchCode: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}): Promise<IUpdateSeatResult>;
|
|
74
|
+
}
|
|
75
|
+
export {};
|