@7365admin1/module-hygiene 4.29.1-staging.13 → 4.29.1-staging.14
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/.changeset/area-import-unit-ids.md +5 -0
- package/dist/index.js +271 -265
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +271 -265
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/area-import-unit-id.test.mjs +18 -0
package/dist/index.mjs
CHANGED
|
@@ -843,21 +843,30 @@ function useHygieneDashboardController() {
|
|
|
843
843
|
}
|
|
844
844
|
|
|
845
845
|
// src/models/hygiene-area.model.ts
|
|
846
|
-
import
|
|
846
|
+
import Joi3 from "joi";
|
|
847
847
|
import { ObjectId as ObjectId2 } from "mongodb";
|
|
848
848
|
import { BadRequestError as BadRequestError3, logger as logger3 } from "@7365admin1/node-server-utils";
|
|
849
849
|
import { AppServiceType as AppServiceType2 } from "@7365admin1/core";
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
850
|
+
|
|
851
|
+
// src/utils/area-unit.util.ts
|
|
852
|
+
import Joi2 from "joi";
|
|
853
|
+
var areaUnitSchema = Joi2.object({
|
|
854
|
+
unit: Joi2.string().hex().required(),
|
|
855
|
+
name: Joi2.string().required()
|
|
856
|
+
});
|
|
857
|
+
function toAreaUnit(unit) {
|
|
858
|
+
return { unit: String(unit._id), name: unit.name };
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// src/models/hygiene-area.model.ts
|
|
862
|
+
var areaSchema = Joi3.object({
|
|
863
|
+
site: Joi3.string().hex().required(),
|
|
864
|
+
serviceType: Joi3.string().valid(...Object.values(AppServiceType2)).required(),
|
|
865
|
+
name: Joi3.string().required(),
|
|
866
|
+
type: Joi3.string().valid(...allowedTypes).required(),
|
|
867
|
+
set: Joi3.number().min(0).optional(),
|
|
868
|
+
units: Joi3.array().items(
|
|
869
|
+
areaUnitSchema.optional()
|
|
861
870
|
).min(1).unique("unit", { ignoreUndefined: true }).messages({
|
|
862
871
|
"array.unique": "Duplicate area units are not allowed"
|
|
863
872
|
})
|
|
@@ -1371,14 +1380,14 @@ import {
|
|
|
1371
1380
|
} from "@7365admin1/node-server-utils";
|
|
1372
1381
|
|
|
1373
1382
|
// src/models/hygiene-unit.model.ts
|
|
1374
|
-
import
|
|
1383
|
+
import Joi4 from "joi";
|
|
1375
1384
|
import { ObjectId as ObjectId4 } from "mongodb";
|
|
1376
1385
|
import { BadRequestError as BadRequestError5, logger as logger6 } from "@7365admin1/node-server-utils";
|
|
1377
1386
|
import { AppServiceType as AppServiceType3 } from "@7365admin1/core";
|
|
1378
|
-
var unitSchema =
|
|
1379
|
-
site:
|
|
1380
|
-
serviceType:
|
|
1381
|
-
name:
|
|
1387
|
+
var unitSchema = Joi4.object({
|
|
1388
|
+
site: Joi4.string().hex().required(),
|
|
1389
|
+
serviceType: Joi4.string().valid(...Object.values(AppServiceType3)).required(),
|
|
1390
|
+
name: Joi4.string().required()
|
|
1382
1391
|
});
|
|
1383
1392
|
function MUnit(value) {
|
|
1384
1393
|
const { error } = unitSchema.validate(value);
|
|
@@ -1713,10 +1722,7 @@ function useAreaService() {
|
|
|
1713
1722
|
}
|
|
1714
1723
|
}
|
|
1715
1724
|
if (foundUnit) {
|
|
1716
|
-
areaUnits.push(
|
|
1717
|
-
unit: foundUnit._id,
|
|
1718
|
-
name: foundUnit.name
|
|
1719
|
-
});
|
|
1725
|
+
areaUnits.push(toAreaUnit(foundUnit));
|
|
1720
1726
|
}
|
|
1721
1727
|
}
|
|
1722
1728
|
if (areaUnits.length > 0) {
|
|
@@ -1813,7 +1819,7 @@ function useAreaService() {
|
|
|
1813
1819
|
}
|
|
1814
1820
|
|
|
1815
1821
|
// src/controllers/hygiene-area.controller.ts
|
|
1816
|
-
import
|
|
1822
|
+
import Joi5 from "joi";
|
|
1817
1823
|
import { BadRequestError as BadRequestError8, logger as logger9 } from "@7365admin1/node-server-utils";
|
|
1818
1824
|
import { AppServiceType as AppServiceType4 } from "@7365admin1/core";
|
|
1819
1825
|
|
|
@@ -1874,13 +1880,13 @@ function useAreaController() {
|
|
|
1874
1880
|
}
|
|
1875
1881
|
async function getAreas(req, res, next) {
|
|
1876
1882
|
const query = { ...req.query, ...req.params };
|
|
1877
|
-
const validation =
|
|
1878
|
-
page:
|
|
1879
|
-
limit:
|
|
1880
|
-
search:
|
|
1881
|
-
type:
|
|
1882
|
-
site:
|
|
1883
|
-
serviceType:
|
|
1883
|
+
const validation = Joi5.object({
|
|
1884
|
+
page: Joi5.number().min(1).optional().allow("", null),
|
|
1885
|
+
limit: Joi5.number().min(1).optional().allow("", null),
|
|
1886
|
+
search: Joi5.string().optional().allow("", null),
|
|
1887
|
+
type: Joi5.string().valid("all", ...allowedTypes).optional().allow("", null),
|
|
1888
|
+
site: Joi5.string().hex().required(),
|
|
1889
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
1884
1890
|
});
|
|
1885
1891
|
const { error } = validation.validate(query);
|
|
1886
1892
|
if (error) {
|
|
@@ -1911,7 +1917,7 @@ function useAreaController() {
|
|
|
1911
1917
|
}
|
|
1912
1918
|
}
|
|
1913
1919
|
async function getAreaById(req, res, next) {
|
|
1914
|
-
const validation =
|
|
1920
|
+
const validation = Joi5.string().hex().required();
|
|
1915
1921
|
const _id = req.params.id;
|
|
1916
1922
|
const { error, value } = validation.validate(_id);
|
|
1917
1923
|
if (error) {
|
|
@@ -1931,15 +1937,15 @@ function useAreaController() {
|
|
|
1931
1937
|
}
|
|
1932
1938
|
async function updateArea(req, res, next) {
|
|
1933
1939
|
const payload = { id: req.params.id, ...req.body };
|
|
1934
|
-
const schema =
|
|
1935
|
-
id:
|
|
1936
|
-
name:
|
|
1937
|
-
type:
|
|
1938
|
-
set:
|
|
1939
|
-
units:
|
|
1940
|
-
|
|
1941
|
-
unit:
|
|
1942
|
-
name:
|
|
1940
|
+
const schema = Joi5.object({
|
|
1941
|
+
id: Joi5.string().hex().required(),
|
|
1942
|
+
name: Joi5.string().optional().allow("", null),
|
|
1943
|
+
type: Joi5.string().optional().allow("", null, ...allowedTypes),
|
|
1944
|
+
set: Joi5.number().min(0).optional(),
|
|
1945
|
+
units: Joi5.array().items(
|
|
1946
|
+
Joi5.object({
|
|
1947
|
+
unit: Joi5.string().hex().required(),
|
|
1948
|
+
name: Joi5.string().required()
|
|
1943
1949
|
}).required()
|
|
1944
1950
|
).min(1).unique("unit", { ignoreUndefined: true }).optional().messages({
|
|
1945
1951
|
"array.unique": "Duplicate area units are not allowed"
|
|
@@ -1964,7 +1970,7 @@ function useAreaController() {
|
|
|
1964
1970
|
}
|
|
1965
1971
|
async function deleteArea(req, res, next) {
|
|
1966
1972
|
const id = req.params.id;
|
|
1967
|
-
const validation =
|
|
1973
|
+
const validation = Joi5.string().hex().required();
|
|
1968
1974
|
const { error, value } = validation.validate(id);
|
|
1969
1975
|
if (error) {
|
|
1970
1976
|
logger9.log({ level: "error", message: error.message });
|
|
@@ -1987,9 +1993,9 @@ function useAreaController() {
|
|
|
1987
1993
|
return;
|
|
1988
1994
|
}
|
|
1989
1995
|
const query = { ...req.query, ...req.params };
|
|
1990
|
-
const validation =
|
|
1991
|
-
site:
|
|
1992
|
-
serviceType:
|
|
1996
|
+
const validation = Joi5.object({
|
|
1997
|
+
site: Joi5.string().hex().required(),
|
|
1998
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
1993
1999
|
});
|
|
1994
2000
|
const { error, value } = validation.validate(query);
|
|
1995
2001
|
if (error) {
|
|
@@ -2010,9 +2016,9 @@ function useAreaController() {
|
|
|
2010
2016
|
}
|
|
2011
2017
|
async function exportAreas(req, res, next) {
|
|
2012
2018
|
const query = { ...req.query, ...req.params };
|
|
2013
|
-
const validation =
|
|
2014
|
-
site:
|
|
2015
|
-
serviceType:
|
|
2019
|
+
const validation = Joi5.object({
|
|
2020
|
+
site: Joi5.string().hex().required(),
|
|
2021
|
+
serviceType: Joi5.string().valid(...Object.values(AppServiceType4)).required()
|
|
2016
2022
|
});
|
|
2017
2023
|
const { error, value } = validation.validate(query);
|
|
2018
2024
|
if (error) {
|
|
@@ -2299,7 +2305,7 @@ function useUnitService() {
|
|
|
2299
2305
|
}
|
|
2300
2306
|
|
|
2301
2307
|
// src/controllers/hygiene-unit.controller.ts
|
|
2302
|
-
import
|
|
2308
|
+
import Joi6 from "joi";
|
|
2303
2309
|
import { BadRequestError as BadRequestError10, logger as logger12 } from "@7365admin1/node-server-utils";
|
|
2304
2310
|
import { AppServiceType as AppServiceType5 } from "@7365admin1/core";
|
|
2305
2311
|
function useUnitController() {
|
|
@@ -2330,12 +2336,12 @@ function useUnitController() {
|
|
|
2330
2336
|
}
|
|
2331
2337
|
async function getUnits(req, res, next) {
|
|
2332
2338
|
const query = { ...req.query, ...req.params };
|
|
2333
|
-
const validation =
|
|
2334
|
-
page:
|
|
2335
|
-
limit:
|
|
2336
|
-
search:
|
|
2337
|
-
site:
|
|
2338
|
-
serviceType:
|
|
2339
|
+
const validation = Joi6.object({
|
|
2340
|
+
page: Joi6.number().min(1).optional().allow("", null),
|
|
2341
|
+
limit: Joi6.number().min(1).optional().allow("", null),
|
|
2342
|
+
search: Joi6.string().optional().allow("", null),
|
|
2343
|
+
site: Joi6.string().hex().required(),
|
|
2344
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2339
2345
|
});
|
|
2340
2346
|
const { error } = validation.validate(query);
|
|
2341
2347
|
if (error) {
|
|
@@ -2366,9 +2372,9 @@ function useUnitController() {
|
|
|
2366
2372
|
}
|
|
2367
2373
|
async function updateUnit(req, res, next) {
|
|
2368
2374
|
const payload = { id: req.params.id, ...req.body };
|
|
2369
|
-
const validation =
|
|
2370
|
-
id:
|
|
2371
|
-
name:
|
|
2375
|
+
const validation = Joi6.object({
|
|
2376
|
+
id: Joi6.string().hex().required(),
|
|
2377
|
+
name: Joi6.string().required()
|
|
2372
2378
|
});
|
|
2373
2379
|
const { error } = validation.validate(payload);
|
|
2374
2380
|
if (error) {
|
|
@@ -2389,8 +2395,8 @@ function useUnitController() {
|
|
|
2389
2395
|
}
|
|
2390
2396
|
async function deleteUnit(req, res, next) {
|
|
2391
2397
|
const id = req.params.id;
|
|
2392
|
-
const validation =
|
|
2393
|
-
id:
|
|
2398
|
+
const validation = Joi6.object({
|
|
2399
|
+
id: Joi6.string().hex().required()
|
|
2394
2400
|
});
|
|
2395
2401
|
const { error, value } = validation.validate({ id });
|
|
2396
2402
|
if (error) {
|
|
@@ -2414,9 +2420,9 @@ function useUnitController() {
|
|
|
2414
2420
|
return;
|
|
2415
2421
|
}
|
|
2416
2422
|
const query = { ...req.query, ...req.params };
|
|
2417
|
-
const validation =
|
|
2418
|
-
site:
|
|
2419
|
-
serviceType:
|
|
2423
|
+
const validation = Joi6.object({
|
|
2424
|
+
site: Joi6.string().hex().required(),
|
|
2425
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2420
2426
|
});
|
|
2421
2427
|
const { error, value } = validation.validate(query);
|
|
2422
2428
|
if (error) {
|
|
@@ -2437,9 +2443,9 @@ function useUnitController() {
|
|
|
2437
2443
|
}
|
|
2438
2444
|
async function exportUnits(req, res, next) {
|
|
2439
2445
|
const query = { ...req.query, ...req.params };
|
|
2440
|
-
const validation =
|
|
2441
|
-
site:
|
|
2442
|
-
serviceType:
|
|
2446
|
+
const validation = Joi6.object({
|
|
2447
|
+
site: Joi6.string().hex().required(),
|
|
2448
|
+
serviceType: Joi6.string().valid(...Object.values(AppServiceType5)).required()
|
|
2443
2449
|
});
|
|
2444
2450
|
const { error, value } = validation.validate(query);
|
|
2445
2451
|
if (error) {
|
|
@@ -2482,15 +2488,15 @@ function useUnitController() {
|
|
|
2482
2488
|
}
|
|
2483
2489
|
|
|
2484
2490
|
// src/models/hygiene-parent-checklist.model.ts
|
|
2485
|
-
import
|
|
2491
|
+
import Joi7 from "joi";
|
|
2486
2492
|
import { ObjectId as ObjectId6 } from "mongodb";
|
|
2487
2493
|
import { BadRequestError as BadRequestError11, logger as logger13 } from "@7365admin1/node-server-utils";
|
|
2488
2494
|
import { AppServiceType as AppServiceType6 } from "@7365admin1/core";
|
|
2489
|
-
var parentChecklistSchema =
|
|
2490
|
-
createdAt:
|
|
2491
|
-
site:
|
|
2492
|
-
serviceType:
|
|
2493
|
-
dateStr:
|
|
2495
|
+
var parentChecklistSchema = Joi7.object({
|
|
2496
|
+
createdAt: Joi7.alternatives().try(Joi7.date(), Joi7.string()).optional().allow("", null),
|
|
2497
|
+
site: Joi7.string().hex().required(),
|
|
2498
|
+
serviceType: Joi7.string().valid(...Object.values(AppServiceType6)).required(),
|
|
2499
|
+
dateStr: Joi7.string().optional().allow("", null)
|
|
2494
2500
|
});
|
|
2495
2501
|
function MParentChecklist(value) {
|
|
2496
2502
|
const { error } = parentChecklistSchema.validate(value);
|
|
@@ -3071,7 +3077,7 @@ function useParentChecklistRepo() {
|
|
|
3071
3077
|
}
|
|
3072
3078
|
|
|
3073
3079
|
// src/controllers/hygiene-parent-checklist.controller.ts
|
|
3074
|
-
import
|
|
3080
|
+
import Joi8 from "joi";
|
|
3075
3081
|
import { BadRequestError as BadRequestError13, logger as logger15 } from "@7365admin1/node-server-utils";
|
|
3076
3082
|
import { AppServiceType as AppServiceType8 } from "@7365admin1/core";
|
|
3077
3083
|
function useParentChecklistController() {
|
|
@@ -3081,10 +3087,10 @@ function useParentChecklistController() {
|
|
|
3081
3087
|
} = useParentChecklistRepo();
|
|
3082
3088
|
async function createParentChecklist(req, res, next) {
|
|
3083
3089
|
const payload = req.body;
|
|
3084
|
-
const validation =
|
|
3085
|
-
createdAt:
|
|
3086
|
-
site:
|
|
3087
|
-
serviceType:
|
|
3090
|
+
const validation = Joi8.object({
|
|
3091
|
+
createdAt: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3092
|
+
site: Joi8.string().hex().required(),
|
|
3093
|
+
serviceType: Joi8.string().valid(...Object.values(AppServiceType8)).optional().allow("", null)
|
|
3088
3094
|
});
|
|
3089
3095
|
const { error } = validation.validate(payload);
|
|
3090
3096
|
if (error) {
|
|
@@ -3104,15 +3110,15 @@ function useParentChecklistController() {
|
|
|
3104
3110
|
}
|
|
3105
3111
|
async function getAllParentChecklist(req, res, next) {
|
|
3106
3112
|
const query = { ...req.query, ...req.params };
|
|
3107
|
-
const validation =
|
|
3108
|
-
page:
|
|
3109
|
-
limit:
|
|
3110
|
-
search:
|
|
3111
|
-
site:
|
|
3112
|
-
serviceType:
|
|
3113
|
-
startDate:
|
|
3114
|
-
endDate:
|
|
3115
|
-
status:
|
|
3113
|
+
const validation = Joi8.object({
|
|
3114
|
+
page: Joi8.number().min(1).optional().allow("", null),
|
|
3115
|
+
limit: Joi8.number().min(1).optional().allow("", null),
|
|
3116
|
+
search: Joi8.string().optional().allow("", null),
|
|
3117
|
+
site: Joi8.string().hex().required(),
|
|
3118
|
+
serviceType: Joi8.string().valid(...Object.values(AppServiceType8)).required(),
|
|
3119
|
+
startDate: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3120
|
+
endDate: Joi8.alternatives().try(Joi8.date(), Joi8.string()).optional().allow("", null),
|
|
3121
|
+
status: Joi8.string().valid(...allowedStatus, "all").optional().allow("", null)
|
|
3116
3122
|
});
|
|
3117
3123
|
const { error } = validation.validate(query);
|
|
3118
3124
|
if (error) {
|
|
@@ -3154,28 +3160,28 @@ function useParentChecklistController() {
|
|
|
3154
3160
|
}
|
|
3155
3161
|
|
|
3156
3162
|
// src/models/hygiene-area-checklist.model.ts
|
|
3157
|
-
import
|
|
3163
|
+
import Joi9 from "joi";
|
|
3158
3164
|
import { ObjectId as ObjectId8 } from "mongodb";
|
|
3159
3165
|
import { BadRequestError as BadRequestError14, logger as logger16 } from "@7365admin1/node-server-utils";
|
|
3160
3166
|
import { AppServiceType as AppServiceType9 } from "@7365admin1/core";
|
|
3161
3167
|
var allowedChecklistStatus = ["open", "completed", "closed"];
|
|
3162
|
-
var areaChecklistSchema =
|
|
3163
|
-
schedule:
|
|
3164
|
-
serviceType:
|
|
3165
|
-
area:
|
|
3166
|
-
name:
|
|
3167
|
-
type:
|
|
3168
|
-
checklist:
|
|
3169
|
-
|
|
3170
|
-
set:
|
|
3171
|
-
units:
|
|
3172
|
-
|
|
3173
|
-
unit:
|
|
3174
|
-
name:
|
|
3168
|
+
var areaChecklistSchema = Joi9.object({
|
|
3169
|
+
schedule: Joi9.string().hex().required(),
|
|
3170
|
+
serviceType: Joi9.string().valid(...Object.values(AppServiceType9)).required(),
|
|
3171
|
+
area: Joi9.string().hex().required(),
|
|
3172
|
+
name: Joi9.string().required(),
|
|
3173
|
+
type: Joi9.string().valid(...allowedTypes).required(),
|
|
3174
|
+
checklist: Joi9.array().items(
|
|
3175
|
+
Joi9.object({
|
|
3176
|
+
set: Joi9.number().min(0).required(),
|
|
3177
|
+
units: Joi9.array().items(
|
|
3178
|
+
Joi9.object({
|
|
3179
|
+
unit: Joi9.string().hex().required(),
|
|
3180
|
+
name: Joi9.string().required()
|
|
3175
3181
|
}).required()
|
|
3176
3182
|
).min(1).required(),
|
|
3177
|
-
isScheduleTask:
|
|
3178
|
-
scheduleTaskId:
|
|
3183
|
+
isScheduleTask: Joi9.boolean().optional().default(false),
|
|
3184
|
+
scheduleTaskId: Joi9.string().hex().optional().allow(null)
|
|
3179
3185
|
}).required()
|
|
3180
3186
|
).optional().default([])
|
|
3181
3187
|
});
|
|
@@ -4664,7 +4670,7 @@ function useAreaChecklistService() {
|
|
|
4664
4670
|
}
|
|
4665
4671
|
|
|
4666
4672
|
// src/controllers/hygiene-area-checklist.controller.ts
|
|
4667
|
-
import
|
|
4673
|
+
import Joi10 from "joi";
|
|
4668
4674
|
import {
|
|
4669
4675
|
BadRequestError as BadRequestError16,
|
|
4670
4676
|
InternalServerError as InternalServerError7,
|
|
@@ -4909,9 +4915,9 @@ function useAreaChecklistController() {
|
|
|
4909
4915
|
site: req.params.site,
|
|
4910
4916
|
schedule: req.params.schedule
|
|
4911
4917
|
};
|
|
4912
|
-
const validation =
|
|
4913
|
-
site:
|
|
4914
|
-
schedule:
|
|
4918
|
+
const validation = Joi10.object({
|
|
4919
|
+
site: Joi10.string().hex().required(),
|
|
4920
|
+
schedule: Joi10.string().hex().required()
|
|
4915
4921
|
});
|
|
4916
4922
|
const { error, value } = validation.validate(payload);
|
|
4917
4923
|
if (error) {
|
|
@@ -4931,14 +4937,14 @@ function useAreaChecklistController() {
|
|
|
4931
4937
|
}
|
|
4932
4938
|
async function getAllAreaChecklist(req, res, next) {
|
|
4933
4939
|
const query = { ...req.query, ...req.params };
|
|
4934
|
-
const validation =
|
|
4935
|
-
page:
|
|
4936
|
-
limit:
|
|
4937
|
-
search:
|
|
4938
|
-
type:
|
|
4939
|
-
status:
|
|
4940
|
-
schedule:
|
|
4941
|
-
serviceType:
|
|
4940
|
+
const validation = Joi10.object({
|
|
4941
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
4942
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
4943
|
+
search: Joi10.string().optional().allow("", null),
|
|
4944
|
+
type: Joi10.string().valid(...allowedTypes, "all").optional().allow("", null),
|
|
4945
|
+
status: Joi10.string().valid(...allowedStatus, "all").optional().allow("", null),
|
|
4946
|
+
schedule: Joi10.string().hex().required(),
|
|
4947
|
+
serviceType: Joi10.string().valid(...Object.values(AppServiceType10)).required()
|
|
4942
4948
|
});
|
|
4943
4949
|
const { error } = validation.validate(query);
|
|
4944
4950
|
if (error) {
|
|
@@ -4973,14 +4979,14 @@ function useAreaChecklistController() {
|
|
|
4973
4979
|
}
|
|
4974
4980
|
async function getAreaChecklistHistory(req, res, next) {
|
|
4975
4981
|
const query = { ...req.query, ...req.params };
|
|
4976
|
-
const validation =
|
|
4977
|
-
page:
|
|
4978
|
-
limit:
|
|
4979
|
-
search:
|
|
4980
|
-
type:
|
|
4981
|
-
schedule:
|
|
4982
|
-
status:
|
|
4983
|
-
createdAt:
|
|
4982
|
+
const validation = Joi10.object({
|
|
4983
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
4984
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
4985
|
+
search: Joi10.string().optional().allow("", null),
|
|
4986
|
+
type: Joi10.string().optional().allow("", ...allowedTypes),
|
|
4987
|
+
schedule: Joi10.string().hex().required(),
|
|
4988
|
+
status: Joi10.string().allow("", null, ...allowedStatus),
|
|
4989
|
+
createdAt: Joi10.alternatives().try(Joi10.date(), Joi10.string()).optional().allow("", null)
|
|
4984
4990
|
});
|
|
4985
4991
|
const { error } = validation.validate(query);
|
|
4986
4992
|
if (error) {
|
|
@@ -5014,7 +5020,7 @@ function useAreaChecklistController() {
|
|
|
5014
5020
|
}
|
|
5015
5021
|
}
|
|
5016
5022
|
async function getAreaChecklistHistoryDetails(req, res, next) {
|
|
5017
|
-
const validation =
|
|
5023
|
+
const validation = Joi10.string().hex().required();
|
|
5018
5024
|
const _id = req.params.id;
|
|
5019
5025
|
const { error, value } = validation.validate(_id);
|
|
5020
5026
|
if (error) {
|
|
@@ -5034,12 +5040,12 @@ function useAreaChecklistController() {
|
|
|
5034
5040
|
}
|
|
5035
5041
|
async function getAreaChecklistUnits(req, res, next) {
|
|
5036
5042
|
const query = { ...req.query, ...req.params };
|
|
5037
|
-
const validation =
|
|
5038
|
-
page:
|
|
5039
|
-
limit:
|
|
5040
|
-
search:
|
|
5041
|
-
serviceType:
|
|
5042
|
-
id:
|
|
5043
|
+
const validation = Joi10.object({
|
|
5044
|
+
page: Joi10.number().min(1).optional().allow("", null),
|
|
5045
|
+
limit: Joi10.number().min(1).optional().allow("", null),
|
|
5046
|
+
search: Joi10.string().optional().allow("", null),
|
|
5047
|
+
serviceType: Joi10.string().valid(...Object.values(AppServiceType10)).required(),
|
|
5048
|
+
id: Joi10.string().hex().required()
|
|
5043
5049
|
});
|
|
5044
5050
|
const { error } = validation.validate(query);
|
|
5045
5051
|
if (error) {
|
|
@@ -5089,21 +5095,21 @@ function useAreaChecklistController() {
|
|
|
5089
5095
|
...decisionValues,
|
|
5090
5096
|
completedBy
|
|
5091
5097
|
};
|
|
5092
|
-
const validation =
|
|
5093
|
-
id:
|
|
5094
|
-
set:
|
|
5095
|
-
unit:
|
|
5096
|
-
decision:
|
|
5097
|
-
approve:
|
|
5098
|
-
reject:
|
|
5099
|
-
remarks:
|
|
5098
|
+
const validation = Joi10.object({
|
|
5099
|
+
id: Joi10.string().hex().required(),
|
|
5100
|
+
set: Joi10.number().integer().min(1).required(),
|
|
5101
|
+
unit: Joi10.string().hex().required(),
|
|
5102
|
+
decision: Joi10.string().valid("approve", "reject").required(),
|
|
5103
|
+
approve: Joi10.boolean().optional(),
|
|
5104
|
+
reject: Joi10.boolean().optional(),
|
|
5105
|
+
remarks: Joi10.string().optional().allow("", null),
|
|
5100
5106
|
/*
|
|
5101
5107
|
* Shape only. WHETHER a photo is required depends on the set's current
|
|
5102
5108
|
* state in the database, which Joi cannot see — see the check below.
|
|
5103
5109
|
* Each entry must still be a real id: a blank string carries no evidence.
|
|
5104
5110
|
*/
|
|
5105
|
-
attachment:
|
|
5106
|
-
completedBy:
|
|
5111
|
+
attachment: Joi10.array().items(Joi10.string().trim().min(1)).optional(),
|
|
5112
|
+
completedBy: Joi10.string().hex().required()
|
|
5107
5113
|
});
|
|
5108
5114
|
const { error } = validation.validate(payload);
|
|
5109
5115
|
if (error) {
|
|
@@ -5140,7 +5146,7 @@ function useAreaChecklistController() {
|
|
|
5140
5146
|
}
|
|
5141
5147
|
}
|
|
5142
5148
|
async function downloadChecklistPdf(req, res, next) {
|
|
5143
|
-
const validation =
|
|
5149
|
+
const validation = Joi10.string().hex().required();
|
|
5144
5150
|
const schedule = req.params.schedule;
|
|
5145
5151
|
const { error, value } = validation.validate(schedule);
|
|
5146
5152
|
if (error) {
|
|
@@ -5186,16 +5192,16 @@ function useAreaChecklistController() {
|
|
|
5186
5192
|
}
|
|
5187
5193
|
|
|
5188
5194
|
// src/models/hygiene-supply.model.ts
|
|
5189
|
-
import
|
|
5195
|
+
import Joi11 from "joi";
|
|
5190
5196
|
import { ObjectId as ObjectId12 } from "mongodb";
|
|
5191
5197
|
import { BadRequestError as BadRequestError17, logger as logger21 } from "@7365admin1/node-server-utils";
|
|
5192
5198
|
import { AppServiceType as AppServiceType11 } from "@7365admin1/core";
|
|
5193
|
-
var supplySchema =
|
|
5194
|
-
site:
|
|
5195
|
-
serviceType:
|
|
5196
|
-
name:
|
|
5197
|
-
unitOfMeasurement:
|
|
5198
|
-
attachment:
|
|
5199
|
+
var supplySchema = Joi11.object({
|
|
5200
|
+
site: Joi11.string().hex().required(),
|
|
5201
|
+
serviceType: Joi11.string().valid(...Object.values(AppServiceType11)).required(),
|
|
5202
|
+
name: Joi11.string().required(),
|
|
5203
|
+
unitOfMeasurement: Joi11.string().required(),
|
|
5204
|
+
attachment: Joi11.string().allow(null, "").optional()
|
|
5199
5205
|
});
|
|
5200
5206
|
function MSupply(value) {
|
|
5201
5207
|
const { error } = supplySchema.validate(value);
|
|
@@ -5494,7 +5500,7 @@ function useSupplyRepository() {
|
|
|
5494
5500
|
}
|
|
5495
5501
|
|
|
5496
5502
|
// src/controllers/hygiene-supply.controller.ts
|
|
5497
|
-
import
|
|
5503
|
+
import Joi12 from "joi";
|
|
5498
5504
|
import { BadRequestError as BadRequestError19, logger as logger23 } from "@7365admin1/node-server-utils";
|
|
5499
5505
|
import { AppServiceType as AppServiceType12 } from "@7365admin1/core";
|
|
5500
5506
|
function useSupplyController() {
|
|
@@ -5525,12 +5531,12 @@ function useSupplyController() {
|
|
|
5525
5531
|
}
|
|
5526
5532
|
async function getSupplies(req, res, next) {
|
|
5527
5533
|
const query = { ...req.query, ...req.params };
|
|
5528
|
-
const validation =
|
|
5529
|
-
page:
|
|
5530
|
-
limit:
|
|
5531
|
-
search:
|
|
5532
|
-
site:
|
|
5533
|
-
serviceType:
|
|
5534
|
+
const validation = Joi12.object({
|
|
5535
|
+
page: Joi12.number().min(1).optional().allow("", null),
|
|
5536
|
+
limit: Joi12.number().min(1).optional().allow("", null),
|
|
5537
|
+
search: Joi12.string().optional().allow("", null),
|
|
5538
|
+
site: Joi12.string().hex().required(),
|
|
5539
|
+
serviceType: Joi12.string().valid(...Object.values(AppServiceType12)).required()
|
|
5534
5540
|
});
|
|
5535
5541
|
const { error } = validation.validate(query);
|
|
5536
5542
|
if (error) {
|
|
@@ -5560,7 +5566,7 @@ function useSupplyController() {
|
|
|
5560
5566
|
}
|
|
5561
5567
|
}
|
|
5562
5568
|
async function getSupplyById(req, res, next) {
|
|
5563
|
-
const validation =
|
|
5569
|
+
const validation = Joi12.string().hex().required();
|
|
5564
5570
|
const _id = req.params.id;
|
|
5565
5571
|
const { error, value } = validation.validate(_id);
|
|
5566
5572
|
if (error) {
|
|
@@ -5580,12 +5586,12 @@ function useSupplyController() {
|
|
|
5580
5586
|
}
|
|
5581
5587
|
async function updateSupply(req, res, next) {
|
|
5582
5588
|
const payload = { id: req.params.id, ...req.body };
|
|
5583
|
-
const validation =
|
|
5584
|
-
id:
|
|
5585
|
-
name:
|
|
5586
|
-
unitOfMeasurement:
|
|
5587
|
-
qty:
|
|
5588
|
-
attachment:
|
|
5589
|
+
const validation = Joi12.object({
|
|
5590
|
+
id: Joi12.string().hex().required(),
|
|
5591
|
+
name: Joi12.string().optional().allow("", null),
|
|
5592
|
+
unitOfMeasurement: Joi12.string().optional().allow("", null),
|
|
5593
|
+
qty: Joi12.number().min(0).optional().allow("", null),
|
|
5594
|
+
attachment: Joi12.string().optional().allow("", null)
|
|
5589
5595
|
});
|
|
5590
5596
|
const { error } = validation.validate(payload);
|
|
5591
5597
|
if (error) {
|
|
@@ -5606,7 +5612,7 @@ function useSupplyController() {
|
|
|
5606
5612
|
}
|
|
5607
5613
|
async function deleteSupply(req, res, next) {
|
|
5608
5614
|
const id = req.params.id;
|
|
5609
|
-
const validation =
|
|
5615
|
+
const validation = Joi12.string().hex().required();
|
|
5610
5616
|
const { error, value } = validation.validate(id);
|
|
5611
5617
|
if (error) {
|
|
5612
5618
|
logger23.log({ level: "error", message: error.message });
|
|
@@ -5633,18 +5639,18 @@ function useSupplyController() {
|
|
|
5633
5639
|
}
|
|
5634
5640
|
|
|
5635
5641
|
// src/models/hygiene-stock.model.ts
|
|
5636
|
-
import
|
|
5642
|
+
import Joi13 from "joi";
|
|
5637
5643
|
import { ObjectId as ObjectId14 } from "mongodb";
|
|
5638
5644
|
import { BadRequestError as BadRequestError20, logger as logger24 } from "@7365admin1/node-server-utils";
|
|
5639
5645
|
import { AppServiceType as AppServiceType13 } from "@7365admin1/core";
|
|
5640
|
-
var stockSchema =
|
|
5641
|
-
site:
|
|
5642
|
-
serviceType:
|
|
5643
|
-
supply:
|
|
5644
|
-
in:
|
|
5645
|
-
out:
|
|
5646
|
-
balance:
|
|
5647
|
-
remarks:
|
|
5646
|
+
var stockSchema = Joi13.object({
|
|
5647
|
+
site: Joi13.string().hex().required(),
|
|
5648
|
+
serviceType: Joi13.string().valid(...Object.values(AppServiceType13)).required(),
|
|
5649
|
+
supply: Joi13.string().hex().required(),
|
|
5650
|
+
in: Joi13.number().min(0).optional(),
|
|
5651
|
+
out: Joi13.number().min(0).optional(),
|
|
5652
|
+
balance: Joi13.number().min(0).required(),
|
|
5653
|
+
remarks: Joi13.string().optional().allow("", null)
|
|
5648
5654
|
});
|
|
5649
5655
|
function MStock(value) {
|
|
5650
5656
|
const { error } = stockSchema.validate(value);
|
|
@@ -5871,7 +5877,7 @@ function useStockService() {
|
|
|
5871
5877
|
}
|
|
5872
5878
|
|
|
5873
5879
|
// src/controllers/hygiene-stock.controller.ts
|
|
5874
|
-
import
|
|
5880
|
+
import Joi14 from "joi";
|
|
5875
5881
|
import { BadRequestError as BadRequestError23, logger as logger26 } from "@7365admin1/node-server-utils";
|
|
5876
5882
|
import { AppServiceType as AppServiceType14 } from "@7365admin1/core";
|
|
5877
5883
|
function useStockController() {
|
|
@@ -5879,12 +5885,12 @@ function useStockController() {
|
|
|
5879
5885
|
const { createStock: _createStock } = useStockService();
|
|
5880
5886
|
async function createStock(req, res, next) {
|
|
5881
5887
|
const payload = { ...req.body, ...req.params };
|
|
5882
|
-
const validation =
|
|
5883
|
-
site:
|
|
5884
|
-
serviceType:
|
|
5885
|
-
supply:
|
|
5886
|
-
qty:
|
|
5887
|
-
remarks:
|
|
5888
|
+
const validation = Joi14.object({
|
|
5889
|
+
site: Joi14.string().hex().required(),
|
|
5890
|
+
serviceType: Joi14.string().valid(...Object.values(AppServiceType14)).required(),
|
|
5891
|
+
supply: Joi14.string().hex().required(),
|
|
5892
|
+
qty: Joi14.number().min(0).required(),
|
|
5893
|
+
remarks: Joi14.string().optional().allow("", null)
|
|
5888
5894
|
});
|
|
5889
5895
|
const { error } = validation.validate(payload);
|
|
5890
5896
|
if (error) {
|
|
@@ -5904,13 +5910,13 @@ function useStockController() {
|
|
|
5904
5910
|
}
|
|
5905
5911
|
async function getStocksBySupplyId(req, res, next) {
|
|
5906
5912
|
const query = { ...req.query, ...req.params };
|
|
5907
|
-
const validation =
|
|
5908
|
-
page:
|
|
5909
|
-
limit:
|
|
5910
|
-
search:
|
|
5911
|
-
site:
|
|
5912
|
-
serviceType:
|
|
5913
|
-
supply:
|
|
5913
|
+
const validation = Joi14.object({
|
|
5914
|
+
page: Joi14.number().min(1).optional().allow("", null),
|
|
5915
|
+
limit: Joi14.number().min(1).optional().allow("", null),
|
|
5916
|
+
search: Joi14.string().optional().allow("", null),
|
|
5917
|
+
site: Joi14.string().hex().required(),
|
|
5918
|
+
serviceType: Joi14.string().valid(...Object.values(AppServiceType14)).required(),
|
|
5919
|
+
supply: Joi14.string().hex().required()
|
|
5914
5920
|
});
|
|
5915
5921
|
const { error } = validation.validate(query);
|
|
5916
5922
|
if (error) {
|
|
@@ -5972,21 +5978,21 @@ async function applyCheckOutDecision(decision, decide, returnStock) {
|
|
|
5972
5978
|
}
|
|
5973
5979
|
|
|
5974
5980
|
// src/models/hygiene-checkout-item.model.ts
|
|
5975
|
-
import
|
|
5981
|
+
import Joi15 from "joi";
|
|
5976
5982
|
import { ObjectId as ObjectId16 } from "mongodb";
|
|
5977
5983
|
import { BadRequestError as BadRequestError24, logger as logger27 } from "@7365admin1/node-server-utils";
|
|
5978
5984
|
import { AppServiceType as AppServiceType15 } from "@7365admin1/core";
|
|
5979
5985
|
var allowedCheckOutItemStatus = ["pending", "completed"];
|
|
5980
|
-
var checkOutItemSchema =
|
|
5981
|
-
site:
|
|
5982
|
-
serviceType:
|
|
5983
|
-
supply:
|
|
5984
|
-
supplyName:
|
|
5985
|
-
supplyQty:
|
|
5986
|
-
qty:
|
|
5987
|
-
attachment:
|
|
5988
|
-
createdBy:
|
|
5989
|
-
createdByName:
|
|
5986
|
+
var checkOutItemSchema = Joi15.object({
|
|
5987
|
+
site: Joi15.string().hex().required(),
|
|
5988
|
+
serviceType: Joi15.string().valid(...Object.values(AppServiceType15)).required(),
|
|
5989
|
+
supply: Joi15.string().hex().required(),
|
|
5990
|
+
supplyName: Joi15.string().required(),
|
|
5991
|
+
supplyQty: Joi15.number().min(0).required(),
|
|
5992
|
+
qty: Joi15.number().min(0).required(),
|
|
5993
|
+
attachment: Joi15.array().items(Joi15.string()).optional().allow(null),
|
|
5994
|
+
createdBy: Joi15.string().hex().required(),
|
|
5995
|
+
createdByName: Joi15.string().required()
|
|
5990
5996
|
});
|
|
5991
5997
|
function MCheckOutItem(value) {
|
|
5992
5998
|
const { error } = checkOutItemSchema.validate(value);
|
|
@@ -6475,7 +6481,7 @@ function useCheckOutItemService() {
|
|
|
6475
6481
|
}
|
|
6476
6482
|
|
|
6477
6483
|
// src/controllers/hygiene-checkout-item.controller.ts
|
|
6478
|
-
import
|
|
6484
|
+
import Joi16 from "joi";
|
|
6479
6485
|
import { BadRequestError as BadRequestError27, logger as logger29 } from "@7365admin1/node-server-utils";
|
|
6480
6486
|
import { AppServiceType as AppServiceType16 } from "@7365admin1/core";
|
|
6481
6487
|
function useCheckOutItemController() {
|
|
@@ -6499,13 +6505,13 @@ function useCheckOutItemController() {
|
|
|
6499
6505
|
...req.params,
|
|
6500
6506
|
createdBy
|
|
6501
6507
|
};
|
|
6502
|
-
const validation =
|
|
6503
|
-
site:
|
|
6504
|
-
serviceType:
|
|
6505
|
-
supply:
|
|
6506
|
-
qty:
|
|
6507
|
-
attachment:
|
|
6508
|
-
createdBy:
|
|
6508
|
+
const validation = Joi16.object({
|
|
6509
|
+
site: Joi16.string().hex().required(),
|
|
6510
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required(),
|
|
6511
|
+
supply: Joi16.string().hex().required(),
|
|
6512
|
+
qty: Joi16.number().min(0).required(),
|
|
6513
|
+
attachment: Joi16.array().items(Joi16.string()).optional().allow(null),
|
|
6514
|
+
createdBy: Joi16.string().hex().required()
|
|
6509
6515
|
});
|
|
6510
6516
|
const { error } = validation.validate(payload);
|
|
6511
6517
|
if (error) {
|
|
@@ -6534,15 +6540,15 @@ function useCheckOutItemController() {
|
|
|
6534
6540
|
...req.params,
|
|
6535
6541
|
createdBy
|
|
6536
6542
|
};
|
|
6537
|
-
const validation =
|
|
6538
|
-
site:
|
|
6539
|
-
serviceType:
|
|
6540
|
-
createdBy:
|
|
6541
|
-
items:
|
|
6542
|
-
|
|
6543
|
-
supply:
|
|
6544
|
-
qty:
|
|
6545
|
-
attachment:
|
|
6543
|
+
const validation = Joi16.object({
|
|
6544
|
+
site: Joi16.string().hex().required(),
|
|
6545
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required(),
|
|
6546
|
+
createdBy: Joi16.string().hex().required(),
|
|
6547
|
+
items: Joi16.array().items(
|
|
6548
|
+
Joi16.object({
|
|
6549
|
+
supply: Joi16.string().hex().required(),
|
|
6550
|
+
qty: Joi16.number().min(0).required(),
|
|
6551
|
+
attachment: Joi16.array().items(Joi16.string()).optional().allow(null)
|
|
6546
6552
|
})
|
|
6547
6553
|
).min(1).required()
|
|
6548
6554
|
});
|
|
@@ -6564,12 +6570,12 @@ function useCheckOutItemController() {
|
|
|
6564
6570
|
}
|
|
6565
6571
|
async function getCheckOutItems(req, res, next) {
|
|
6566
6572
|
const query = { ...req.query, ...req.params };
|
|
6567
|
-
const validation =
|
|
6568
|
-
page:
|
|
6569
|
-
limit:
|
|
6570
|
-
search:
|
|
6571
|
-
site:
|
|
6572
|
-
serviceType:
|
|
6573
|
+
const validation = Joi16.object({
|
|
6574
|
+
page: Joi16.number().min(1).optional().allow("", null),
|
|
6575
|
+
limit: Joi16.number().min(1).optional().allow("", null),
|
|
6576
|
+
search: Joi16.string().optional().allow("", null),
|
|
6577
|
+
site: Joi16.string().hex().required(),
|
|
6578
|
+
serviceType: Joi16.string().valid(...Object.values(AppServiceType16)).required()
|
|
6573
6579
|
});
|
|
6574
6580
|
const { error } = validation.validate(query);
|
|
6575
6581
|
if (error) {
|
|
@@ -6599,7 +6605,7 @@ function useCheckOutItemController() {
|
|
|
6599
6605
|
}
|
|
6600
6606
|
}
|
|
6601
6607
|
async function getCheckOutItemById(req, res, next) {
|
|
6602
|
-
const validation =
|
|
6608
|
+
const validation = Joi16.string().hex().required();
|
|
6603
6609
|
const _id = req.params.id;
|
|
6604
6610
|
const { error, value } = validation.validate(_id);
|
|
6605
6611
|
if (error) {
|
|
@@ -6638,13 +6644,13 @@ function useCheckOutItemController() {
|
|
|
6638
6644
|
...decisionValues,
|
|
6639
6645
|
completedBy
|
|
6640
6646
|
};
|
|
6641
|
-
const validation =
|
|
6642
|
-
id:
|
|
6643
|
-
decision:
|
|
6644
|
-
approve:
|
|
6645
|
-
reject:
|
|
6646
|
-
remarks:
|
|
6647
|
-
completedBy:
|
|
6647
|
+
const validation = Joi16.object({
|
|
6648
|
+
id: Joi16.string().hex().required(),
|
|
6649
|
+
decision: Joi16.string().valid("approve", "disapprove").required(),
|
|
6650
|
+
approve: Joi16.boolean().required(),
|
|
6651
|
+
reject: Joi16.boolean().required(),
|
|
6652
|
+
remarks: Joi16.string().optional().allow("", null),
|
|
6653
|
+
completedBy: Joi16.string().hex().required()
|
|
6648
6654
|
});
|
|
6649
6655
|
const { error } = validation.validate(payload);
|
|
6650
6656
|
if (error) {
|
|
@@ -6677,21 +6683,21 @@ function useCheckOutItemController() {
|
|
|
6677
6683
|
// src/models/hygiene-schedule-task.model.ts
|
|
6678
6684
|
import { BadRequestError as BadRequestError28, logger as logger30 } from "@7365admin1/node-server-utils";
|
|
6679
6685
|
import { AppServiceType as AppServiceType17 } from "@7365admin1/core";
|
|
6680
|
-
import
|
|
6686
|
+
import Joi17 from "joi";
|
|
6681
6687
|
import { ObjectId as ObjectId18 } from "mongodb";
|
|
6682
|
-
var scheduleTaskSchema =
|
|
6683
|
-
site:
|
|
6684
|
-
serviceType:
|
|
6685
|
-
title:
|
|
6686
|
-
time:
|
|
6687
|
-
dates:
|
|
6688
|
-
|
|
6688
|
+
var scheduleTaskSchema = Joi17.object({
|
|
6689
|
+
site: Joi17.string().hex().required(),
|
|
6690
|
+
serviceType: Joi17.string().valid(...Object.values(AppServiceType17)).required(),
|
|
6691
|
+
title: Joi17.string().required(),
|
|
6692
|
+
time: Joi17.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).required(),
|
|
6693
|
+
dates: Joi17.array().min(1).items(
|
|
6694
|
+
Joi17.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required()
|
|
6689
6695
|
).required(),
|
|
6690
|
-
description:
|
|
6691
|
-
areas:
|
|
6692
|
-
|
|
6693
|
-
name:
|
|
6694
|
-
value:
|
|
6696
|
+
description: Joi17.string().optional().allow("", null),
|
|
6697
|
+
areas: Joi17.array().min(1).items(
|
|
6698
|
+
Joi17.object({
|
|
6699
|
+
name: Joi17.string().required(),
|
|
6700
|
+
value: Joi17.any().required()
|
|
6695
6701
|
})
|
|
6696
6702
|
).required()
|
|
6697
6703
|
});
|
|
@@ -7295,7 +7301,7 @@ function useScheduleTaskService() {
|
|
|
7295
7301
|
}
|
|
7296
7302
|
|
|
7297
7303
|
// src/controllers/hygiene-schedule-task.controller.ts
|
|
7298
|
-
import
|
|
7304
|
+
import Joi18 from "joi";
|
|
7299
7305
|
import { BadRequestError as BadRequestError30, logger as logger33 } from "@7365admin1/node-server-utils";
|
|
7300
7306
|
import { AppServiceType as AppServiceType18 } from "@7365admin1/core";
|
|
7301
7307
|
function useScheduleTaskController() {
|
|
@@ -7326,12 +7332,12 @@ function useScheduleTaskController() {
|
|
|
7326
7332
|
}
|
|
7327
7333
|
async function getScheduleTasks(req, res, next) {
|
|
7328
7334
|
const query = { ...req.query, ...req.params };
|
|
7329
|
-
const validation =
|
|
7330
|
-
page:
|
|
7331
|
-
limit:
|
|
7332
|
-
search:
|
|
7333
|
-
site:
|
|
7334
|
-
serviceType:
|
|
7335
|
+
const validation = Joi18.object({
|
|
7336
|
+
page: Joi18.number().min(1).optional().allow("", null),
|
|
7337
|
+
limit: Joi18.number().min(1).optional().allow("", null),
|
|
7338
|
+
search: Joi18.string().optional().allow("", null),
|
|
7339
|
+
site: Joi18.string().hex().required(),
|
|
7340
|
+
serviceType: Joi18.string().valid(...Object.values(AppServiceType18)).required()
|
|
7335
7341
|
});
|
|
7336
7342
|
const { error } = validation.validate(query);
|
|
7337
7343
|
if (error) {
|
|
@@ -7361,7 +7367,7 @@ function useScheduleTaskController() {
|
|
|
7361
7367
|
}
|
|
7362
7368
|
}
|
|
7363
7369
|
async function getScheduleTaskById(req, res, next) {
|
|
7364
|
-
const validation =
|
|
7370
|
+
const validation = Joi18.string().hex().required();
|
|
7365
7371
|
const _id = req.params.id;
|
|
7366
7372
|
const { error, value } = validation.validate(_id);
|
|
7367
7373
|
if (error) {
|
|
@@ -7381,18 +7387,18 @@ function useScheduleTaskController() {
|
|
|
7381
7387
|
}
|
|
7382
7388
|
async function updateScheduleTask(req, res, next) {
|
|
7383
7389
|
const payload = { id: req.params.id, ...req.body };
|
|
7384
|
-
const validation =
|
|
7385
|
-
id:
|
|
7386
|
-
title:
|
|
7387
|
-
time:
|
|
7388
|
-
dates:
|
|
7389
|
-
|
|
7390
|
+
const validation = Joi18.object({
|
|
7391
|
+
id: Joi18.string().hex().required(),
|
|
7392
|
+
title: Joi18.string().optional().allow("", null),
|
|
7393
|
+
time: Joi18.string().pattern(/^([0-1]\d|2[0-3]):([0-5]\d)$/).optional().allow("", null),
|
|
7394
|
+
dates: Joi18.array().min(1).items(
|
|
7395
|
+
Joi18.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required()
|
|
7390
7396
|
).optional(),
|
|
7391
|
-
description:
|
|
7392
|
-
areas:
|
|
7393
|
-
|
|
7394
|
-
name:
|
|
7395
|
-
value:
|
|
7397
|
+
description: Joi18.string().optional().allow("", null),
|
|
7398
|
+
areas: Joi18.array().min(1).items(
|
|
7399
|
+
Joi18.object({
|
|
7400
|
+
name: Joi18.string().required(),
|
|
7401
|
+
value: Joi18.any().required()
|
|
7396
7402
|
})
|
|
7397
7403
|
).optional()
|
|
7398
7404
|
});
|
|
@@ -7414,7 +7420,7 @@ function useScheduleTaskController() {
|
|
|
7414
7420
|
}
|
|
7415
7421
|
}
|
|
7416
7422
|
async function deleteScheduleTask(req, res, next) {
|
|
7417
|
-
const validation =
|
|
7423
|
+
const validation = Joi18.string().hex().required();
|
|
7418
7424
|
const _id = req.params.id;
|
|
7419
7425
|
const { error, value } = validation.validate(_id);
|
|
7420
7426
|
if (error) {
|
|
@@ -7658,17 +7664,17 @@ function useQRService() {
|
|
|
7658
7664
|
}
|
|
7659
7665
|
|
|
7660
7666
|
// src/controllers/hygiene-qr.controller.ts
|
|
7661
|
-
import
|
|
7667
|
+
import Joi19 from "joi";
|
|
7662
7668
|
import { BadRequestError as BadRequestError31, logger as logger35 } from "@7365admin1/node-server-utils";
|
|
7663
7669
|
function useQRController() {
|
|
7664
7670
|
const { generateQRImage: _generateQRImage, generateQRPDF: _generateQRPDF } = useQRService();
|
|
7665
7671
|
async function generateQR(req, res, next) {
|
|
7666
|
-
const validation =
|
|
7667
|
-
url:
|
|
7668
|
-
filename:
|
|
7669
|
-
title:
|
|
7670
|
-
subtitle:
|
|
7671
|
-
download:
|
|
7672
|
+
const validation = Joi19.object({
|
|
7673
|
+
url: Joi19.string().uri().required(),
|
|
7674
|
+
filename: Joi19.string().optional().allow("", null),
|
|
7675
|
+
title: Joi19.string().optional().allow("", null),
|
|
7676
|
+
subtitle: Joi19.string().optional().allow("", null),
|
|
7677
|
+
download: Joi19.boolean().optional().default(false)
|
|
7672
7678
|
});
|
|
7673
7679
|
const query = { ...req.query };
|
|
7674
7680
|
const { error, value } = validation.validate(query);
|