@eeplatform/basic-edu 1.10.12 → 1.10.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/CHANGELOG.md +13 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +40 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1347,6 +1347,7 @@ import Joi from "joi";
|
|
|
1347
1347
|
import { ObjectId } from "mongodb";
|
|
1348
1348
|
var schemaCurriculum = Joi.object({
|
|
1349
1349
|
_id: Joi.string().hex().optional(),
|
|
1350
|
+
school: Joi.string().hex().required(),
|
|
1350
1351
|
name: Joi.string().required(),
|
|
1351
1352
|
effectiveSchoolYear: Joi.string().required(),
|
|
1352
1353
|
maxTeachingHoursPerDay: Joi.number().integer().min(1).required(),
|
|
@@ -1373,8 +1374,14 @@ function MCurriculum(value) {
|
|
|
1373
1374
|
throw new BadRequestError("Invalid _id format");
|
|
1374
1375
|
}
|
|
1375
1376
|
}
|
|
1377
|
+
try {
|
|
1378
|
+
value.school = new ObjectId(value.school);
|
|
1379
|
+
} catch (error2) {
|
|
1380
|
+
throw new BadRequestError("Invalid school format");
|
|
1381
|
+
}
|
|
1376
1382
|
return {
|
|
1377
1383
|
_id: value._id ?? void 0,
|
|
1384
|
+
school: value.school,
|
|
1378
1385
|
name: value.name ?? "",
|
|
1379
1386
|
effectiveSchoolYear: value.effectiveSchoolYear ?? "",
|
|
1380
1387
|
maxTeachingHoursPerDay: value.maxTeachingHoursPerDay ?? 0,
|
|
@@ -1416,6 +1423,7 @@ function useCurriculumRepo() {
|
|
|
1416
1423
|
{
|
|
1417
1424
|
key: {
|
|
1418
1425
|
name: 1,
|
|
1426
|
+
school: 1,
|
|
1419
1427
|
effectiveSchoolYear: 1,
|
|
1420
1428
|
status: 1
|
|
1421
1429
|
},
|
|
@@ -1488,12 +1496,19 @@ function useCurriculumRepo() {
|
|
|
1488
1496
|
page = 1,
|
|
1489
1497
|
limit = 10,
|
|
1490
1498
|
sort = {},
|
|
1491
|
-
status = "active"
|
|
1499
|
+
status = "active",
|
|
1500
|
+
school = ""
|
|
1492
1501
|
} = {}) {
|
|
1493
1502
|
page = page > 0 ? page - 1 : 0;
|
|
1494
1503
|
const query = {
|
|
1495
1504
|
status
|
|
1496
1505
|
};
|
|
1506
|
+
const cacheKeyOptions = {
|
|
1507
|
+
page,
|
|
1508
|
+
limit,
|
|
1509
|
+
sort: JSON.stringify(sort),
|
|
1510
|
+
status
|
|
1511
|
+
};
|
|
1497
1512
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
1498
1513
|
if (search) {
|
|
1499
1514
|
query.$or = [
|
|
@@ -1501,16 +1516,17 @@ function useCurriculumRepo() {
|
|
|
1501
1516
|
{ effectiveSchoolYear: { $regex: search, $options: "i" } },
|
|
1502
1517
|
{ curriculumMemoRef: { $regex: search, $options: "i" } }
|
|
1503
1518
|
];
|
|
1519
|
+
cacheKeyOptions.search = search;
|
|
1504
1520
|
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1521
|
+
if (school) {
|
|
1522
|
+
try {
|
|
1523
|
+
query.school = new ObjectId2(school);
|
|
1524
|
+
} catch (error) {
|
|
1525
|
+
throw new BadRequestError2("Invalid school ID format.");
|
|
1526
|
+
}
|
|
1527
|
+
cacheKeyOptions.school = school;
|
|
1528
|
+
}
|
|
1529
|
+
const cacheParams = cacheKeyOptions;
|
|
1514
1530
|
const cacheKey = makeCacheKey(namespace_collection, cacheParams);
|
|
1515
1531
|
logger2.log({
|
|
1516
1532
|
level: "info",
|
|
@@ -1860,6 +1876,7 @@ function useCurriculumController() {
|
|
|
1860
1876
|
limit = isNaN(limit) ? 20 : limit;
|
|
1861
1877
|
const sort = req.query.sort ? String(req.query.sort).split(",") : "";
|
|
1862
1878
|
const sortOrder = req.query.sortOrder ? String(req.query.sortOrder).split(",") : "";
|
|
1879
|
+
const school = req.query.school;
|
|
1863
1880
|
const sortObj = {};
|
|
1864
1881
|
if (sort && Array.isArray(sort) && sort.length && sortOrder && Array.isArray(sortOrder) && sortOrder.length) {
|
|
1865
1882
|
sort.forEach((field, index) => {
|
|
@@ -1874,7 +1891,8 @@ function useCurriculumController() {
|
|
|
1874
1891
|
limit,
|
|
1875
1892
|
sort: sortObj,
|
|
1876
1893
|
status,
|
|
1877
|
-
search
|
|
1894
|
+
search,
|
|
1895
|
+
school
|
|
1878
1896
|
});
|
|
1879
1897
|
res.json(curriculums);
|
|
1880
1898
|
return;
|
|
@@ -5116,11 +5134,11 @@ function useProgramRepo() {
|
|
|
5116
5134
|
sort = {},
|
|
5117
5135
|
status = "active",
|
|
5118
5136
|
school = "",
|
|
5119
|
-
isDefault
|
|
5137
|
+
isDefault,
|
|
5138
|
+
gradeLevel = []
|
|
5120
5139
|
} = {}) {
|
|
5121
5140
|
page = page > 0 ? page - 1 : 0;
|
|
5122
5141
|
const query = {
|
|
5123
|
-
deletedAt: { $in: ["", null] },
|
|
5124
5142
|
status
|
|
5125
5143
|
};
|
|
5126
5144
|
sort = Object.keys(sort).length > 0 ? sort : { _id: 1 };
|
|
@@ -5146,6 +5164,10 @@ function useProgramRepo() {
|
|
|
5146
5164
|
query.isDefault = isDefault;
|
|
5147
5165
|
cacheKeyOptions.isDefault = isDefault;
|
|
5148
5166
|
}
|
|
5167
|
+
if (gradeLevel && Array.isArray(gradeLevel) && gradeLevel.length > 0) {
|
|
5168
|
+
query.gradeLevels = { $in: gradeLevel };
|
|
5169
|
+
cacheKeyOptions.gradeLevel = gradeLevel.join(",");
|
|
5170
|
+
}
|
|
5149
5171
|
const cacheKey = makeCacheKey7(namespace_collection, cacheKeyOptions);
|
|
5150
5172
|
logger12.log({
|
|
5151
5173
|
level: "info",
|
|
@@ -5395,7 +5417,8 @@ function useProgramController() {
|
|
|
5395
5417
|
search: Joi13.string().optional().allow("", null),
|
|
5396
5418
|
status: Joi13.string().optional().allow("", null),
|
|
5397
5419
|
school: Joi13.string().hex().optional().allow("", null),
|
|
5398
|
-
isDefault: Joi13.boolean().optional().allow("", null)
|
|
5420
|
+
isDefault: Joi13.boolean().optional().allow("", null),
|
|
5421
|
+
gradeLevel: Joi13.string().optional().allow("", null)
|
|
5399
5422
|
});
|
|
5400
5423
|
const { error } = validation.validate(query);
|
|
5401
5424
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -5404,6 +5427,7 @@ function useProgramController() {
|
|
|
5404
5427
|
const status = req.query.status ?? "active";
|
|
5405
5428
|
const school = req.query.school ?? "";
|
|
5406
5429
|
const isDefault = req.query.isDefault === "true" ? true : req.query.isDefault === "false" ? false : void 0;
|
|
5430
|
+
const gradeLevel = req.query.gradeLevel ? req.query.gradeLevel?.split(",") : [];
|
|
5407
5431
|
const isPageNumber = isFinite(page);
|
|
5408
5432
|
if (!isPageNumber) {
|
|
5409
5433
|
next(new BadRequestError19("Invalid page number."));
|
|
@@ -5425,7 +5449,8 @@ function useProgramController() {
|
|
|
5425
5449
|
search,
|
|
5426
5450
|
status,
|
|
5427
5451
|
school,
|
|
5428
|
-
isDefault
|
|
5452
|
+
isDefault,
|
|
5453
|
+
gradeLevel
|
|
5429
5454
|
});
|
|
5430
5455
|
res.json(data);
|
|
5431
5456
|
return;
|