@chevre/domain 22.3.0-alpha.21 → 22.3.0-alpha.22
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/migrateMovieTheaters2secondary.ts +70 -0
- package/lib/chevre/repo/mongoose/schemas/civicStructure.d.ts +18 -0
- package/lib/chevre/repo/mongoose/schemas/civicStructure.js +131 -0
- package/lib/chevre/repo/place/busStop.d.ts +1 -1
- package/lib/chevre/repo/place/busStop.js +16 -10
- package/lib/chevre/repo/place/hasPOS.d.ts +1 -1
- package/lib/chevre/repo/place/hasPOS.js +12 -6
- package/lib/chevre/repo/place/movieTheater.d.ts +6 -1
- package/lib/chevre/repo/place/movieTheater.js +48 -49
- package/lib/chevre/repo/place/screeningRoom.d.ts +5 -0
- package/lib/chevre/repo/place/screeningRoom.js +72 -3
- package/lib/chevre/repo/place/seat.d.ts +1 -0
- package/lib/chevre/repo/place/seat.js +9 -1
- package/lib/chevre/repo/place/section.d.ts +1 -0
- package/lib/chevre/repo/place/section.js +9 -1
- package/lib/chevre/service/event.js +4 -3
- package/lib/chevre/settings.d.ts +4 -0
- package/lib/chevre/settings.js +13 -1
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = movieTheaterRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
typeOf: { $eq: chevre.factory.placeType.MovieTheater }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
_id: 1,
|
|
20
|
+
branchCode: 1,
|
|
21
|
+
project: 1,
|
|
22
|
+
typeOf: 1
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
console.log('docs found');
|
|
26
|
+
|
|
27
|
+
let i = 0;
|
|
28
|
+
let updateCount = 0;
|
|
29
|
+
await cursor.eachAsync(async (doc) => {
|
|
30
|
+
i += 1;
|
|
31
|
+
const movieTheater: Pick<chevre.factory.place.movieTheater.IPlace, 'id' | 'branchCode' | 'project' | 'typeOf'> =
|
|
32
|
+
doc.toObject();
|
|
33
|
+
const alreadyMigrated = false;
|
|
34
|
+
if (alreadyMigrated) {
|
|
35
|
+
console.log(
|
|
36
|
+
'already exist.',
|
|
37
|
+
movieTheater.project.id,
|
|
38
|
+
movieTheater.typeOf,
|
|
39
|
+
movieTheater.id,
|
|
40
|
+
movieTheater.branchCode, i, updateCount
|
|
41
|
+
);
|
|
42
|
+
} else {
|
|
43
|
+
updateCount += 1;
|
|
44
|
+
console.log(
|
|
45
|
+
'updating...',
|
|
46
|
+
movieTheater.project.id,
|
|
47
|
+
movieTheater.typeOf,
|
|
48
|
+
movieTheater.id,
|
|
49
|
+
movieTheater.branchCode, i, updateCount
|
|
50
|
+
);
|
|
51
|
+
await movieTheaterRepo.sync2secondary({
|
|
52
|
+
id: movieTheater.id
|
|
53
|
+
});
|
|
54
|
+
console.log(
|
|
55
|
+
'updated.',
|
|
56
|
+
movieTheater.project.id,
|
|
57
|
+
movieTheater.typeOf,
|
|
58
|
+
movieTheater.id,
|
|
59
|
+
movieTheater.branchCode, i, updateCount
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log(i, 'docs checked');
|
|
65
|
+
console.log(updateCount, 'docs updated');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main()
|
|
69
|
+
.then()
|
|
70
|
+
.catch(console.error);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IDocType = ((factory.place.movieTheater.IPlace & {
|
|
4
|
+
hasPOS?: factory.place.movieTheater.IPOS[];
|
|
5
|
+
}) | factory.place.screeningRoom.IPlace) & {
|
|
6
|
+
alternateName?: any;
|
|
7
|
+
description?: any;
|
|
8
|
+
openingHoursSpecification?: any;
|
|
9
|
+
smokingAllowed?: boolean;
|
|
10
|
+
sameAs?: any;
|
|
11
|
+
};
|
|
12
|
+
type IModel = Model<IDocType>;
|
|
13
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
14
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
15
|
+
declare const modelName = "CivicStructure";
|
|
16
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
17
|
+
declare function createSchema(): ISchema;
|
|
18
|
+
export { createSchema, IModel, indexes, modelName };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modelName = exports.indexes = exports.createSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const modelName = 'CivicStructure';
|
|
8
|
+
exports.modelName = modelName;
|
|
9
|
+
const schemaDefinition = {
|
|
10
|
+
project: {
|
|
11
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
parentOrganization: {
|
|
15
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
typeOf: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
name: mongoose_1.SchemaTypes.Mixed,
|
|
23
|
+
branchCode: String,
|
|
24
|
+
hasEntranceGate: [mongoose_1.SchemaTypes.Mixed],
|
|
25
|
+
hasPOS: [mongoose_1.SchemaTypes.Mixed],
|
|
26
|
+
telephone: String,
|
|
27
|
+
url: String,
|
|
28
|
+
kanaName: String,
|
|
29
|
+
offers: mongoose_1.SchemaTypes.Mixed,
|
|
30
|
+
additionalProperty: [mongoose_1.SchemaTypes.Mixed]
|
|
31
|
+
};
|
|
32
|
+
const schemaOptions = {
|
|
33
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
34
|
+
autoCreate: false,
|
|
35
|
+
collection: 'civicStructures',
|
|
36
|
+
id: true,
|
|
37
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
38
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
39
|
+
strict: true,
|
|
40
|
+
strictQuery: false,
|
|
41
|
+
timestamps: false,
|
|
42
|
+
versionKey: false,
|
|
43
|
+
toJSON: {
|
|
44
|
+
getters: false,
|
|
45
|
+
virtuals: false,
|
|
46
|
+
minimize: false,
|
|
47
|
+
versionKey: false
|
|
48
|
+
},
|
|
49
|
+
toObject: {
|
|
50
|
+
getters: false,
|
|
51
|
+
virtuals: true,
|
|
52
|
+
minimize: false,
|
|
53
|
+
versionKey: false
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const indexes = [
|
|
57
|
+
[
|
|
58
|
+
{ branchCode: 1 },
|
|
59
|
+
{ name: 'branchCode' }
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
{ typeOf: 1, branchCode: 1 },
|
|
63
|
+
{ name: 'typeOf' }
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
{ 'project.id': 1, branchCode: 1 },
|
|
67
|
+
{ name: 'projectId' }
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
{ 'name.ja': 1, branchCode: 1 },
|
|
71
|
+
{
|
|
72
|
+
name: 'nameJa',
|
|
73
|
+
partialFilterExpression: {
|
|
74
|
+
'name.ja': { $exists: true }
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
{ 'name.en': 1, branchCode: 1 },
|
|
80
|
+
{
|
|
81
|
+
name: 'nameEn',
|
|
82
|
+
partialFilterExpression: {
|
|
83
|
+
'name.en': { $exists: true }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
{ kanaName: 1, branchCode: 1 },
|
|
89
|
+
{
|
|
90
|
+
name: 'kanaName',
|
|
91
|
+
partialFilterExpression: {
|
|
92
|
+
kanaName: { $exists: true }
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
{ 'parentOrganization.id': 1, branchCode: 1 },
|
|
98
|
+
{
|
|
99
|
+
name: 'parentOrganizationId',
|
|
100
|
+
partialFilterExpression: {
|
|
101
|
+
'parentOrganization.id': { $exists: true }
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
{ additionalProperty: 1, branchCode: 1 },
|
|
107
|
+
{
|
|
108
|
+
name: 'additionalProperty',
|
|
109
|
+
partialFilterExpression: {
|
|
110
|
+
additionalProperty: { $exists: true }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
];
|
|
115
|
+
exports.indexes = indexes;
|
|
116
|
+
/**
|
|
117
|
+
* 施設スキーマ
|
|
118
|
+
*/
|
|
119
|
+
let schema;
|
|
120
|
+
function createSchema() {
|
|
121
|
+
if (schema === undefined) {
|
|
122
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
123
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
124
|
+
indexes.forEach((indexParams) => {
|
|
125
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return schema;
|
|
130
|
+
}
|
|
131
|
+
exports.createSchema = createSchema;
|
|
@@ -4,7 +4,7 @@ import * as factory from '../../factory';
|
|
|
4
4
|
* ターミナルリポジトリ
|
|
5
5
|
*/
|
|
6
6
|
export declare class BusStopRepo {
|
|
7
|
-
private readonly
|
|
7
|
+
private readonly civicStructureModel;
|
|
8
8
|
constructor(connection: Connection);
|
|
9
9
|
static CREATE_BUS_STOP_MONGO_CONDITIONS(params: factory.place.busStop.ISearchConditions): FilterQuery<import("@chevre/factory/lib/place/busStop").IPlace>[];
|
|
10
10
|
saveBusStop(params: factory.place.busStop.IPlace): Promise<factory.place.busStop.IPlace>;
|
|
@@ -23,13 +23,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.BusStopRepo = void 0;
|
|
24
24
|
const factory = require("../../factory");
|
|
25
25
|
const settings_1 = require("../../settings");
|
|
26
|
+
const civicStructure_1 = require("../mongoose/schemas/civicStructure");
|
|
26
27
|
const place_1 = require("../mongoose/schemas/place");
|
|
27
28
|
/**
|
|
28
29
|
* ターミナルリポジトリ
|
|
29
30
|
*/
|
|
30
31
|
class BusStopRepo {
|
|
31
32
|
constructor(connection) {
|
|
32
|
-
|
|
33
|
+
if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
|
|
34
|
+
this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
// tslint:disable-next-line:max-func-body-length
|
|
35
41
|
static CREATE_BUS_STOP_MONGO_CONDITIONS(params) {
|
|
@@ -111,23 +117,23 @@ class BusStopRepo {
|
|
|
111
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
118
|
let doc;
|
|
113
119
|
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
114
|
-
doc = yield this.
|
|
120
|
+
doc = yield this.civicStructureModel.create(params);
|
|
115
121
|
}
|
|
116
122
|
else {
|
|
117
123
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
118
124
|
const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
|
|
119
|
-
doc = yield this.
|
|
125
|
+
doc = yield this.civicStructureModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
|
|
120
126
|
.exec();
|
|
121
127
|
}
|
|
122
128
|
if (doc === null) {
|
|
123
|
-
throw new factory.errors.NotFound(this.
|
|
129
|
+
throw new factory.errors.NotFound(this.civicStructureModel.modelName);
|
|
124
130
|
}
|
|
125
131
|
return doc.toObject();
|
|
126
132
|
});
|
|
127
133
|
}
|
|
128
134
|
findBusStopByBranchCode(params) {
|
|
129
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
return this.
|
|
136
|
+
return this.civicStructureModel.findOne({
|
|
131
137
|
typeOf: { $eq: factory.placeType.BusStop },
|
|
132
138
|
'project.id': { $eq: params.project.id },
|
|
133
139
|
branchCode: { $eq: params.branchCode }
|
|
@@ -146,7 +152,7 @@ class BusStopRepo {
|
|
|
146
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
153
|
const conditions = BusStopRepo.CREATE_BUS_STOP_MONGO_CONDITIONS(params);
|
|
148
154
|
// containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
|
|
149
|
-
const query = this.
|
|
155
|
+
const query = this.civicStructureModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
|
|
150
156
|
__v: 0,
|
|
151
157
|
createdAt: 0,
|
|
152
158
|
updatedAt: 0,
|
|
@@ -169,20 +175,20 @@ class BusStopRepo {
|
|
|
169
175
|
}
|
|
170
176
|
findBusStopById(params, projection) {
|
|
171
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
const doc = yield this.
|
|
178
|
+
const doc = yield this.civicStructureModel.findOne({
|
|
173
179
|
typeOf: { $eq: factory.placeType.BusStop },
|
|
174
180
|
_id: { $eq: params.id }
|
|
175
181
|
}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
|
|
176
182
|
.exec();
|
|
177
183
|
if (doc === null) {
|
|
178
|
-
throw new factory.errors.NotFound(this.
|
|
184
|
+
throw new factory.errors.NotFound(this.civicStructureModel.modelName);
|
|
179
185
|
}
|
|
180
186
|
return doc.toObject();
|
|
181
187
|
});
|
|
182
188
|
}
|
|
183
189
|
deleteBusStopById(params) {
|
|
184
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
yield this.
|
|
191
|
+
yield this.civicStructureModel.findOneAndDelete({
|
|
186
192
|
typeOf: { $eq: factory.placeType.BusStop },
|
|
187
193
|
_id: { $eq: params.id },
|
|
188
194
|
'project.id': { $eq: params.project.id }
|
|
@@ -190,7 +196,7 @@ class BusStopRepo {
|
|
|
190
196
|
.exec()
|
|
191
197
|
.then((doc) => {
|
|
192
198
|
if (doc === null) {
|
|
193
|
-
throw new factory.errors.NotFound(this.
|
|
199
|
+
throw new factory.errors.NotFound(this.civicStructureModel.modelName);
|
|
194
200
|
}
|
|
195
201
|
});
|
|
196
202
|
});
|
|
@@ -14,7 +14,7 @@ interface IOperator {
|
|
|
14
14
|
*/
|
|
15
15
|
export declare class HasPOSRepo {
|
|
16
16
|
readonly operator: IOperator;
|
|
17
|
-
private readonly
|
|
17
|
+
private readonly civicStructureModel;
|
|
18
18
|
constructor(connection: Connection, operater: IOperator);
|
|
19
19
|
search(params: {
|
|
20
20
|
limit?: number;
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.HasPOSRepo = void 0;
|
|
13
13
|
const mongoose_1 = require("mongoose");
|
|
14
|
+
const civicStructure_1 = require("../mongoose/schemas/civicStructure");
|
|
14
15
|
const place_1 = require("../mongoose/schemas/place");
|
|
15
16
|
const factory = require("../../factory");
|
|
16
17
|
const settings_1 = require("../../settings");
|
|
@@ -19,7 +20,12 @@ const settings_1 = require("../../settings");
|
|
|
19
20
|
*/
|
|
20
21
|
class HasPOSRepo {
|
|
21
22
|
constructor(connection, operater) {
|
|
22
|
-
|
|
23
|
+
if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
|
|
24
|
+
this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
28
|
+
}
|
|
23
29
|
this.operator = operater;
|
|
24
30
|
}
|
|
25
31
|
search(params) {
|
|
@@ -40,7 +46,7 @@ class HasPOSRepo {
|
|
|
40
46
|
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
41
47
|
matchStages.push({ $match: { 'hasPOS.branchCode': { $regex: new RegExp(branchCodeRegex) } } });
|
|
42
48
|
}
|
|
43
|
-
const aggregate = this.
|
|
49
|
+
const aggregate = this.civicStructureModel.aggregate([
|
|
44
50
|
{
|
|
45
51
|
$unwind: {
|
|
46
52
|
path: '$hasPOS'
|
|
@@ -69,7 +75,7 @@ class HasPOSRepo {
|
|
|
69
75
|
createByBranchCode(params) {
|
|
70
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
77
|
// 施設存在確認
|
|
72
|
-
let doc = yield this.
|
|
78
|
+
let doc = yield this.civicStructureModel.findOne({
|
|
73
79
|
'project.id': { $eq: params.project.id },
|
|
74
80
|
_id: { $eq: this.operator.id }
|
|
75
81
|
}, { _id: 1, typeOf: 1 })
|
|
@@ -82,7 +88,7 @@ class HasPOSRepo {
|
|
|
82
88
|
branchCode: params.branchCode,
|
|
83
89
|
name: params.name
|
|
84
90
|
};
|
|
85
|
-
doc = yield this.
|
|
91
|
+
doc = yield this.civicStructureModel.findOneAndUpdate({
|
|
86
92
|
'project.id': { $eq: params.project.id },
|
|
87
93
|
_id: { $eq: this.operator.id },
|
|
88
94
|
'hasPOS.branchCode': { $ne: params.branchCode }
|
|
@@ -102,7 +108,7 @@ class HasPOSRepo {
|
|
|
102
108
|
}
|
|
103
109
|
updateByBranchCode(params) {
|
|
104
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
const doc = yield this.
|
|
111
|
+
const doc = yield this.civicStructureModel.findOneAndUpdate({
|
|
106
112
|
'project.id': { $eq: params.project.id },
|
|
107
113
|
_id: { $eq: this.operator.id },
|
|
108
114
|
'hasPOS.branchCode': { $eq: params.branchCode }
|
|
@@ -124,7 +130,7 @@ class HasPOSRepo {
|
|
|
124
130
|
}
|
|
125
131
|
deleteByBranchCode(params) {
|
|
126
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
const doc = yield this.
|
|
133
|
+
const doc = yield this.civicStructureModel.findOneAndUpdate({
|
|
128
134
|
'project.id': { $eq: params.project.id },
|
|
129
135
|
_id: { $eq: this.operator.id },
|
|
130
136
|
'hasPOS.branchCode': { $eq: params.branchCode }
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import type { Connection, Document, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../../factory';
|
|
27
27
|
export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
|
|
28
|
-
export type IMovieTheaterIncludingScreeningRooms = factory.place.movieTheater.IPlace & {
|
|
28
|
+
export type IMovieTheaterIncludingScreeningRooms = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'kanaName' | 'name' | 'offers' | 'parentOrganization' | 'project' | 'telephone' | 'typeOf'> & {
|
|
29
29
|
containsPlace: factory.place.screeningRoom.IPlace[];
|
|
30
30
|
};
|
|
31
31
|
type IKeyOfProjectionMovieTheater = keyof factory.place.movieTheater.IPlace | '_id';
|
|
@@ -33,6 +33,8 @@ type IKeyOfProjectionMovieTheater = keyof factory.place.movieTheater.IPlace | '_
|
|
|
33
33
|
* 施設リポジトリ
|
|
34
34
|
*/
|
|
35
35
|
export declare class MovieTheaterRepo {
|
|
36
|
+
private readonly civicStructureModel;
|
|
37
|
+
private readonly civicStructureModelAsSecondary;
|
|
36
38
|
private readonly placeModel;
|
|
37
39
|
constructor(connection: Connection);
|
|
38
40
|
static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions): FilterQuery<import("@chevre/factory/lib/place/movieTheater").IPlace>[];
|
|
@@ -130,5 +132,8 @@ export declare class MovieTheaterRepo {
|
|
|
130
132
|
filter: any;
|
|
131
133
|
$unset: any;
|
|
132
134
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
135
|
+
sync2secondary(params: {
|
|
136
|
+
id: string;
|
|
137
|
+
}): Promise<void>;
|
|
133
138
|
}
|
|
134
139
|
export {};
|
|
@@ -23,12 +23,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.MovieTheaterRepo = void 0;
|
|
24
24
|
const factory = require("../../factory");
|
|
25
25
|
const settings_1 = require("../../settings");
|
|
26
|
+
const civicStructure_1 = require("../mongoose/schemas/civicStructure");
|
|
26
27
|
const place_1 = require("../mongoose/schemas/place");
|
|
27
28
|
/**
|
|
28
29
|
* 施設リポジトリ
|
|
29
30
|
*/
|
|
30
31
|
class MovieTheaterRepo {
|
|
31
32
|
constructor(connection) {
|
|
33
|
+
if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
|
|
34
|
+
this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
38
|
+
}
|
|
39
|
+
this.civicStructureModelAsSecondary = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
32
40
|
this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
33
41
|
}
|
|
34
42
|
// tslint:disable-next-line:max-func-body-length
|
|
@@ -140,12 +148,12 @@ class MovieTheaterRepo {
|
|
|
140
148
|
let doc;
|
|
141
149
|
if (params.id === '') {
|
|
142
150
|
const { id } = params, creatingParams = __rest(params, ["id"]); // omit id(2024-09-12~)
|
|
143
|
-
doc = yield this.
|
|
151
|
+
doc = yield this.civicStructureModel.create(creatingParams);
|
|
144
152
|
}
|
|
145
153
|
else {
|
|
146
154
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
147
155
|
const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
|
|
148
|
-
doc = yield this.
|
|
156
|
+
doc = yield this.civicStructureModel.findOneAndUpdate({ _id: params.id }, updateFields, {
|
|
149
157
|
upsert: false,
|
|
150
158
|
new: true,
|
|
151
159
|
projection: {
|
|
@@ -158,23 +166,19 @@ class MovieTheaterRepo {
|
|
|
158
166
|
.exec();
|
|
159
167
|
}
|
|
160
168
|
if (doc === null) {
|
|
161
|
-
throw new factory.errors.NotFound(this.
|
|
169
|
+
throw new factory.errors.NotFound(this.civicStructureModel.modelName);
|
|
162
170
|
}
|
|
163
171
|
return doc.toObject();
|
|
164
172
|
});
|
|
165
173
|
}
|
|
166
|
-
// void化(2023-06-23~)
|
|
167
174
|
saveMovieTheaterByBranchCode4coa(params) {
|
|
168
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
176
|
const { containsPlace } = params, movieTheater4update = __rest(params, ["containsPlace"]);
|
|
170
|
-
const movieTheaterDoc = yield this.
|
|
177
|
+
const movieTheaterDoc = yield this.civicStructureModel.findOneAndUpdate({
|
|
171
178
|
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
172
179
|
'project.id': { $eq: params.project.id },
|
|
173
180
|
branchCode: { $eq: params.branchCode }
|
|
174
|
-
},
|
|
175
|
-
// containsPlaceの保管を廃止(2023-07-04~)
|
|
176
|
-
// params,
|
|
177
|
-
movieTheater4update, {
|
|
181
|
+
}, movieTheater4update, {
|
|
178
182
|
new: true,
|
|
179
183
|
projection: { _id: 1 }
|
|
180
184
|
})
|
|
@@ -182,39 +186,6 @@ class MovieTheaterRepo {
|
|
|
182
186
|
if (movieTheaterDoc === null) {
|
|
183
187
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
184
188
|
}
|
|
185
|
-
const movieTheater = movieTheaterDoc.toObject();
|
|
186
|
-
// ScreeningRoomも保管する(2023-06-24~)
|
|
187
|
-
const creatingScreeningRooms = params.containsPlace.map((place) => {
|
|
188
|
-
return Object.assign(Object.assign({}, place), { containedInPlace: {
|
|
189
|
-
id: movieTheater.id,
|
|
190
|
-
typeOf: params.typeOf,
|
|
191
|
-
branchCode: params.branchCode,
|
|
192
|
-
name: params.name
|
|
193
|
-
}, containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [], project: params.project });
|
|
194
|
-
});
|
|
195
|
-
yield Promise.all(creatingScreeningRooms.map((createScreeningRoom) => __awaiter(this, void 0, void 0, function* () {
|
|
196
|
-
const { typeOf, project, branchCode } = createScreeningRoom, setFields = __rest(createScreeningRoom, ["typeOf", "project", "branchCode"]);
|
|
197
|
-
if (typeof branchCode === 'string' && branchCode.length > 0) {
|
|
198
|
-
yield this.placeModel.findOneAndUpdate({
|
|
199
|
-
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
200
|
-
'project.id': { $eq: createScreeningRoom.project.id },
|
|
201
|
-
'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
|
|
202
|
-
branchCode: { $eq: createScreeningRoom.branchCode }
|
|
203
|
-
}, {
|
|
204
|
-
$setOnInsert: {
|
|
205
|
-
typeOf: createScreeningRoom.typeOf,
|
|
206
|
-
project: createScreeningRoom.project,
|
|
207
|
-
branchCode: createScreeningRoom.branchCode
|
|
208
|
-
},
|
|
209
|
-
$set: setFields
|
|
210
|
-
}, {
|
|
211
|
-
upsert: true,
|
|
212
|
-
new: true,
|
|
213
|
-
projection: { _id: 1 }
|
|
214
|
-
})
|
|
215
|
-
.exec();
|
|
216
|
-
}
|
|
217
|
-
})));
|
|
218
189
|
});
|
|
219
190
|
}
|
|
220
191
|
/**
|
|
@@ -247,7 +218,7 @@ class MovieTheaterRepo {
|
|
|
247
218
|
});
|
|
248
219
|
}
|
|
249
220
|
}
|
|
250
|
-
const query = this.
|
|
221
|
+
const query = this.civicStructureModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
251
222
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
252
223
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
253
224
|
query.limit(params.limit)
|
|
@@ -265,7 +236,7 @@ class MovieTheaterRepo {
|
|
|
265
236
|
}
|
|
266
237
|
deleteMovieTheaterById(params) {
|
|
267
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
-
yield this.
|
|
239
|
+
yield this.civicStructureModel.findOneAndDelete({
|
|
269
240
|
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
270
241
|
_id: { $eq: params.id },
|
|
271
242
|
'project.id': { $eq: params.project.id }
|
|
@@ -273,7 +244,7 @@ class MovieTheaterRepo {
|
|
|
273
244
|
.exec()
|
|
274
245
|
.then((doc) => {
|
|
275
246
|
if (doc === null) {
|
|
276
|
-
throw new factory.errors.NotFound(this.
|
|
247
|
+
throw new factory.errors.NotFound(this.civicStructureModel.modelName);
|
|
277
248
|
}
|
|
278
249
|
});
|
|
279
250
|
});
|
|
@@ -283,7 +254,7 @@ class MovieTheaterRepo {
|
|
|
283
254
|
*/
|
|
284
255
|
deleteMovieTheatersByParentOrganizationId(params) {
|
|
285
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
286
|
-
return this.
|
|
257
|
+
return this.civicStructureModel.deleteMany({
|
|
287
258
|
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
288
259
|
'project.id': { $eq: params.project.id },
|
|
289
260
|
'parentOrganization.id': { $exists: true, $eq: params.parentOrganization.id }
|
|
@@ -296,7 +267,7 @@ class MovieTheaterRepo {
|
|
|
296
267
|
*/
|
|
297
268
|
deleteMovieTheatersByProject(params) {
|
|
298
269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
299
|
-
yield this.
|
|
270
|
+
yield this.civicStructureModel.deleteMany({
|
|
300
271
|
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
301
272
|
'project.id': { $eq: params.project.id }
|
|
302
273
|
})
|
|
@@ -304,14 +275,42 @@ class MovieTheaterRepo {
|
|
|
304
275
|
});
|
|
305
276
|
}
|
|
306
277
|
getCursor(conditions, projection) {
|
|
307
|
-
return this.
|
|
278
|
+
return this.civicStructureModel.find(conditions, projection)
|
|
308
279
|
.sort({ branchCode: factory.sortType.Ascending })
|
|
309
280
|
.cursor();
|
|
310
281
|
}
|
|
311
282
|
unsetUnnecessaryFields(params) {
|
|
312
283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
-
return this.
|
|
284
|
+
return this.civicStructureModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
285
|
+
.exec();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
// tslint:disable-next-line:prefer-function-over-method
|
|
289
|
+
sync2secondary(params) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
+
if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const doc = yield this.placeModel.findOne({
|
|
295
|
+
_id: { $eq: params.id },
|
|
296
|
+
typeOf: { $eq: factory.placeType.MovieTheater }
|
|
297
|
+
})
|
|
298
|
+
.lean()
|
|
314
299
|
.exec();
|
|
300
|
+
if (doc !== null) {
|
|
301
|
+
const { _id } = doc, replacement = __rest(doc, ["_id"]);
|
|
302
|
+
// console.log('replacing eventSeries', params.id, 'replacement:', replacement);
|
|
303
|
+
const replaceResult = yield this.civicStructureModelAsSecondary.findOneAndReplace({
|
|
304
|
+
_id: { $eq: params.id },
|
|
305
|
+
typeOf: { $eq: factory.placeType.MovieTheater }
|
|
306
|
+
}, replacement, {
|
|
307
|
+
upsert: true,
|
|
308
|
+
rawResult: true
|
|
309
|
+
})
|
|
310
|
+
.exec();
|
|
311
|
+
// tslint:disable-next-line:no-console
|
|
312
|
+
console.log('factory.placeType.MovieTheater', params.id, 'replaced. result:', replaceResult);
|
|
313
|
+
}
|
|
315
314
|
});
|
|
316
315
|
}
|
|
317
316
|
}
|
|
@@ -13,12 +13,17 @@ interface IUpdateScreeningRoomResult {
|
|
|
13
13
|
};
|
|
14
14
|
typeOf: factory.placeType.ScreeningRoom;
|
|
15
15
|
}
|
|
16
|
+
type IMovieTheaterIncludingScreeningRooms = Pick<factory.place.movieTheater.IPlace, 'name' | 'branchCode' | 'typeOf' | 'project'> & {
|
|
17
|
+
containsPlace: factory.place.screeningRoom.IPlace[];
|
|
18
|
+
};
|
|
16
19
|
/**
|
|
17
20
|
* ルームリポジトリ
|
|
18
21
|
*/
|
|
19
22
|
export declare class ScreeningRoomRepo {
|
|
23
|
+
private readonly civicStructureModel;
|
|
20
24
|
private readonly placeModel;
|
|
21
25
|
constructor(connection: Connection);
|
|
26
|
+
saveScreeningRooms4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
|
|
22
27
|
createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
|
|
23
28
|
containedInPlace: {
|
|
24
29
|
branchCode: string;
|
|
@@ -8,30 +8,99 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.ScreeningRoomRepo = void 0;
|
|
13
24
|
const factory = require("../../factory");
|
|
14
25
|
const settings_1 = require("../../settings");
|
|
26
|
+
const civicStructure_1 = require("../mongoose/schemas/civicStructure");
|
|
15
27
|
const place_1 = require("../mongoose/schemas/place");
|
|
16
28
|
/**
|
|
17
29
|
* ルームリポジトリ
|
|
18
30
|
*/
|
|
19
31
|
class ScreeningRoomRepo {
|
|
20
32
|
constructor(connection) {
|
|
33
|
+
if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
|
|
34
|
+
this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
38
|
+
}
|
|
21
39
|
this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
22
40
|
}
|
|
41
|
+
saveScreeningRooms4coa(params) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const { containsPlace } = params, movieTheater4update = __rest(params, ["containsPlace"]);
|
|
44
|
+
const movieTheater = yield this.civicStructureModel.findOne({
|
|
45
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
46
|
+
'project.id': { $eq: params.project.id },
|
|
47
|
+
branchCode: { $eq: movieTheater4update.branchCode }
|
|
48
|
+
}, { _id: 0, id: { $toString: '$_id' } })
|
|
49
|
+
.lean()
|
|
50
|
+
.exec();
|
|
51
|
+
if (movieTheater === null) {
|
|
52
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
53
|
+
}
|
|
54
|
+
const creatingScreeningRooms = params.containsPlace.map((place) => {
|
|
55
|
+
return Object.assign(Object.assign({}, place), { containedInPlace: {
|
|
56
|
+
id: movieTheater.id,
|
|
57
|
+
typeOf: movieTheater4update.typeOf,
|
|
58
|
+
branchCode: movieTheater4update.branchCode,
|
|
59
|
+
name: movieTheater4update.name
|
|
60
|
+
}, containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [], project: params.project });
|
|
61
|
+
});
|
|
62
|
+
yield Promise.all(creatingScreeningRooms.map((createScreeningRoom) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const { typeOf, project, branchCode } = createScreeningRoom, setFields = __rest(createScreeningRoom, ["typeOf", "project", "branchCode"]);
|
|
64
|
+
if (typeof branchCode === 'string' && branchCode.length > 0) {
|
|
65
|
+
yield this.placeModel.findOneAndUpdate({
|
|
66
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
67
|
+
'project.id': { $eq: createScreeningRoom.project.id },
|
|
68
|
+
'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
|
|
69
|
+
branchCode: { $eq: createScreeningRoom.branchCode }
|
|
70
|
+
}, {
|
|
71
|
+
$setOnInsert: {
|
|
72
|
+
typeOf: createScreeningRoom.typeOf,
|
|
73
|
+
project: createScreeningRoom.project,
|
|
74
|
+
branchCode: createScreeningRoom.branchCode
|
|
75
|
+
},
|
|
76
|
+
$set: setFields
|
|
77
|
+
}, {
|
|
78
|
+
upsert: true,
|
|
79
|
+
new: true,
|
|
80
|
+
projection: { _id: 1 }
|
|
81
|
+
})
|
|
82
|
+
.exec();
|
|
83
|
+
}
|
|
84
|
+
})));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
23
87
|
createScreeningRoom(screeningRoom) {
|
|
24
88
|
var _a;
|
|
25
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
90
|
// 施設存在確認
|
|
27
|
-
const movieTheaterDoc = yield this.
|
|
91
|
+
const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoom.project.id }, branchCode: { $eq: screeningRoom.containedInPlace.branchCode } }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
28
92
|
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoom.parentOrganization.id } }
|
|
29
|
-
: undefined), { _id:
|
|
93
|
+
: undefined), { _id: 0, id: { $toString: '$_id' }, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
|
|
94
|
+
.lean()
|
|
30
95
|
.exec();
|
|
31
96
|
if (movieTheaterDoc === null) {
|
|
32
97
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
33
98
|
}
|
|
34
|
-
const movieTheater =
|
|
99
|
+
// const movieTheater = <Pick<
|
|
100
|
+
// factory.place.movieTheater.IPlace,
|
|
101
|
+
// 'id' | 'typeOf' | 'branchCode' | 'name' | 'parentOrganization'
|
|
102
|
+
// >>movieTheaterDoc.toObject();
|
|
103
|
+
const movieTheater = movieTheaterDoc;
|
|
35
104
|
const creatingScreeningRoom = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
|
|
36
105
|
id: movieTheater.id,
|
|
37
106
|
typeOf: movieTheater.typeOf,
|
|
@@ -16,6 +16,7 @@ interface IUpdateSeatResult {
|
|
|
16
16
|
* 座席リポジトリ
|
|
17
17
|
*/
|
|
18
18
|
export declare class SeatRepo {
|
|
19
|
+
private readonly civicStructureModel;
|
|
19
20
|
private readonly placeModel;
|
|
20
21
|
constructor(connection: Connection);
|
|
21
22
|
static CREATE_SEARCH_SEATS_PROJECTION(params: factory.place.seat.IProjection): {
|
|
@@ -12,12 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.SeatRepo = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const settings_1 = require("../../settings");
|
|
15
|
+
const civicStructure_1 = require("../mongoose/schemas/civicStructure");
|
|
15
16
|
const place_1 = require("../mongoose/schemas/place");
|
|
16
17
|
/**
|
|
17
18
|
* 座席リポジトリ
|
|
18
19
|
*/
|
|
19
20
|
class SeatRepo {
|
|
20
21
|
constructor(connection) {
|
|
22
|
+
if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
|
|
23
|
+
this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
27
|
+
}
|
|
21
28
|
this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
22
29
|
}
|
|
23
30
|
static CREATE_SEARCH_SEATS_PROJECTION(params) {
|
|
@@ -75,9 +82,10 @@ class SeatRepo {
|
|
|
75
82
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
76
83
|
}
|
|
77
84
|
// 施設存在確認
|
|
78
|
-
const movieTheaterDoc = yield this.
|
|
85
|
+
const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: seat.project.id }, branchCode: { $eq: movieTheater.branchCode } }, (typeof ((_a = seat.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
79
86
|
? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
|
|
80
87
|
: undefined), { _id: 1 })
|
|
88
|
+
.lean()
|
|
81
89
|
.exec();
|
|
82
90
|
if (movieTheaterDoc === null) {
|
|
83
91
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
@@ -17,6 +17,7 @@ interface IUpdateSectionResult {
|
|
|
17
17
|
* セクションリポジトリ
|
|
18
18
|
*/
|
|
19
19
|
export declare class SectionRepo {
|
|
20
|
+
private readonly civicStructureModel;
|
|
20
21
|
private readonly placeModel;
|
|
21
22
|
constructor(connection: Connection);
|
|
22
23
|
createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace & {
|
|
@@ -12,12 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.SectionRepo = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const settings_1 = require("../../settings");
|
|
15
|
+
const civicStructure_1 = require("../mongoose/schemas/civicStructure");
|
|
15
16
|
const place_1 = require("../mongoose/schemas/place");
|
|
16
17
|
/**
|
|
17
18
|
* セクションリポジトリ
|
|
18
19
|
*/
|
|
19
20
|
class SectionRepo {
|
|
20
21
|
constructor(connection) {
|
|
22
|
+
if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
|
|
23
|
+
this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
27
|
+
}
|
|
21
28
|
this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
22
29
|
}
|
|
23
30
|
// tslint:disable-next-line:max-func-body-length
|
|
@@ -33,9 +40,10 @@ class SectionRepo {
|
|
|
33
40
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
34
41
|
}
|
|
35
42
|
// 施設存在確認
|
|
36
|
-
const movieTheaterDoc = yield this.
|
|
43
|
+
const movieTheaterDoc = yield this.civicStructureModel.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')
|
|
37
44
|
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
|
|
38
45
|
: undefined), { _id: 1 })
|
|
46
|
+
.lean()
|
|
39
47
|
.exec();
|
|
40
48
|
if (movieTheaterDoc === null) {
|
|
41
49
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
@@ -178,6 +178,7 @@ function processUpdateMovieTheater(params) {
|
|
|
178
178
|
const processStart = process.hrtime.bigint();
|
|
179
179
|
const savingMovieTheater = createMovieTheaterFromCOA(params.project, { id: seller.id }, yield repos.masterService.theater({ theaterCode: params.locationBranchCode }), yield repos.masterService.screen({ theaterCode: params.locationBranchCode }));
|
|
180
180
|
yield repos.movieTheater.saveMovieTheaterByBranchCode4coa(savingMovieTheater);
|
|
181
|
+
yield repos.screeningRoom.saveScreeningRooms4coa(savingMovieTheater);
|
|
181
182
|
const processEnd = process.hrtime.bigint();
|
|
182
183
|
processTime = processEnd - processStart;
|
|
183
184
|
}
|
|
@@ -751,11 +752,11 @@ function createScreeningEventSeriesId(params) {
|
|
|
751
752
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
752
753
|
/* istanbul ignore next */
|
|
753
754
|
function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromCOA) {
|
|
754
|
-
const id = `MovieTheater-${theaterFromCOA.theaterCode}`;
|
|
755
|
+
// const id = `MovieTheater-${theaterFromCOA.theaterCode}`;
|
|
755
756
|
return {
|
|
756
757
|
project: { typeOf: project.typeOf, id: project.id },
|
|
757
|
-
id: id,
|
|
758
|
-
screenCount: screensFromCOA.length,
|
|
758
|
+
// id: id,
|
|
759
|
+
// screenCount: screensFromCOA.length,
|
|
759
760
|
branchCode: theaterFromCOA.theaterCode,
|
|
760
761
|
name: {
|
|
761
762
|
ja: theaterFromCOA.theaterName,
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export declare const MONGO_AUTO_INDEX: boolean;
|
|
|
8
8
|
/**
|
|
9
9
|
* 施設コンテンツのsecondaryコレクションへ同期するかどうか
|
|
10
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* 施設のprimaryコレクションとして新スキーマを使用するかどうか
|
|
13
|
+
*/
|
|
14
|
+
export declare const USE_CIVIC_STRUCTURE_SCHEMA: boolean;
|
|
11
15
|
interface IOptions {
|
|
12
16
|
onOrderStatusChanged: factory.project.IOnOrderStatusChanged;
|
|
13
17
|
onEventChanged: {
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Settings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
|
|
3
|
+
exports.Settings = exports.USE_CIVIC_STRUCTURE_SCHEMA = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
|
|
4
4
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
5
5
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
6
6
|
// tslint:disable-next-line:no-magic-numbers
|
|
@@ -9,6 +9,18 @@ exports.MONGO_READ_PREFERENCE = (typeof process.env.MONGO_READ_PREFERENCE === 's
|
|
|
9
9
|
? process.env.MONGO_READ_PREFERENCE
|
|
10
10
|
: 'primaryPreferred';
|
|
11
11
|
exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
|
|
12
|
+
/**
|
|
13
|
+
* 施設コンテンツのprimaryコレクションとして新スキーマを使用するかどうか
|
|
14
|
+
*/
|
|
15
|
+
// export const USE_EVENT_SERIES_NEW_SCHEMA = process.env.USE_EVENT_SERIES_NEW_SCHEMA === '1';
|
|
16
|
+
/**
|
|
17
|
+
* 施設コンテンツのsecondaryコレクションへ同期するかどうか
|
|
18
|
+
*/
|
|
19
|
+
// export const USE_EVENT_SERIES_SYNC2SECONDARY = process.env.USE_EVENT_SERIES_SYNC2SECONDARY === '1';
|
|
20
|
+
/**
|
|
21
|
+
* 施設のprimaryコレクションとして新スキーマを使用するかどうか
|
|
22
|
+
*/
|
|
23
|
+
exports.USE_CIVIC_STRUCTURE_SCHEMA = process.env.USE_CIVIC_STRUCTURE_SCHEMA === '1';
|
|
12
24
|
/**
|
|
13
25
|
* domain settings
|
|
14
26
|
*/
|
package/package.json
CHANGED