@chevre/domain 28.0.0-alpha.12 → 28.0.0-alpha.13
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.
|
@@ -30,10 +30,13 @@ export declare class POSRepo {
|
|
|
30
30
|
*/
|
|
31
31
|
excludePOSId: boolean;
|
|
32
32
|
}): Promise<Pick<factory.place.movieTheater.IPOS, 'branchCode' | 'name'>[]>;
|
|
33
|
-
|
|
33
|
+
private countPOS;
|
|
34
|
+
addPOSByBranchCode(params: Pick<factory.place.movieTheater.IPOS, 'branchCode' | 'name'> & {
|
|
34
35
|
project: {
|
|
35
36
|
id: string;
|
|
36
37
|
};
|
|
38
|
+
}, options: {
|
|
39
|
+
maxNumPOS: number;
|
|
37
40
|
}): Promise<{
|
|
38
41
|
id: string;
|
|
39
42
|
}>;
|
|
@@ -58,7 +58,32 @@ class POSRepo {
|
|
|
58
58
|
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
59
59
|
.exec();
|
|
60
60
|
}
|
|
61
|
-
async
|
|
61
|
+
async countPOS() {
|
|
62
|
+
const posCount = (await this.civicStructureModel.aggregate([
|
|
63
|
+
{
|
|
64
|
+
$match: {
|
|
65
|
+
_id: { $eq: new mongoose_1.Types.ObjectId(this.operator.id) },
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
$project: {
|
|
70
|
+
posCount: {
|
|
71
|
+
$cond: {
|
|
72
|
+
if: { $isArray: '$hasPOS' },
|
|
73
|
+
then: { $size: '$hasPOS' },
|
|
74
|
+
else: 0
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]).option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
80
|
+
.exec()).at(0)?.posCount;
|
|
81
|
+
if (typeof posCount !== 'number') {
|
|
82
|
+
throw new factory_1.factory.errors.NotFound(factory_1.factory.placeType.MovieTheater);
|
|
83
|
+
}
|
|
84
|
+
return { posCount };
|
|
85
|
+
}
|
|
86
|
+
async addPOSByBranchCode(params, options) {
|
|
62
87
|
// 施設存在確認
|
|
63
88
|
let doc = await this.civicStructureModel.findOne({
|
|
64
89
|
'project.id': { $eq: params.project.id },
|
|
@@ -68,6 +93,12 @@ class POSRepo {
|
|
|
68
93
|
if (doc === null) {
|
|
69
94
|
throw new factory_1.factory.errors.NotFound(factory_1.factory.placeType.MovieTheater);
|
|
70
95
|
}
|
|
96
|
+
// 最大数検証(2026-09-20~)
|
|
97
|
+
const { maxNumPOS } = options;
|
|
98
|
+
const { posCount } = await this.countPOS();
|
|
99
|
+
if (posCount >= maxNumPOS) {
|
|
100
|
+
throw new factory_1.factory.errors.Argument('operator.id', 'maxNumPOS exceeded');
|
|
101
|
+
}
|
|
71
102
|
const creatingPOS = {
|
|
72
103
|
// 互換性維持対応としてidを保管
|
|
73
104
|
id: params.branchCode, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -79,7 +110,12 @@ class POSRepo {
|
|
|
79
110
|
_id: { $eq: this.operator.id },
|
|
80
111
|
'hasPOS.branchCode': { $ne: params.branchCode }
|
|
81
112
|
}, {
|
|
82
|
-
$push: {
|
|
113
|
+
$push: {
|
|
114
|
+
hasPOS: {
|
|
115
|
+
$each: [creatingPOS],
|
|
116
|
+
$slice: maxNumPOS // 最大数担保(2026-09-20~)
|
|
117
|
+
},
|
|
118
|
+
}
|
|
83
119
|
}, {
|
|
84
120
|
new: true,
|
|
85
121
|
projection: { _id: 1 }
|
package/package.json
CHANGED