@7365admin1/core 2.61.0 → 2.62.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 +11 -1
- package/dist/index.js +336 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +369 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2081,7 +2081,7 @@ declare function useDahuaService(): {
|
|
|
2081
2081
|
}) => Promise<urllib.HttpClientResponse<any>>;
|
|
2082
2082
|
};
|
|
2083
2083
|
|
|
2084
|
-
type TVehicleUpdate = Partial<Pick<TVehicle, "name" | "phoneNumber" | "block" | "level" | "unit" | "plateNumber" | "recNo">>;
|
|
2084
|
+
type TVehicleUpdate = Partial<Pick<TVehicle, "name" | "phoneNumber" | "block" | "level" | "unit" | "plateNumber" | "recNo" | "type">>;
|
|
2085
2085
|
declare enum VehicleType {
|
|
2086
2086
|
WHITELIST = "whitelist",
|
|
2087
2087
|
BLOCKLIST = "blocklist"
|
|
@@ -2300,6 +2300,8 @@ declare function useVehicleService(): {
|
|
|
2300
2300
|
[key: number]: any;
|
|
2301
2301
|
};
|
|
2302
2302
|
}>;
|
|
2303
|
+
blocklistVehicles: (_id: string, value: TVehicle) => Promise<void>;
|
|
2304
|
+
removeFromBlocklist: (_id: string, value: TVehicle) => Promise<void>;
|
|
2303
2305
|
};
|
|
2304
2306
|
|
|
2305
2307
|
declare function useVehicleController(): {
|
|
@@ -2316,6 +2318,8 @@ declare function useVehicleController(): {
|
|
|
2316
2318
|
uploadSpreadsheetVehicles: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2317
2319
|
getSpecificVehicleById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2318
2320
|
getBlocklistedVehicles: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2321
|
+
blocklistVehicles: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2322
|
+
removeFromBlocklist: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
2319
2323
|
};
|
|
2320
2324
|
|
|
2321
2325
|
declare function useSiteCameraRepo(): {
|
|
@@ -4733,6 +4737,11 @@ declare function UseAccessManagementRepo(): {
|
|
|
4733
4737
|
visitorCheckoutRepo: ({ userId }: {
|
|
4734
4738
|
userId: string;
|
|
4735
4739
|
}) => Promise<string>;
|
|
4740
|
+
uploadTemplateRepo: ({ site, id, name }: {
|
|
4741
|
+
site: string | ObjectId;
|
|
4742
|
+
id: string | ObjectId;
|
|
4743
|
+
name: string;
|
|
4744
|
+
}) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
4736
4745
|
};
|
|
4737
4746
|
|
|
4738
4747
|
declare function useAccessManagementController(): {
|
|
@@ -4775,6 +4784,7 @@ declare function useAccessManagementController(): {
|
|
|
4775
4784
|
getTransactions: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
4776
4785
|
assignMultipleCards: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
4777
4786
|
visitorCheckout: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
4787
|
+
uploadTemplate: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
4778
4788
|
};
|
|
4779
4789
|
|
|
4780
4790
|
declare const DEVICE_STATUS: {
|
package/dist/index.js
CHANGED
|
@@ -18292,6 +18292,167 @@ function useVehicleService() {
|
|
|
18292
18292
|
throw error;
|
|
18293
18293
|
}
|
|
18294
18294
|
}
|
|
18295
|
+
async function blocklistVehicles(_id, value) {
|
|
18296
|
+
const session = import_node_server_utils75.useAtlas.getClient()?.startSession();
|
|
18297
|
+
if (!session) {
|
|
18298
|
+
throw new Error("Unable to start session for vehicle service.");
|
|
18299
|
+
}
|
|
18300
|
+
try {
|
|
18301
|
+
session.startTransaction();
|
|
18302
|
+
const vehicle = await _getVehicleById(_id);
|
|
18303
|
+
const plate = vehicle.plates.find((p) => p._id.toString() === _id);
|
|
18304
|
+
const _name = value.name ? value.name : vehicle.name;
|
|
18305
|
+
const _plateNumber = plate?.plateNumber;
|
|
18306
|
+
const _start = vehicle.start;
|
|
18307
|
+
const _end = vehicle.end;
|
|
18308
|
+
const _recNo = plate.recNo;
|
|
18309
|
+
const _type = plate.type;
|
|
18310
|
+
if (value.peopleId) {
|
|
18311
|
+
value.peopleId = new import_mongodb46.ObjectId(value.peopleId);
|
|
18312
|
+
}
|
|
18313
|
+
const { site } = value;
|
|
18314
|
+
const startDahua = formatDahuaDate(_start);
|
|
18315
|
+
const endPlus24Hours = _end ? _end : new Date(new Date(_end).getTime() + 24 * 60 * 60 * 1e3);
|
|
18316
|
+
const endDahua = formatDahuaDate(endPlus24Hours);
|
|
18317
|
+
if (_plateNumber) {
|
|
18318
|
+
const siteCameras = [];
|
|
18319
|
+
let page = 1;
|
|
18320
|
+
let pages = 1;
|
|
18321
|
+
const limit = 20;
|
|
18322
|
+
do {
|
|
18323
|
+
const siteCameraReq = await _getAllSiteCameras({
|
|
18324
|
+
site,
|
|
18325
|
+
type: "anpr",
|
|
18326
|
+
direction: ["both", "entry"],
|
|
18327
|
+
page,
|
|
18328
|
+
limit
|
|
18329
|
+
});
|
|
18330
|
+
pages = siteCameraReq.pages || 1;
|
|
18331
|
+
siteCameras.push(...siteCameraReq.items);
|
|
18332
|
+
page++;
|
|
18333
|
+
} while (page < pages);
|
|
18334
|
+
if (!siteCameras.length) {
|
|
18335
|
+
throw new import_node_server_utils75.BadRequestError("No site cameras found.");
|
|
18336
|
+
}
|
|
18337
|
+
for (const camera of siteCameras) {
|
|
18338
|
+
const { host, username, password } = camera;
|
|
18339
|
+
const removePlateNumber = {
|
|
18340
|
+
host,
|
|
18341
|
+
username,
|
|
18342
|
+
password,
|
|
18343
|
+
mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
|
|
18344
|
+
recno: _recNo
|
|
18345
|
+
};
|
|
18346
|
+
const responseForDeletion = await _removePlateNumber(
|
|
18347
|
+
removePlateNumber
|
|
18348
|
+
);
|
|
18349
|
+
if (responseForDeletion?.statusCode !== 200) {
|
|
18350
|
+
throw new import_node_server_utils75.BadRequestError("Failed to delete plate number to ANPR");
|
|
18351
|
+
}
|
|
18352
|
+
const dahuaPayload = {
|
|
18353
|
+
host,
|
|
18354
|
+
username,
|
|
18355
|
+
password,
|
|
18356
|
+
plateNumber: _plateNumber,
|
|
18357
|
+
mode: "TrafficBlackList" /* TRAFFIC_BLACKLIST */,
|
|
18358
|
+
owner: _name,
|
|
18359
|
+
...startDahua ? { start: startDahua } : {},
|
|
18360
|
+
...endDahua ? { end: endDahua } : {}
|
|
18361
|
+
};
|
|
18362
|
+
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
18363
|
+
if (dahuaResponse?.statusCode !== 200) {
|
|
18364
|
+
throw new import_node_server_utils75.BadRequestError("Failed to update plate number to ANPR");
|
|
18365
|
+
}
|
|
18366
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
18367
|
+
value.recNo = responseData.split("=")[1]?.trim();
|
|
18368
|
+
const normalizedPlateNumber = _plateNumber;
|
|
18369
|
+
if (value.peopleId && value.recNo) {
|
|
18370
|
+
await _pushVehicleById(
|
|
18371
|
+
value.peopleId,
|
|
18372
|
+
{
|
|
18373
|
+
plateNumber: normalizedPlateNumber,
|
|
18374
|
+
recNo: value.recNo
|
|
18375
|
+
},
|
|
18376
|
+
session
|
|
18377
|
+
);
|
|
18378
|
+
}
|
|
18379
|
+
}
|
|
18380
|
+
}
|
|
18381
|
+
const formattedValue = {
|
|
18382
|
+
type: "blocklist" /* BLOCKLIST */,
|
|
18383
|
+
recNo: value.recNo
|
|
18384
|
+
};
|
|
18385
|
+
await _updateVehicleById(_id, formattedValue, session);
|
|
18386
|
+
await session.commitTransaction();
|
|
18387
|
+
} catch (error) {
|
|
18388
|
+
await session.abortTransaction();
|
|
18389
|
+
throw error;
|
|
18390
|
+
} finally {
|
|
18391
|
+
session.endSession();
|
|
18392
|
+
}
|
|
18393
|
+
}
|
|
18394
|
+
async function removeFromBlocklist(_id, value) {
|
|
18395
|
+
const session = import_node_server_utils75.useAtlas.getClient()?.startSession();
|
|
18396
|
+
if (!session) {
|
|
18397
|
+
throw new Error("Unable to start session for vehicle service.");
|
|
18398
|
+
}
|
|
18399
|
+
try {
|
|
18400
|
+
session.startTransaction();
|
|
18401
|
+
const vehicle = await _getVehicleById(_id);
|
|
18402
|
+
const plate = vehicle.plates.find((p) => p._id.toString() === _id);
|
|
18403
|
+
const _plateNumber = plate?.plateNumber;
|
|
18404
|
+
const _recNo = plate.recNo;
|
|
18405
|
+
if (value.peopleId) {
|
|
18406
|
+
value.peopleId = new import_mongodb46.ObjectId(value.peopleId);
|
|
18407
|
+
}
|
|
18408
|
+
const { site } = value;
|
|
18409
|
+
if (_plateNumber) {
|
|
18410
|
+
const siteCameras = [];
|
|
18411
|
+
let page = 1;
|
|
18412
|
+
let pages = 1;
|
|
18413
|
+
const limit = 20;
|
|
18414
|
+
do {
|
|
18415
|
+
const siteCameraReq = await _getAllSiteCameras({
|
|
18416
|
+
site,
|
|
18417
|
+
type: "anpr",
|
|
18418
|
+
direction: ["both", "entry"],
|
|
18419
|
+
page,
|
|
18420
|
+
limit
|
|
18421
|
+
});
|
|
18422
|
+
pages = siteCameraReq.pages || 1;
|
|
18423
|
+
siteCameras.push(...siteCameraReq.items);
|
|
18424
|
+
page++;
|
|
18425
|
+
} while (page < pages);
|
|
18426
|
+
if (!siteCameras.length) {
|
|
18427
|
+
throw new import_node_server_utils75.BadRequestError("No site cameras found.");
|
|
18428
|
+
}
|
|
18429
|
+
for (const camera of siteCameras) {
|
|
18430
|
+
const { host, username, password } = camera;
|
|
18431
|
+
const removePlateNumber = {
|
|
18432
|
+
host,
|
|
18433
|
+
username,
|
|
18434
|
+
password,
|
|
18435
|
+
mode: "TrafficBlackList" /* TRAFFIC_BLACKLIST */,
|
|
18436
|
+
recno: _recNo
|
|
18437
|
+
};
|
|
18438
|
+
console.log(removePlateNumber);
|
|
18439
|
+
const responseForDeletion = await _removePlateNumber(
|
|
18440
|
+
removePlateNumber
|
|
18441
|
+
);
|
|
18442
|
+
if (responseForDeletion?.statusCode !== 200) {
|
|
18443
|
+
throw new import_node_server_utils75.BadRequestError("Failed to delete plate number to ANPR");
|
|
18444
|
+
}
|
|
18445
|
+
}
|
|
18446
|
+
}
|
|
18447
|
+
await _deleteVehicle(_id, session);
|
|
18448
|
+
await session.commitTransaction();
|
|
18449
|
+
} catch (error) {
|
|
18450
|
+
await session.abortTransaction();
|
|
18451
|
+
throw error;
|
|
18452
|
+
} finally {
|
|
18453
|
+
session.endSession();
|
|
18454
|
+
}
|
|
18455
|
+
}
|
|
18295
18456
|
return {
|
|
18296
18457
|
add,
|
|
18297
18458
|
deleteVehicle,
|
|
@@ -18299,7 +18460,9 @@ function useVehicleService() {
|
|
|
18299
18460
|
processDeletingExpiredVehicles,
|
|
18300
18461
|
reactivateVehicleById,
|
|
18301
18462
|
updateVehicleById,
|
|
18302
|
-
bulkUpsertVehicles
|
|
18463
|
+
bulkUpsertVehicles,
|
|
18464
|
+
blocklistVehicles,
|
|
18465
|
+
removeFromBlocklist
|
|
18303
18466
|
};
|
|
18304
18467
|
}
|
|
18305
18468
|
|
|
@@ -20650,7 +20813,7 @@ function useBuildingService() {
|
|
|
20650
20813
|
getByBuildingLevel,
|
|
20651
20814
|
updateLevelByBuildingLevel,
|
|
20652
20815
|
updateByBuildingId,
|
|
20653
|
-
|
|
20816
|
+
bulkAddBuildingUnits: _bulkAddBuildingUnits
|
|
20654
20817
|
} = useBuildingUnitRepo();
|
|
20655
20818
|
const { updateStatusById } = useFileRepo();
|
|
20656
20819
|
const { deleteFile } = useFileService();
|
|
@@ -20839,15 +21002,16 @@ function useBuildingService() {
|
|
|
20839
21002
|
companyName: "",
|
|
20840
21003
|
companyRegistrationNumber: "",
|
|
20841
21004
|
billing: [],
|
|
20842
|
-
unitNumber: parseInt(unit.replace("Unit ", ""), 10) || null
|
|
21005
|
+
unitNumber: parseInt(unit.replace("Unit ", ""), 10) || null,
|
|
21006
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
21007
|
+
updatedAt: "",
|
|
21008
|
+
deletedAt: ""
|
|
20843
21009
|
});
|
|
20844
21010
|
});
|
|
20845
21011
|
});
|
|
20846
21012
|
}
|
|
20847
21013
|
);
|
|
20848
|
-
|
|
20849
|
-
const result = await _addBuildingUnit(buildingUnitPayload);
|
|
20850
|
-
}
|
|
21014
|
+
await _bulkAddBuildingUnits(buildingUnitPayloads);
|
|
20851
21015
|
await session?.commitTransaction();
|
|
20852
21016
|
return { buildingPayloads, buildingUnitPayloads };
|
|
20853
21017
|
} catch (error) {
|
|
@@ -21588,7 +21752,9 @@ function useVehicleController() {
|
|
|
21588
21752
|
approveVehicleById: _approveVehicleById,
|
|
21589
21753
|
reactivateVehicleById: _reactivateVehicleById,
|
|
21590
21754
|
updateVehicleById: _updateVehicleById,
|
|
21591
|
-
bulkUpsertVehicles: _bulkUpsertVehicles
|
|
21755
|
+
bulkUpsertVehicles: _bulkUpsertVehicles,
|
|
21756
|
+
blocklistVehicles: _blocklistVehicles,
|
|
21757
|
+
removeFromBlocklist: _removeFromBlocklist
|
|
21592
21758
|
} = useVehicleService();
|
|
21593
21759
|
const {
|
|
21594
21760
|
getSeasonPassTypes: _getSeasonPassTypes,
|
|
@@ -22165,6 +22331,68 @@ function useVehicleController() {
|
|
|
22165
22331
|
return;
|
|
22166
22332
|
}
|
|
22167
22333
|
}
|
|
22334
|
+
async function blocklistVehicles(req, res, next) {
|
|
22335
|
+
try {
|
|
22336
|
+
const schema2 = import_joi47.default.object({
|
|
22337
|
+
_id: import_joi47.default.string().hex().length(24).required(),
|
|
22338
|
+
site: import_joi47.default.string().hex().length(24).required(),
|
|
22339
|
+
peopleId: import_joi47.default.string().hex().length(24).optional().allow(null, ""),
|
|
22340
|
+
remarks: import_joi47.default.string().optional().allow("", null)
|
|
22341
|
+
});
|
|
22342
|
+
const { error, value } = schema2.validate(
|
|
22343
|
+
{
|
|
22344
|
+
_id: req.params.id,
|
|
22345
|
+
...req.body
|
|
22346
|
+
},
|
|
22347
|
+
{ abortEarly: false }
|
|
22348
|
+
);
|
|
22349
|
+
if (error) {
|
|
22350
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
22351
|
+
import_node_server_utils88.logger.log({ level: "error", message: messages });
|
|
22352
|
+
next(new import_node_server_utils88.BadRequestError(messages));
|
|
22353
|
+
return;
|
|
22354
|
+
}
|
|
22355
|
+
const { _id, ...rest } = value;
|
|
22356
|
+
await _blocklistVehicles(_id, rest);
|
|
22357
|
+
res.json({ message: "Successfully blocked vehicle." });
|
|
22358
|
+
return;
|
|
22359
|
+
} catch (error) {
|
|
22360
|
+
import_node_server_utils88.logger.log({ level: "error", message: error.message });
|
|
22361
|
+
next(error);
|
|
22362
|
+
return;
|
|
22363
|
+
}
|
|
22364
|
+
}
|
|
22365
|
+
async function removeFromBlocklist(req, res, next) {
|
|
22366
|
+
try {
|
|
22367
|
+
const schema2 = import_joi47.default.object({
|
|
22368
|
+
_id: import_joi47.default.string().hex().length(24).required(),
|
|
22369
|
+
site: import_joi47.default.string().hex().length(24).required(),
|
|
22370
|
+
peopleId: import_joi47.default.string().hex().length(24).optional().allow(null, ""),
|
|
22371
|
+
remarks: import_joi47.default.string().optional().allow("", null)
|
|
22372
|
+
});
|
|
22373
|
+
const { error, value } = schema2.validate(
|
|
22374
|
+
{
|
|
22375
|
+
_id: req.params.id,
|
|
22376
|
+
...req.body
|
|
22377
|
+
},
|
|
22378
|
+
{ abortEarly: false }
|
|
22379
|
+
);
|
|
22380
|
+
if (error) {
|
|
22381
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
22382
|
+
import_node_server_utils88.logger.log({ level: "error", message: messages });
|
|
22383
|
+
next(new import_node_server_utils88.BadRequestError(messages));
|
|
22384
|
+
return;
|
|
22385
|
+
}
|
|
22386
|
+
const { _id, ...rest } = value;
|
|
22387
|
+
await _removeFromBlocklist(_id, rest);
|
|
22388
|
+
res.json({ message: "Successfully removed vehicle from blocklist." });
|
|
22389
|
+
return;
|
|
22390
|
+
} catch (error) {
|
|
22391
|
+
import_node_server_utils88.logger.log({ level: "error", message: error.message });
|
|
22392
|
+
next(error);
|
|
22393
|
+
return;
|
|
22394
|
+
}
|
|
22395
|
+
}
|
|
22168
22396
|
return {
|
|
22169
22397
|
add,
|
|
22170
22398
|
getVehicles,
|
|
@@ -22178,7 +22406,9 @@ function useVehicleController() {
|
|
|
22178
22406
|
getAllVehiclesByUnitId,
|
|
22179
22407
|
uploadSpreadsheetVehicles,
|
|
22180
22408
|
getSpecificVehicleById,
|
|
22181
|
-
getBlocklistedVehicles
|
|
22409
|
+
getBlocklistedVehicles,
|
|
22410
|
+
blocklistVehicles,
|
|
22411
|
+
removeFromBlocklist
|
|
22182
22412
|
};
|
|
22183
22413
|
}
|
|
22184
22414
|
|
|
@@ -31669,6 +31899,18 @@ function MBulletinBoard(value) {
|
|
|
31669
31899
|
throw new Error("Invalid org ID.");
|
|
31670
31900
|
}
|
|
31671
31901
|
}
|
|
31902
|
+
if (value.file && Array.isArray(value.file)) {
|
|
31903
|
+
value.file = value.file.map((f) => {
|
|
31904
|
+
if (f._id && typeof f._id === "string") {
|
|
31905
|
+
try {
|
|
31906
|
+
return { ...f, _id: new import_mongodb78.ObjectId(f._id) };
|
|
31907
|
+
} catch {
|
|
31908
|
+
throw new Error("Invalid file ID.");
|
|
31909
|
+
}
|
|
31910
|
+
}
|
|
31911
|
+
return f;
|
|
31912
|
+
});
|
|
31913
|
+
}
|
|
31672
31914
|
return {
|
|
31673
31915
|
_id: value._id ?? new import_mongodb78.ObjectId(),
|
|
31674
31916
|
site: value.site ?? "",
|
|
@@ -31987,7 +32229,7 @@ function useBulletinBoardService() {
|
|
|
31987
32229
|
deleteBulletinBoardById: _deleteBulletinBoardById,
|
|
31988
32230
|
getBulletinBoardById: _getBulletinBoardById
|
|
31989
32231
|
} = useBulletinBoardRepo();
|
|
31990
|
-
const { deleteFileById: _deleteFileById } = useFileRepo();
|
|
32232
|
+
const { deleteFileById: _deleteFileById, updateStatusById } = useFileRepo();
|
|
31991
32233
|
async function add(value) {
|
|
31992
32234
|
const session = import_node_server_utils137.useAtlas.getClient()?.startSession();
|
|
31993
32235
|
session?.startTransaction();
|
|
@@ -31995,6 +32237,21 @@ function useBulletinBoardService() {
|
|
|
31995
32237
|
value.status = "upcoming" /* UPCOMING */;
|
|
31996
32238
|
}
|
|
31997
32239
|
try {
|
|
32240
|
+
const bulletinFiles = value?.file ?? [];
|
|
32241
|
+
if (bulletinFiles.length > 0) {
|
|
32242
|
+
for (const bulletinFile of bulletinFiles) {
|
|
32243
|
+
if (!bulletinFile._id)
|
|
32244
|
+
continue;
|
|
32245
|
+
const file = await updateStatusById(
|
|
32246
|
+
bulletinFile._id.toString(),
|
|
32247
|
+
{ status: "active" },
|
|
32248
|
+
session
|
|
32249
|
+
);
|
|
32250
|
+
if (!file) {
|
|
32251
|
+
throw new import_node_server_utils137.NotFoundError("File not found.");
|
|
32252
|
+
}
|
|
32253
|
+
}
|
|
32254
|
+
}
|
|
31998
32255
|
await _add(value, session);
|
|
31999
32256
|
await session?.commitTransaction();
|
|
32000
32257
|
return "Successfully added bulletin board.";
|
|
@@ -37756,6 +38013,19 @@ function UseAccessManagementRepo() {
|
|
|
37756
38013
|
await session?.endSession();
|
|
37757
38014
|
}
|
|
37758
38015
|
}
|
|
38016
|
+
async function uploadTemplateRepo({ site, id, name }) {
|
|
38017
|
+
site = new import_mongodb90.ObjectId(site);
|
|
38018
|
+
id = new import_mongodb90.ObjectId(id);
|
|
38019
|
+
try {
|
|
38020
|
+
const result = await collectionName("sites").updateOne(
|
|
38021
|
+
{ _id: site },
|
|
38022
|
+
{ $set: { "siteSettings.entryPass.settings.template": { id, name } } }
|
|
38023
|
+
);
|
|
38024
|
+
return result;
|
|
38025
|
+
} catch (error) {
|
|
38026
|
+
throw new Error(error.message);
|
|
38027
|
+
}
|
|
38028
|
+
}
|
|
37759
38029
|
return {
|
|
37760
38030
|
createIndexes,
|
|
37761
38031
|
createIndexForEntrypass,
|
|
@@ -37790,7 +38060,8 @@ function UseAccessManagementRepo() {
|
|
|
37790
38060
|
indexCombination,
|
|
37791
38061
|
getTransactionsRepo,
|
|
37792
38062
|
assignMultipleCardsRepo,
|
|
37793
|
-
visitorCheckoutRepo
|
|
38063
|
+
visitorCheckoutRepo,
|
|
38064
|
+
uploadTemplateRepo
|
|
37794
38065
|
};
|
|
37795
38066
|
}
|
|
37796
38067
|
|
|
@@ -37833,7 +38104,8 @@ function useAccessManagementSvc() {
|
|
|
37833
38104
|
getBlockLevelAndUnitListRepo,
|
|
37834
38105
|
getTransactionsRepo,
|
|
37835
38106
|
assignMultipleCardsRepo,
|
|
37836
|
-
visitorCheckoutRepo
|
|
38107
|
+
visitorCheckoutRepo,
|
|
38108
|
+
uploadTemplateRepo
|
|
37837
38109
|
} = UseAccessManagementRepo();
|
|
37838
38110
|
const addPhysicalCardSvc = async (payload) => {
|
|
37839
38111
|
try {
|
|
@@ -38146,7 +38418,15 @@ function useAccessManagementSvc() {
|
|
|
38146
38418
|
const response = await visitorCheckoutRepo({ userId });
|
|
38147
38419
|
return response;
|
|
38148
38420
|
} catch (err) {
|
|
38149
|
-
|
|
38421
|
+
throw new Error(err.message);
|
|
38422
|
+
}
|
|
38423
|
+
};
|
|
38424
|
+
const uploadTemplateSvc = async ({ site, id, name }) => {
|
|
38425
|
+
try {
|
|
38426
|
+
const response = await uploadTemplateRepo({ site, id, name });
|
|
38427
|
+
return response;
|
|
38428
|
+
} catch (err) {
|
|
38429
|
+
throw new Error(err.message);
|
|
38150
38430
|
}
|
|
38151
38431
|
};
|
|
38152
38432
|
return {
|
|
@@ -38186,7 +38466,8 @@ function useAccessManagementSvc() {
|
|
|
38186
38466
|
getBlockLevelAndUnitListSvc,
|
|
38187
38467
|
getTransactionsSvc,
|
|
38188
38468
|
assignMultipleCardsSvc,
|
|
38189
|
-
visitorCheckoutSvc
|
|
38469
|
+
visitorCheckoutSvc,
|
|
38470
|
+
uploadTemplateSvc
|
|
38190
38471
|
};
|
|
38191
38472
|
}
|
|
38192
38473
|
|
|
@@ -38229,7 +38510,8 @@ function useAccessManagementController() {
|
|
|
38229
38510
|
getBlockLevelAndUnitListSvc,
|
|
38230
38511
|
getTransactionsSvc,
|
|
38231
38512
|
assignMultipleCardsSvc,
|
|
38232
|
-
visitorCheckoutSvc
|
|
38513
|
+
visitorCheckoutSvc,
|
|
38514
|
+
uploadTemplateSvc
|
|
38233
38515
|
} = useAccessManagementSvc();
|
|
38234
38516
|
const addPhysicalCard = async (req, res) => {
|
|
38235
38517
|
try {
|
|
@@ -39046,7 +39328,32 @@ function useAccessManagementController() {
|
|
|
39046
39328
|
const result = await visitorCheckoutSvc({ userId });
|
|
39047
39329
|
return res.status(200).json({ message: "Success", data: result });
|
|
39048
39330
|
} catch (error) {
|
|
39049
|
-
return
|
|
39331
|
+
return res.status(400).json({
|
|
39332
|
+
data: null,
|
|
39333
|
+
message: error.message
|
|
39334
|
+
});
|
|
39335
|
+
}
|
|
39336
|
+
};
|
|
39337
|
+
const uploadTemplate = async (req, res) => {
|
|
39338
|
+
try {
|
|
39339
|
+
const { site } = req.query;
|
|
39340
|
+
const { id, name } = req.body;
|
|
39341
|
+
const schema2 = import_joi86.default.object({
|
|
39342
|
+
site: import_joi86.default.string().hex().required(),
|
|
39343
|
+
id: import_joi86.default.string().hex().required(),
|
|
39344
|
+
name: import_joi86.default.string().required()
|
|
39345
|
+
});
|
|
39346
|
+
const { error } = schema2.validate({ site, id, name });
|
|
39347
|
+
if (error) {
|
|
39348
|
+
return res.status(400).json({ message: error.message });
|
|
39349
|
+
}
|
|
39350
|
+
const result = await uploadTemplateSvc({ site, id, name });
|
|
39351
|
+
return res.status(200).json({ message: "Success", data: result });
|
|
39352
|
+
} catch (error) {
|
|
39353
|
+
return res.status(400).json({
|
|
39354
|
+
data: null,
|
|
39355
|
+
message: error.message
|
|
39356
|
+
});
|
|
39050
39357
|
}
|
|
39051
39358
|
};
|
|
39052
39359
|
return {
|
|
@@ -39084,7 +39391,8 @@ function useAccessManagementController() {
|
|
|
39084
39391
|
getBlockLevelAndUnitList,
|
|
39085
39392
|
getTransactions: getTransactions2,
|
|
39086
39393
|
assignMultipleCards,
|
|
39087
|
-
visitorCheckout
|
|
39394
|
+
visitorCheckout,
|
|
39395
|
+
uploadTemplate
|
|
39088
39396
|
};
|
|
39089
39397
|
}
|
|
39090
39398
|
|
|
@@ -40487,11 +40795,22 @@ function useBulletinVideoService() {
|
|
|
40487
40795
|
deleteBulletinVideoById: _deleteBulletinVideoById,
|
|
40488
40796
|
getBulletinVideoById: _getBulletinVideoById
|
|
40489
40797
|
} = useBulletinVideoRepo();
|
|
40490
|
-
const { deleteFileById: _deleteFileById } = useFileRepo();
|
|
40798
|
+
const { deleteFileById: _deleteFileById, updateStatusById } = useFileRepo();
|
|
40491
40799
|
async function add(value) {
|
|
40492
40800
|
const session = import_node_server_utils163.useAtlas.getClient()?.startSession();
|
|
40493
40801
|
session?.startTransaction();
|
|
40494
40802
|
try {
|
|
40803
|
+
const bulletinVideo = value.file;
|
|
40804
|
+
if (bulletinVideo) {
|
|
40805
|
+
const file = await updateStatusById(
|
|
40806
|
+
bulletinVideo,
|
|
40807
|
+
{ status: "active" },
|
|
40808
|
+
session
|
|
40809
|
+
);
|
|
40810
|
+
if (!file) {
|
|
40811
|
+
throw new import_node_server_utils163.NotFoundError("File not found.");
|
|
40812
|
+
}
|
|
40813
|
+
}
|
|
40495
40814
|
await _add(value, session);
|
|
40496
40815
|
await session?.commitTransaction();
|
|
40497
40816
|
return "Successfully added bulletin video.";
|