@7365admin1/core 2.13.0 → 2.14.0
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +92 -14
- package/dist/index.js +1475 -776
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +790 -91
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -20153,7 +20153,10 @@ function usePatrolQuestionRepo() {
|
|
|
20153
20153
|
const query = {
|
|
20154
20154
|
status,
|
|
20155
20155
|
...search && {
|
|
20156
|
-
$or: [
|
|
20156
|
+
$or: [
|
|
20157
|
+
{ question: { $regex: search, $options: "i" } },
|
|
20158
|
+
{ answers: { $regex: search, $options: "i" } }
|
|
20159
|
+
]
|
|
20157
20160
|
},
|
|
20158
20161
|
...ObjectId58.isValid(site) && { site: new ObjectId58(site) }
|
|
20159
20162
|
};
|
|
@@ -20581,9 +20584,6 @@ function usePatrolRouteRepo() {
|
|
|
20581
20584
|
page = page > 0 ? page - 1 : 0;
|
|
20582
20585
|
const query = {
|
|
20583
20586
|
status,
|
|
20584
|
-
...search && {
|
|
20585
|
-
$or: [{ name: { $regex: search, $options: "i" } }]
|
|
20586
|
-
},
|
|
20587
20587
|
...ObjectId60.isValid(site) && { site: new ObjectId60(site) }
|
|
20588
20588
|
};
|
|
20589
20589
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -20603,14 +20603,57 @@ function usePatrolRouteRepo() {
|
|
|
20603
20603
|
}
|
|
20604
20604
|
try {
|
|
20605
20605
|
const basePipeline = [
|
|
20606
|
-
{
|
|
20606
|
+
{
|
|
20607
|
+
$lookup: {
|
|
20608
|
+
from: "members",
|
|
20609
|
+
localField: "assignee",
|
|
20610
|
+
foreignField: "_id",
|
|
20611
|
+
as: "assigneeData"
|
|
20612
|
+
}
|
|
20613
|
+
},
|
|
20614
|
+
{
|
|
20615
|
+
$match: {
|
|
20616
|
+
...query,
|
|
20617
|
+
...search && {
|
|
20618
|
+
$or: [
|
|
20619
|
+
{ name: { $regex: search, $options: "i" } },
|
|
20620
|
+
{ "assigneeData.name": { $regex: search, $options: "i" } },
|
|
20621
|
+
{ start: { $regex: search, $options: "i" } },
|
|
20622
|
+
{ end: { $regex: search, $options: "i" } }
|
|
20623
|
+
]
|
|
20624
|
+
}
|
|
20625
|
+
}
|
|
20626
|
+
},
|
|
20607
20627
|
{ $sort: sort },
|
|
20608
20628
|
{ $skip: page * limit },
|
|
20609
20629
|
{ $limit: limit }
|
|
20610
20630
|
];
|
|
20631
|
+
const countPipeline = [
|
|
20632
|
+
{
|
|
20633
|
+
$lookup: {
|
|
20634
|
+
from: "members",
|
|
20635
|
+
localField: "assignee",
|
|
20636
|
+
foreignField: "_id",
|
|
20637
|
+
as: "assigneeData"
|
|
20638
|
+
}
|
|
20639
|
+
},
|
|
20640
|
+
{
|
|
20641
|
+
$match: {
|
|
20642
|
+
...query,
|
|
20643
|
+
...search && {
|
|
20644
|
+
$or: [
|
|
20645
|
+
{ name: { $regex: search, $options: "i" } },
|
|
20646
|
+
{ "assigneeData.name": { $regex: search, $options: "i" } },
|
|
20647
|
+
{ start: { $regex: search, $options: "i" } },
|
|
20648
|
+
{ end: { $regex: search, $options: "i" } }
|
|
20649
|
+
]
|
|
20650
|
+
}
|
|
20651
|
+
}
|
|
20652
|
+
}
|
|
20653
|
+
];
|
|
20611
20654
|
const [items, countResult] = await Promise.all([
|
|
20612
20655
|
collection.aggregate(basePipeline, { session }).toArray(),
|
|
20613
|
-
collection.aggregate([
|
|
20656
|
+
collection.aggregate([...countPipeline, { $count: "total" }], { session }).toArray()
|
|
20614
20657
|
]);
|
|
20615
20658
|
const totalCount = countResult[0]?.total || 0;
|
|
20616
20659
|
const data = paginate27(items, page, limit, totalCount);
|
|
@@ -20719,24 +20762,16 @@ function usePatrolRouteRepo() {
|
|
|
20719
20762
|
{
|
|
20720
20763
|
$multiply: [
|
|
20721
20764
|
{
|
|
20722
|
-
$
|
|
20723
|
-
$
|
|
20724
|
-
startDate: { $toDate: "$start" },
|
|
20725
|
-
unit: "hour",
|
|
20726
|
-
amount: 8
|
|
20727
|
-
}
|
|
20765
|
+
$toInt: {
|
|
20766
|
+
$arrayElemAt: [{ $split: ["$start", ":"] }, 0]
|
|
20728
20767
|
}
|
|
20729
20768
|
},
|
|
20730
20769
|
60
|
|
20731
20770
|
]
|
|
20732
20771
|
},
|
|
20733
20772
|
{
|
|
20734
|
-
$
|
|
20735
|
-
$
|
|
20736
|
-
startDate: { $toDate: "$start" },
|
|
20737
|
-
unit: "hour",
|
|
20738
|
-
amount: 8
|
|
20739
|
-
}
|
|
20773
|
+
$toInt: {
|
|
20774
|
+
$arrayElemAt: [{ $split: ["$start", ":"] }, 1]
|
|
20740
20775
|
}
|
|
20741
20776
|
}
|
|
20742
20777
|
]
|
|
@@ -20749,24 +20784,16 @@ function usePatrolRouteRepo() {
|
|
|
20749
20784
|
{
|
|
20750
20785
|
$multiply: [
|
|
20751
20786
|
{
|
|
20752
|
-
$
|
|
20753
|
-
$
|
|
20754
|
-
startDate: { $toDate: "$end" },
|
|
20755
|
-
unit: "hour",
|
|
20756
|
-
amount: 8
|
|
20757
|
-
}
|
|
20787
|
+
$toInt: {
|
|
20788
|
+
$arrayElemAt: [{ $split: ["$end", ":"] }, 0]
|
|
20758
20789
|
}
|
|
20759
20790
|
},
|
|
20760
20791
|
60
|
|
20761
20792
|
]
|
|
20762
20793
|
},
|
|
20763
20794
|
{
|
|
20764
|
-
$
|
|
20765
|
-
$
|
|
20766
|
-
startDate: { $toDate: "$end" },
|
|
20767
|
-
unit: "hour",
|
|
20768
|
-
amount: 8
|
|
20769
|
-
}
|
|
20795
|
+
$toInt: {
|
|
20796
|
+
$arrayElemAt: [{ $split: ["$end", ":"] }, 1]
|
|
20770
20797
|
}
|
|
20771
20798
|
}
|
|
20772
20799
|
]
|
|
@@ -21104,6 +21131,8 @@ var schemeLogCamera = Joi65.object({
|
|
|
21104
21131
|
start: Joi65.string().optional().allow("", null),
|
|
21105
21132
|
end: Joi65.string().optional().allow("", null),
|
|
21106
21133
|
duration: Joi65.number().optional().allow("", null),
|
|
21134
|
+
status: Joi65.string().optional().allow("", null),
|
|
21135
|
+
description: Joi65.string().optional().allow("", null),
|
|
21107
21136
|
questions: Joi65.array().items(
|
|
21108
21137
|
Joi65.object({
|
|
21109
21138
|
questionId: Joi65.string().hex().required(),
|
|
@@ -21124,7 +21153,7 @@ var schemaPatrolLog = Joi65.object({
|
|
|
21124
21153
|
start: Joi65.string().required(),
|
|
21125
21154
|
end: Joi65.string().required(),
|
|
21126
21155
|
cameras: Joi65.array().items(schemeLogCamera).required(),
|
|
21127
|
-
status: Joi65.array().items(Joi65.string().valid("complete", "late")).required(),
|
|
21156
|
+
status: Joi65.array().items(Joi65.string().valid("complete", "late", "incomplete")).required(),
|
|
21128
21157
|
createdAt: Joi65.date().optional(),
|
|
21129
21158
|
updatedAt: Joi65.date().optional(),
|
|
21130
21159
|
deletedAt: Joi65.date().optional()
|
|
@@ -21137,7 +21166,7 @@ var schemaUpdatePatrolLog = Joi65.object({
|
|
|
21137
21166
|
start: Joi65.string().optional().allow(null, ""),
|
|
21138
21167
|
end: Joi65.string().optional().allow(null, ""),
|
|
21139
21168
|
cameras: Joi65.array().items(schemeLogCamera).optional().allow(null, ""),
|
|
21140
|
-
status: Joi65.array().items(Joi65.string().valid("complete", "late")).optional().allow(null, "")
|
|
21169
|
+
status: Joi65.array().items(Joi65.string().valid("complete", "late", "incomplete")).optional().allow(null, "")
|
|
21141
21170
|
});
|
|
21142
21171
|
function MPatrolLog(value) {
|
|
21143
21172
|
const { error } = schemaPatrolLog.validate(value);
|
|
@@ -21275,9 +21304,6 @@ function usePatrolLogRepo() {
|
|
|
21275
21304
|
}, session) {
|
|
21276
21305
|
page = page > 0 ? page - 1 : 0;
|
|
21277
21306
|
const query = {
|
|
21278
|
-
...search && {
|
|
21279
|
-
$or: [{ name: { $regex: search, $options: "i" } }]
|
|
21280
|
-
},
|
|
21281
21307
|
...ObjectId62.isValid(site) && { site: new ObjectId62(site) }
|
|
21282
21308
|
};
|
|
21283
21309
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -21297,14 +21323,113 @@ function usePatrolLogRepo() {
|
|
|
21297
21323
|
}
|
|
21298
21324
|
try {
|
|
21299
21325
|
const basePipeline = [
|
|
21300
|
-
{
|
|
21326
|
+
{
|
|
21327
|
+
$lookup: {
|
|
21328
|
+
from: "members",
|
|
21329
|
+
localField: "assignee",
|
|
21330
|
+
foreignField: "_id",
|
|
21331
|
+
as: "assigneeData"
|
|
21332
|
+
}
|
|
21333
|
+
},
|
|
21334
|
+
{
|
|
21335
|
+
$match: {
|
|
21336
|
+
...query,
|
|
21337
|
+
...search && {
|
|
21338
|
+
$or: [
|
|
21339
|
+
{ name: { $regex: search, $options: "i" } },
|
|
21340
|
+
{ "assigneeData.name": { $regex: search, $options: "i" } },
|
|
21341
|
+
{
|
|
21342
|
+
$expr: {
|
|
21343
|
+
$regexMatch: {
|
|
21344
|
+
input: {
|
|
21345
|
+
$dateToString: {
|
|
21346
|
+
date: { $toDate: "$start" },
|
|
21347
|
+
format: "%H:%M",
|
|
21348
|
+
timezone: "Asia/Singapore"
|
|
21349
|
+
}
|
|
21350
|
+
},
|
|
21351
|
+
regex: search,
|
|
21352
|
+
options: "i"
|
|
21353
|
+
}
|
|
21354
|
+
}
|
|
21355
|
+
},
|
|
21356
|
+
{
|
|
21357
|
+
$expr: {
|
|
21358
|
+
$regexMatch: {
|
|
21359
|
+
input: {
|
|
21360
|
+
$dateToString: {
|
|
21361
|
+
date: { $toDate: "$start" },
|
|
21362
|
+
format: "%H:%M",
|
|
21363
|
+
timezone: "Asia/Singapore"
|
|
21364
|
+
}
|
|
21365
|
+
},
|
|
21366
|
+
regex: search,
|
|
21367
|
+
options: "i"
|
|
21368
|
+
}
|
|
21369
|
+
}
|
|
21370
|
+
}
|
|
21371
|
+
]
|
|
21372
|
+
}
|
|
21373
|
+
}
|
|
21374
|
+
},
|
|
21301
21375
|
{ $sort: sort },
|
|
21302
21376
|
{ $skip: page * limit },
|
|
21303
21377
|
{ $limit: limit }
|
|
21304
21378
|
];
|
|
21379
|
+
const countPipeline = [
|
|
21380
|
+
{
|
|
21381
|
+
$lookup: {
|
|
21382
|
+
from: "members",
|
|
21383
|
+
localField: "assignee",
|
|
21384
|
+
foreignField: "_id",
|
|
21385
|
+
as: "assigneeData"
|
|
21386
|
+
}
|
|
21387
|
+
},
|
|
21388
|
+
{
|
|
21389
|
+
$match: {
|
|
21390
|
+
...query,
|
|
21391
|
+
...search && {
|
|
21392
|
+
$or: [
|
|
21393
|
+
{ name: { $regex: search, $options: "i" } },
|
|
21394
|
+
{ "assigneeData.name": { $regex: search, $options: "i" } },
|
|
21395
|
+
{
|
|
21396
|
+
$expr: {
|
|
21397
|
+
$regexMatch: {
|
|
21398
|
+
input: {
|
|
21399
|
+
$dateToString: {
|
|
21400
|
+
date: { $toDate: "$start" },
|
|
21401
|
+
format: "%H:%M",
|
|
21402
|
+
timezone: "Asia/Singapore"
|
|
21403
|
+
}
|
|
21404
|
+
},
|
|
21405
|
+
regex: search,
|
|
21406
|
+
options: "i"
|
|
21407
|
+
}
|
|
21408
|
+
}
|
|
21409
|
+
},
|
|
21410
|
+
{
|
|
21411
|
+
$expr: {
|
|
21412
|
+
$regexMatch: {
|
|
21413
|
+
input: {
|
|
21414
|
+
$dateToString: {
|
|
21415
|
+
date: { $toDate: "$start" },
|
|
21416
|
+
format: "%H:%M",
|
|
21417
|
+
timezone: "Asia/Singapore"
|
|
21418
|
+
}
|
|
21419
|
+
},
|
|
21420
|
+
regex: search,
|
|
21421
|
+
options: "i"
|
|
21422
|
+
}
|
|
21423
|
+
}
|
|
21424
|
+
}
|
|
21425
|
+
]
|
|
21426
|
+
}
|
|
21427
|
+
}
|
|
21428
|
+
}
|
|
21429
|
+
];
|
|
21305
21430
|
const [items, countResult] = await Promise.all([
|
|
21306
21431
|
collection.aggregate(basePipeline, { session }).toArray(),
|
|
21307
|
-
collection.aggregate([
|
|
21432
|
+
collection.aggregate([...countPipeline, { $count: "total" }], { session }).toArray()
|
|
21308
21433
|
]);
|
|
21309
21434
|
const totalCount = countResult[0]?.total || 0;
|
|
21310
21435
|
const data = paginate28(items, page, limit, totalCount);
|
|
@@ -26009,14 +26134,16 @@ var schemaEventManagement = Joi81.object({
|
|
|
26009
26134
|
title: Joi81.string().required(),
|
|
26010
26135
|
description: Joi81.string().optional().allow(""),
|
|
26011
26136
|
dateTime: Joi81.alternatives().try(Joi81.string(), Joi81.date()).required(),
|
|
26012
|
-
status: Joi81.string().optional().default("planned")
|
|
26137
|
+
status: Joi81.string().optional().default("planned"),
|
|
26138
|
+
type: Joi81.string().optional().default("TASK")
|
|
26013
26139
|
});
|
|
26014
26140
|
var schemaUpdateEventManagement = Joi81.object({
|
|
26015
26141
|
_id: Joi81.string().hex().required(),
|
|
26016
26142
|
title: Joi81.string().optional().allow(null, ""),
|
|
26017
26143
|
description: Joi81.string().optional().allow(null, ""),
|
|
26018
26144
|
dateTime: Joi81.alternatives().try(Joi81.string(), Joi81.date()).optional().allow(null, ""),
|
|
26019
|
-
status: Joi81.string().optional().allow(null, "")
|
|
26145
|
+
status: Joi81.string().optional().allow(null, ""),
|
|
26146
|
+
type: Joi81.string().optional().allow(null, "")
|
|
26020
26147
|
});
|
|
26021
26148
|
function MEventManagement(value) {
|
|
26022
26149
|
if (value._id && typeof value._id === "string") {
|
|
@@ -26040,6 +26167,7 @@ function MEventManagement(value) {
|
|
|
26040
26167
|
description: value.description ?? "",
|
|
26041
26168
|
dateTime: value.dateTime,
|
|
26042
26169
|
status: value.status ?? "planned",
|
|
26170
|
+
type: value.type ?? "TASK",
|
|
26043
26171
|
createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
26044
26172
|
updatedAt: value.updatedAt,
|
|
26045
26173
|
deletedAt: value.deletedAt
|
|
@@ -26114,7 +26242,8 @@ function useEventManagementRepo() {
|
|
|
26114
26242
|
limit = 10,
|
|
26115
26243
|
sort = {},
|
|
26116
26244
|
site = "",
|
|
26117
|
-
status = ""
|
|
26245
|
+
status = "",
|
|
26246
|
+
type = ""
|
|
26118
26247
|
}, session) {
|
|
26119
26248
|
page = page > 0 ? page - 1 : 0;
|
|
26120
26249
|
try {
|
|
@@ -26124,7 +26253,8 @@ function useEventManagementRepo() {
|
|
|
26124
26253
|
}
|
|
26125
26254
|
const baseQuery = {
|
|
26126
26255
|
site,
|
|
26127
|
-
status: status ? status : { $ne: "deleted" }
|
|
26256
|
+
status: status ? status : { $ne: "deleted" },
|
|
26257
|
+
...type && { type }
|
|
26128
26258
|
};
|
|
26129
26259
|
let query = { ...baseQuery };
|
|
26130
26260
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -26133,7 +26263,8 @@ function useEventManagementRepo() {
|
|
|
26133
26263
|
status: status ? status : { $ne: "deleted" },
|
|
26134
26264
|
sort: JSON.stringify(sort),
|
|
26135
26265
|
page,
|
|
26136
|
-
limit
|
|
26266
|
+
limit,
|
|
26267
|
+
...type && { type }
|
|
26137
26268
|
};
|
|
26138
26269
|
if (search) {
|
|
26139
26270
|
query.$text = { $search: search };
|
|
@@ -26420,7 +26551,8 @@ function useEventManagementController() {
|
|
|
26420
26551
|
sort: Joi82.string().pattern(/^([a-zA-Z0-9_]+)(,[a-zA-Z0-9_]+)*$/).optional().allow("", ...allowedFields),
|
|
26421
26552
|
order: Joi82.string().pattern(/^(asc|desc)(,(asc|desc))*$/).optional().allow("", ...allowedOrder),
|
|
26422
26553
|
site: Joi82.string().hex().required(),
|
|
26423
|
-
status: Joi82.string().optional()
|
|
26554
|
+
status: Joi82.string().optional(),
|
|
26555
|
+
type: Joi82.string().optional().valid("TASK", "EVENT").allow(null, "")
|
|
26424
26556
|
});
|
|
26425
26557
|
const query = { ...req.query };
|
|
26426
26558
|
const { error } = validation.validate(query, {
|
|
@@ -26437,6 +26569,7 @@ function useEventManagementController() {
|
|
|
26437
26569
|
const limit = parseInt(req.query.limit ?? "10");
|
|
26438
26570
|
const site = req.query.site ?? "";
|
|
26439
26571
|
const status = req.query.status ?? "";
|
|
26572
|
+
const type = req.query.type ?? "";
|
|
26440
26573
|
const sortObj = {};
|
|
26441
26574
|
const sortFields = String(req.query.sort).split(",");
|
|
26442
26575
|
const sortOrders = String(req.query.order).split(",");
|
|
@@ -26453,7 +26586,8 @@ function useEventManagementController() {
|
|
|
26453
26586
|
limit,
|
|
26454
26587
|
sort: sortObj,
|
|
26455
26588
|
site,
|
|
26456
|
-
status
|
|
26589
|
+
status,
|
|
26590
|
+
type
|
|
26457
26591
|
});
|
|
26458
26592
|
res.status(200).json(data);
|
|
26459
26593
|
return;
|
|
@@ -27412,11 +27546,12 @@ var EAccessCardTypes = /* @__PURE__ */ ((EAccessCardTypes2) => {
|
|
|
27412
27546
|
EAccessCardTypes2["QR"] = "QRCODE";
|
|
27413
27547
|
return EAccessCardTypes2;
|
|
27414
27548
|
})(EAccessCardTypes || {});
|
|
27415
|
-
var EAccessCardUserTypes = /* @__PURE__ */ ((
|
|
27416
|
-
|
|
27417
|
-
|
|
27418
|
-
|
|
27419
|
-
|
|
27549
|
+
var EAccessCardUserTypes = /* @__PURE__ */ ((EAccessCardUserTypes2) => {
|
|
27550
|
+
EAccessCardUserTypes2["RESIDENT"] = "Resident/Tenant";
|
|
27551
|
+
EAccessCardUserTypes2["CONTRACTOR"] = "Contractor";
|
|
27552
|
+
EAccessCardUserTypes2["VISITOR"] = "Visitor";
|
|
27553
|
+
EAccessCardUserTypes2["DEFAULT"] = "Visitor/Resident";
|
|
27554
|
+
return EAccessCardUserTypes2;
|
|
27420
27555
|
})(EAccessCardUserTypes || {});
|
|
27421
27556
|
var AccessTypeProps = /* @__PURE__ */ ((AccessTypeProps2) => {
|
|
27422
27557
|
AccessTypeProps2["NORMAL"] = "Normal";
|
|
@@ -28077,16 +28212,16 @@ function UseAccessManagementRepo() {
|
|
|
28077
28212
|
preserveNullAndEmptyArrays: false
|
|
28078
28213
|
}
|
|
28079
28214
|
},
|
|
28080
|
-
// Groups by unit _id and keeps only the first occurrence
|
|
28081
|
-
{
|
|
28082
|
-
|
|
28083
|
-
|
|
28084
|
-
|
|
28085
|
-
|
|
28086
|
-
},
|
|
28087
|
-
{
|
|
28088
|
-
|
|
28089
|
-
},
|
|
28215
|
+
// // Groups by unit _id and keeps only the first occurrence
|
|
28216
|
+
// {
|
|
28217
|
+
// $group: {
|
|
28218
|
+
// _id: "$level.units._id",
|
|
28219
|
+
// doc: { $first: "$$ROOT" },
|
|
28220
|
+
// },
|
|
28221
|
+
// },
|
|
28222
|
+
// {
|
|
28223
|
+
// $replaceRoot: { newRoot: "$doc" },
|
|
28224
|
+
// },
|
|
28090
28225
|
// ✅ Apply search filter
|
|
28091
28226
|
{
|
|
28092
28227
|
$match: {
|
|
@@ -28098,7 +28233,6 @@ function UseAccessManagementRepo() {
|
|
|
28098
28233
|
totalCount: [{ $count: "count" }],
|
|
28099
28234
|
items: [
|
|
28100
28235
|
// ✅ Sort BEFORE skip/limit for correct pagination
|
|
28101
|
-
{ $sort: { _id: -1 } },
|
|
28102
28236
|
{ $skip: page * limit },
|
|
28103
28237
|
{ $limit: limit },
|
|
28104
28238
|
// ✅ Users lookup - optimized with index hint
|
|
@@ -28196,7 +28330,8 @@ function UseAccessManagementRepo() {
|
|
|
28196
28330
|
]
|
|
28197
28331
|
}
|
|
28198
28332
|
}
|
|
28199
|
-
}
|
|
28333
|
+
},
|
|
28334
|
+
{ $sort: { totalCardCount: -1 } }
|
|
28200
28335
|
]
|
|
28201
28336
|
}
|
|
28202
28337
|
}
|
|
@@ -28659,6 +28794,337 @@ function UseAccessManagementRepo() {
|
|
|
28659
28794
|
await session?.endSession();
|
|
28660
28795
|
}
|
|
28661
28796
|
}
|
|
28797
|
+
async function visitorAccessCardsRepo(params) {
|
|
28798
|
+
try {
|
|
28799
|
+
const page = params.page ? params.page - 1 : 0;
|
|
28800
|
+
const siteId = new ObjectId83(params.site);
|
|
28801
|
+
const search = params.search;
|
|
28802
|
+
const type = params.type;
|
|
28803
|
+
const limit = Number(params.limit);
|
|
28804
|
+
const query = {
|
|
28805
|
+
site: siteId,
|
|
28806
|
+
assignedUnit: { $ne: null },
|
|
28807
|
+
type: "NFC" /* NFC */
|
|
28808
|
+
};
|
|
28809
|
+
if (search) {
|
|
28810
|
+
query.$or = [{ accessLevel: { $regex: search, $options: "i" } }, { cardNo: { $regex: search, $options: "i" } }];
|
|
28811
|
+
}
|
|
28812
|
+
if (type) {
|
|
28813
|
+
query.userType = type;
|
|
28814
|
+
} else {
|
|
28815
|
+
query.userType = { $ne: "Resident/Tenant" /* RESIDENT */ };
|
|
28816
|
+
}
|
|
28817
|
+
const res = await collection().aggregate([
|
|
28818
|
+
{
|
|
28819
|
+
$match: query
|
|
28820
|
+
},
|
|
28821
|
+
{
|
|
28822
|
+
$project: {
|
|
28823
|
+
cardNo: 1,
|
|
28824
|
+
accessLevel: 1,
|
|
28825
|
+
site: 1,
|
|
28826
|
+
userType: 1,
|
|
28827
|
+
qrTag: 1,
|
|
28828
|
+
qrTagCardNo: 1,
|
|
28829
|
+
qrData: 1
|
|
28830
|
+
}
|
|
28831
|
+
},
|
|
28832
|
+
{
|
|
28833
|
+
$addFields: {
|
|
28834
|
+
extractedCardNo: {
|
|
28835
|
+
$substr: ["$cardNo", { $subtract: [{ $strLenCP: "$cardNo" }, 5] }, 5]
|
|
28836
|
+
}
|
|
28837
|
+
}
|
|
28838
|
+
},
|
|
28839
|
+
{
|
|
28840
|
+
$facet: {
|
|
28841
|
+
totalCount: [{ $count: "count" }],
|
|
28842
|
+
items: [{ $sort: { _id: -1 } }, { $skip: page * limit }, { $limit: limit }]
|
|
28843
|
+
}
|
|
28844
|
+
}
|
|
28845
|
+
]).toArray();
|
|
28846
|
+
const length = res[0].totalCount[0] ? res[0].totalCount[0].count : 0;
|
|
28847
|
+
const items = res[0].items;
|
|
28848
|
+
const paginatedResult = paginate38(items, page, limit, length);
|
|
28849
|
+
return paginatedResult;
|
|
28850
|
+
} catch (error) {
|
|
28851
|
+
throw new Error(error.message);
|
|
28852
|
+
}
|
|
28853
|
+
}
|
|
28854
|
+
async function getCardReplacementRepo(params) {
|
|
28855
|
+
try {
|
|
28856
|
+
const site = new ObjectId83(params.site);
|
|
28857
|
+
const search = params.search;
|
|
28858
|
+
const statusFilter = params.statusFilter;
|
|
28859
|
+
const dateFrom = params.dateFrom;
|
|
28860
|
+
const dateTo = params.dateTo;
|
|
28861
|
+
const page = Number(params.page) - 1;
|
|
28862
|
+
const limit = Number(params.limit);
|
|
28863
|
+
const query = {
|
|
28864
|
+
site,
|
|
28865
|
+
replacementStatus: { $in: ["Complete", "Issuance", "Pending"] },
|
|
28866
|
+
isActivated: false
|
|
28867
|
+
};
|
|
28868
|
+
const searchQuery = buildSearchQuery(search);
|
|
28869
|
+
if (statusFilter) {
|
|
28870
|
+
query.replacementStatus = statusFilter;
|
|
28871
|
+
}
|
|
28872
|
+
if (dateFrom && dateTo) {
|
|
28873
|
+
query.requestDate = { $gte: new Date(dateFrom), $lte: new Date(dateTo) };
|
|
28874
|
+
} else if (dateFrom) {
|
|
28875
|
+
query.requestDate = { $gte: new Date(dateFrom) };
|
|
28876
|
+
} else if (dateTo) {
|
|
28877
|
+
query.requestDate = { $lte: new Date(dateTo) };
|
|
28878
|
+
}
|
|
28879
|
+
const res = await collection().aggregate([
|
|
28880
|
+
{
|
|
28881
|
+
$match: { ...query }
|
|
28882
|
+
},
|
|
28883
|
+
{
|
|
28884
|
+
$lookup: {
|
|
28885
|
+
from: "building-units",
|
|
28886
|
+
let: { unit: "$assignedUnit" },
|
|
28887
|
+
pipeline: [
|
|
28888
|
+
{
|
|
28889
|
+
$match: {
|
|
28890
|
+
$expr: {
|
|
28891
|
+
$eq: ["$_id", "$$unit"]
|
|
28892
|
+
}
|
|
28893
|
+
}
|
|
28894
|
+
},
|
|
28895
|
+
{
|
|
28896
|
+
$project: {
|
|
28897
|
+
_id: 1,
|
|
28898
|
+
name: 1,
|
|
28899
|
+
level: 1
|
|
28900
|
+
}
|
|
28901
|
+
}
|
|
28902
|
+
],
|
|
28903
|
+
as: "unit"
|
|
28904
|
+
}
|
|
28905
|
+
},
|
|
28906
|
+
{
|
|
28907
|
+
$unwind: { path: "$unit", preserveNullAndEmptyArrays: true }
|
|
28908
|
+
},
|
|
28909
|
+
{
|
|
28910
|
+
$lookup: {
|
|
28911
|
+
from: "building-levels",
|
|
28912
|
+
let: { level: "$unit.level" },
|
|
28913
|
+
pipeline: [
|
|
28914
|
+
{
|
|
28915
|
+
$match: {
|
|
28916
|
+
$expr: {
|
|
28917
|
+
$eq: ["$_id", "$$level"]
|
|
28918
|
+
}
|
|
28919
|
+
}
|
|
28920
|
+
},
|
|
28921
|
+
{
|
|
28922
|
+
$project: {
|
|
28923
|
+
_id: 1,
|
|
28924
|
+
level: 1,
|
|
28925
|
+
block: 1
|
|
28926
|
+
}
|
|
28927
|
+
}
|
|
28928
|
+
],
|
|
28929
|
+
as: "level"
|
|
28930
|
+
}
|
|
28931
|
+
},
|
|
28932
|
+
{
|
|
28933
|
+
$unwind: { path: "$level", preserveNullAndEmptyArrays: true }
|
|
28934
|
+
},
|
|
28935
|
+
{
|
|
28936
|
+
$lookup: {
|
|
28937
|
+
from: "buildings",
|
|
28938
|
+
let: { block: "$level.block" },
|
|
28939
|
+
pipeline: [
|
|
28940
|
+
{
|
|
28941
|
+
$match: {
|
|
28942
|
+
$expr: {
|
|
28943
|
+
$eq: ["$_id", "$$block"]
|
|
28944
|
+
}
|
|
28945
|
+
}
|
|
28946
|
+
},
|
|
28947
|
+
{
|
|
28948
|
+
$project: {
|
|
28949
|
+
_id: 1,
|
|
28950
|
+
name: 1
|
|
28951
|
+
}
|
|
28952
|
+
}
|
|
28953
|
+
],
|
|
28954
|
+
as: "building"
|
|
28955
|
+
}
|
|
28956
|
+
},
|
|
28957
|
+
{
|
|
28958
|
+
$unwind: { path: "$building", preserveNullAndEmptyArrays: true }
|
|
28959
|
+
},
|
|
28960
|
+
{
|
|
28961
|
+
$lookup: {
|
|
28962
|
+
from: "users",
|
|
28963
|
+
let: { id: "$userId" },
|
|
28964
|
+
pipeline: [
|
|
28965
|
+
{
|
|
28966
|
+
$match: {
|
|
28967
|
+
$expr: {
|
|
28968
|
+
$eq: ["$_id", "$$id"]
|
|
28969
|
+
}
|
|
28970
|
+
}
|
|
28971
|
+
},
|
|
28972
|
+
{
|
|
28973
|
+
$project: {
|
|
28974
|
+
givenName: 1,
|
|
28975
|
+
surname: 1
|
|
28976
|
+
}
|
|
28977
|
+
}
|
|
28978
|
+
],
|
|
28979
|
+
as: "user"
|
|
28980
|
+
}
|
|
28981
|
+
},
|
|
28982
|
+
{
|
|
28983
|
+
$unwind: { path: "$user", preserveNullAndEmptyArrays: true }
|
|
28984
|
+
},
|
|
28985
|
+
{
|
|
28986
|
+
$match: { ...searchQuery }
|
|
28987
|
+
},
|
|
28988
|
+
{
|
|
28989
|
+
$facet: {
|
|
28990
|
+
data: [
|
|
28991
|
+
{ $skip: page * limit },
|
|
28992
|
+
{ $limit: limit },
|
|
28993
|
+
{
|
|
28994
|
+
$project: {
|
|
28995
|
+
_id: 1,
|
|
28996
|
+
cardNo: 1,
|
|
28997
|
+
accessLevel: 1,
|
|
28998
|
+
liftAccessLevel: 1,
|
|
28999
|
+
replacementStatus: 1,
|
|
29000
|
+
remarks: 1,
|
|
29001
|
+
block: "$building.name",
|
|
29002
|
+
level: "$level.level",
|
|
29003
|
+
unit: "$unit.name",
|
|
29004
|
+
user: "$user"
|
|
29005
|
+
}
|
|
29006
|
+
}
|
|
29007
|
+
],
|
|
29008
|
+
totalCount: [{ $count: "count" }]
|
|
29009
|
+
}
|
|
29010
|
+
}
|
|
29011
|
+
], { allowDiskUse: true }).toArray();
|
|
29012
|
+
const count = res[0]?.totalCount[0] ? res[0].totalCount[0].count : 0;
|
|
29013
|
+
const pagination = paginate38(res[0].data, page, limit, count);
|
|
29014
|
+
return pagination;
|
|
29015
|
+
} catch (error) {
|
|
29016
|
+
throw new Error(error.message);
|
|
29017
|
+
}
|
|
29018
|
+
}
|
|
29019
|
+
async function getAccessManagementSettingsRepo(params) {
|
|
29020
|
+
try {
|
|
29021
|
+
const { site } = params;
|
|
29022
|
+
const siteId = new ObjectId83(site);
|
|
29023
|
+
const res = await collectionName("entrypass-settings").findOne({ site: siteId }, { allowDiskUse: true });
|
|
29024
|
+
return res;
|
|
29025
|
+
} catch (error) {
|
|
29026
|
+
throw new Error(error.message);
|
|
29027
|
+
}
|
|
29028
|
+
}
|
|
29029
|
+
async function bulkPhysicalAccessCardRepo(params) {
|
|
29030
|
+
const session = useAtlas74.getClient()?.startSession();
|
|
29031
|
+
try {
|
|
29032
|
+
const { dataJson, site } = params;
|
|
29033
|
+
const rawItems = JSON.parse(dataJson).filter((_, index) => index !== -1);
|
|
29034
|
+
const items = await Promise.all(
|
|
29035
|
+
rawItems.map(async (item) => {
|
|
29036
|
+
const date = new Date(item["startDate (format MM/DD/YYYY)"]);
|
|
29037
|
+
const endDate = new Date(date.setFullYear(date.getFullYear() + 10));
|
|
29038
|
+
const cardNumber = item["cardNo (number 0-65535 ex. 301)"].toString().padStart(10, "0");
|
|
29039
|
+
const pin = item["pin (number 6 digits only)"] ? item["pin (number 6 digits only)"].toString().padStart(6, "0") : "123456";
|
|
29040
|
+
const match = item["accessLevel (number ex. 1)"];
|
|
29041
|
+
const accessLevel = match ? match : null;
|
|
29042
|
+
const userType = item["userType(Contractor, Visitor, Resident/Tenant, Visitor/Resident)"];
|
|
29043
|
+
const rawAccessGroup = item["accessGroup (value ex. Full Access, No Access)"];
|
|
29044
|
+
const accessGroup = typeof rawAccessGroup === "string" ? rawAccessGroup.split(",").map((v) => v.trim()).filter((v) => v !== "") : [];
|
|
29045
|
+
return new MAccessCard({
|
|
29046
|
+
site: new ObjectId83(site),
|
|
29047
|
+
type: "NFC" /* NFC */,
|
|
29048
|
+
staffNo: null,
|
|
29049
|
+
accessLevel,
|
|
29050
|
+
accessGroup,
|
|
29051
|
+
accessType: "Normal" /* NORMAL */,
|
|
29052
|
+
cardNo: cardNumber,
|
|
29053
|
+
pin,
|
|
29054
|
+
qrData: await createQrData({ cardNumber }),
|
|
29055
|
+
startDate: new Date(item["startDate (format MM/DD/YYYY)"]),
|
|
29056
|
+
endDate: new Date(item["endDate (format MM/DD/YYYY)"] || endDate),
|
|
29057
|
+
isActivated: true,
|
|
29058
|
+
isAntiPassBack: false,
|
|
29059
|
+
isLiftCard: item["isLiftCard (TRUE OR FALSE)"] === "TRUE" ? true : false,
|
|
29060
|
+
liftAccessLevel: item["liftAccessLevel(number ex. 1)"] || null,
|
|
29061
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
29062
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
29063
|
+
assignedUnit: null,
|
|
29064
|
+
userType: userType.toLowerCase() === "contractor" ? "Contractor" /* CONTRACTOR */ : userType.toLowerCase() === "visitor" ? "Visitor" /* VISITOR */ : userType.toLowerCase() === "resident/tenant" ? "Resident/Tenant" /* RESIDENT */ : "Visitor/Resident" /* DEFAULT */,
|
|
29065
|
+
doorName: item["Door Name (ex. Main Door)"] || null,
|
|
29066
|
+
liftName: item["Lift Name (ex. Main Lift)"] || null
|
|
29067
|
+
});
|
|
29068
|
+
})
|
|
29069
|
+
);
|
|
29070
|
+
const result = await collection().insertMany(items, { session, ordered: false });
|
|
29071
|
+
const mapping = items.map((item, i) => ({
|
|
29072
|
+
cardNo: item.cardNo,
|
|
29073
|
+
insertedId: result.insertedIds[i]
|
|
29074
|
+
}));
|
|
29075
|
+
return mapping;
|
|
29076
|
+
} catch (error) {
|
|
29077
|
+
throw new Error(error.message);
|
|
29078
|
+
}
|
|
29079
|
+
}
|
|
29080
|
+
async function assignAccessCardToUnitRepo(params) {
|
|
29081
|
+
const session = useAtlas74.getClient()?.startSession();
|
|
29082
|
+
try {
|
|
29083
|
+
session?.startTransaction();
|
|
29084
|
+
const { units, quantity, type, site, userType, accessLevel, liftAccessLevel } = params;
|
|
29085
|
+
const [convertedUnits, convertedSite] = await Promise.all([Promise.all(units.map((id) => new ObjectId83(id))), new ObjectId83(site)]);
|
|
29086
|
+
const totalRequired = quantity * convertedUnits.length;
|
|
29087
|
+
const availableCards = await collection().find({
|
|
29088
|
+
assignedUnit: null,
|
|
29089
|
+
userId: null,
|
|
29090
|
+
type,
|
|
29091
|
+
userType,
|
|
29092
|
+
isActivated: true,
|
|
29093
|
+
site: convertedSite,
|
|
29094
|
+
accessLevel: accessLevel ?? null,
|
|
29095
|
+
liftAccessLevel: liftAccessLevel ?? null
|
|
29096
|
+
}).limit(totalRequired).toArray();
|
|
29097
|
+
if (availableCards.length < totalRequired) {
|
|
29098
|
+
session?.abortTransaction();
|
|
29099
|
+
return {
|
|
29100
|
+
status: "error",
|
|
29101
|
+
message: `Insufficient ${type} access cards. Need ${totalRequired}, but only ${availableCards.length} available.`
|
|
29102
|
+
};
|
|
29103
|
+
}
|
|
29104
|
+
const bulkUpdates = availableCards.map((card, index) => ({
|
|
29105
|
+
updateOne: {
|
|
29106
|
+
filter: { _id: card._id },
|
|
29107
|
+
update: {
|
|
29108
|
+
$set: {
|
|
29109
|
+
assignedUnit: convertedUnits[Math.floor(index / quantity)]
|
|
29110
|
+
}
|
|
29111
|
+
}
|
|
29112
|
+
}
|
|
29113
|
+
}));
|
|
29114
|
+
await collection().bulkWrite(bulkUpdates, { session });
|
|
29115
|
+
session?.commitTransaction();
|
|
29116
|
+
return {
|
|
29117
|
+
status: "success",
|
|
29118
|
+
message: "Cards assigned to units successfully.",
|
|
29119
|
+
assigned: bulkUpdates.length
|
|
29120
|
+
};
|
|
29121
|
+
} catch (error) {
|
|
29122
|
+
session?.abortTransaction();
|
|
29123
|
+
return Promise.reject(error.message);
|
|
29124
|
+
} finally {
|
|
29125
|
+
session?.endSession();
|
|
29126
|
+
}
|
|
29127
|
+
}
|
|
28662
29128
|
return {
|
|
28663
29129
|
createIndexes,
|
|
28664
29130
|
createIndexForEntrypass,
|
|
@@ -28674,7 +29140,12 @@ function UseAccessManagementRepo() {
|
|
|
28674
29140
|
replaceCardRepo,
|
|
28675
29141
|
updateNFCStatusRepo,
|
|
28676
29142
|
doorAndLiftDropdownRepo,
|
|
28677
|
-
cardReplacementRepo
|
|
29143
|
+
cardReplacementRepo,
|
|
29144
|
+
visitorAccessCardsRepo,
|
|
29145
|
+
getCardReplacementRepo,
|
|
29146
|
+
getAccessManagementSettingsRepo,
|
|
29147
|
+
bulkPhysicalAccessCardRepo,
|
|
29148
|
+
assignAccessCardToUnitRepo
|
|
28678
29149
|
};
|
|
28679
29150
|
}
|
|
28680
29151
|
|
|
@@ -28684,6 +29155,8 @@ import Joi85 from "joi";
|
|
|
28684
29155
|
// src/services/access-management.service.ts
|
|
28685
29156
|
import { parseStringPromise as parseStringPromise2 } from "xml2js";
|
|
28686
29157
|
import { useCache as useCache47 } from "@7365admin1/node-server-utils";
|
|
29158
|
+
import { Readable } from "stream";
|
|
29159
|
+
import * as xlsx from "xlsx";
|
|
28687
29160
|
var namespace = "cache:acm";
|
|
28688
29161
|
function useAccessManagementSvc() {
|
|
28689
29162
|
const {
|
|
@@ -28699,7 +29172,12 @@ function useAccessManagementSvc() {
|
|
|
28699
29172
|
replaceCardRepo,
|
|
28700
29173
|
updateNFCStatusRepo,
|
|
28701
29174
|
doorAndLiftDropdownRepo,
|
|
28702
|
-
cardReplacementRepo
|
|
29175
|
+
cardReplacementRepo,
|
|
29176
|
+
visitorAccessCardsRepo,
|
|
29177
|
+
getCardReplacementRepo,
|
|
29178
|
+
getAccessManagementSettingsRepo,
|
|
29179
|
+
bulkPhysicalAccessCardRepo,
|
|
29180
|
+
assignAccessCardToUnitRepo
|
|
28703
29181
|
} = UseAccessManagementRepo();
|
|
28704
29182
|
const addPhysicalCardSvc = async (payload) => {
|
|
28705
29183
|
try {
|
|
@@ -28884,12 +29362,77 @@ function useAccessManagementSvc() {
|
|
|
28884
29362
|
throw new Error(err.message);
|
|
28885
29363
|
}
|
|
28886
29364
|
};
|
|
29365
|
+
const visitorAccessCardsSvc = async (params) => {
|
|
29366
|
+
try {
|
|
29367
|
+
const response = await visitorAccessCardsRepo({ ...params });
|
|
29368
|
+
return response;
|
|
29369
|
+
} catch (err) {
|
|
29370
|
+
throw new Error(err.message);
|
|
29371
|
+
}
|
|
29372
|
+
};
|
|
29373
|
+
const getCardReplacementSvc = async (params) => {
|
|
29374
|
+
try {
|
|
29375
|
+
const response = await getCardReplacementRepo({ ...params });
|
|
29376
|
+
return response;
|
|
29377
|
+
} catch (err) {
|
|
29378
|
+
throw new Error(err.message);
|
|
29379
|
+
}
|
|
29380
|
+
};
|
|
29381
|
+
const getAccessManagementSettingsSvc = async (params) => {
|
|
29382
|
+
try {
|
|
29383
|
+
const response = await getAccessManagementSettingsRepo({ ...params });
|
|
29384
|
+
return response;
|
|
29385
|
+
} catch (err) {
|
|
29386
|
+
throw new Error(err.message);
|
|
29387
|
+
}
|
|
29388
|
+
};
|
|
29389
|
+
const convertBufferFile = async (bufferFile) => {
|
|
29390
|
+
return new Promise((resolve, reject) => {
|
|
29391
|
+
const fileStream = Readable.from(bufferFile);
|
|
29392
|
+
let fileBuffer = Buffer.alloc(0);
|
|
29393
|
+
fileStream.on("data", (chunk) => {
|
|
29394
|
+
fileBuffer = Buffer.concat([fileBuffer, chunk]);
|
|
29395
|
+
});
|
|
29396
|
+
fileStream.on("end", () => {
|
|
29397
|
+
try {
|
|
29398
|
+
const workbook = xlsx.read(fileBuffer, { type: "buffer" });
|
|
29399
|
+
const sheetName = workbook.SheetNames[0];
|
|
29400
|
+
const sheet = workbook.Sheets[sheetName];
|
|
29401
|
+
const jsonData = xlsx.utils.sheet_to_json(sheet, { raw: false });
|
|
29402
|
+
resolve(jsonData);
|
|
29403
|
+
} catch (error) {
|
|
29404
|
+
reject("Error parsing file");
|
|
29405
|
+
}
|
|
29406
|
+
});
|
|
29407
|
+
fileStream.on("error", (err) => {
|
|
29408
|
+
reject("Error Reading File: " + err.message);
|
|
29409
|
+
});
|
|
29410
|
+
});
|
|
29411
|
+
};
|
|
29412
|
+
const bulkPhysicalAccessCardSvc = async (params) => {
|
|
29413
|
+
try {
|
|
29414
|
+
const response = await bulkPhysicalAccessCardRepo({ ...params });
|
|
29415
|
+
return response;
|
|
29416
|
+
} catch (err) {
|
|
29417
|
+
throw new Error(err.message);
|
|
29418
|
+
}
|
|
29419
|
+
};
|
|
29420
|
+
const assignAccessCardToUnitSvc = async (params) => {
|
|
29421
|
+
try {
|
|
29422
|
+
const response = await assignAccessCardToUnitRepo({ ...params });
|
|
29423
|
+
return response;
|
|
29424
|
+
} catch (err) {
|
|
29425
|
+
throw new Error(err.message);
|
|
29426
|
+
}
|
|
29427
|
+
};
|
|
28887
29428
|
return {
|
|
28888
29429
|
addPhysicalCardSvc,
|
|
28889
29430
|
addNonPhysicalCardSvc,
|
|
28890
29431
|
doorAccessLevelsSvc,
|
|
28891
29432
|
liftAccessLevelsSvc,
|
|
28892
29433
|
accessGroupsSvc,
|
|
29434
|
+
setCache,
|
|
29435
|
+
getCache,
|
|
28893
29436
|
accessManagementSettingsSvc,
|
|
28894
29437
|
allAccessCardsCountsSvc,
|
|
28895
29438
|
availableAccessCardsSvc,
|
|
@@ -28900,11 +29443,19 @@ function useAccessManagementSvc() {
|
|
|
28900
29443
|
replaceCardSvc,
|
|
28901
29444
|
updateNFCStatusSvc,
|
|
28902
29445
|
doorAndLiftDropdownSvc,
|
|
28903
|
-
cardReplacementSvc
|
|
29446
|
+
cardReplacementSvc,
|
|
29447
|
+
visitorAccessCardsSvc,
|
|
29448
|
+
getCardReplacementSvc,
|
|
29449
|
+
getAccessManagementSettingsSvc,
|
|
29450
|
+
convertBufferFile,
|
|
29451
|
+
bulkPhysicalAccessCardSvc,
|
|
29452
|
+
assignAccessCardToUnitSvc
|
|
28904
29453
|
};
|
|
28905
29454
|
}
|
|
28906
29455
|
|
|
28907
29456
|
// src/controllers/access-management.controller.ts
|
|
29457
|
+
import { useCache as useCache48 } from "@7365admin1/node-server-utils";
|
|
29458
|
+
var namespace2 = "cache:acm";
|
|
28908
29459
|
function useAccessManagementController() {
|
|
28909
29460
|
const {
|
|
28910
29461
|
addPhysicalCardSvc,
|
|
@@ -28912,6 +29463,8 @@ function useAccessManagementController() {
|
|
|
28912
29463
|
doorAccessLevelsSvc,
|
|
28913
29464
|
liftAccessLevelsSvc,
|
|
28914
29465
|
accessGroupsSvc,
|
|
29466
|
+
setCache,
|
|
29467
|
+
getCache,
|
|
28915
29468
|
accessManagementSettingsSvc,
|
|
28916
29469
|
allAccessCardsCountsSvc,
|
|
28917
29470
|
availableAccessCardsSvc,
|
|
@@ -28922,7 +29475,13 @@ function useAccessManagementController() {
|
|
|
28922
29475
|
replaceCardSvc,
|
|
28923
29476
|
updateNFCStatusSvc,
|
|
28924
29477
|
doorAndLiftDropdownSvc,
|
|
28925
|
-
cardReplacementSvc
|
|
29478
|
+
cardReplacementSvc,
|
|
29479
|
+
visitorAccessCardsSvc,
|
|
29480
|
+
getCardReplacementSvc,
|
|
29481
|
+
getAccessManagementSettingsSvc,
|
|
29482
|
+
convertBufferFile,
|
|
29483
|
+
bulkPhysicalAccessCardSvc,
|
|
29484
|
+
assignAccessCardToUnitSvc
|
|
28926
29485
|
} = useAccessManagementSvc();
|
|
28927
29486
|
const addPhysicalCard = async (req, res) => {
|
|
28928
29487
|
try {
|
|
@@ -29113,6 +29672,7 @@ function useAccessManagementController() {
|
|
|
29113
29672
|
const allAccessCardsCounts = async (req, res) => {
|
|
29114
29673
|
try {
|
|
29115
29674
|
const { site, userType } = req.query;
|
|
29675
|
+
const user = req.cookies?.sid;
|
|
29116
29676
|
const schema2 = Joi85.object({
|
|
29117
29677
|
site: Joi85.string().hex().required(),
|
|
29118
29678
|
userType: Joi85.string().required()
|
|
@@ -29121,7 +29681,19 @@ function useAccessManagementController() {
|
|
|
29121
29681
|
if (error) {
|
|
29122
29682
|
throw new Error(`${error.message}`);
|
|
29123
29683
|
}
|
|
29684
|
+
const key = `${namespace2}:${user}:access-card-counts`;
|
|
29685
|
+
const listKey = `${namespace2}:${user}:list`;
|
|
29686
|
+
const { redis } = useCache48(key);
|
|
29687
|
+
const cachedData = await getCache({ key, redis });
|
|
29688
|
+
if (cachedData) {
|
|
29689
|
+
console.log("\u26A1 Cache hit:", key);
|
|
29690
|
+
redis.expire(key, 60).catch(console.error);
|
|
29691
|
+
redis.lrem(listKey, 0, key).then(() => redis.lpush(listKey, key)).then(() => redis.ltrim(listKey, 0, 9)).catch(console.error);
|
|
29692
|
+
return res.status(200).json({ message: "Success", data: cachedData });
|
|
29693
|
+
}
|
|
29124
29694
|
const result = await allAccessCardsCountsSvc({ site, userType });
|
|
29695
|
+
await setCache({ key, data: result, ttlSeconds: 60, redis });
|
|
29696
|
+
redis.lrem(listKey, 0, key).then(() => redis.lpush(listKey, key)).then(() => redis.ltrim(listKey, 0, 9)).catch(console.error);
|
|
29125
29697
|
return res.status(200).json({ message: "Success", data: result });
|
|
29126
29698
|
} catch (error) {
|
|
29127
29699
|
return res.status(400).json({
|
|
@@ -29342,6 +29914,128 @@ function useAccessManagementController() {
|
|
|
29342
29914
|
});
|
|
29343
29915
|
}
|
|
29344
29916
|
};
|
|
29917
|
+
const visitorAccessCards = async (req, res) => {
|
|
29918
|
+
try {
|
|
29919
|
+
const {
|
|
29920
|
+
page = 1,
|
|
29921
|
+
limit = 10,
|
|
29922
|
+
search,
|
|
29923
|
+
type,
|
|
29924
|
+
site
|
|
29925
|
+
} = req.query;
|
|
29926
|
+
const schema2 = Joi85.object({
|
|
29927
|
+
site: Joi85.string().hex().required(),
|
|
29928
|
+
page: Joi85.number().required(),
|
|
29929
|
+
limit: Joi85.number().optional().default(10),
|
|
29930
|
+
type: Joi85.string().required().valid(...Object.values(EAccessCardUserTypes)),
|
|
29931
|
+
search: Joi85.string().optional().allow("", null)
|
|
29932
|
+
});
|
|
29933
|
+
const { error } = schema2.validate({ site, page, limit, type, search });
|
|
29934
|
+
if (error) {
|
|
29935
|
+
return res.status(400).json({ message: error.message });
|
|
29936
|
+
}
|
|
29937
|
+
const result = await visitorAccessCardsSvc({ site, page, limit, type, search });
|
|
29938
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
29939
|
+
} catch (error) {
|
|
29940
|
+
return res.status(500).json({
|
|
29941
|
+
data: null,
|
|
29942
|
+
message: error.message
|
|
29943
|
+
});
|
|
29944
|
+
}
|
|
29945
|
+
};
|
|
29946
|
+
const getCardReplacement = async (req, res) => {
|
|
29947
|
+
try {
|
|
29948
|
+
const site = req.params.site;
|
|
29949
|
+
const {
|
|
29950
|
+
search,
|
|
29951
|
+
statusFilter,
|
|
29952
|
+
dateFrom,
|
|
29953
|
+
dateTo,
|
|
29954
|
+
page = 0,
|
|
29955
|
+
limit = 10
|
|
29956
|
+
} = req.query;
|
|
29957
|
+
const schema2 = Joi85.object({
|
|
29958
|
+
search: Joi85.string().optional().allow("", null),
|
|
29959
|
+
statusFilter: Joi85.string().optional().allow("", null),
|
|
29960
|
+
dateFrom: Joi85.date().optional().allow("", null),
|
|
29961
|
+
dateTo: Joi85.date().optional().allow("", null),
|
|
29962
|
+
page: Joi85.number().optional().default(0),
|
|
29963
|
+
limit: Joi85.number().optional().default(10),
|
|
29964
|
+
site: Joi85.string().hex().required()
|
|
29965
|
+
});
|
|
29966
|
+
const { error } = schema2.validate({ search, statusFilter, dateFrom, dateTo, page, limit, site });
|
|
29967
|
+
if (error) {
|
|
29968
|
+
return res.status(400).json({ message: error.message });
|
|
29969
|
+
}
|
|
29970
|
+
const result = await getCardReplacementSvc({ site, page, limit, search, statusFilter, dateFrom, dateTo });
|
|
29971
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
29972
|
+
} catch (error) {
|
|
29973
|
+
return res.status(500).json({
|
|
29974
|
+
data: null,
|
|
29975
|
+
message: error.message
|
|
29976
|
+
});
|
|
29977
|
+
}
|
|
29978
|
+
};
|
|
29979
|
+
const getAccessManagementSettings = async (req, res) => {
|
|
29980
|
+
try {
|
|
29981
|
+
const { site } = req.params;
|
|
29982
|
+
const schema2 = Joi85.object({
|
|
29983
|
+
site: Joi85.string().hex().required()
|
|
29984
|
+
});
|
|
29985
|
+
const { error } = schema2.validate({ site });
|
|
29986
|
+
if (error) {
|
|
29987
|
+
return res.status(400).json({ message: error.message });
|
|
29988
|
+
}
|
|
29989
|
+
const result = await getAccessManagementSettingsSvc({ site });
|
|
29990
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
29991
|
+
} catch (error) {
|
|
29992
|
+
return res.status(500).json({
|
|
29993
|
+
data: null,
|
|
29994
|
+
message: error.message
|
|
29995
|
+
});
|
|
29996
|
+
}
|
|
29997
|
+
};
|
|
29998
|
+
const bulkPhysicalAccessCard = async (req, res) => {
|
|
29999
|
+
try {
|
|
30000
|
+
const { site } = req.query;
|
|
30001
|
+
if (!req.file)
|
|
30002
|
+
throw new Error("File is required!");
|
|
30003
|
+
const xlsData = await convertBufferFile(req.file.buffer);
|
|
30004
|
+
const dataJson = JSON.stringify(xlsData);
|
|
30005
|
+
const result = await bulkPhysicalAccessCardSvc({ dataJson, site });
|
|
30006
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
30007
|
+
} catch (error) {
|
|
30008
|
+
return res.status(500).json({
|
|
30009
|
+
data: null,
|
|
30010
|
+
message: error.message
|
|
30011
|
+
});
|
|
30012
|
+
}
|
|
30013
|
+
};
|
|
30014
|
+
const assignAccessCardToUnit = async (req, res) => {
|
|
30015
|
+
try {
|
|
30016
|
+
const { units, type, quantity, site, userType, accessLevel, liftAccessLevel } = req.body;
|
|
30017
|
+
const schema2 = Joi85.object({
|
|
30018
|
+
units: Joi85.array().items(Joi85.string().hex()).required(),
|
|
30019
|
+
quantity: Joi85.number().required(),
|
|
30020
|
+
type: Joi85.string().required(),
|
|
30021
|
+
site: Joi85.string().hex().required(),
|
|
30022
|
+
userType: Joi85.string().required(),
|
|
30023
|
+
accessLevel: Joi85.string().optional().allow("", null),
|
|
30024
|
+
liftAccessLevel: Joi85.string().optional().allow("", null)
|
|
30025
|
+
});
|
|
30026
|
+
const { error } = schema2.validate({ units, quantity, type, site, userType, accessLevel, liftAccessLevel });
|
|
30027
|
+
if (error) {
|
|
30028
|
+
return res.status(400).json({ message: error.message });
|
|
30029
|
+
}
|
|
30030
|
+
const result = await assignAccessCardToUnitSvc({ units, quantity, type, site, userType, accessLevel, liftAccessLevel });
|
|
30031
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
30032
|
+
} catch (error) {
|
|
30033
|
+
return res.status(500).json({
|
|
30034
|
+
data: null,
|
|
30035
|
+
message: error.message
|
|
30036
|
+
});
|
|
30037
|
+
}
|
|
30038
|
+
};
|
|
29345
30039
|
return {
|
|
29346
30040
|
addPhysicalCard,
|
|
29347
30041
|
addNonPhysicalCard,
|
|
@@ -29358,7 +30052,12 @@ function useAccessManagementController() {
|
|
|
29358
30052
|
replaceCard,
|
|
29359
30053
|
updateNFCStatus,
|
|
29360
30054
|
doorAndLiftDropdown,
|
|
29361
|
-
cardReplacement
|
|
30055
|
+
cardReplacement,
|
|
30056
|
+
visitorAccessCards,
|
|
30057
|
+
getCardReplacement,
|
|
30058
|
+
getAccessManagementSettings,
|
|
30059
|
+
bulkPhysicalAccessCard,
|
|
30060
|
+
assignAccessCardToUnit
|
|
29362
30061
|
};
|
|
29363
30062
|
}
|
|
29364
30063
|
|
|
@@ -29428,7 +30127,7 @@ import {
|
|
|
29428
30127
|
makeCacheKey as makeCacheKey45,
|
|
29429
30128
|
paginate as paginate39,
|
|
29430
30129
|
useAtlas as useAtlas75,
|
|
29431
|
-
useCache as
|
|
30130
|
+
useCache as useCache49
|
|
29432
30131
|
} from "@7365admin1/node-server-utils";
|
|
29433
30132
|
import { ObjectId as ObjectId85 } from "mongodb";
|
|
29434
30133
|
function useNfcPatrolTagRepo() {
|
|
@@ -29439,8 +30138,8 @@ function useNfcPatrolTagRepo() {
|
|
|
29439
30138
|
const namespace_collection = "nfc-patrol-tags";
|
|
29440
30139
|
const namespace_collection_nfc_patrol_routes = "nfc-patrol-routes";
|
|
29441
30140
|
const collection = db.collection(namespace_collection);
|
|
29442
|
-
const { delNamespace, getCache, setCache } =
|
|
29443
|
-
const { delNamespace: delNamespaceNfcPatrolRoutes } =
|
|
30141
|
+
const { delNamespace, getCache, setCache } = useCache49(namespace_collection);
|
|
30142
|
+
const { delNamespace: delNamespaceNfcPatrolRoutes } = useCache49(
|
|
29444
30143
|
namespace_collection_nfc_patrol_routes
|
|
29445
30144
|
);
|
|
29446
30145
|
async function createIndexes() {
|
|
@@ -29887,7 +30586,7 @@ import {
|
|
|
29887
30586
|
NotFoundError as NotFoundError37,
|
|
29888
30587
|
paginate as paginate40,
|
|
29889
30588
|
useAtlas as useAtlas77,
|
|
29890
|
-
useCache as
|
|
30589
|
+
useCache as useCache50
|
|
29891
30590
|
} from "@7365admin1/node-server-utils";
|
|
29892
30591
|
import { ObjectId as ObjectId87 } from "mongodb";
|
|
29893
30592
|
function useOccurrenceBookRepo() {
|
|
@@ -29919,7 +30618,7 @@ function useOccurrenceBookRepo() {
|
|
|
29919
30618
|
}
|
|
29920
30619
|
const namespace_collection = "occurrence-books";
|
|
29921
30620
|
const collection = db.collection(namespace_collection);
|
|
29922
|
-
const { delNamespace, getCache, setCache } =
|
|
30621
|
+
const { delNamespace, getCache, setCache } = useCache50(namespace_collection);
|
|
29923
30622
|
async function add(value, session) {
|
|
29924
30623
|
try {
|
|
29925
30624
|
value = MOccurrenceBook(value);
|
|
@@ -30497,7 +31196,7 @@ import {
|
|
|
30497
31196
|
NotFoundError as NotFoundError38,
|
|
30498
31197
|
paginate as paginate41,
|
|
30499
31198
|
useAtlas as useAtlas79,
|
|
30500
|
-
useCache as
|
|
31199
|
+
useCache as useCache51
|
|
30501
31200
|
} from "@7365admin1/node-server-utils";
|
|
30502
31201
|
import { ObjectId as ObjectId89 } from "mongodb";
|
|
30503
31202
|
function useBulletinVideoRepo() {
|
|
@@ -30516,7 +31215,7 @@ function useBulletinVideoRepo() {
|
|
|
30516
31215
|
}
|
|
30517
31216
|
const namespace_collection = "bulletin-videos";
|
|
30518
31217
|
const collection = db.collection(namespace_collection);
|
|
30519
|
-
const { delNamespace, getCache, setCache } =
|
|
31218
|
+
const { delNamespace, getCache, setCache } = useCache51(namespace_collection);
|
|
30520
31219
|
async function add(value, session) {
|
|
30521
31220
|
try {
|
|
30522
31221
|
value = MBulletinVideo(value);
|
|
@@ -31048,7 +31747,7 @@ import {
|
|
|
31048
31747
|
InternalServerError as InternalServerError51,
|
|
31049
31748
|
logger as logger127,
|
|
31050
31749
|
useAtlas as useAtlas81,
|
|
31051
|
-
useCache as
|
|
31750
|
+
useCache as useCache52,
|
|
31052
31751
|
paginate as paginate42,
|
|
31053
31752
|
makeCacheKey as makeCacheKey48
|
|
31054
31753
|
} from "@7365admin1/node-server-utils";
|
|
@@ -31060,7 +31759,7 @@ function useStatementOfAccountRepo() {
|
|
|
31060
31759
|
}
|
|
31061
31760
|
const namespace_collection = "site.statement-of-accounts";
|
|
31062
31761
|
const collection = db.collection(namespace_collection);
|
|
31063
|
-
const { delNamespace, getCache, setCache } =
|
|
31762
|
+
const { delNamespace, getCache, setCache } = useCache52(namespace_collection);
|
|
31064
31763
|
async function createTextIndex() {
|
|
31065
31764
|
try {
|
|
31066
31765
|
await collection.createIndex({
|
|
@@ -31823,7 +32522,7 @@ import {
|
|
|
31823
32522
|
NotFoundError as NotFoundError40,
|
|
31824
32523
|
paginate as paginate43,
|
|
31825
32524
|
useAtlas as useAtlas83,
|
|
31826
|
-
useCache as
|
|
32525
|
+
useCache as useCache53
|
|
31827
32526
|
} from "@7365admin1/node-server-utils";
|
|
31828
32527
|
import { ObjectId as ObjectId93 } from "mongodb";
|
|
31829
32528
|
function useEntryPassSettingsRepo() {
|
|
@@ -31833,7 +32532,7 @@ function useEntryPassSettingsRepo() {
|
|
|
31833
32532
|
}
|
|
31834
32533
|
const namespace_collection = "site.entrypass-settings";
|
|
31835
32534
|
const collection = db.collection(namespace_collection);
|
|
31836
|
-
const { delNamespace, getCache, setCache } =
|
|
32535
|
+
const { delNamespace, getCache, setCache } = useCache53(namespace_collection);
|
|
31837
32536
|
async function createTextIndex() {
|
|
31838
32537
|
try {
|
|
31839
32538
|
await collection.createIndex({
|
|
@@ -32395,7 +33094,7 @@ import {
|
|
|
32395
33094
|
logger as logger133,
|
|
32396
33095
|
makeCacheKey as makeCacheKey50,
|
|
32397
33096
|
useAtlas as useAtlas84,
|
|
32398
|
-
useCache as
|
|
33097
|
+
useCache as useCache54
|
|
32399
33098
|
} from "@7365admin1/node-server-utils";
|
|
32400
33099
|
function useDashboardRepo() {
|
|
32401
33100
|
const db = useAtlas84.getDb();
|
|
@@ -32406,7 +33105,7 @@ function useDashboardRepo() {
|
|
|
32406
33105
|
const work_order_collection = db.collection("work-orders");
|
|
32407
33106
|
const visitor_collection = db.collection("visitor.transactions");
|
|
32408
33107
|
const namespace_collection = "dashboard";
|
|
32409
|
-
const { delNamespace, getCache, setCache } =
|
|
33108
|
+
const { delNamespace, getCache, setCache } = useCache54(namespace_collection);
|
|
32410
33109
|
async function getAll({
|
|
32411
33110
|
site = ""
|
|
32412
33111
|
}, session) {
|
|
@@ -32570,7 +33269,7 @@ import {
|
|
|
32570
33269
|
makeCacheKey as makeCacheKey51,
|
|
32571
33270
|
paginate as paginate44,
|
|
32572
33271
|
useAtlas as useAtlas85,
|
|
32573
|
-
useCache as
|
|
33272
|
+
useCache as useCache55
|
|
32574
33273
|
} from "@7365admin1/node-server-utils";
|
|
32575
33274
|
import { ObjectId as ObjectId95 } from "mongodb";
|
|
32576
33275
|
function useNfcPatrolRouteRepo() {
|
|
@@ -32580,7 +33279,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
32580
33279
|
}
|
|
32581
33280
|
const namespace_collection = "nfc-patrol-routes";
|
|
32582
33281
|
const collection = db.collection(namespace_collection);
|
|
32583
|
-
const { delNamespace, getCache, setCache } =
|
|
33282
|
+
const { delNamespace, getCache, setCache } = useCache55(namespace_collection);
|
|
32584
33283
|
async function createIndexes() {
|
|
32585
33284
|
try {
|
|
32586
33285
|
await collection.createIndexes([
|
|
@@ -33317,7 +34016,7 @@ import {
|
|
|
33317
34016
|
NotFoundError as NotFoundError43,
|
|
33318
34017
|
paginate as paginate45,
|
|
33319
34018
|
useAtlas as useAtlas87,
|
|
33320
|
-
useCache as
|
|
34019
|
+
useCache as useCache56
|
|
33321
34020
|
} from "@7365admin1/node-server-utils";
|
|
33322
34021
|
import { ObjectId as ObjectId97 } from "mongodb";
|
|
33323
34022
|
function useIncidentReportRepo() {
|
|
@@ -33348,7 +34047,7 @@ function useIncidentReportRepo() {
|
|
|
33348
34047
|
}
|
|
33349
34048
|
const namespace_collection = "incident-reports";
|
|
33350
34049
|
const collection = db.collection(namespace_collection);
|
|
33351
|
-
const { delNamespace, getCache, setCache } =
|
|
34050
|
+
const { delNamespace, getCache, setCache } = useCache56(namespace_collection);
|
|
33352
34051
|
async function add(value, session) {
|
|
33353
34052
|
try {
|
|
33354
34053
|
value = MIncidentReport(value);
|
|
@@ -34089,7 +34788,7 @@ import {
|
|
|
34089
34788
|
makeCacheKey as makeCacheKey53,
|
|
34090
34789
|
NotFoundError as NotFoundError45,
|
|
34091
34790
|
useAtlas as useAtlas89,
|
|
34092
|
-
useCache as
|
|
34791
|
+
useCache as useCache57
|
|
34093
34792
|
} from "@7365admin1/node-server-utils";
|
|
34094
34793
|
import { ObjectId as ObjectId99 } from "mongodb";
|
|
34095
34794
|
function useNfcPatrolSettingsRepository() {
|
|
@@ -34099,7 +34798,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
34099
34798
|
}
|
|
34100
34799
|
const namespace_collection = "site.nfc-patrol-settings";
|
|
34101
34800
|
const collection = db.collection(namespace_collection);
|
|
34102
|
-
const { delNamespace, setCache, getCache } =
|
|
34801
|
+
const { delNamespace, setCache, getCache } = useCache57(namespace_collection);
|
|
34103
34802
|
async function createIndexes() {
|
|
34104
34803
|
try {
|
|
34105
34804
|
await collection.createIndexes([{ key: { site: 1 }, unique: true }]);
|
|
@@ -34344,7 +35043,7 @@ import {
|
|
|
34344
35043
|
NotFoundError as NotFoundError46,
|
|
34345
35044
|
paginate as paginate46,
|
|
34346
35045
|
useAtlas as useAtlas91,
|
|
34347
|
-
useCache as
|
|
35046
|
+
useCache as useCache58
|
|
34348
35047
|
} from "@7365admin1/node-server-utils";
|
|
34349
35048
|
|
|
34350
35049
|
// src/models/occurrence-subject.model.ts
|
|
@@ -34421,7 +35120,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
34421
35120
|
}
|
|
34422
35121
|
const namespace_collection = "occurrence-subjects";
|
|
34423
35122
|
const collection = db.collection(namespace_collection);
|
|
34424
|
-
const { delNamespace, getCache, setCache } =
|
|
35123
|
+
const { delNamespace, getCache, setCache } = useCache58(namespace_collection);
|
|
34425
35124
|
async function add(value, session) {
|
|
34426
35125
|
try {
|
|
34427
35126
|
value = MOccurrenceSubject(value);
|
|
@@ -34989,7 +35688,7 @@ import {
|
|
|
34989
35688
|
NotFoundError as NotFoundError47,
|
|
34990
35689
|
paginate as paginate47,
|
|
34991
35690
|
useAtlas as useAtlas93,
|
|
34992
|
-
useCache as
|
|
35691
|
+
useCache as useCache59
|
|
34993
35692
|
} from "@7365admin1/node-server-utils";
|
|
34994
35693
|
import { ObjectId as ObjectId103 } from "mongodb";
|
|
34995
35694
|
function useOnlineFormRepo() {
|
|
@@ -34999,7 +35698,7 @@ function useOnlineFormRepo() {
|
|
|
34999
35698
|
}
|
|
35000
35699
|
const namespace_collection = "online-forms";
|
|
35001
35700
|
const collection = db.collection(namespace_collection);
|
|
35002
|
-
const { delNamespace, getCache, setCache } =
|
|
35701
|
+
const { delNamespace, getCache, setCache } = useCache59(namespace_collection);
|
|
35003
35702
|
async function createTextIndex() {
|
|
35004
35703
|
try {
|
|
35005
35704
|
await collection.createIndex({
|
|
@@ -35745,7 +36444,7 @@ import {
|
|
|
35745
36444
|
makeCacheKey as makeCacheKey56,
|
|
35746
36445
|
paginate as paginate48,
|
|
35747
36446
|
useAtlas as useAtlas95,
|
|
35748
|
-
useCache as
|
|
36447
|
+
useCache as useCache60
|
|
35749
36448
|
} from "@7365admin1/node-server-utils";
|
|
35750
36449
|
import { ObjectId as ObjectId105 } from "mongodb";
|
|
35751
36450
|
function useNfcPatrolLogRepo() {
|
|
@@ -35755,7 +36454,7 @@ function useNfcPatrolLogRepo() {
|
|
|
35755
36454
|
}
|
|
35756
36455
|
const namespace_collection = "nfc-patrol-logs";
|
|
35757
36456
|
const collection = db.collection(namespace_collection);
|
|
35758
|
-
const { delNamespace, getCache, setCache } =
|
|
36457
|
+
const { delNamespace, getCache, setCache } = useCache60(namespace_collection);
|
|
35759
36458
|
async function createIndexes() {
|
|
35760
36459
|
try {
|
|
35761
36460
|
await collection.createIndexes([
|