@chevre/domain 23.2.0-alpha.6 → 23.2.0-alpha.8
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/eventSeries/migrateEventSeriesOffers.ts +75 -0
- package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
- package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
- package/example/src/chevre/roles/addAdminSeatReadPermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminSeatWritePermissionIfNotExists.ts +33 -0
- package/lib/chevre/repo/place/screeningRoom.d.ts +22 -1
- package/lib/chevre/repo/place/screeningRoom.js +5 -0
- package/lib/chevre/repo/place/section.d.ts +28 -29
- package/lib/chevre/repo/place/section.js +86 -39
- package/package.json +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const cursor = eventSeriesRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
// _id: { $eq: 'bmd7x21f2' },
|
|
16
|
+
// 'project.id': { $eq: 'xxx' },
|
|
17
|
+
'offers.typeOf': {
|
|
18
|
+
$exists: true,
|
|
19
|
+
$eq: chevre.factory.offerType.AggregateOffer
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
// _id: 1,
|
|
24
|
+
// offers: 1,
|
|
25
|
+
// startDate: 1,
|
|
26
|
+
// project: 1,
|
|
27
|
+
// typeOf: 1
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
console.log('docs found');
|
|
31
|
+
|
|
32
|
+
let i = 0;
|
|
33
|
+
let updateCount = 0;
|
|
34
|
+
await cursor.eachAsync(async (doc) => {
|
|
35
|
+
i += 1;
|
|
36
|
+
const eventSeries: Pick<
|
|
37
|
+
chevre.factory.eventSeries.IEvent,
|
|
38
|
+
'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
|
|
39
|
+
> = doc.toObject();
|
|
40
|
+
|
|
41
|
+
console.log(
|
|
42
|
+
'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
43
|
+
const alreadyMigrated = eventSeries.offers?.typeOf === chevre.factory.offerType.Offer;
|
|
44
|
+
|
|
45
|
+
if (alreadyMigrated) {
|
|
46
|
+
console.log(
|
|
47
|
+
'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
48
|
+
} else {
|
|
49
|
+
console.log(
|
|
50
|
+
'updating...',
|
|
51
|
+
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
52
|
+
await eventSeriesRepo.saveEventSeries({
|
|
53
|
+
id: eventSeries.id,
|
|
54
|
+
attributes: <any>{
|
|
55
|
+
...{
|
|
56
|
+
typeOf: eventSeries.typeOf,
|
|
57
|
+
'offers.typeOf': chevre.factory.offerType.Offer
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
updateCount += 1;
|
|
62
|
+
console.log(
|
|
63
|
+
'updated.',
|
|
64
|
+
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(i, 'docs checked');
|
|
70
|
+
console.log(updateCount, 'docs updated');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main()
|
|
74
|
+
.then()
|
|
75
|
+
.catch(console.error);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment-timezone';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
15
|
+
const sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = roomRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
'project.id': {
|
|
20
|
+
$ne: 'sskts-development',
|
|
21
|
+
$eq: 'ttts-development'
|
|
22
|
+
}
|
|
23
|
+
// _id: { $eq: '67de46777ec0510590b68922' }
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
// _id: 1,
|
|
27
|
+
// about: 1,
|
|
28
|
+
// project: 1,
|
|
29
|
+
// typeOf: 1,
|
|
30
|
+
// issuedBy: 1
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
console.log('docs found');
|
|
34
|
+
|
|
35
|
+
const timestamp = moment()
|
|
36
|
+
.tz('Asia/Tokyo')
|
|
37
|
+
.format('YYYYMMDDHHmmss');
|
|
38
|
+
|
|
39
|
+
let i = 0;
|
|
40
|
+
let updateCount = 0;
|
|
41
|
+
await cursor.eachAsync(async (doc) => {
|
|
42
|
+
const room: chevre.factory.place.screeningRoom.IPlace = doc.toObject();
|
|
43
|
+
|
|
44
|
+
const sections = room.containsPlace;
|
|
45
|
+
if (Array.isArray(sections)) {
|
|
46
|
+
for (const section of sections) {
|
|
47
|
+
i += 1;
|
|
48
|
+
const movieTheaterCode = room.containedInPlace?.branchCode;
|
|
49
|
+
if (typeof movieTheaterCode !== 'string') {
|
|
50
|
+
throw new Error('movieTheaterCode undefined');
|
|
51
|
+
}
|
|
52
|
+
const alreadyMigrated = typeof (<any>section).identifier === 'string';
|
|
53
|
+
|
|
54
|
+
if (alreadyMigrated) {
|
|
55
|
+
console.log(
|
|
56
|
+
'already migrated.', room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
57
|
+
} else {
|
|
58
|
+
// if (typeof identity.id !== 'string') {
|
|
59
|
+
// throw new Error(`id undefined ${identity.id}`);
|
|
60
|
+
// }
|
|
61
|
+
const identifier = `${movieTheaterCode}:${room.branchCode}:${section.branchCode}:${timestamp}`;
|
|
62
|
+
|
|
63
|
+
console.log(
|
|
64
|
+
'updating...',
|
|
65
|
+
identifier,
|
|
66
|
+
room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
67
|
+
await sectionRepo.migrateSectionIdentifier({
|
|
68
|
+
project: { id: room.project.id },
|
|
69
|
+
identifier,
|
|
70
|
+
branchCode: section.branchCode,
|
|
71
|
+
containedInPlace: {
|
|
72
|
+
branchCode: room.branchCode,
|
|
73
|
+
containedInPlace: {
|
|
74
|
+
branchCode: movieTheaterCode
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
updateCount += 1;
|
|
79
|
+
console.log(
|
|
80
|
+
'updated.', room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
console.log(i, 'docs checked');
|
|
87
|
+
console.log(updateCount, 'docs updated');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
main()
|
|
91
|
+
.then()
|
|
92
|
+
.catch(console.error);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const roleNames = [
|
|
12
|
+
// chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
13
|
+
chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
|
|
15
|
+
chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
16
|
+
];
|
|
17
|
+
const permissions = [
|
|
18
|
+
'admin.creativeWorks.read'
|
|
19
|
+
];
|
|
20
|
+
for (const roleName of roleNames) {
|
|
21
|
+
for (const permission of permissions) {
|
|
22
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
23
|
+
roleName: { $eq: roleName },
|
|
24
|
+
permission
|
|
25
|
+
});
|
|
26
|
+
console.log('permission added.', result, roleName);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// roleNames = [
|
|
31
|
+
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
32
|
+
// ];
|
|
33
|
+
// permissions = [
|
|
34
|
+
// 'admin.sellers.productOffers.read'
|
|
35
|
+
// ];
|
|
36
|
+
// for (const roleName of roleNames) {
|
|
37
|
+
// for (const permission of permissions) {
|
|
38
|
+
// const result = await roleRepo.addPermissionIfNotExists({
|
|
39
|
+
// roleName: { $eq: roleName },
|
|
40
|
+
// permission
|
|
41
|
+
// });
|
|
42
|
+
// console.log('permission added.', result, roleName);
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
main()
|
|
48
|
+
.then()
|
|
49
|
+
.catch(console.error);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const roleNames = [
|
|
12
|
+
// chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
13
|
+
// chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
+
// chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
|
|
15
|
+
chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
16
|
+
];
|
|
17
|
+
const permissions = [
|
|
18
|
+
'admin.sellers.seats.read'
|
|
19
|
+
];
|
|
20
|
+
for (const roleName of roleNames) {
|
|
21
|
+
for (const permission of permissions) {
|
|
22
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
23
|
+
roleName: { $eq: roleName },
|
|
24
|
+
permission
|
|
25
|
+
});
|
|
26
|
+
console.log('permission added.', result, roleName);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
main()
|
|
32
|
+
.then()
|
|
33
|
+
.catch(console.error);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const roleNames = [
|
|
12
|
+
chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
13
|
+
chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
15
|
+
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
16
|
+
];
|
|
17
|
+
const permissions = [
|
|
18
|
+
'admin.sellers.seats.*'
|
|
19
|
+
];
|
|
20
|
+
for (const roleName of roleNames) {
|
|
21
|
+
for (const permission of permissions) {
|
|
22
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
23
|
+
roleName: { $eq: roleName },
|
|
24
|
+
permission
|
|
25
|
+
});
|
|
26
|
+
console.log('permission added.', result, roleName);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
main()
|
|
32
|
+
.then()
|
|
33
|
+
.catch(console.error);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
|
|
4
4
|
/**
|
|
@@ -114,5 +114,26 @@ export declare class ScreeningRoomRepo {
|
|
|
114
114
|
id: string;
|
|
115
115
|
};
|
|
116
116
|
}): Promise<void>;
|
|
117
|
+
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/place/screeningRoom").IPlace & {
|
|
118
|
+
description?: any;
|
|
119
|
+
openingHoursSpecification?: any;
|
|
120
|
+
smokingAllowed?: boolean;
|
|
121
|
+
}> & import("@chevre/factory/lib/place/screeningRoom").IPlace & {
|
|
122
|
+
description?: any;
|
|
123
|
+
openingHoursSpecification?: any;
|
|
124
|
+
smokingAllowed?: boolean;
|
|
125
|
+
} & {
|
|
126
|
+
_id: import("mongoose").Types.ObjectId;
|
|
127
|
+
}, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/place/screeningRoom").IPlace & {
|
|
128
|
+
description?: any;
|
|
129
|
+
openingHoursSpecification?: any;
|
|
130
|
+
smokingAllowed?: boolean;
|
|
131
|
+
}> & import("@chevre/factory/lib/place/screeningRoom").IPlace & {
|
|
132
|
+
description?: any;
|
|
133
|
+
openingHoursSpecification?: any;
|
|
134
|
+
smokingAllowed?: boolean;
|
|
135
|
+
} & {
|
|
136
|
+
_id: import("mongoose").Types.ObjectId;
|
|
137
|
+
}>>;
|
|
117
138
|
}
|
|
118
139
|
export {};
|
|
@@ -430,5 +430,10 @@ class ScreeningRoomRepo {
|
|
|
430
430
|
.exec();
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
|
+
getCursor(conditions, projection) {
|
|
434
|
+
return this.placeModel.find(conditions, projection)
|
|
435
|
+
.sort({ branchCode: factory.sortType.Ascending })
|
|
436
|
+
.cursor();
|
|
437
|
+
}
|
|
433
438
|
}
|
|
434
439
|
exports.ScreeningRoomRepo = ScreeningRoomRepo;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
|
|
4
|
+
type ICreatingSection = Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name'>;
|
|
5
|
+
interface IUpdateOptions {
|
|
6
|
+
project: {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
parentOrganization?: {
|
|
10
|
+
id?: string;
|
|
11
|
+
};
|
|
12
|
+
movieTheaterCode: string;
|
|
13
|
+
roomCode: string;
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* セクション編集時レスポンス
|
|
6
17
|
*/
|
|
@@ -20,22 +31,28 @@ export declare class SectionRepo {
|
|
|
20
31
|
private readonly civicStructureModel;
|
|
21
32
|
private readonly placeModel;
|
|
22
33
|
constructor(connection: Connection);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
createSection(screeningRoomSection: ICreatingSection, options: IUpdateOptions): Promise<IUpdateSectionResult>;
|
|
35
|
+
/**
|
|
36
|
+
* セクションの名称と追加特性を編集する
|
|
37
|
+
*/
|
|
38
|
+
updateSectionByBranchCode(screeningRoomSection: ICreatingSection, $unset: any, options: IUpdateOptions): Promise<IUpdateSectionResult>;
|
|
39
|
+
/**
|
|
40
|
+
* セクションの座席を上書きする
|
|
41
|
+
*/
|
|
42
|
+
overwriteSeats(screeningRoomSection: Pick<factory.place.screeningRoomSection.IPlace, 'branchCode' | 'containsPlace'>, options: IUpdateOptions): Promise<IUpdateSectionResult>;
|
|
43
|
+
migrateSectionIdentifier(screeningRoomSection: {
|
|
44
|
+
project: {
|
|
45
|
+
id: string;
|
|
26
46
|
};
|
|
27
|
-
|
|
28
|
-
|
|
47
|
+
identifier: string;
|
|
48
|
+
branchCode: string;
|
|
29
49
|
containedInPlace: {
|
|
30
50
|
branchCode: string;
|
|
31
51
|
containedInPlace: {
|
|
32
52
|
branchCode: string;
|
|
33
53
|
};
|
|
34
54
|
};
|
|
35
|
-
|
|
36
|
-
id?: string;
|
|
37
|
-
};
|
|
38
|
-
}, $unset: any): Promise<IUpdateSectionResult>;
|
|
55
|
+
}): Promise<IUpdateSectionResult>;
|
|
39
56
|
searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
|
|
40
57
|
/**
|
|
41
58
|
* ルーム指定のセクション検索として再定義(2025-12-07~)
|
|
@@ -57,29 +74,11 @@ export declare class SectionRepo {
|
|
|
57
74
|
*/
|
|
58
75
|
roomCode: string;
|
|
59
76
|
}): Promise<Pick<IScreeningRoomSectionWithoutContainsPlace, 'additionalProperty' | 'branchCode' | 'name'>[]>;
|
|
60
|
-
|
|
61
|
-
project: {
|
|
62
|
-
id: string;
|
|
63
|
-
};
|
|
64
|
-
parentOrganization?: {
|
|
65
|
-
id?: string;
|
|
66
|
-
};
|
|
77
|
+
deleteSectionByBranchCode(screeningRoomSection: {
|
|
67
78
|
/**
|
|
68
79
|
* セクションコード
|
|
69
80
|
*/
|
|
70
81
|
branchCode: string;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* ルームコード
|
|
74
|
-
*/
|
|
75
|
-
branchCode: string;
|
|
76
|
-
containedInPlace: {
|
|
77
|
-
/**
|
|
78
|
-
* 施設コード
|
|
79
|
-
*/
|
|
80
|
-
branchCode: string;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
}): Promise<IUpdateSectionResult>;
|
|
82
|
+
}, options: IUpdateOptions): Promise<IUpdateSectionResult>;
|
|
84
83
|
}
|
|
85
84
|
export {};
|
|
@@ -23,20 +23,12 @@ class SectionRepo {
|
|
|
23
23
|
this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
|
|
24
24
|
}
|
|
25
25
|
// tslint:disable-next-line:max-func-body-length
|
|
26
|
-
|
|
26
|
+
createSection(screeningRoomSection, options) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
|
|
29
|
-
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
30
|
-
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
31
|
-
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
32
|
-
}
|
|
33
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
34
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
35
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
36
|
-
}
|
|
28
|
+
const { project, parentOrganization, movieTheaterCode, roomCode } = options;
|
|
37
29
|
// 施設存在確認
|
|
38
|
-
const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq:
|
|
39
|
-
? { 'parentOrganization.id': { $exists: true, $eq:
|
|
30
|
+
const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: project.id }, branchCode: { $eq: movieTheaterCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
|
|
31
|
+
? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
|
|
40
32
|
: undefined), { _id: 1 })
|
|
41
33
|
.lean()
|
|
42
34
|
.exec();
|
|
@@ -46,13 +38,13 @@ class SectionRepo {
|
|
|
46
38
|
// セクションコードが存在しなければ追加する
|
|
47
39
|
const doc = yield this.placeModel.findOneAndUpdate({
|
|
48
40
|
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
49
|
-
'project.id': { $eq:
|
|
50
|
-
'containedInPlace.branchCode': { $exists: true, $eq:
|
|
51
|
-
branchCode: { $eq:
|
|
41
|
+
'project.id': { $eq: project.id },
|
|
42
|
+
'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode },
|
|
43
|
+
branchCode: { $eq: roomCode },
|
|
52
44
|
'containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
|
|
53
45
|
}, {
|
|
54
46
|
$push: {
|
|
55
|
-
containsPlace: Object.assign({ typeOf:
|
|
47
|
+
containsPlace: Object.assign({ typeOf: factory.placeType.ScreeningRoomSection, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
|
|
56
48
|
? { additionalProperty: screeningRoomSection.additionalProperty }
|
|
57
49
|
: undefined)
|
|
58
50
|
}
|
|
@@ -68,21 +60,16 @@ class SectionRepo {
|
|
|
68
60
|
return doc.toObject();
|
|
69
61
|
});
|
|
70
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* セクションの名称と追加特性を編集する
|
|
65
|
+
*/
|
|
71
66
|
// tslint:disable-next-line:max-func-body-length
|
|
72
|
-
|
|
67
|
+
updateSectionByBranchCode(screeningRoomSection, $unset, options) {
|
|
73
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
const movieTheater = screeningRoom.containedInPlace;
|
|
80
|
-
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
81
|
-
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
82
|
-
}
|
|
83
|
-
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')
|
|
84
|
-
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
|
|
85
|
-
: undefined), Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
|
|
69
|
+
const { project, parentOrganization, movieTheaterCode, roomCode } = options;
|
|
70
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
|
|
71
|
+
? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
|
|
72
|
+
: undefined), Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
|
|
86
73
|
? {
|
|
87
74
|
'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
|
|
88
75
|
}
|
|
@@ -90,13 +77,73 @@ class SectionRepo {
|
|
|
90
77
|
? {
|
|
91
78
|
'containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
|
|
92
79
|
}
|
|
93
|
-
: undefined), (
|
|
80
|
+
: undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
|
|
81
|
+
new: true,
|
|
82
|
+
arrayFilters: [
|
|
83
|
+
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
|
|
84
|
+
],
|
|
85
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
86
|
+
})
|
|
87
|
+
.exec();
|
|
88
|
+
if (doc === null) {
|
|
89
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
90
|
+
}
|
|
91
|
+
return doc.toObject();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* セクションの座席を上書きする
|
|
96
|
+
*/
|
|
97
|
+
// tslint:disable-next-line:max-func-body-length
|
|
98
|
+
overwriteSeats(screeningRoomSection, options) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const { project, parentOrganization, movieTheaterCode, roomCode } = options;
|
|
101
|
+
const { containsPlace } = screeningRoomSection;
|
|
102
|
+
if (!Array.isArray(containsPlace)) {
|
|
103
|
+
throw new factory.errors.ArgumentNull('containsPlace');
|
|
104
|
+
}
|
|
105
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
|
|
106
|
+
? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
|
|
107
|
+
: undefined), Object.assign({}, (containsPlace.length > 0)
|
|
94
108
|
? {
|
|
95
|
-
'containsPlace.$[screeningRoomSection].containsPlace':
|
|
109
|
+
'containsPlace.$[screeningRoomSection].containsPlace': containsPlace.map((p) => {
|
|
96
110
|
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);
|
|
97
111
|
})
|
|
98
112
|
}
|
|
99
|
-
: undefined),
|
|
113
|
+
: undefined), {
|
|
114
|
+
new: true,
|
|
115
|
+
arrayFilters: [
|
|
116
|
+
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
|
|
117
|
+
],
|
|
118
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
119
|
+
})
|
|
120
|
+
.exec();
|
|
121
|
+
if (doc === null) {
|
|
122
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
|
|
123
|
+
}
|
|
124
|
+
return doc.toObject();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// tslint:disable-next-line:max-func-body-length
|
|
128
|
+
migrateSectionIdentifier(screeningRoomSection) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
131
|
+
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
132
|
+
throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
|
|
133
|
+
}
|
|
134
|
+
const movieTheater = screeningRoom.containedInPlace;
|
|
135
|
+
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
136
|
+
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
137
|
+
}
|
|
138
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
139
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
140
|
+
'project.id': { $eq: screeningRoomSection.project.id },
|
|
141
|
+
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
142
|
+
branchCode: { $eq: screeningRoom.branchCode },
|
|
143
|
+
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
|
|
144
|
+
}, {
|
|
145
|
+
'containsPlace.$[screeningRoomSection].identifier': screeningRoomSection.identifier
|
|
146
|
+
}, {
|
|
100
147
|
new: true,
|
|
101
148
|
arrayFilters: [
|
|
102
149
|
{ 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
|
|
@@ -209,7 +256,7 @@ class SectionRepo {
|
|
|
209
256
|
{ $unwind: '$containsPlace' },
|
|
210
257
|
...matchStages,
|
|
211
258
|
{
|
|
212
|
-
$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)
|
|
259
|
+
$project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', identifier: '$containsPlace.identifier', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.containedInPlace) === 1)
|
|
213
260
|
? {
|
|
214
261
|
containedInPlace: {
|
|
215
262
|
typeOf: '$typeOf',
|
|
@@ -295,14 +342,14 @@ class SectionRepo {
|
|
|
295
342
|
.exec();
|
|
296
343
|
});
|
|
297
344
|
}
|
|
298
|
-
|
|
345
|
+
deleteSectionByBranchCode(screeningRoomSection, options) {
|
|
299
346
|
return __awaiter(this, void 0, void 0, function* () {
|
|
300
|
-
|
|
301
|
-
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq:
|
|
347
|
+
const { project, parentOrganization, movieTheaterCode, roomCode } = options;
|
|
348
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': {
|
|
302
349
|
$exists: true,
|
|
303
|
-
$eq:
|
|
304
|
-
}, branchCode: { $eq:
|
|
305
|
-
? { 'parentOrganization.id': { $exists: true, $eq:
|
|
350
|
+
$eq: movieTheaterCode
|
|
351
|
+
}, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
|
|
352
|
+
? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
|
|
306
353
|
: undefined), {
|
|
307
354
|
$pull: {
|
|
308
355
|
containsPlace: {
|
package/package.json
CHANGED