@eeplatform/basic-edu 1.3.10 → 1.3.12
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 +12 -0
- package/dist/index.d.ts +51 -33
- package/dist/index.js +588 -507
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +588 -507
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1804,7 +1804,7 @@ var addressSchema = Joi3.object({
|
|
|
1804
1804
|
sitio: Joi3.string().optional().allow("", null),
|
|
1805
1805
|
barangay: Joi3.string().required(),
|
|
1806
1806
|
municipalityCity: Joi3.string().required(),
|
|
1807
|
-
province: Joi3.string().
|
|
1807
|
+
province: Joi3.string().optional().allow("", null),
|
|
1808
1808
|
country: Joi3.string().optional().allow("", null),
|
|
1809
1809
|
zipCode: Joi3.string().optional().allow("", null)
|
|
1810
1810
|
});
|
|
@@ -1815,93 +1815,100 @@ var personContactSchema = Joi3.object({
|
|
|
1815
1815
|
contactNumber: Joi3.string().optional().allow("", null)
|
|
1816
1816
|
});
|
|
1817
1817
|
var learnerInfoSchema = Joi3.object({
|
|
1818
|
+
psaBirthCertificateNo: Joi3.string().optional().allow("", null),
|
|
1818
1819
|
lrn: Joi3.string().optional().allow("", null),
|
|
1819
1820
|
lastName: Joi3.string().required(),
|
|
1820
1821
|
firstName: Joi3.string().required(),
|
|
1821
1822
|
middleName: Joi3.string().optional().allow("", null),
|
|
1822
1823
|
extensionName: Joi3.string().optional().allow("", null),
|
|
1823
|
-
birthDate: Joi3.string().
|
|
1824
|
-
sex: Joi3.string().
|
|
1824
|
+
birthDate: Joi3.string().required(),
|
|
1825
|
+
sex: Joi3.string().required(),
|
|
1826
|
+
// Changed to accept any string to match frontend
|
|
1825
1827
|
age: Joi3.number().integer().min(0).max(150).required(),
|
|
1826
|
-
placeOfBirth: Joi3.
|
|
1827
|
-
|
|
1828
|
-
province: Joi3.string().optional().allow("", null),
|
|
1829
|
-
country: Joi3.string().optional().allow("", null)
|
|
1830
|
-
}).optional(),
|
|
1828
|
+
placeOfBirth: Joi3.string().required(),
|
|
1829
|
+
// Made required to match frontend
|
|
1831
1830
|
motherTongue: Joi3.string().optional().allow("", null),
|
|
1832
|
-
|
|
1833
|
-
disabilityTypes: Joi3.array().items(
|
|
1834
|
-
Joi3.string().valid(
|
|
1835
|
-
"Visual Impairment",
|
|
1836
|
-
"Visual Impairment(Blind)",
|
|
1837
|
-
"Visual Impairment(Low Vision)",
|
|
1838
|
-
"Hearing Impairment",
|
|
1839
|
-
"Learning Disability",
|
|
1840
|
-
"Intellectual Disability",
|
|
1841
|
-
"Autism Spectrum Disorder",
|
|
1842
|
-
"Emotional-Behavioral Disorder",
|
|
1843
|
-
"Orthopedic/Physical Handicap",
|
|
1844
|
-
"Speech/Language Disorder",
|
|
1845
|
-
"Cerebral Palsy",
|
|
1846
|
-
"Special Health Problem/Chronic Disease",
|
|
1847
|
-
"Multiple Disorder",
|
|
1848
|
-
"Cancer"
|
|
1849
|
-
)
|
|
1850
|
-
).optional(),
|
|
1851
|
-
otherDisabilityDetails: Joi3.string().optional().allow("", null),
|
|
1852
|
-
isIndigenous: Joi3.boolean().optional(),
|
|
1831
|
+
fourPsHouseholdId: Joi3.string().optional().allow("", null),
|
|
1853
1832
|
indigenousCommunity: Joi3.string().optional().allow("", null),
|
|
1854
|
-
|
|
1855
|
-
|
|
1833
|
+
withDisability: Joi3.boolean().required(),
|
|
1834
|
+
// Added to match frontend
|
|
1835
|
+
disabilities: Joi3.array().items(Joi3.string()).optional(),
|
|
1836
|
+
// Changed from disabilityTypes to disabilities
|
|
1837
|
+
otherDisabilityDetails: Joi3.string().optional().allow("", null)
|
|
1856
1838
|
});
|
|
1839
|
+
var gradeLevels = [
|
|
1840
|
+
"K1",
|
|
1841
|
+
"K2",
|
|
1842
|
+
"grade-1",
|
|
1843
|
+
"grade-2",
|
|
1844
|
+
"grade-3",
|
|
1845
|
+
"grade-4",
|
|
1846
|
+
"grade-5",
|
|
1847
|
+
"grade-6",
|
|
1848
|
+
"grade-7",
|
|
1849
|
+
"grade-8",
|
|
1850
|
+
"grade-9",
|
|
1851
|
+
"grade-10",
|
|
1852
|
+
"grade-11",
|
|
1853
|
+
"grade-12"
|
|
1854
|
+
];
|
|
1857
1855
|
var schemaEnrollment = Joi3.object({
|
|
1858
|
-
_id: Joi3.string().
|
|
1859
|
-
region: Joi3.string().
|
|
1860
|
-
|
|
1856
|
+
_id: Joi3.string().optional(),
|
|
1857
|
+
region: Joi3.string().required(),
|
|
1858
|
+
// Changed from hex to string to match frontend
|
|
1859
|
+
regionName: Joi3.string().optional().allow("", null),
|
|
1860
|
+
province: Joi3.string().optional().allow("", null),
|
|
1861
|
+
// Made required to match frontend
|
|
1862
|
+
cityMunicipality: Joi3.string().required(),
|
|
1863
|
+
// Made required to match frontend
|
|
1864
|
+
division: Joi3.string().required(),
|
|
1865
|
+
// Changed from hex to string to match frontend
|
|
1866
|
+
divisionName: Joi3.string().optional().allow("", null),
|
|
1867
|
+
schoolId: Joi3.string().required(),
|
|
1868
|
+
// Changed from hex to string to match frontend
|
|
1861
1869
|
school: Joi3.string().hex().required(),
|
|
1870
|
+
// Added to match frontend
|
|
1871
|
+
schoolName: Joi3.string().required(),
|
|
1872
|
+
// Added to match frontend
|
|
1862
1873
|
schoolYear: Joi3.string().required(),
|
|
1863
|
-
|
|
1874
|
+
gradeLevel: Joi3.string().valid(...gradeLevels).required(),
|
|
1875
|
+
returningLearner: Joi3.boolean().required(),
|
|
1876
|
+
// Added to match frontend
|
|
1864
1877
|
learnerInfo: learnerInfoSchema.required(),
|
|
1865
1878
|
parentGuardianInfo: Joi3.object({
|
|
1866
|
-
father: personContactSchema.
|
|
1867
|
-
|
|
1868
|
-
|
|
1879
|
+
father: personContactSchema.required(),
|
|
1880
|
+
// Made required to match frontend
|
|
1881
|
+
mother: personContactSchema.required(),
|
|
1882
|
+
// Made required to match frontend
|
|
1883
|
+
legalGuardian: personContactSchema.required()
|
|
1884
|
+
// Made required to match frontend
|
|
1869
1885
|
}).required(),
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1886
|
+
address: Joi3.object({
|
|
1887
|
+
// Changed from addressInfo to address
|
|
1888
|
+
current: addressSchema.required(),
|
|
1889
|
+
// Changed from currentAddress to current
|
|
1890
|
+
permanent: addressSchema.required(),
|
|
1891
|
+
// Changed from permanentAddress to permanent and made required
|
|
1873
1892
|
sameAsCurrent: Joi3.boolean().optional()
|
|
1874
1893
|
}).required(),
|
|
1875
1894
|
returningLearnerInfo: Joi3.object({
|
|
1876
|
-
lastGradeLevelCompleted: Joi3.string().
|
|
1877
|
-
lastSchoolYearCompleted: Joi3.string().
|
|
1878
|
-
lastSchoolAttended: Joi3.string().
|
|
1879
|
-
lastSchoolId: Joi3.string().optional().allow("", null)
|
|
1880
|
-
isReturningLearner: Joi3.boolean().required(),
|
|
1881
|
-
isTransferIn: Joi3.boolean().required()
|
|
1895
|
+
lastGradeLevelCompleted: Joi3.string().optional().allow("", null),
|
|
1896
|
+
lastSchoolYearCompleted: Joi3.string().optional().allow("", null),
|
|
1897
|
+
lastSchoolAttended: Joi3.string().optional().allow("", null),
|
|
1898
|
+
lastSchoolId: Joi3.string().optional().allow("", null)
|
|
1882
1899
|
}).optional(),
|
|
1883
1900
|
seniorHighInfo: Joi3.object({
|
|
1884
|
-
semester: Joi3.string().
|
|
1885
|
-
track: Joi3.string().
|
|
1886
|
-
strand: Joi3.string().
|
|
1901
|
+
semester: Joi3.string().optional().allow("", null),
|
|
1902
|
+
track: Joi3.string().optional().allow("", null),
|
|
1903
|
+
strand: Joi3.string().optional().allow("", null)
|
|
1887
1904
|
}).optional(),
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
"Online",
|
|
1893
|
-
"Radio-Based Instruction",
|
|
1894
|
-
"Educational Television",
|
|
1895
|
-
"Blended",
|
|
1896
|
-
"Homeschooling"
|
|
1897
|
-
)
|
|
1898
|
-
).optional(),
|
|
1899
|
-
certification: Joi3.object({
|
|
1900
|
-
certifiedBy: Joi3.string().required(),
|
|
1901
|
-
date: Joi3.string().isoDate().required(),
|
|
1902
|
-
consentGiven: Joi3.boolean().required()
|
|
1903
|
-
}).required(),
|
|
1905
|
+
alternativeLearningOptions: Joi3.array().items(Joi3.string()).optional(),
|
|
1906
|
+
// Added to match frontend
|
|
1907
|
+
isCertifiedAndConsented: Joi3.boolean().required(),
|
|
1908
|
+
// Simplified certification to match frontend
|
|
1904
1909
|
status: Joi3.string().optional().allow("", null),
|
|
1910
|
+
remarks: Joi3.string().optional().allow("", null),
|
|
1911
|
+
// Added to match frontend
|
|
1905
1912
|
rejectionReason: Joi3.string().optional().allow("", null),
|
|
1906
1913
|
createdAt: Joi3.date().optional().allow("", null),
|
|
1907
1914
|
updatedAt: Joi3.date().optional().allow("", null),
|
|
@@ -1923,42 +1930,35 @@ function MEnrollment(value) {
|
|
|
1923
1930
|
throw new BadRequestError4("Invalid _id format");
|
|
1924
1931
|
}
|
|
1925
1932
|
}
|
|
1926
|
-
if (typeof value.region === "string") {
|
|
1927
|
-
try {
|
|
1928
|
-
value.region = new ObjectId3(value.region);
|
|
1929
|
-
} catch (error2) {
|
|
1930
|
-
throw new BadRequestError4("Invalid region format");
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
if (typeof value.sdo === "string") {
|
|
1934
|
-
try {
|
|
1935
|
-
value.sdo = new ObjectId3(value.sdo);
|
|
1936
|
-
} catch (error2) {
|
|
1937
|
-
throw new BadRequestError4("Invalid sdo format");
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
if (typeof value.school === "string") {
|
|
1941
|
-
try {
|
|
1942
|
-
value.school = new ObjectId3(value.school);
|
|
1943
|
-
} catch (error2) {
|
|
1944
|
-
throw new BadRequestError4("Invalid school format");
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
1933
|
return {
|
|
1948
1934
|
_id: value._id ?? void 0,
|
|
1949
1935
|
region: value.region,
|
|
1950
|
-
|
|
1936
|
+
regionName: value.regionName ?? "",
|
|
1937
|
+
province: value.province ?? "",
|
|
1938
|
+
cityMunicipality: value.cityMunicipality ?? "",
|
|
1939
|
+
division: value.division,
|
|
1940
|
+
divisionName: value.divisionName ?? "",
|
|
1951
1941
|
school: value.school,
|
|
1942
|
+
schoolId: value.schoolId,
|
|
1943
|
+
schoolName: value.schoolName ?? "",
|
|
1944
|
+
// Added to match frontend
|
|
1952
1945
|
schoolYear: value.schoolYear ?? "",
|
|
1953
|
-
|
|
1946
|
+
gradeLevel: value.gradeLevel ?? "",
|
|
1947
|
+
returningLearner: value.returningLearner ?? false,
|
|
1948
|
+
// Added to match frontend
|
|
1954
1949
|
learnerInfo: value.learnerInfo,
|
|
1955
1950
|
parentGuardianInfo: value.parentGuardianInfo,
|
|
1956
|
-
|
|
1951
|
+
address: value.address,
|
|
1952
|
+
// Changed from addressInfo to address
|
|
1957
1953
|
returningLearnerInfo: value.returningLearnerInfo,
|
|
1958
1954
|
seniorHighInfo: value.seniorHighInfo,
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1955
|
+
alternativeLearningOptions: value.alternativeLearningOptions ?? [],
|
|
1956
|
+
// Added to match frontend
|
|
1957
|
+
isCertifiedAndConsented: value.isCertifiedAndConsented ?? true,
|
|
1958
|
+
// Simplified certification
|
|
1959
|
+
status: value.status ?? "pending",
|
|
1960
|
+
remarks: value.remarks ?? "",
|
|
1961
|
+
// Added to match frontend
|
|
1962
1962
|
rejectionReason: value.rejectionReason ?? "",
|
|
1963
1963
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
1964
1964
|
updatedAt: value.updatedAt ?? "",
|
|
@@ -1981,28 +1981,18 @@ import {
|
|
|
1981
1981
|
useCache as useCache2
|
|
1982
1982
|
} from "@eeplatform/nodejs-utils";
|
|
1983
1983
|
import { ObjectId as ObjectId4 } from "mongodb";
|
|
1984
|
+
import Joi4 from "joi";
|
|
1984
1985
|
function useEnrollmentRepo() {
|
|
1985
1986
|
const db = useAtlas2.getDb();
|
|
1986
1987
|
if (!db) {
|
|
1987
1988
|
throw new Error("Unable to connect to server.");
|
|
1988
1989
|
}
|
|
1989
|
-
const namespace_collection = "school.enrollments";
|
|
1990
|
+
const namespace_collection = "deped.school.enrollments";
|
|
1990
1991
|
const collection = db.collection(namespace_collection);
|
|
1991
1992
|
const { getCache, setCache, delNamespace } = useCache2(namespace_collection);
|
|
1992
1993
|
async function createIndexes() {
|
|
1993
1994
|
try {
|
|
1994
1995
|
await collection.createIndexes([
|
|
1995
|
-
{
|
|
1996
|
-
key: {
|
|
1997
|
-
school: 1,
|
|
1998
|
-
schoolYear: 1,
|
|
1999
|
-
"learnerInfo.lrn": 1,
|
|
2000
|
-
status: 1
|
|
2001
|
-
},
|
|
2002
|
-
unique: true,
|
|
2003
|
-
partialFilterExpression: { status: "active" },
|
|
2004
|
-
name: "unique_enrollment_index"
|
|
2005
|
-
},
|
|
2006
1996
|
{ key: { status: 1 } },
|
|
2007
1997
|
{ key: { school: 1, status: 1 } },
|
|
2008
1998
|
{ key: { "learnerInfo.lrn": 1 } },
|
|
@@ -2094,7 +2084,7 @@ function useEnrollmentRepo() {
|
|
|
2094
2084
|
try {
|
|
2095
2085
|
query.school = new ObjectId4(school);
|
|
2096
2086
|
} catch (error) {
|
|
2097
|
-
throw new BadRequestError5("Invalid school ID
|
|
2087
|
+
throw new BadRequestError5("Invalid school ID.");
|
|
2098
2088
|
}
|
|
2099
2089
|
}
|
|
2100
2090
|
if (schoolYear) {
|
|
@@ -2142,36 +2132,13 @@ function useEnrollmentRepo() {
|
|
|
2142
2132
|
});
|
|
2143
2133
|
return cached;
|
|
2144
2134
|
}
|
|
2145
|
-
const
|
|
2146
|
-
|
|
2147
|
-
{
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
as: "schoolInfo"
|
|
2153
|
-
}
|
|
2154
|
-
},
|
|
2155
|
-
{
|
|
2156
|
-
$lookup: {
|
|
2157
|
-
from: "admin.regions",
|
|
2158
|
-
localField: "region",
|
|
2159
|
-
foreignField: "_id",
|
|
2160
|
-
as: "regionInfo"
|
|
2161
|
-
}
|
|
2162
|
-
},
|
|
2163
|
-
{
|
|
2164
|
-
$lookup: {
|
|
2165
|
-
from: "admin.divisions",
|
|
2166
|
-
localField: "sdo",
|
|
2167
|
-
foreignField: "_id",
|
|
2168
|
-
as: "sdoInfo"
|
|
2169
|
-
}
|
|
2170
|
-
},
|
|
2171
|
-
{ $sort: sort },
|
|
2172
|
-
{ $skip: page * limit },
|
|
2173
|
-
{ $limit: limit }
|
|
2174
|
-
]).toArray();
|
|
2135
|
+
const pipeline = [{ $match: query }];
|
|
2136
|
+
if (Object.keys(sort).length) {
|
|
2137
|
+
pipeline.push({ $sort: sort });
|
|
2138
|
+
}
|
|
2139
|
+
pipeline.push({ $skip: page * limit });
|
|
2140
|
+
pipeline.push({ $limit: limit });
|
|
2141
|
+
const items = await collection.aggregate(pipeline).toArray();
|
|
2175
2142
|
const length = await collection.countDocuments(query);
|
|
2176
2143
|
const data = paginate2(items, page, limit, length);
|
|
2177
2144
|
setCache(cacheKey, data, 600).then(() => {
|
|
@@ -2234,7 +2201,7 @@ function useEnrollmentRepo() {
|
|
|
2234
2201
|
async function getByLrn(lrn, schoolYear) {
|
|
2235
2202
|
const query = {
|
|
2236
2203
|
"learnerInfo.lrn": lrn,
|
|
2237
|
-
status: "
|
|
2204
|
+
status: "accepted"
|
|
2238
2205
|
};
|
|
2239
2206
|
if (schoolYear) {
|
|
2240
2207
|
query.schoolYear = schoolYear;
|
|
@@ -2304,12 +2271,8 @@ function useEnrollmentRepo() {
|
|
|
2304
2271
|
}
|
|
2305
2272
|
}
|
|
2306
2273
|
async function getBySchoolAndYear(school, schoolYear) {
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
school = new ObjectId4(school);
|
|
2310
|
-
}
|
|
2311
|
-
} catch (error) {
|
|
2312
|
-
throw new BadRequestError5("Invalid school ID format.");
|
|
2274
|
+
if (typeof school === "object") {
|
|
2275
|
+
school = school.toString();
|
|
2313
2276
|
}
|
|
2314
2277
|
const query = {
|
|
2315
2278
|
school,
|
|
@@ -2349,6 +2312,110 @@ function useEnrollmentRepo() {
|
|
|
2349
2312
|
);
|
|
2350
2313
|
}
|
|
2351
2314
|
}
|
|
2315
|
+
async function getByApplicantInfo({
|
|
2316
|
+
school = "",
|
|
2317
|
+
schoolYear = "",
|
|
2318
|
+
gradeLevel = "",
|
|
2319
|
+
firstName = "",
|
|
2320
|
+
lastName = "",
|
|
2321
|
+
middleName = "",
|
|
2322
|
+
birthDate = "",
|
|
2323
|
+
placeOfBirth = ""
|
|
2324
|
+
} = {}) {
|
|
2325
|
+
const validation = Joi4.object({
|
|
2326
|
+
school: Joi4.string().required(),
|
|
2327
|
+
schoolYear: Joi4.string().required(),
|
|
2328
|
+
gradeLevel: Joi4.string().required(),
|
|
2329
|
+
firstName: Joi4.string().required(),
|
|
2330
|
+
lastName: Joi4.string().required(),
|
|
2331
|
+
middleName: Joi4.string().optional().allow("", null),
|
|
2332
|
+
birthDate: Joi4.string().required(),
|
|
2333
|
+
placeOfBirth: Joi4.string().required()
|
|
2334
|
+
});
|
|
2335
|
+
const { error } = validation.validate({
|
|
2336
|
+
school,
|
|
2337
|
+
schoolYear,
|
|
2338
|
+
gradeLevel,
|
|
2339
|
+
firstName,
|
|
2340
|
+
lastName,
|
|
2341
|
+
middleName,
|
|
2342
|
+
birthDate,
|
|
2343
|
+
placeOfBirth
|
|
2344
|
+
});
|
|
2345
|
+
if (error) {
|
|
2346
|
+
throw new BadRequestError5(`Validation error: ${error.message}`);
|
|
2347
|
+
}
|
|
2348
|
+
const query = {
|
|
2349
|
+
school,
|
|
2350
|
+
schoolYear,
|
|
2351
|
+
gradeLevel,
|
|
2352
|
+
"learnerInfo.firstName": {
|
|
2353
|
+
$regex: `^${firstName}$`,
|
|
2354
|
+
$options: "i"
|
|
2355
|
+
},
|
|
2356
|
+
"learnerInfo.lastName": {
|
|
2357
|
+
$regex: `^${lastName}$`,
|
|
2358
|
+
$options: "i"
|
|
2359
|
+
},
|
|
2360
|
+
"learnerInfo.birthDate": birthDate,
|
|
2361
|
+
"learnerInfo.placeOfBirth": {
|
|
2362
|
+
$regex: `^${placeOfBirth}$`,
|
|
2363
|
+
$options: "i"
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
const cacheKeyOptions = {
|
|
2367
|
+
school,
|
|
2368
|
+
schoolYear,
|
|
2369
|
+
gradeLevel,
|
|
2370
|
+
firstName,
|
|
2371
|
+
lastName,
|
|
2372
|
+
birthDate,
|
|
2373
|
+
placeOfBirth
|
|
2374
|
+
};
|
|
2375
|
+
if (middleName && middleName.trim() !== "") {
|
|
2376
|
+
query["learnerInfo.middleName"] = {
|
|
2377
|
+
$regex: `^${middleName}$`,
|
|
2378
|
+
$options: "i"
|
|
2379
|
+
};
|
|
2380
|
+
cacheKeyOptions.middleName = middleName;
|
|
2381
|
+
}
|
|
2382
|
+
const cacheKey = makeCacheKey2(namespace_collection, cacheKeyOptions);
|
|
2383
|
+
const cachedData = await getCache(cacheKey);
|
|
2384
|
+
if (cachedData) {
|
|
2385
|
+
logger5.log({
|
|
2386
|
+
level: "info",
|
|
2387
|
+
message: `Cache hit for enrollment by applicant info: ${cacheKey}`
|
|
2388
|
+
});
|
|
2389
|
+
return cachedData;
|
|
2390
|
+
}
|
|
2391
|
+
try {
|
|
2392
|
+
const data = await collection.findOne({
|
|
2393
|
+
...query,
|
|
2394
|
+
status: "accepted"
|
|
2395
|
+
});
|
|
2396
|
+
const length = await collection.countDocuments({
|
|
2397
|
+
...query,
|
|
2398
|
+
status: { $nin: ["accepted", "deleted"] }
|
|
2399
|
+
});
|
|
2400
|
+
const result = { accepted: data ? true : false, length };
|
|
2401
|
+
setCache(cacheKey, result, 600).then(() => {
|
|
2402
|
+
logger5.log({
|
|
2403
|
+
level: "info",
|
|
2404
|
+
message: `Cache set for enrollment by applicant info: ${cacheKey}`
|
|
2405
|
+
});
|
|
2406
|
+
}).catch((err) => {
|
|
2407
|
+
logger5.log({
|
|
2408
|
+
level: "error",
|
|
2409
|
+
message: `Failed to set cache for enrollment by applicant info: ${err.message}`
|
|
2410
|
+
});
|
|
2411
|
+
});
|
|
2412
|
+
return result;
|
|
2413
|
+
} catch (error2) {
|
|
2414
|
+
throw new InternalServerError2(
|
|
2415
|
+
"Failed to get enrollment by applicant info."
|
|
2416
|
+
);
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2352
2419
|
return {
|
|
2353
2420
|
createIndexes,
|
|
2354
2421
|
add,
|
|
@@ -2357,6 +2424,7 @@ function useEnrollmentRepo() {
|
|
|
2357
2424
|
getById,
|
|
2358
2425
|
getByLrn,
|
|
2359
2426
|
deleteById,
|
|
2427
|
+
getByApplicantInfo,
|
|
2360
2428
|
getBySchoolAndYear
|
|
2361
2429
|
};
|
|
2362
2430
|
}
|
|
@@ -2376,39 +2444,52 @@ function useEnrollmentService() {
|
|
|
2376
2444
|
getById: _getById,
|
|
2377
2445
|
getByLrn: _getByLrn,
|
|
2378
2446
|
deleteById: _deleteById,
|
|
2379
|
-
getBySchoolAndYear: _getBySchoolAndYear
|
|
2447
|
+
getBySchoolAndYear: _getBySchoolAndYear,
|
|
2448
|
+
getByApplicantInfo: _getByApplicantInfo
|
|
2380
2449
|
} = useEnrollmentRepo();
|
|
2381
2450
|
async function createEnrollment(value) {
|
|
2382
2451
|
try {
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2452
|
+
const applicantInfo = await _getByApplicantInfo({
|
|
2453
|
+
firstName: value.learnerInfo.firstName,
|
|
2454
|
+
lastName: value.learnerInfo.lastName,
|
|
2455
|
+
middleName: value.learnerInfo.middleName,
|
|
2456
|
+
birthDate: value.learnerInfo.birthDate,
|
|
2457
|
+
placeOfBirth: value.learnerInfo.placeOfBirth,
|
|
2458
|
+
gradeLevel: value.gradeLevel,
|
|
2459
|
+
schoolYear: value.schoolYear,
|
|
2460
|
+
school: value.schoolId
|
|
2461
|
+
});
|
|
2462
|
+
if (applicantInfo.accepted) {
|
|
2463
|
+
throw new BadRequestError6(
|
|
2464
|
+
"This applicant already has an accepted application for the same school year and grade level."
|
|
2465
|
+
);
|
|
2466
|
+
}
|
|
2467
|
+
if (applicantInfo.length >= 3) {
|
|
2468
|
+
throw new BadRequestError6(
|
|
2469
|
+
"This applicant has already submitted applications to 3 schools for the same school year and grade level. Maximum limit reached."
|
|
2387
2470
|
);
|
|
2388
|
-
if (existingEnrollment) {
|
|
2389
|
-
throw new BadRequestError6(
|
|
2390
|
-
"Learner is already enrolled for this school year."
|
|
2391
|
-
);
|
|
2392
|
-
}
|
|
2393
2471
|
}
|
|
2394
|
-
const gradeLevel = value.
|
|
2472
|
+
const gradeLevel = value.gradeLevel.toLowerCase();
|
|
2395
2473
|
const age = value.learnerInfo.age;
|
|
2396
|
-
if (
|
|
2474
|
+
if (["K1", "K2"].includes(gradeLevel) && age < 5) {
|
|
2397
2475
|
throw new BadRequestError6("Learner is too young for Kindergarten.");
|
|
2398
2476
|
}
|
|
2399
|
-
if (gradeLevel
|
|
2477
|
+
if (gradeLevel === "grade-1" && age < 6) {
|
|
2400
2478
|
throw new BadRequestError6("Learner is too young for Grade 1.");
|
|
2401
2479
|
}
|
|
2402
2480
|
const { father, mother, legalGuardian } = value.parentGuardianInfo;
|
|
2403
|
-
|
|
2481
|
+
const hasFatherInfo = father && (father.firstName || father.lastName);
|
|
2482
|
+
const hasMotherInfo = mother && (mother.firstName || mother.lastName);
|
|
2483
|
+
const hasGuardianInfo = legalGuardian && (legalGuardian.firstName || legalGuardian.lastName);
|
|
2484
|
+
if (!hasFatherInfo && !hasMotherInfo && !hasGuardianInfo) {
|
|
2404
2485
|
throw new BadRequestError6(
|
|
2405
2486
|
"At least one parent or legal guardian information is required."
|
|
2406
2487
|
);
|
|
2407
2488
|
}
|
|
2408
|
-
if (gradeLevel.includes("grade
|
|
2409
|
-
if (!value.seniorHighInfo) {
|
|
2489
|
+
if (gradeLevel.includes("grade-11") || gradeLevel.includes("grade-12")) {
|
|
2490
|
+
if (!value.seniorHighInfo || !value.seniorHighInfo.track || !value.seniorHighInfo.strand) {
|
|
2410
2491
|
throw new BadRequestError6(
|
|
2411
|
-
"Senior high school information is required for Grade 11 and 12."
|
|
2492
|
+
"Senior high school information (track and strand) is required for Grade 11 and 12."
|
|
2412
2493
|
);
|
|
2413
2494
|
}
|
|
2414
2495
|
}
|
|
@@ -2642,7 +2723,7 @@ function useEnrollmentService() {
|
|
|
2642
2723
|
|
|
2643
2724
|
// src/resources/enrollment/enrollment.controller.ts
|
|
2644
2725
|
import { BadRequestError as BadRequestError7, logger as logger7 } from "@eeplatform/nodejs-utils";
|
|
2645
|
-
import
|
|
2726
|
+
import Joi5 from "joi";
|
|
2646
2727
|
function useEnrollmentController() {
|
|
2647
2728
|
const {
|
|
2648
2729
|
createEnrollment: _createEnrollment,
|
|
@@ -2674,18 +2755,18 @@ function useEnrollmentController() {
|
|
|
2674
2755
|
async function updateById(req, res, next) {
|
|
2675
2756
|
const value = req.body;
|
|
2676
2757
|
const id = req.params.id ?? "";
|
|
2677
|
-
const validation =
|
|
2678
|
-
id:
|
|
2679
|
-
value:
|
|
2680
|
-
learnerInfo:
|
|
2681
|
-
parentGuardianInfo:
|
|
2682
|
-
addressInfo:
|
|
2683
|
-
returningLearnerInfo:
|
|
2684
|
-
seniorHighInfo:
|
|
2685
|
-
preferredLearningModalities:
|
|
2686
|
-
certification:
|
|
2687
|
-
status:
|
|
2688
|
-
rejectionReason:
|
|
2758
|
+
const validation = Joi5.object({
|
|
2759
|
+
id: Joi5.string().hex().required(),
|
|
2760
|
+
value: Joi5.object({
|
|
2761
|
+
learnerInfo: Joi5.object().optional(),
|
|
2762
|
+
parentGuardianInfo: Joi5.object().optional(),
|
|
2763
|
+
addressInfo: Joi5.object().optional(),
|
|
2764
|
+
returningLearnerInfo: Joi5.object().optional(),
|
|
2765
|
+
seniorHighInfo: Joi5.object().optional(),
|
|
2766
|
+
preferredLearningModalities: Joi5.array().optional(),
|
|
2767
|
+
certification: Joi5.object().optional(),
|
|
2768
|
+
status: Joi5.string().valid("active", "pending", "approved", "rejected", "deleted").optional(),
|
|
2769
|
+
rejectionReason: Joi5.string().optional().allow("", null)
|
|
2689
2770
|
}).min(1)
|
|
2690
2771
|
});
|
|
2691
2772
|
const { error } = validation.validate({ id, value });
|
|
@@ -2704,14 +2785,14 @@ function useEnrollmentController() {
|
|
|
2704
2785
|
}
|
|
2705
2786
|
async function getAll(req, res, next) {
|
|
2706
2787
|
const query = req.query;
|
|
2707
|
-
const validation =
|
|
2708
|
-
page:
|
|
2709
|
-
limit:
|
|
2710
|
-
search:
|
|
2711
|
-
status:
|
|
2712
|
-
school:
|
|
2713
|
-
schoolYear:
|
|
2714
|
-
gradeLevelToEnroll:
|
|
2788
|
+
const validation = Joi5.object({
|
|
2789
|
+
page: Joi5.number().min(1).optional().allow("", null),
|
|
2790
|
+
limit: Joi5.number().min(1).max(100).optional().allow("", null),
|
|
2791
|
+
search: Joi5.string().optional().allow("", null),
|
|
2792
|
+
status: Joi5.string().optional().allow("", null),
|
|
2793
|
+
school: Joi5.string().hex().optional().allow("", null),
|
|
2794
|
+
schoolYear: Joi5.string().optional().allow("", null),
|
|
2795
|
+
gradeLevelToEnroll: Joi5.string().optional().allow("", null)
|
|
2715
2796
|
});
|
|
2716
2797
|
const { error } = validation.validate(query);
|
|
2717
2798
|
if (error) {
|
|
@@ -2749,7 +2830,7 @@ function useEnrollmentController() {
|
|
|
2749
2830
|
}
|
|
2750
2831
|
async function getById(req, res, next) {
|
|
2751
2832
|
const id = req.params.id ?? "";
|
|
2752
|
-
const validation =
|
|
2833
|
+
const validation = Joi5.string().hex().required();
|
|
2753
2834
|
const { error } = validation.validate(id);
|
|
2754
2835
|
if (error) {
|
|
2755
2836
|
next(new BadRequestError7(error.message));
|
|
@@ -2766,9 +2847,9 @@ function useEnrollmentController() {
|
|
|
2766
2847
|
async function getByLrn(req, res, next) {
|
|
2767
2848
|
const lrn = req.params.lrn ?? "";
|
|
2768
2849
|
const schoolYear = req.query.schoolYear;
|
|
2769
|
-
const validation =
|
|
2770
|
-
lrn:
|
|
2771
|
-
schoolYear:
|
|
2850
|
+
const validation = Joi5.object({
|
|
2851
|
+
lrn: Joi5.string().required(),
|
|
2852
|
+
schoolYear: Joi5.string().optional().allow("", null)
|
|
2772
2853
|
});
|
|
2773
2854
|
const { error } = validation.validate({ lrn, schoolYear });
|
|
2774
2855
|
if (error) {
|
|
@@ -2786,9 +2867,9 @@ function useEnrollmentController() {
|
|
|
2786
2867
|
async function deleteById(req, res, next) {
|
|
2787
2868
|
const id = req.params.id ?? "";
|
|
2788
2869
|
const deletedBy = req.body.deletedBy;
|
|
2789
|
-
const validation =
|
|
2790
|
-
id:
|
|
2791
|
-
deletedBy:
|
|
2870
|
+
const validation = Joi5.object({
|
|
2871
|
+
id: Joi5.string().hex().required(),
|
|
2872
|
+
deletedBy: Joi5.string().optional().allow("", null)
|
|
2792
2873
|
});
|
|
2793
2874
|
const { error } = validation.validate({ id, deletedBy });
|
|
2794
2875
|
if (error) {
|
|
@@ -2806,9 +2887,9 @@ function useEnrollmentController() {
|
|
|
2806
2887
|
async function getBySchoolAndYear(req, res, next) {
|
|
2807
2888
|
const school = req.params.school ?? "";
|
|
2808
2889
|
const schoolYear = req.params.schoolYear ?? "";
|
|
2809
|
-
const validation =
|
|
2810
|
-
school:
|
|
2811
|
-
schoolYear:
|
|
2890
|
+
const validation = Joi5.object({
|
|
2891
|
+
school: Joi5.string().hex().required(),
|
|
2892
|
+
schoolYear: Joi5.string().required()
|
|
2812
2893
|
});
|
|
2813
2894
|
const { error } = validation.validate({ school, schoolYear });
|
|
2814
2895
|
if (error) {
|
|
@@ -2826,9 +2907,9 @@ function useEnrollmentController() {
|
|
|
2826
2907
|
async function approve(req, res, next) {
|
|
2827
2908
|
const id = req.params.id ?? "";
|
|
2828
2909
|
const approvedBy = req.body.approvedBy;
|
|
2829
|
-
const validation =
|
|
2830
|
-
id:
|
|
2831
|
-
approvedBy:
|
|
2910
|
+
const validation = Joi5.object({
|
|
2911
|
+
id: Joi5.string().hex().required(),
|
|
2912
|
+
approvedBy: Joi5.string().required()
|
|
2832
2913
|
});
|
|
2833
2914
|
const { error } = validation.validate({ id, approvedBy });
|
|
2834
2915
|
if (error) {
|
|
@@ -2848,10 +2929,10 @@ function useEnrollmentController() {
|
|
|
2848
2929
|
const id = req.params.id ?? "";
|
|
2849
2930
|
const rejectedBy = req.body.rejectedBy;
|
|
2850
2931
|
const rejectionReason = req.body.rejectionReason;
|
|
2851
|
-
const validation =
|
|
2852
|
-
id:
|
|
2853
|
-
rejectedBy:
|
|
2854
|
-
rejectionReason:
|
|
2932
|
+
const validation = Joi5.object({
|
|
2933
|
+
id: Joi5.string().hex().required(),
|
|
2934
|
+
rejectedBy: Joi5.string().required(),
|
|
2935
|
+
rejectionReason: Joi5.string().optional().allow("", null)
|
|
2855
2936
|
});
|
|
2856
2937
|
const { error } = validation.validate({ id, rejectedBy, rejectionReason });
|
|
2857
2938
|
if (error) {
|
|
@@ -2870,9 +2951,9 @@ function useEnrollmentController() {
|
|
|
2870
2951
|
async function getStatsBySchool(req, res, next) {
|
|
2871
2952
|
const school = req.params.school ?? "";
|
|
2872
2953
|
const schoolYear = req.query.schoolYear;
|
|
2873
|
-
const validation =
|
|
2874
|
-
school:
|
|
2875
|
-
schoolYear:
|
|
2954
|
+
const validation = Joi5.object({
|
|
2955
|
+
school: Joi5.string().hex().required(),
|
|
2956
|
+
schoolYear: Joi5.string().optional().allow("", null)
|
|
2876
2957
|
});
|
|
2877
2958
|
const { error } = validation.validate({ school, schoolYear });
|
|
2878
2959
|
if (error) {
|
|
@@ -2939,26 +3020,26 @@ function useEnrollmentController() {
|
|
|
2939
3020
|
|
|
2940
3021
|
// src/resources/grade-level/grade-level.model.ts
|
|
2941
3022
|
import { BadRequestError as BadRequestError8, logger as logger8 } from "@eeplatform/nodejs-utils";
|
|
2942
|
-
import
|
|
3023
|
+
import Joi6 from "joi";
|
|
2943
3024
|
import { ObjectId as ObjectId5 } from "mongodb";
|
|
2944
|
-
var schemaGradeLevel =
|
|
2945
|
-
_id:
|
|
2946
|
-
school:
|
|
2947
|
-
educationLevel:
|
|
2948
|
-
gradeLevel:
|
|
2949
|
-
tracks:
|
|
2950
|
-
trackStrands:
|
|
2951
|
-
teachingStyle:
|
|
2952
|
-
maxNumberOfLearners:
|
|
2953
|
-
defaultStartTime:
|
|
2954
|
-
defaultEndTime:
|
|
2955
|
-
status:
|
|
2956
|
-
createdAt:
|
|
2957
|
-
updatedAt:
|
|
2958
|
-
deletedAt:
|
|
2959
|
-
createdBy:
|
|
2960
|
-
updatedBy:
|
|
2961
|
-
deletedBy:
|
|
3025
|
+
var schemaGradeLevel = Joi6.object({
|
|
3026
|
+
_id: Joi6.string().hex().optional(),
|
|
3027
|
+
school: Joi6.string().hex().optional(),
|
|
3028
|
+
educationLevel: Joi6.string().required(),
|
|
3029
|
+
gradeLevel: Joi6.string().required(),
|
|
3030
|
+
tracks: Joi6.array().items(Joi6.string()).optional(),
|
|
3031
|
+
trackStrands: Joi6.array().items(Joi6.string()).optional(),
|
|
3032
|
+
teachingStyle: Joi6.string().required(),
|
|
3033
|
+
maxNumberOfLearners: Joi6.number().required(),
|
|
3034
|
+
defaultStartTime: Joi6.string().optional().allow("", null),
|
|
3035
|
+
defaultEndTime: Joi6.string().optional().allow("", null),
|
|
3036
|
+
status: Joi6.string().optional().allow("", null),
|
|
3037
|
+
createdAt: Joi6.date().optional().allow("", null),
|
|
3038
|
+
updatedAt: Joi6.date().optional().allow("", null),
|
|
3039
|
+
deletedAt: Joi6.date().optional().allow("", null),
|
|
3040
|
+
createdBy: Joi6.string().optional().allow("", null),
|
|
3041
|
+
updatedBy: Joi6.string().optional().allow("", null),
|
|
3042
|
+
deletedBy: Joi6.string().optional().allow("", null)
|
|
2962
3043
|
});
|
|
2963
3044
|
function MGradeLevel(value) {
|
|
2964
3045
|
const { error } = schemaGradeLevel.validate(value);
|
|
@@ -3370,7 +3451,7 @@ function useGradeLevelRepo() {
|
|
|
3370
3451
|
|
|
3371
3452
|
// src/resources/grade-level/grade-level.controller.ts
|
|
3372
3453
|
import { BadRequestError as BadRequestError10, logger as logger10 } from "@eeplatform/nodejs-utils";
|
|
3373
|
-
import
|
|
3454
|
+
import Joi7 from "joi";
|
|
3374
3455
|
function useGradeLevelController() {
|
|
3375
3456
|
const {
|
|
3376
3457
|
getAll: _getAll,
|
|
@@ -3402,17 +3483,17 @@ function useGradeLevelController() {
|
|
|
3402
3483
|
async function updateById(req, res, next) {
|
|
3403
3484
|
const value = req.body;
|
|
3404
3485
|
const id = req.params.id ?? "";
|
|
3405
|
-
const validation =
|
|
3406
|
-
id:
|
|
3407
|
-
value:
|
|
3408
|
-
school:
|
|
3409
|
-
educationLevel:
|
|
3410
|
-
gradeLevel:
|
|
3411
|
-
teachingStyle:
|
|
3412
|
-
maxTeachingHoursPerDay:
|
|
3413
|
-
maxTeachingHoursPerWeek:
|
|
3414
|
-
defaultStartTime:
|
|
3415
|
-
defaultEndTime:
|
|
3486
|
+
const validation = Joi7.object({
|
|
3487
|
+
id: Joi7.string().hex().required(),
|
|
3488
|
+
value: Joi7.object({
|
|
3489
|
+
school: Joi7.string().hex().optional(),
|
|
3490
|
+
educationLevel: Joi7.string().optional(),
|
|
3491
|
+
gradeLevel: Joi7.string().optional(),
|
|
3492
|
+
teachingStyle: Joi7.string().optional(),
|
|
3493
|
+
maxTeachingHoursPerDay: Joi7.number().integer().min(0).optional(),
|
|
3494
|
+
maxTeachingHoursPerWeek: Joi7.number().integer().min(0).optional(),
|
|
3495
|
+
defaultStartTime: Joi7.string().optional().allow("", null),
|
|
3496
|
+
defaultEndTime: Joi7.string().optional().allow("", null)
|
|
3416
3497
|
}).min(1)
|
|
3417
3498
|
});
|
|
3418
3499
|
const { error } = validation.validate({ id, value });
|
|
@@ -3434,15 +3515,15 @@ function useGradeLevelController() {
|
|
|
3434
3515
|
}
|
|
3435
3516
|
async function getAll(req, res, next) {
|
|
3436
3517
|
const query = req.query;
|
|
3437
|
-
const validation =
|
|
3438
|
-
page:
|
|
3439
|
-
limit:
|
|
3440
|
-
search:
|
|
3441
|
-
educationLevel:
|
|
3442
|
-
gradeLevel:
|
|
3443
|
-
teachingStyle:
|
|
3444
|
-
school:
|
|
3445
|
-
status:
|
|
3518
|
+
const validation = Joi7.object({
|
|
3519
|
+
page: Joi7.number().min(1).optional().allow("", null),
|
|
3520
|
+
limit: Joi7.number().min(1).optional().allow("", null),
|
|
3521
|
+
search: Joi7.string().optional().allow("", null),
|
|
3522
|
+
educationLevel: Joi7.string().optional().allow("", null),
|
|
3523
|
+
gradeLevel: Joi7.string().optional().allow("", null),
|
|
3524
|
+
teachingStyle: Joi7.string().optional().allow("", null),
|
|
3525
|
+
school: Joi7.string().hex().optional().allow("", null),
|
|
3526
|
+
status: Joi7.string().optional().allow("", null)
|
|
3446
3527
|
});
|
|
3447
3528
|
const { error } = validation.validate(query);
|
|
3448
3529
|
if (error) {
|
|
@@ -3467,7 +3548,7 @@ function useGradeLevelController() {
|
|
|
3467
3548
|
const school = req.query.school ?? "";
|
|
3468
3549
|
const search = req.query.search ?? "";
|
|
3469
3550
|
try {
|
|
3470
|
-
const
|
|
3551
|
+
const gradeLevels2 = await _getAll({
|
|
3471
3552
|
page,
|
|
3472
3553
|
limit,
|
|
3473
3554
|
sort: sortObj,
|
|
@@ -3478,7 +3559,7 @@ function useGradeLevelController() {
|
|
|
3478
3559
|
school,
|
|
3479
3560
|
search
|
|
3480
3561
|
});
|
|
3481
|
-
res.json(
|
|
3562
|
+
res.json(gradeLevels2);
|
|
3482
3563
|
return;
|
|
3483
3564
|
} catch (error2) {
|
|
3484
3565
|
next(error2);
|
|
@@ -3486,8 +3567,8 @@ function useGradeLevelController() {
|
|
|
3486
3567
|
}
|
|
3487
3568
|
async function getById(req, res, next) {
|
|
3488
3569
|
const id = req.params.id;
|
|
3489
|
-
const validation =
|
|
3490
|
-
id:
|
|
3570
|
+
const validation = Joi7.object({
|
|
3571
|
+
id: Joi7.string().hex().required()
|
|
3491
3572
|
});
|
|
3492
3573
|
const { error } = validation.validate({ id });
|
|
3493
3574
|
if (error) {
|
|
@@ -3507,8 +3588,8 @@ function useGradeLevelController() {
|
|
|
3507
3588
|
}
|
|
3508
3589
|
async function deleteById(req, res, next) {
|
|
3509
3590
|
const id = req.params.id;
|
|
3510
|
-
const validation =
|
|
3511
|
-
id:
|
|
3591
|
+
const validation = Joi7.object({
|
|
3592
|
+
id: Joi7.string().hex().required()
|
|
3512
3593
|
});
|
|
3513
3594
|
const { error } = validation.validate({ id });
|
|
3514
3595
|
if (error) {
|
|
@@ -3529,9 +3610,9 @@ function useGradeLevelController() {
|
|
|
3529
3610
|
async function getByEducationLevel(req, res, next) {
|
|
3530
3611
|
const educationLevel = req.params.educationLevel;
|
|
3531
3612
|
const school = req.query.school;
|
|
3532
|
-
const validation =
|
|
3533
|
-
educationLevel:
|
|
3534
|
-
school:
|
|
3613
|
+
const validation = Joi7.object({
|
|
3614
|
+
educationLevel: Joi7.string().required(),
|
|
3615
|
+
school: Joi7.string().hex().optional().allow("", null)
|
|
3535
3616
|
});
|
|
3536
3617
|
const { error } = validation.validate({ educationLevel, school });
|
|
3537
3618
|
if (error) {
|
|
@@ -3539,10 +3620,10 @@ function useGradeLevelController() {
|
|
|
3539
3620
|
return;
|
|
3540
3621
|
}
|
|
3541
3622
|
try {
|
|
3542
|
-
const
|
|
3623
|
+
const gradeLevels2 = await _getByEducationLevel(educationLevel, school);
|
|
3543
3624
|
res.json({
|
|
3544
3625
|
message: "Successfully retrieved grade levels by education level.",
|
|
3545
|
-
data: { gradeLevels }
|
|
3626
|
+
data: { gradeLevels: gradeLevels2 }
|
|
3546
3627
|
});
|
|
3547
3628
|
return;
|
|
3548
3629
|
} catch (error2) {
|
|
@@ -3561,14 +3642,14 @@ function useGradeLevelController() {
|
|
|
3561
3642
|
|
|
3562
3643
|
// src/resources/region/region.model.ts
|
|
3563
3644
|
import { BadRequestError as BadRequestError11 } from "@eeplatform/nodejs-utils";
|
|
3564
|
-
import
|
|
3645
|
+
import Joi8 from "joi";
|
|
3565
3646
|
import { ObjectId as ObjectId7 } from "mongodb";
|
|
3566
|
-
var schemaRegion =
|
|
3567
|
-
_id:
|
|
3568
|
-
name:
|
|
3569
|
-
createdAt:
|
|
3570
|
-
updatedAt:
|
|
3571
|
-
deletedAt:
|
|
3647
|
+
var schemaRegion = Joi8.object({
|
|
3648
|
+
_id: Joi8.string().hex().optional().allow(null, ""),
|
|
3649
|
+
name: Joi8.string().min(1).max(100).required(),
|
|
3650
|
+
createdAt: Joi8.string().isoDate().optional(),
|
|
3651
|
+
updatedAt: Joi8.string().isoDate().optional(),
|
|
3652
|
+
deletedAt: Joi8.string().isoDate().optional().allow(null, "")
|
|
3572
3653
|
});
|
|
3573
3654
|
function modelRegion(value) {
|
|
3574
3655
|
const { error } = schemaRegion.validate(value);
|
|
@@ -3856,7 +3937,7 @@ function useRegionRepo() {
|
|
|
3856
3937
|
|
|
3857
3938
|
// src/resources/region/region.controller.ts
|
|
3858
3939
|
import { BadRequestError as BadRequestError13 } from "@eeplatform/nodejs-utils";
|
|
3859
|
-
import
|
|
3940
|
+
import Joi9 from "joi";
|
|
3860
3941
|
function useRegionController() {
|
|
3861
3942
|
const {
|
|
3862
3943
|
add: _add,
|
|
@@ -3886,11 +3967,11 @@ function useRegionController() {
|
|
|
3886
3967
|
}
|
|
3887
3968
|
async function getAll(req, res, next) {
|
|
3888
3969
|
const query = req.query;
|
|
3889
|
-
const validation =
|
|
3890
|
-
page:
|
|
3891
|
-
limit:
|
|
3892
|
-
search:
|
|
3893
|
-
status:
|
|
3970
|
+
const validation = Joi9.object({
|
|
3971
|
+
page: Joi9.number().min(1).optional().allow("", null),
|
|
3972
|
+
limit: Joi9.number().min(1).optional().allow("", null),
|
|
3973
|
+
search: Joi9.string().optional().allow("", null),
|
|
3974
|
+
status: Joi9.string().optional().allow("", null)
|
|
3894
3975
|
});
|
|
3895
3976
|
const { error } = validation.validate(query);
|
|
3896
3977
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -3921,8 +4002,8 @@ function useRegionController() {
|
|
|
3921
4002
|
}
|
|
3922
4003
|
async function getById(req, res, next) {
|
|
3923
4004
|
const id = req.params.id;
|
|
3924
|
-
const validation =
|
|
3925
|
-
id:
|
|
4005
|
+
const validation = Joi9.object({
|
|
4006
|
+
id: Joi9.string().hex().required()
|
|
3926
4007
|
});
|
|
3927
4008
|
const { error } = validation.validate({ id });
|
|
3928
4009
|
if (error) {
|
|
@@ -3942,8 +4023,8 @@ function useRegionController() {
|
|
|
3942
4023
|
}
|
|
3943
4024
|
async function getByName(req, res, next) {
|
|
3944
4025
|
const name = req.params.name;
|
|
3945
|
-
const validation =
|
|
3946
|
-
name:
|
|
4026
|
+
const validation = Joi9.object({
|
|
4027
|
+
name: Joi9.string().required()
|
|
3947
4028
|
});
|
|
3948
4029
|
const { error } = validation.validate({ name });
|
|
3949
4030
|
if (error) {
|
|
@@ -3964,10 +4045,10 @@ function useRegionController() {
|
|
|
3964
4045
|
async function updateField(req, res, next) {
|
|
3965
4046
|
const _id = req.params.id;
|
|
3966
4047
|
const { field, value } = req.body;
|
|
3967
|
-
const validation =
|
|
3968
|
-
_id:
|
|
3969
|
-
field:
|
|
3970
|
-
value:
|
|
4048
|
+
const validation = Joi9.object({
|
|
4049
|
+
_id: Joi9.string().hex().required(),
|
|
4050
|
+
field: Joi9.string().valid("name", "director", "directorName").required(),
|
|
4051
|
+
value: Joi9.string().required()
|
|
3971
4052
|
});
|
|
3972
4053
|
const { error } = validation.validate({ _id, field, value });
|
|
3973
4054
|
if (error) {
|
|
@@ -3984,8 +4065,8 @@ function useRegionController() {
|
|
|
3984
4065
|
}
|
|
3985
4066
|
async function deleteById(req, res, next) {
|
|
3986
4067
|
const _id = req.params.id;
|
|
3987
|
-
const validation =
|
|
3988
|
-
_id:
|
|
4068
|
+
const validation = Joi9.object({
|
|
4069
|
+
_id: Joi9.string().hex().required()
|
|
3989
4070
|
});
|
|
3990
4071
|
const { error } = validation.validate({ _id });
|
|
3991
4072
|
if (error) {
|
|
@@ -4012,26 +4093,26 @@ function useRegionController() {
|
|
|
4012
4093
|
|
|
4013
4094
|
// src/resources/division/division.model.ts
|
|
4014
4095
|
import { BadRequestError as BadRequestError14 } from "@eeplatform/nodejs-utils";
|
|
4015
|
-
import
|
|
4096
|
+
import Joi10 from "joi";
|
|
4016
4097
|
import { ObjectId as ObjectId9 } from "mongodb";
|
|
4017
|
-
var schemaDivision =
|
|
4018
|
-
_id:
|
|
4019
|
-
name:
|
|
4020
|
-
region:
|
|
4021
|
-
regionName:
|
|
4022
|
-
superintendent:
|
|
4023
|
-
superintendentName:
|
|
4024
|
-
createdAt:
|
|
4025
|
-
updatedAt:
|
|
4026
|
-
deletedAt:
|
|
4098
|
+
var schemaDivision = Joi10.object({
|
|
4099
|
+
_id: Joi10.string().hex().optional().allow(null, ""),
|
|
4100
|
+
name: Joi10.string().min(1).max(100).required(),
|
|
4101
|
+
region: Joi10.string().hex().required(),
|
|
4102
|
+
regionName: Joi10.string().min(1).max(100).required(),
|
|
4103
|
+
superintendent: Joi10.string().hex().optional().allow(null, ""),
|
|
4104
|
+
superintendentName: Joi10.string().min(1).max(100).optional().allow(null, ""),
|
|
4105
|
+
createdAt: Joi10.string().isoDate().optional(),
|
|
4106
|
+
updatedAt: Joi10.string().isoDate().optional(),
|
|
4107
|
+
deletedAt: Joi10.string().isoDate().optional().allow(null, "")
|
|
4027
4108
|
});
|
|
4028
|
-
var schemaDivisionUpdate =
|
|
4029
|
-
_id:
|
|
4030
|
-
name:
|
|
4031
|
-
region:
|
|
4032
|
-
regionName:
|
|
4033
|
-
superintendent:
|
|
4034
|
-
superintendentName:
|
|
4109
|
+
var schemaDivisionUpdate = Joi10.object({
|
|
4110
|
+
_id: Joi10.string().hex().optional().allow(null, ""),
|
|
4111
|
+
name: Joi10.string().min(1).max(100).required(),
|
|
4112
|
+
region: Joi10.string().hex().required(),
|
|
4113
|
+
regionName: Joi10.string().min(1).max(100).required(),
|
|
4114
|
+
superintendent: Joi10.string().hex().optional().allow(null, ""),
|
|
4115
|
+
superintendentName: Joi10.string().min(1).max(100).optional().allow(null, "")
|
|
4035
4116
|
});
|
|
4036
4117
|
function modelDivision(value) {
|
|
4037
4118
|
const { error } = schemaDivision.validate(value);
|
|
@@ -4386,49 +4467,49 @@ import { useRoleRepo as useRoleRepo2 } from "@eeplatform/core";
|
|
|
4386
4467
|
|
|
4387
4468
|
// src/resources/school/school.model.ts
|
|
4388
4469
|
import { BadRequestError as BadRequestError16 } from "@eeplatform/nodejs-utils";
|
|
4389
|
-
import
|
|
4470
|
+
import Joi11 from "joi";
|
|
4390
4471
|
import { ObjectId as ObjectId11 } from "mongodb";
|
|
4391
|
-
var schemaSchool =
|
|
4392
|
-
_id:
|
|
4393
|
-
id:
|
|
4394
|
-
name:
|
|
4395
|
-
region:
|
|
4396
|
-
regionName:
|
|
4397
|
-
division:
|
|
4398
|
-
divisionName:
|
|
4399
|
-
principal:
|
|
4400
|
-
principalName:
|
|
4401
|
-
street:
|
|
4402
|
-
barangay:
|
|
4403
|
-
cityMunicipality:
|
|
4404
|
-
province:
|
|
4405
|
-
cityMunicipalityPSGC:
|
|
4406
|
-
postalCode:
|
|
4407
|
-
contactNumber:
|
|
4408
|
-
email:
|
|
4409
|
-
status:
|
|
4410
|
-
createdBy:
|
|
4411
|
-
createdAt:
|
|
4412
|
-
updatedAt:
|
|
4413
|
-
deletedAt:
|
|
4472
|
+
var schemaSchool = Joi11.object({
|
|
4473
|
+
_id: Joi11.string().hex().optional().allow(null, ""),
|
|
4474
|
+
id: Joi11.string().min(1).max(50).required(),
|
|
4475
|
+
name: Joi11.string().min(1).max(100).required(),
|
|
4476
|
+
region: Joi11.string().hex().required(),
|
|
4477
|
+
regionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4478
|
+
division: Joi11.string().hex().required(),
|
|
4479
|
+
divisionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4480
|
+
principal: Joi11.string().hex().optional().allow(null, ""),
|
|
4481
|
+
principalName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4482
|
+
street: Joi11.string().max(200).optional().allow(null, ""),
|
|
4483
|
+
barangay: Joi11.string().max(200).optional().allow(null, ""),
|
|
4484
|
+
cityMunicipality: Joi11.string().max(100).optional().allow(null, ""),
|
|
4485
|
+
province: Joi11.string().max(100).optional().allow(null, ""),
|
|
4486
|
+
cityMunicipalityPSGC: Joi11.string().length(10).optional().allow(null, ""),
|
|
4487
|
+
postalCode: Joi11.string().max(20).optional().allow(null, ""),
|
|
4488
|
+
contactNumber: Joi11.string().max(20).optional().allow(null, ""),
|
|
4489
|
+
email: Joi11.string().email().max(100).optional().allow(null, ""),
|
|
4490
|
+
status: Joi11.string().optional().allow(null, ""),
|
|
4491
|
+
createdBy: Joi11.string().optional().allow(null, ""),
|
|
4492
|
+
createdAt: Joi11.string().isoDate().optional().allow(null, ""),
|
|
4493
|
+
updatedAt: Joi11.string().isoDate().optional().allow(null, ""),
|
|
4494
|
+
deletedAt: Joi11.string().isoDate().optional().allow(null, "")
|
|
4414
4495
|
});
|
|
4415
|
-
var schemaSchoolUpdate =
|
|
4416
|
-
id:
|
|
4417
|
-
name:
|
|
4418
|
-
region:
|
|
4419
|
-
regionName:
|
|
4420
|
-
division:
|
|
4421
|
-
divisionName:
|
|
4422
|
-
principal:
|
|
4423
|
-
principalName:
|
|
4424
|
-
street:
|
|
4425
|
-
barangay:
|
|
4426
|
-
cityMunicipality:
|
|
4427
|
-
province:
|
|
4428
|
-
cityMunicipalityPSGC:
|
|
4429
|
-
postalCode:
|
|
4430
|
-
contactNumber:
|
|
4431
|
-
email:
|
|
4496
|
+
var schemaSchoolUpdate = Joi11.object({
|
|
4497
|
+
id: Joi11.string().min(1).max(50).required(),
|
|
4498
|
+
name: Joi11.string().min(1).max(100).required(),
|
|
4499
|
+
region: Joi11.string().hex().required(),
|
|
4500
|
+
regionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4501
|
+
division: Joi11.string().hex().required(),
|
|
4502
|
+
divisionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4503
|
+
principal: Joi11.string().hex().optional().allow(null, ""),
|
|
4504
|
+
principalName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4505
|
+
street: Joi11.string().max(200).optional().allow(null, ""),
|
|
4506
|
+
barangay: Joi11.string().max(200).optional().allow(null, ""),
|
|
4507
|
+
cityMunicipality: Joi11.string().max(100).optional().allow(null, ""),
|
|
4508
|
+
province: Joi11.string().max(100).optional().allow(null, ""),
|
|
4509
|
+
cityMunicipalityPSGC: Joi11.string().length(10).optional().allow(null, ""),
|
|
4510
|
+
postalCode: Joi11.string().max(20).optional().allow(null, ""),
|
|
4511
|
+
contactNumber: Joi11.string().max(20).optional().allow(null, ""),
|
|
4512
|
+
email: Joi11.string().email().max(100).optional().allow(null, "")
|
|
4432
4513
|
});
|
|
4433
4514
|
function modelSchool(value) {
|
|
4434
4515
|
const { error } = schemaSchool.validate(value);
|
|
@@ -33365,7 +33446,7 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
|
|
|
33365
33446
|
|
|
33366
33447
|
// src/resources/school/school.controller.ts
|
|
33367
33448
|
import { BadRequestError as BadRequestError19 } from "@eeplatform/nodejs-utils";
|
|
33368
|
-
import
|
|
33449
|
+
import Joi12 from "joi";
|
|
33369
33450
|
function useSchoolController() {
|
|
33370
33451
|
const {
|
|
33371
33452
|
getAll: _getAll,
|
|
@@ -33398,16 +33479,16 @@ function useSchoolController() {
|
|
|
33398
33479
|
}
|
|
33399
33480
|
}
|
|
33400
33481
|
async function getAll(req, res, next) {
|
|
33401
|
-
const validation =
|
|
33402
|
-
page:
|
|
33403
|
-
limit:
|
|
33404
|
-
sort:
|
|
33405
|
-
sortOrder:
|
|
33406
|
-
status:
|
|
33407
|
-
org:
|
|
33408
|
-
app:
|
|
33409
|
-
search:
|
|
33410
|
-
psgc:
|
|
33482
|
+
const validation = Joi12.object({
|
|
33483
|
+
page: Joi12.number().optional().allow(null, ""),
|
|
33484
|
+
limit: Joi12.number().optional().allow(null, ""),
|
|
33485
|
+
sort: Joi12.string().optional().allow(null, ""),
|
|
33486
|
+
sortOrder: Joi12.string().optional().allow(null, ""),
|
|
33487
|
+
status: Joi12.string().optional().allow(null, ""),
|
|
33488
|
+
org: Joi12.string().hex().optional().allow(null, ""),
|
|
33489
|
+
app: Joi12.string().optional().allow(null, ""),
|
|
33490
|
+
search: Joi12.string().optional().allow(null, ""),
|
|
33491
|
+
psgc: Joi12.string().optional().allow(null, "")
|
|
33411
33492
|
});
|
|
33412
33493
|
const { error } = validation.validate(req.query);
|
|
33413
33494
|
if (error) {
|
|
@@ -33445,7 +33526,7 @@ function useSchoolController() {
|
|
|
33445
33526
|
}
|
|
33446
33527
|
async function getByCreatedBy(req, res, next) {
|
|
33447
33528
|
const createdBy = req.params.createdBy;
|
|
33448
|
-
const validation =
|
|
33529
|
+
const validation = Joi12.string().hex().required();
|
|
33449
33530
|
const { error } = validation.validate(createdBy);
|
|
33450
33531
|
if (error) {
|
|
33451
33532
|
next(new BadRequestError19(`Validation error: ${error.message}`));
|
|
@@ -33462,9 +33543,9 @@ function useSchoolController() {
|
|
|
33462
33543
|
async function updateStatusById(req, res, next) {
|
|
33463
33544
|
const schoolId = req.params.id;
|
|
33464
33545
|
const status = req.params.status;
|
|
33465
|
-
const validation =
|
|
33466
|
-
id:
|
|
33467
|
-
status:
|
|
33546
|
+
const validation = Joi12.object({
|
|
33547
|
+
id: Joi12.string().hex().required(),
|
|
33548
|
+
status: Joi12.string().valid("active", "deleted", "suspended").required()
|
|
33468
33549
|
});
|
|
33469
33550
|
const { error } = validation.validate({ id: schoolId, status });
|
|
33470
33551
|
if (error) {
|
|
@@ -33497,8 +33578,8 @@ function useSchoolController() {
|
|
|
33497
33578
|
}
|
|
33498
33579
|
async function approveSchool(req, res, next) {
|
|
33499
33580
|
const schoolId = req.params.id;
|
|
33500
|
-
const validation =
|
|
33501
|
-
id:
|
|
33581
|
+
const validation = Joi12.object({
|
|
33582
|
+
id: Joi12.string().hex().required()
|
|
33502
33583
|
});
|
|
33503
33584
|
const { error } = validation.validate({ id: schoolId });
|
|
33504
33585
|
if (error) {
|
|
@@ -33521,11 +33602,11 @@ function useSchoolController() {
|
|
|
33521
33602
|
return;
|
|
33522
33603
|
}
|
|
33523
33604
|
const { region, regionName, division, divisionName } = req.body;
|
|
33524
|
-
const validation =
|
|
33525
|
-
region:
|
|
33526
|
-
regionName:
|
|
33527
|
-
division:
|
|
33528
|
-
divisionName:
|
|
33605
|
+
const validation = Joi12.object({
|
|
33606
|
+
region: Joi12.string().hex().required(),
|
|
33607
|
+
regionName: Joi12.string().min(1).required(),
|
|
33608
|
+
division: Joi12.string().hex().required(),
|
|
33609
|
+
divisionName: Joi12.string().min(1).required()
|
|
33529
33610
|
});
|
|
33530
33611
|
const { error } = validation.validate({
|
|
33531
33612
|
region,
|
|
@@ -33554,10 +33635,10 @@ function useSchoolController() {
|
|
|
33554
33635
|
async function updateFieldById(req, res, next) {
|
|
33555
33636
|
const _id = req.params.id;
|
|
33556
33637
|
const { field, value } = req.body;
|
|
33557
|
-
const validation =
|
|
33558
|
-
_id:
|
|
33559
|
-
field:
|
|
33560
|
-
value:
|
|
33638
|
+
const validation = Joi12.object({
|
|
33639
|
+
_id: Joi12.string().hex().required(),
|
|
33640
|
+
field: Joi12.string().valid("name", "director", "directorName").required(),
|
|
33641
|
+
value: Joi12.string().required()
|
|
33561
33642
|
});
|
|
33562
33643
|
const { error } = validation.validate({ _id, field, value });
|
|
33563
33644
|
if (error) {
|
|
@@ -33575,8 +33656,8 @@ function useSchoolController() {
|
|
|
33575
33656
|
async function updateById(req, res, next) {
|
|
33576
33657
|
const id = req.params.id;
|
|
33577
33658
|
const payload = req.body;
|
|
33578
|
-
const validation =
|
|
33579
|
-
id:
|
|
33659
|
+
const validation = Joi12.object({
|
|
33660
|
+
id: Joi12.string().hex().required()
|
|
33580
33661
|
});
|
|
33581
33662
|
const { error: idError } = validation.validate({ id });
|
|
33582
33663
|
if (idError) {
|
|
@@ -33598,8 +33679,8 @@ function useSchoolController() {
|
|
|
33598
33679
|
}
|
|
33599
33680
|
async function deleteById(req, res, next) {
|
|
33600
33681
|
const _id = req.params.id;
|
|
33601
|
-
const validation =
|
|
33602
|
-
_id:
|
|
33682
|
+
const validation = Joi12.object({
|
|
33683
|
+
_id: Joi12.string().hex().required()
|
|
33603
33684
|
});
|
|
33604
33685
|
const { error } = validation.validate({ _id });
|
|
33605
33686
|
if (error) {
|
|
@@ -33694,7 +33775,7 @@ function useDivisionService() {
|
|
|
33694
33775
|
|
|
33695
33776
|
// src/resources/division/division.controller.ts
|
|
33696
33777
|
import { BadRequestError as BadRequestError20 } from "@eeplatform/nodejs-utils";
|
|
33697
|
-
import
|
|
33778
|
+
import Joi13 from "joi";
|
|
33698
33779
|
function useDivisionController() {
|
|
33699
33780
|
const { add: _add, updateById: _updateById } = useDivisionService();
|
|
33700
33781
|
const {
|
|
@@ -33724,12 +33805,12 @@ function useDivisionController() {
|
|
|
33724
33805
|
}
|
|
33725
33806
|
async function getAll(req, res, next) {
|
|
33726
33807
|
const query = req.query;
|
|
33727
|
-
const validation =
|
|
33728
|
-
page:
|
|
33729
|
-
limit:
|
|
33730
|
-
search:
|
|
33731
|
-
status:
|
|
33732
|
-
region:
|
|
33808
|
+
const validation = Joi13.object({
|
|
33809
|
+
page: Joi13.number().min(1).optional().allow("", null),
|
|
33810
|
+
limit: Joi13.number().min(1).optional().allow("", null),
|
|
33811
|
+
search: Joi13.string().optional().allow("", null),
|
|
33812
|
+
status: Joi13.string().optional().allow("", null),
|
|
33813
|
+
region: Joi13.string().hex().optional().allow("", null)
|
|
33733
33814
|
});
|
|
33734
33815
|
const { error } = validation.validate(query);
|
|
33735
33816
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -33761,8 +33842,8 @@ function useDivisionController() {
|
|
|
33761
33842
|
}
|
|
33762
33843
|
async function getById(req, res, next) {
|
|
33763
33844
|
const id = req.params.id;
|
|
33764
|
-
const validation =
|
|
33765
|
-
id:
|
|
33845
|
+
const validation = Joi13.object({
|
|
33846
|
+
id: Joi13.string().hex().required()
|
|
33766
33847
|
});
|
|
33767
33848
|
const { error } = validation.validate({ id });
|
|
33768
33849
|
if (error) {
|
|
@@ -33782,8 +33863,8 @@ function useDivisionController() {
|
|
|
33782
33863
|
}
|
|
33783
33864
|
async function getByName(req, res, next) {
|
|
33784
33865
|
const name = req.params.name;
|
|
33785
|
-
const validation =
|
|
33786
|
-
name:
|
|
33866
|
+
const validation = Joi13.object({
|
|
33867
|
+
name: Joi13.string().required()
|
|
33787
33868
|
});
|
|
33788
33869
|
const { error } = validation.validate({ name });
|
|
33789
33870
|
if (error) {
|
|
@@ -33804,10 +33885,10 @@ function useDivisionController() {
|
|
|
33804
33885
|
async function updateField(req, res, next) {
|
|
33805
33886
|
const _id = req.params.id;
|
|
33806
33887
|
const { field, value } = req.body;
|
|
33807
|
-
const validation =
|
|
33808
|
-
_id:
|
|
33809
|
-
field:
|
|
33810
|
-
value:
|
|
33888
|
+
const validation = Joi13.object({
|
|
33889
|
+
_id: Joi13.string().hex().required(),
|
|
33890
|
+
field: Joi13.string().valid("name", "director", "directorName").required(),
|
|
33891
|
+
value: Joi13.string().required()
|
|
33811
33892
|
});
|
|
33812
33893
|
const { error } = validation.validate({ _id, field, value });
|
|
33813
33894
|
if (error) {
|
|
@@ -33840,8 +33921,8 @@ function useDivisionController() {
|
|
|
33840
33921
|
}
|
|
33841
33922
|
async function deleteById(req, res, next) {
|
|
33842
33923
|
const _id = req.params.id;
|
|
33843
|
-
const validation =
|
|
33844
|
-
_id:
|
|
33924
|
+
const validation = Joi13.object({
|
|
33925
|
+
_id: Joi13.string().hex().required()
|
|
33845
33926
|
});
|
|
33846
33927
|
const { error } = validation.validate({ _id });
|
|
33847
33928
|
if (error) {
|
|
@@ -33869,48 +33950,48 @@ function useDivisionController() {
|
|
|
33869
33950
|
|
|
33870
33951
|
// src/resources/asset/asset.model.ts
|
|
33871
33952
|
import { BadRequestError as BadRequestError21 } from "@eeplatform/nodejs-utils";
|
|
33872
|
-
import
|
|
33953
|
+
import Joi14 from "joi";
|
|
33873
33954
|
import { ObjectId as ObjectId13 } from "mongodb";
|
|
33874
|
-
var schemaAsset =
|
|
33875
|
-
_id:
|
|
33876
|
-
school:
|
|
33877
|
-
asset_type:
|
|
33878
|
-
name:
|
|
33879
|
-
category:
|
|
33880
|
-
type:
|
|
33881
|
-
brand:
|
|
33882
|
-
unit:
|
|
33883
|
-
status:
|
|
33884
|
-
createdAt:
|
|
33885
|
-
updatedAt:
|
|
33886
|
-
deletedAt:
|
|
33887
|
-
metadata:
|
|
33888
|
-
title:
|
|
33889
|
-
isbn:
|
|
33890
|
-
author:
|
|
33891
|
-
edition:
|
|
33892
|
-
subject:
|
|
33893
|
-
grade_level:
|
|
33894
|
-
publisher:
|
|
33895
|
-
language:
|
|
33955
|
+
var schemaAsset = Joi14.object({
|
|
33956
|
+
_id: Joi14.string().hex().optional(),
|
|
33957
|
+
school: Joi14.string().hex().required(),
|
|
33958
|
+
asset_type: Joi14.string().required().allow("supply", "furniture-equipment", "fixed-asset"),
|
|
33959
|
+
name: Joi14.string().required(),
|
|
33960
|
+
category: Joi14.string().optional().allow("", null),
|
|
33961
|
+
type: Joi14.string().optional().allow("", null),
|
|
33962
|
+
brand: Joi14.string().optional().allow("", null),
|
|
33963
|
+
unit: Joi14.string().required(),
|
|
33964
|
+
status: Joi14.string().optional().allow("", null),
|
|
33965
|
+
createdAt: Joi14.date().optional().allow("", null),
|
|
33966
|
+
updatedAt: Joi14.date().optional().allow("", null),
|
|
33967
|
+
deletedAt: Joi14.date().optional().allow("", null),
|
|
33968
|
+
metadata: Joi14.object({
|
|
33969
|
+
title: Joi14.string().optional().allow("", null),
|
|
33970
|
+
isbn: Joi14.string().optional().allow("", null),
|
|
33971
|
+
author: Joi14.string().optional().allow("", null),
|
|
33972
|
+
edition: Joi14.string().optional().allow("", null),
|
|
33973
|
+
subject: Joi14.string().optional().allow("", null),
|
|
33974
|
+
grade_level: Joi14.number().integer().min(0).optional().allow("", null),
|
|
33975
|
+
publisher: Joi14.string().optional().allow("", null),
|
|
33976
|
+
language: Joi14.string().optional().allow("", null)
|
|
33896
33977
|
}).optional().allow(null)
|
|
33897
33978
|
});
|
|
33898
|
-
var schemaAssetUpdateOption =
|
|
33899
|
-
name:
|
|
33900
|
-
category:
|
|
33901
|
-
type:
|
|
33902
|
-
brand:
|
|
33903
|
-
qty:
|
|
33904
|
-
unit:
|
|
33905
|
-
metadata:
|
|
33906
|
-
title:
|
|
33907
|
-
isbn:
|
|
33908
|
-
author:
|
|
33909
|
-
edition:
|
|
33910
|
-
subject:
|
|
33911
|
-
grade_level:
|
|
33912
|
-
publisher:
|
|
33913
|
-
language:
|
|
33979
|
+
var schemaAssetUpdateOption = Joi14.object({
|
|
33980
|
+
name: Joi14.string().optional().allow("", null),
|
|
33981
|
+
category: Joi14.string().optional().allow("", null),
|
|
33982
|
+
type: Joi14.string().optional().allow("", null),
|
|
33983
|
+
brand: Joi14.string().optional().allow("", null),
|
|
33984
|
+
qty: Joi14.number().integer().min(0).optional().allow("", null),
|
|
33985
|
+
unit: Joi14.string().optional().allow("", null),
|
|
33986
|
+
metadata: Joi14.object({
|
|
33987
|
+
title: Joi14.string().optional().allow("", null),
|
|
33988
|
+
isbn: Joi14.string().optional().allow("", null),
|
|
33989
|
+
author: Joi14.string().optional().allow("", null),
|
|
33990
|
+
edition: Joi14.string().optional().allow("", null),
|
|
33991
|
+
subject: Joi14.string().optional().allow("", null),
|
|
33992
|
+
grade_level: Joi14.number().integer().min(0).optional().allow("", null),
|
|
33993
|
+
publisher: Joi14.string().optional().allow("", null),
|
|
33994
|
+
language: Joi14.string().optional().allow("", null)
|
|
33914
33995
|
}).optional().allow(null)
|
|
33915
33996
|
});
|
|
33916
33997
|
function MAsset(value) {
|
|
@@ -34349,7 +34430,7 @@ function useAssetRepo() {
|
|
|
34349
34430
|
|
|
34350
34431
|
// src/resources/asset/asset.controller.ts
|
|
34351
34432
|
import { BadRequestError as BadRequestError23 } from "@eeplatform/nodejs-utils";
|
|
34352
|
-
import
|
|
34433
|
+
import Joi15 from "joi";
|
|
34353
34434
|
function useAssetController() {
|
|
34354
34435
|
const {
|
|
34355
34436
|
add: _add,
|
|
@@ -34377,13 +34458,13 @@ function useAssetController() {
|
|
|
34377
34458
|
}
|
|
34378
34459
|
async function getAll(req, res, next) {
|
|
34379
34460
|
const query = req.query;
|
|
34380
|
-
const validation =
|
|
34381
|
-
page:
|
|
34382
|
-
limit:
|
|
34383
|
-
search:
|
|
34384
|
-
status:
|
|
34385
|
-
school:
|
|
34386
|
-
asset_type:
|
|
34461
|
+
const validation = Joi15.object({
|
|
34462
|
+
page: Joi15.number().min(1).optional().allow("", null),
|
|
34463
|
+
limit: Joi15.number().min(1).optional().allow("", null),
|
|
34464
|
+
search: Joi15.string().optional().allow("", null),
|
|
34465
|
+
status: Joi15.string().optional().allow("", null),
|
|
34466
|
+
school: Joi15.string().hex().optional().allow("", null),
|
|
34467
|
+
asset_type: Joi15.string().required().allow("supply", "furniture-equipment", "fixed-asset")
|
|
34387
34468
|
});
|
|
34388
34469
|
const { error } = validation.validate(query);
|
|
34389
34470
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -34423,7 +34504,7 @@ function useAssetController() {
|
|
|
34423
34504
|
}
|
|
34424
34505
|
async function deleteById(req, res, next) {
|
|
34425
34506
|
const id = req.params.id;
|
|
34426
|
-
const validation =
|
|
34507
|
+
const validation = Joi15.string().hex().required();
|
|
34427
34508
|
const { error } = validation.validate(id);
|
|
34428
34509
|
if (error) {
|
|
34429
34510
|
next(new BadRequestError23(error.message));
|
|
@@ -34438,7 +34519,7 @@ function useAssetController() {
|
|
|
34438
34519
|
}
|
|
34439
34520
|
async function getById(req, res, next) {
|
|
34440
34521
|
const id = req.params.id;
|
|
34441
|
-
const validation =
|
|
34522
|
+
const validation = Joi15.string().hex().required();
|
|
34442
34523
|
const { error } = validation.validate(id);
|
|
34443
34524
|
if (error) {
|
|
34444
34525
|
next(new BadRequestError23(error.message));
|
|
@@ -34469,7 +34550,7 @@ function useAssetController() {
|
|
|
34469
34550
|
async function getCategories(req, res, next) {
|
|
34470
34551
|
const school = req.params.school;
|
|
34471
34552
|
const asset_type = req.params.asset_type;
|
|
34472
|
-
const validation =
|
|
34553
|
+
const validation = Joi15.string().hex().required();
|
|
34473
34554
|
const { error } = validation.validate(school);
|
|
34474
34555
|
if (error) {
|
|
34475
34556
|
next(new BadRequestError23(error.message));
|
|
@@ -34485,7 +34566,7 @@ function useAssetController() {
|
|
|
34485
34566
|
async function getTypes(req, res, next) {
|
|
34486
34567
|
const school = req.params.school;
|
|
34487
34568
|
const asset_type = req.params.asset_type;
|
|
34488
|
-
const validation =
|
|
34569
|
+
const validation = Joi15.string().hex().required();
|
|
34489
34570
|
const { error } = validation.validate(school);
|
|
34490
34571
|
if (error) {
|
|
34491
34572
|
next(new BadRequestError23(error.message));
|
|
@@ -34500,7 +34581,7 @@ function useAssetController() {
|
|
|
34500
34581
|
}
|
|
34501
34582
|
async function getUnitsBySchool(req, res, next) {
|
|
34502
34583
|
const school = req.params.school;
|
|
34503
|
-
const validation =
|
|
34584
|
+
const validation = Joi15.string().hex().required();
|
|
34504
34585
|
const { error } = validation.validate(school);
|
|
34505
34586
|
if (error) {
|
|
34506
34587
|
next(new BadRequestError23(error.message));
|
|
@@ -34527,26 +34608,26 @@ function useAssetController() {
|
|
|
34527
34608
|
|
|
34528
34609
|
// src/resources/stock-card/stock-card.model.ts
|
|
34529
34610
|
import { BadRequestError as BadRequestError24 } from "@eeplatform/nodejs-utils";
|
|
34530
|
-
import
|
|
34611
|
+
import Joi16 from "joi";
|
|
34531
34612
|
import { ObjectId as ObjectId15 } from "mongodb";
|
|
34532
|
-
var schemaStockCard =
|
|
34533
|
-
_id:
|
|
34534
|
-
school:
|
|
34535
|
-
item:
|
|
34536
|
-
balance:
|
|
34537
|
-
qty:
|
|
34538
|
-
unitCost:
|
|
34539
|
-
totalCost:
|
|
34540
|
-
status:
|
|
34541
|
-
condition:
|
|
34542
|
-
supplier:
|
|
34543
|
-
location:
|
|
34544
|
-
locationName:
|
|
34545
|
-
reason:
|
|
34546
|
-
remarks:
|
|
34547
|
-
createdAt:
|
|
34548
|
-
updatedAt:
|
|
34549
|
-
deletedAt:
|
|
34613
|
+
var schemaStockCard = Joi16.object({
|
|
34614
|
+
_id: Joi16.string().hex().optional().allow("", null),
|
|
34615
|
+
school: Joi16.string().hex().required(),
|
|
34616
|
+
item: Joi16.string().hex().required(),
|
|
34617
|
+
balance: Joi16.number().optional().allow(null, 0),
|
|
34618
|
+
qty: Joi16.number().required(),
|
|
34619
|
+
unitCost: Joi16.number().optional().allow(null, 0),
|
|
34620
|
+
totalCost: Joi16.number().optional().allow(null, 0),
|
|
34621
|
+
status: Joi16.string().optional().allow(null, ""),
|
|
34622
|
+
condition: Joi16.string().required(),
|
|
34623
|
+
supplier: Joi16.string().optional().allow("", null),
|
|
34624
|
+
location: Joi16.string().optional().allow("", null),
|
|
34625
|
+
locationName: Joi16.string().optional().allow("", null),
|
|
34626
|
+
reason: Joi16.string().optional().allow("", null),
|
|
34627
|
+
remarks: Joi16.string().optional().allow("", null),
|
|
34628
|
+
createdAt: Joi16.date().optional().allow("", null),
|
|
34629
|
+
updatedAt: Joi16.date().optional().allow("", null),
|
|
34630
|
+
deletedAt: Joi16.date().optional().allow("", null)
|
|
34550
34631
|
});
|
|
34551
34632
|
function MStockCard(value) {
|
|
34552
34633
|
const { error } = schemaStockCard.validate(value);
|
|
@@ -34845,7 +34926,7 @@ function useStockCardService() {
|
|
|
34845
34926
|
|
|
34846
34927
|
// src/resources/stock-card/stock-card.controller.ts
|
|
34847
34928
|
import { BadRequestError as BadRequestError27 } from "@eeplatform/nodejs-utils";
|
|
34848
|
-
import
|
|
34929
|
+
import Joi17 from "joi";
|
|
34849
34930
|
function useStockCardController() {
|
|
34850
34931
|
const {
|
|
34851
34932
|
getAll: _getAll,
|
|
@@ -34869,11 +34950,11 @@ function useStockCardController() {
|
|
|
34869
34950
|
}
|
|
34870
34951
|
async function getAll(req, res, next) {
|
|
34871
34952
|
const query = req.query;
|
|
34872
|
-
const validation =
|
|
34873
|
-
page:
|
|
34874
|
-
limit:
|
|
34875
|
-
school:
|
|
34876
|
-
id:
|
|
34953
|
+
const validation = Joi17.object({
|
|
34954
|
+
page: Joi17.number().min(1).optional().allow("", null),
|
|
34955
|
+
limit: Joi17.number().min(1).optional().allow("", null),
|
|
34956
|
+
school: Joi17.string().hex().optional().allow("", null),
|
|
34957
|
+
id: Joi17.string().hex().required()
|
|
34877
34958
|
});
|
|
34878
34959
|
const { error } = validation.validate(query);
|
|
34879
34960
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -34909,7 +34990,7 @@ function useStockCardController() {
|
|
|
34909
34990
|
}
|
|
34910
34991
|
async function getById(req, res, next) {
|
|
34911
34992
|
const id = req.params.id;
|
|
34912
|
-
const validation =
|
|
34993
|
+
const validation = Joi17.string().hex().required();
|
|
34913
34994
|
const { error } = validation.validate(id);
|
|
34914
34995
|
if (error) {
|
|
34915
34996
|
next(new BadRequestError27(error.message));
|
|
@@ -34924,7 +35005,7 @@ function useStockCardController() {
|
|
|
34924
35005
|
}
|
|
34925
35006
|
async function getSuppliers(req, res, next) {
|
|
34926
35007
|
const school = req.params.school;
|
|
34927
|
-
const validation =
|
|
35008
|
+
const validation = Joi17.string().hex().required();
|
|
34928
35009
|
const { error } = validation.validate(school);
|
|
34929
35010
|
if (error) {
|
|
34930
35011
|
next(new BadRequestError27(error.message));
|
|
@@ -34947,30 +35028,30 @@ function useStockCardController() {
|
|
|
34947
35028
|
|
|
34948
35029
|
// src/resources/plantilla/plantilla.model.ts
|
|
34949
35030
|
import { BadRequestError as BadRequestError28 } from "@eeplatform/nodejs-utils";
|
|
34950
|
-
import
|
|
35031
|
+
import Joi18 from "joi";
|
|
34951
35032
|
import { ObjectId as ObjectId17 } from "mongodb";
|
|
34952
|
-
var schemaPlantilla =
|
|
34953
|
-
_id:
|
|
34954
|
-
org:
|
|
34955
|
-
orgUnitCode:
|
|
34956
|
-
employmentType:
|
|
34957
|
-
personnelType:
|
|
34958
|
-
itemNumber:
|
|
34959
|
-
positionTitle:
|
|
34960
|
-
positionCategory:
|
|
34961
|
-
region:
|
|
34962
|
-
regionName:
|
|
34963
|
-
division:
|
|
34964
|
-
divisionName:
|
|
34965
|
-
salaryGrade:
|
|
34966
|
-
employeeName:
|
|
34967
|
-
annualSalary:
|
|
34968
|
-
monthlySalary:
|
|
34969
|
-
status:
|
|
34970
|
-
employee:
|
|
34971
|
-
createdAt:
|
|
34972
|
-
updatedAt:
|
|
34973
|
-
deletedAt:
|
|
35033
|
+
var schemaPlantilla = Joi18.object({
|
|
35034
|
+
_id: Joi18.string().hex().optional().allow(null, ""),
|
|
35035
|
+
org: Joi18.string().hex().required(),
|
|
35036
|
+
orgUnitCode: Joi18.string().optional().allow(null, ""),
|
|
35037
|
+
employmentType: Joi18.string().optional().allow(null, ""),
|
|
35038
|
+
personnelType: Joi18.string().required(),
|
|
35039
|
+
itemNumber: Joi18.string().required(),
|
|
35040
|
+
positionTitle: Joi18.string().required(),
|
|
35041
|
+
positionCategory: Joi18.string().required(),
|
|
35042
|
+
region: Joi18.string().hex().optional().allow(null, ""),
|
|
35043
|
+
regionName: Joi18.string().optional().allow(null, ""),
|
|
35044
|
+
division: Joi18.string().hex().optional().allow(null, ""),
|
|
35045
|
+
divisionName: Joi18.string().optional().allow(null, ""),
|
|
35046
|
+
salaryGrade: Joi18.number().required(),
|
|
35047
|
+
employeeName: Joi18.string().optional().allow(null, ""),
|
|
35048
|
+
annualSalary: Joi18.number().optional().allow(null, 0),
|
|
35049
|
+
monthlySalary: Joi18.number().optional().allow(null, 0),
|
|
35050
|
+
status: Joi18.string().required(),
|
|
35051
|
+
employee: Joi18.string().hex().optional().allow(null, ""),
|
|
35052
|
+
createdAt: Joi18.date().iso().optional().allow(null, ""),
|
|
35053
|
+
updatedAt: Joi18.date().iso().optional().allow(null, ""),
|
|
35054
|
+
deletedAt: Joi18.date().iso().optional().allow(null, "")
|
|
34974
35055
|
});
|
|
34975
35056
|
function MPlantilla(data) {
|
|
34976
35057
|
const { error } = schemaPlantilla.validate(data);
|
|
@@ -35461,7 +35542,7 @@ ${errors.slice(0, 10).join("\n")}${errors.length > 10 ? `
|
|
|
35461
35542
|
|
|
35462
35543
|
// src/resources/plantilla/plantilla.controller.ts
|
|
35463
35544
|
import { BadRequestError as BadRequestError31 } from "@eeplatform/nodejs-utils";
|
|
35464
|
-
import
|
|
35545
|
+
import Joi19 from "joi";
|
|
35465
35546
|
function usePlantillaController() {
|
|
35466
35547
|
const {
|
|
35467
35548
|
add: _addPlantilla,
|
|
@@ -35473,11 +35554,11 @@ function usePlantillaController() {
|
|
|
35473
35554
|
const { addBulk: _addBulk } = usePlantillaService();
|
|
35474
35555
|
async function createPlantilla(req, res, next) {
|
|
35475
35556
|
const value = req.body;
|
|
35476
|
-
const validation =
|
|
35477
|
-
itemNumber:
|
|
35478
|
-
positionTitle:
|
|
35479
|
-
positionCategory:
|
|
35480
|
-
status:
|
|
35557
|
+
const validation = Joi19.object({
|
|
35558
|
+
itemNumber: Joi19.string().required(),
|
|
35559
|
+
positionTitle: Joi19.string().required(),
|
|
35560
|
+
positionCategory: Joi19.string().required(),
|
|
35561
|
+
status: Joi19.string().required()
|
|
35481
35562
|
});
|
|
35482
35563
|
const { error } = validation.validate(value);
|
|
35483
35564
|
if (error) {
|
|
@@ -35507,11 +35588,11 @@ function usePlantillaController() {
|
|
|
35507
35588
|
next(new BadRequestError31("Invalid limit number."));
|
|
35508
35589
|
return;
|
|
35509
35590
|
}
|
|
35510
|
-
const validation =
|
|
35511
|
-
page:
|
|
35512
|
-
limit:
|
|
35513
|
-
search:
|
|
35514
|
-
org:
|
|
35591
|
+
const validation = Joi19.object({
|
|
35592
|
+
page: Joi19.number().min(1).optional().allow("", null),
|
|
35593
|
+
limit: Joi19.number().min(1).optional().allow("", null),
|
|
35594
|
+
search: Joi19.string().optional().allow("", null),
|
|
35595
|
+
org: Joi19.string().optional().allow("", null)
|
|
35515
35596
|
});
|
|
35516
35597
|
const { error } = validation.validate({ page, limit, search, org });
|
|
35517
35598
|
if (error) {
|
|
@@ -35533,8 +35614,8 @@ function usePlantillaController() {
|
|
|
35533
35614
|
}
|
|
35534
35615
|
async function getPlantillaById(req, res, next) {
|
|
35535
35616
|
const id = req.params.id;
|
|
35536
|
-
const validation =
|
|
35537
|
-
id:
|
|
35617
|
+
const validation = Joi19.object({
|
|
35618
|
+
id: Joi19.string().hex().required()
|
|
35538
35619
|
});
|
|
35539
35620
|
const { error } = validation.validate({ id });
|
|
35540
35621
|
if (error) {
|
|
@@ -35556,12 +35637,12 @@ function usePlantillaController() {
|
|
|
35556
35637
|
async function updatePlantilla(req, res, next) {
|
|
35557
35638
|
const id = req.params.id;
|
|
35558
35639
|
const value = req.body;
|
|
35559
|
-
const validation =
|
|
35560
|
-
id:
|
|
35561
|
-
employee:
|
|
35562
|
-
status:
|
|
35563
|
-
positionTitle:
|
|
35564
|
-
positionCategory:
|
|
35640
|
+
const validation = Joi19.object({
|
|
35641
|
+
id: Joi19.string().hex().required(),
|
|
35642
|
+
employee: Joi19.string().hex().optional().allow(null, ""),
|
|
35643
|
+
status: Joi19.string().optional(),
|
|
35644
|
+
positionTitle: Joi19.string().optional(),
|
|
35645
|
+
positionCategory: Joi19.string().optional()
|
|
35565
35646
|
});
|
|
35566
35647
|
const { error } = validation.validate({ id, ...value });
|
|
35567
35648
|
if (error) {
|
|
@@ -35582,8 +35663,8 @@ function usePlantillaController() {
|
|
|
35582
35663
|
}
|
|
35583
35664
|
async function deletePlantilla(req, res, next) {
|
|
35584
35665
|
const id = req.params.id;
|
|
35585
|
-
const validation =
|
|
35586
|
-
id:
|
|
35666
|
+
const validation = Joi19.object({
|
|
35667
|
+
id: Joi19.string().hex().required()
|
|
35587
35668
|
});
|
|
35588
35669
|
const { error } = validation.validate({ id });
|
|
35589
35670
|
if (error) {
|
|
@@ -35608,9 +35689,9 @@ function usePlantillaController() {
|
|
|
35608
35689
|
return;
|
|
35609
35690
|
}
|
|
35610
35691
|
const { region, division } = req.body;
|
|
35611
|
-
const validation =
|
|
35612
|
-
region:
|
|
35613
|
-
division:
|
|
35692
|
+
const validation = Joi19.object({
|
|
35693
|
+
region: Joi19.string().hex().optional(),
|
|
35694
|
+
division: Joi19.string().hex().optional()
|
|
35614
35695
|
});
|
|
35615
35696
|
const { error } = validation.validate({ region, division });
|
|
35616
35697
|
if (error) {
|