@eeplatform/basic-edu 1.3.10 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +51 -35
- package/dist/index.js +586 -484
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +586 -484
- 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,98 @@ 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
|
-
|
|
1861
|
-
|
|
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
|
+
school: Joi3.string().required(),
|
|
1868
|
+
// Changed from hex to string to match frontend
|
|
1869
|
+
schoolName: Joi3.string().optional().allow("", null),
|
|
1870
|
+
// Added to match frontend
|
|
1862
1871
|
schoolYear: Joi3.string().required(),
|
|
1863
|
-
|
|
1872
|
+
gradeLevel: Joi3.string().valid(...gradeLevels).required(),
|
|
1873
|
+
returningLearner: Joi3.boolean().required(),
|
|
1874
|
+
// Added to match frontend
|
|
1864
1875
|
learnerInfo: learnerInfoSchema.required(),
|
|
1865
1876
|
parentGuardianInfo: Joi3.object({
|
|
1866
|
-
father: personContactSchema.
|
|
1867
|
-
|
|
1868
|
-
|
|
1877
|
+
father: personContactSchema.required(),
|
|
1878
|
+
// Made required to match frontend
|
|
1879
|
+
mother: personContactSchema.required(),
|
|
1880
|
+
// Made required to match frontend
|
|
1881
|
+
legalGuardian: personContactSchema.required()
|
|
1882
|
+
// Made required to match frontend
|
|
1869
1883
|
}).required(),
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1884
|
+
address: Joi3.object({
|
|
1885
|
+
// Changed from addressInfo to address
|
|
1886
|
+
current: addressSchema.required(),
|
|
1887
|
+
// Changed from currentAddress to current
|
|
1888
|
+
permanent: addressSchema.required(),
|
|
1889
|
+
// Changed from permanentAddress to permanent and made required
|
|
1873
1890
|
sameAsCurrent: Joi3.boolean().optional()
|
|
1874
1891
|
}).required(),
|
|
1875
1892
|
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()
|
|
1893
|
+
lastGradeLevelCompleted: Joi3.string().optional().allow("", null),
|
|
1894
|
+
lastSchoolYearCompleted: Joi3.string().optional().allow("", null),
|
|
1895
|
+
lastSchoolAttended: Joi3.string().optional().allow("", null),
|
|
1896
|
+
lastSchoolId: Joi3.string().optional().allow("", null)
|
|
1882
1897
|
}).optional(),
|
|
1883
1898
|
seniorHighInfo: Joi3.object({
|
|
1884
|
-
semester: Joi3.string().
|
|
1885
|
-
track: Joi3.string().
|
|
1886
|
-
strand: Joi3.string().
|
|
1899
|
+
semester: Joi3.string().optional().allow("", null),
|
|
1900
|
+
track: Joi3.string().optional().allow("", null),
|
|
1901
|
+
strand: Joi3.string().optional().allow("", null)
|
|
1887
1902
|
}).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(),
|
|
1903
|
+
alternativeLearningOptions: Joi3.array().items(Joi3.string()).optional(),
|
|
1904
|
+
// Added to match frontend
|
|
1905
|
+
isCertifiedAndConsented: Joi3.boolean().required(),
|
|
1906
|
+
// Simplified certification to match frontend
|
|
1904
1907
|
status: Joi3.string().optional().allow("", null),
|
|
1908
|
+
remarks: Joi3.string().optional().allow("", null),
|
|
1909
|
+
// Added to match frontend
|
|
1905
1910
|
rejectionReason: Joi3.string().optional().allow("", null),
|
|
1906
1911
|
createdAt: Joi3.date().optional().allow("", null),
|
|
1907
1912
|
updatedAt: Joi3.date().optional().allow("", null),
|
|
@@ -1923,42 +1928,34 @@ function MEnrollment(value) {
|
|
|
1923
1928
|
throw new BadRequestError4("Invalid _id format");
|
|
1924
1929
|
}
|
|
1925
1930
|
}
|
|
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
1931
|
return {
|
|
1948
1932
|
_id: value._id ?? void 0,
|
|
1949
1933
|
region: value.region,
|
|
1950
|
-
|
|
1934
|
+
regionName: value.regionName ?? "",
|
|
1935
|
+
province: value.province ?? "",
|
|
1936
|
+
cityMunicipality: value.cityMunicipality ?? "",
|
|
1937
|
+
division: value.division,
|
|
1938
|
+
divisionName: value.divisionName ?? "",
|
|
1951
1939
|
school: value.school,
|
|
1940
|
+
schoolName: value.schoolName ?? "",
|
|
1941
|
+
// Added to match frontend
|
|
1952
1942
|
schoolYear: value.schoolYear ?? "",
|
|
1953
|
-
|
|
1943
|
+
gradeLevel: value.gradeLevel ?? "",
|
|
1944
|
+
returningLearner: value.returningLearner ?? false,
|
|
1945
|
+
// Added to match frontend
|
|
1954
1946
|
learnerInfo: value.learnerInfo,
|
|
1955
1947
|
parentGuardianInfo: value.parentGuardianInfo,
|
|
1956
|
-
|
|
1948
|
+
address: value.address,
|
|
1949
|
+
// Changed from addressInfo to address
|
|
1957
1950
|
returningLearnerInfo: value.returningLearnerInfo,
|
|
1958
1951
|
seniorHighInfo: value.seniorHighInfo,
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1952
|
+
alternativeLearningOptions: value.alternativeLearningOptions ?? [],
|
|
1953
|
+
// Added to match frontend
|
|
1954
|
+
isCertifiedAndConsented: value.isCertifiedAndConsented ?? true,
|
|
1955
|
+
// Simplified certification
|
|
1956
|
+
status: value.status ?? "pending",
|
|
1957
|
+
remarks: value.remarks ?? "",
|
|
1958
|
+
// Added to match frontend
|
|
1962
1959
|
rejectionReason: value.rejectionReason ?? "",
|
|
1963
1960
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
1964
1961
|
updatedAt: value.updatedAt ?? "",
|
|
@@ -1981,28 +1978,18 @@ import {
|
|
|
1981
1978
|
useCache as useCache2
|
|
1982
1979
|
} from "@eeplatform/nodejs-utils";
|
|
1983
1980
|
import { ObjectId as ObjectId4 } from "mongodb";
|
|
1981
|
+
import Joi4 from "joi";
|
|
1984
1982
|
function useEnrollmentRepo() {
|
|
1985
1983
|
const db = useAtlas2.getDb();
|
|
1986
1984
|
if (!db) {
|
|
1987
1985
|
throw new Error("Unable to connect to server.");
|
|
1988
1986
|
}
|
|
1989
|
-
const namespace_collection = "school.enrollments";
|
|
1987
|
+
const namespace_collection = "deped.school.enrollments";
|
|
1990
1988
|
const collection = db.collection(namespace_collection);
|
|
1991
1989
|
const { getCache, setCache, delNamespace } = useCache2(namespace_collection);
|
|
1992
1990
|
async function createIndexes() {
|
|
1993
1991
|
try {
|
|
1994
1992
|
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
1993
|
{ key: { status: 1 } },
|
|
2007
1994
|
{ key: { school: 1, status: 1 } },
|
|
2008
1995
|
{ key: { "learnerInfo.lrn": 1 } },
|
|
@@ -2091,11 +2078,7 @@ function useEnrollmentRepo() {
|
|
|
2091
2078
|
status
|
|
2092
2079
|
};
|
|
2093
2080
|
if (school) {
|
|
2094
|
-
|
|
2095
|
-
query.school = new ObjectId4(school);
|
|
2096
|
-
} catch (error) {
|
|
2097
|
-
throw new BadRequestError5("Invalid school ID format.");
|
|
2098
|
-
}
|
|
2081
|
+
query.school = school;
|
|
2099
2082
|
}
|
|
2100
2083
|
if (schoolYear) {
|
|
2101
2084
|
query.schoolYear = schoolYear;
|
|
@@ -2149,6 +2132,7 @@ function useEnrollmentRepo() {
|
|
|
2149
2132
|
from: "admin.schools",
|
|
2150
2133
|
localField: "school",
|
|
2151
2134
|
foreignField: "_id",
|
|
2135
|
+
// School collection still uses ObjectId, we'll need to convert during lookup
|
|
2152
2136
|
as: "schoolInfo"
|
|
2153
2137
|
}
|
|
2154
2138
|
},
|
|
@@ -2157,15 +2141,19 @@ function useEnrollmentRepo() {
|
|
|
2157
2141
|
from: "admin.regions",
|
|
2158
2142
|
localField: "region",
|
|
2159
2143
|
foreignField: "_id",
|
|
2144
|
+
// Region collection still uses ObjectId, we'll need to convert during lookup
|
|
2160
2145
|
as: "regionInfo"
|
|
2161
2146
|
}
|
|
2162
2147
|
},
|
|
2163
2148
|
{
|
|
2164
2149
|
$lookup: {
|
|
2165
2150
|
from: "admin.divisions",
|
|
2166
|
-
localField: "
|
|
2151
|
+
localField: "division",
|
|
2152
|
+
// Changed from sdo to division to match frontend
|
|
2167
2153
|
foreignField: "_id",
|
|
2168
|
-
|
|
2154
|
+
// Division collection still uses ObjectId, we'll need to convert during lookup
|
|
2155
|
+
as: "divisionInfo"
|
|
2156
|
+
// Changed from sdoInfo to divisionInfo
|
|
2169
2157
|
}
|
|
2170
2158
|
},
|
|
2171
2159
|
{ $sort: sort },
|
|
@@ -2234,7 +2222,7 @@ function useEnrollmentRepo() {
|
|
|
2234
2222
|
async function getByLrn(lrn, schoolYear) {
|
|
2235
2223
|
const query = {
|
|
2236
2224
|
"learnerInfo.lrn": lrn,
|
|
2237
|
-
status: "
|
|
2225
|
+
status: "accepted"
|
|
2238
2226
|
};
|
|
2239
2227
|
if (schoolYear) {
|
|
2240
2228
|
query.schoolYear = schoolYear;
|
|
@@ -2304,12 +2292,8 @@ function useEnrollmentRepo() {
|
|
|
2304
2292
|
}
|
|
2305
2293
|
}
|
|
2306
2294
|
async function getBySchoolAndYear(school, schoolYear) {
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
school = new ObjectId4(school);
|
|
2310
|
-
}
|
|
2311
|
-
} catch (error) {
|
|
2312
|
-
throw new BadRequestError5("Invalid school ID format.");
|
|
2295
|
+
if (typeof school === "object") {
|
|
2296
|
+
school = school.toString();
|
|
2313
2297
|
}
|
|
2314
2298
|
const query = {
|
|
2315
2299
|
school,
|
|
@@ -2349,6 +2333,110 @@ function useEnrollmentRepo() {
|
|
|
2349
2333
|
);
|
|
2350
2334
|
}
|
|
2351
2335
|
}
|
|
2336
|
+
async function getByApplicantInfo({
|
|
2337
|
+
school = "",
|
|
2338
|
+
schoolYear = "",
|
|
2339
|
+
gradeLevel = "",
|
|
2340
|
+
firstName = "",
|
|
2341
|
+
lastName = "",
|
|
2342
|
+
middleName = "",
|
|
2343
|
+
birthDate = "",
|
|
2344
|
+
placeOfBirth = ""
|
|
2345
|
+
} = {}) {
|
|
2346
|
+
const validation = Joi4.object({
|
|
2347
|
+
school: Joi4.string().required(),
|
|
2348
|
+
schoolYear: Joi4.string().required(),
|
|
2349
|
+
gradeLevel: Joi4.string().required(),
|
|
2350
|
+
firstName: Joi4.string().required(),
|
|
2351
|
+
lastName: Joi4.string().required(),
|
|
2352
|
+
middleName: Joi4.string().optional().allow("", null),
|
|
2353
|
+
birthDate: Joi4.string().required(),
|
|
2354
|
+
placeOfBirth: Joi4.string().required()
|
|
2355
|
+
});
|
|
2356
|
+
const { error } = validation.validate({
|
|
2357
|
+
school,
|
|
2358
|
+
schoolYear,
|
|
2359
|
+
gradeLevel,
|
|
2360
|
+
firstName,
|
|
2361
|
+
lastName,
|
|
2362
|
+
middleName,
|
|
2363
|
+
birthDate,
|
|
2364
|
+
placeOfBirth
|
|
2365
|
+
});
|
|
2366
|
+
if (error) {
|
|
2367
|
+
throw new BadRequestError5(`Validation error: ${error.message}`);
|
|
2368
|
+
}
|
|
2369
|
+
const query = {
|
|
2370
|
+
school,
|
|
2371
|
+
schoolYear,
|
|
2372
|
+
gradeLevel,
|
|
2373
|
+
"learnerInfo.firstName": {
|
|
2374
|
+
$regex: `^${firstName}$`,
|
|
2375
|
+
$options: "i"
|
|
2376
|
+
},
|
|
2377
|
+
"learnerInfo.lastName": {
|
|
2378
|
+
$regex: `^${lastName}$`,
|
|
2379
|
+
$options: "i"
|
|
2380
|
+
},
|
|
2381
|
+
"learnerInfo.birthDate": birthDate,
|
|
2382
|
+
"learnerInfo.placeOfBirth": {
|
|
2383
|
+
$regex: `^${placeOfBirth}$`,
|
|
2384
|
+
$options: "i"
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
const cacheKeyOptions = {
|
|
2388
|
+
school,
|
|
2389
|
+
schoolYear,
|
|
2390
|
+
gradeLevel,
|
|
2391
|
+
firstName,
|
|
2392
|
+
lastName,
|
|
2393
|
+
birthDate,
|
|
2394
|
+
placeOfBirth
|
|
2395
|
+
};
|
|
2396
|
+
if (middleName && middleName.trim() !== "") {
|
|
2397
|
+
query["learnerInfo.middleName"] = {
|
|
2398
|
+
$regex: `^${middleName}$`,
|
|
2399
|
+
$options: "i"
|
|
2400
|
+
};
|
|
2401
|
+
cacheKeyOptions.middleName = middleName;
|
|
2402
|
+
}
|
|
2403
|
+
const cacheKey = makeCacheKey2(namespace_collection, cacheKeyOptions);
|
|
2404
|
+
const cachedData = await getCache(cacheKey);
|
|
2405
|
+
if (cachedData) {
|
|
2406
|
+
logger5.log({
|
|
2407
|
+
level: "info",
|
|
2408
|
+
message: `Cache hit for enrollment by applicant info: ${cacheKey}`
|
|
2409
|
+
});
|
|
2410
|
+
return cachedData;
|
|
2411
|
+
}
|
|
2412
|
+
try {
|
|
2413
|
+
const data = await collection.findOne({
|
|
2414
|
+
...query,
|
|
2415
|
+
status: "accepted"
|
|
2416
|
+
});
|
|
2417
|
+
const length = await collection.countDocuments({
|
|
2418
|
+
...query,
|
|
2419
|
+
status: { $nin: ["accepted", "deleted"] }
|
|
2420
|
+
});
|
|
2421
|
+
const result = { accepted: data ? true : false, length };
|
|
2422
|
+
setCache(cacheKey, result, 600).then(() => {
|
|
2423
|
+
logger5.log({
|
|
2424
|
+
level: "info",
|
|
2425
|
+
message: `Cache set for enrollment by applicant info: ${cacheKey}`
|
|
2426
|
+
});
|
|
2427
|
+
}).catch((err) => {
|
|
2428
|
+
logger5.log({
|
|
2429
|
+
level: "error",
|
|
2430
|
+
message: `Failed to set cache for enrollment by applicant info: ${err.message}`
|
|
2431
|
+
});
|
|
2432
|
+
});
|
|
2433
|
+
return result;
|
|
2434
|
+
} catch (error2) {
|
|
2435
|
+
throw new InternalServerError2(
|
|
2436
|
+
"Failed to get enrollment by applicant info."
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2352
2440
|
return {
|
|
2353
2441
|
createIndexes,
|
|
2354
2442
|
add,
|
|
@@ -2357,6 +2445,7 @@ function useEnrollmentRepo() {
|
|
|
2357
2445
|
getById,
|
|
2358
2446
|
getByLrn,
|
|
2359
2447
|
deleteById,
|
|
2448
|
+
getByApplicantInfo,
|
|
2360
2449
|
getBySchoolAndYear
|
|
2361
2450
|
};
|
|
2362
2451
|
}
|
|
@@ -2376,39 +2465,52 @@ function useEnrollmentService() {
|
|
|
2376
2465
|
getById: _getById,
|
|
2377
2466
|
getByLrn: _getByLrn,
|
|
2378
2467
|
deleteById: _deleteById,
|
|
2379
|
-
getBySchoolAndYear: _getBySchoolAndYear
|
|
2468
|
+
getBySchoolAndYear: _getBySchoolAndYear,
|
|
2469
|
+
getByApplicantInfo: _getByApplicantInfo
|
|
2380
2470
|
} = useEnrollmentRepo();
|
|
2381
2471
|
async function createEnrollment(value) {
|
|
2382
2472
|
try {
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2473
|
+
const applicantInfo = await _getByApplicantInfo({
|
|
2474
|
+
firstName: value.learnerInfo.firstName,
|
|
2475
|
+
lastName: value.learnerInfo.lastName,
|
|
2476
|
+
middleName: value.learnerInfo.middleName,
|
|
2477
|
+
birthDate: value.learnerInfo.birthDate,
|
|
2478
|
+
placeOfBirth: value.learnerInfo.placeOfBirth,
|
|
2479
|
+
gradeLevel: value.gradeLevel,
|
|
2480
|
+
schoolYear: value.schoolYear,
|
|
2481
|
+
school: value.school
|
|
2482
|
+
});
|
|
2483
|
+
if (applicantInfo.accepted) {
|
|
2484
|
+
throw new BadRequestError6(
|
|
2485
|
+
"This applicant already has an accepted application for the same school year and grade level."
|
|
2387
2486
|
);
|
|
2388
|
-
if (existingEnrollment) {
|
|
2389
|
-
throw new BadRequestError6(
|
|
2390
|
-
"Learner is already enrolled for this school year."
|
|
2391
|
-
);
|
|
2392
|
-
}
|
|
2393
2487
|
}
|
|
2394
|
-
|
|
2488
|
+
if (applicantInfo.length >= 3) {
|
|
2489
|
+
throw new BadRequestError6(
|
|
2490
|
+
"This applicant has already submitted applications to 3 schools for the same school year and grade level. Maximum limit reached."
|
|
2491
|
+
);
|
|
2492
|
+
}
|
|
2493
|
+
const gradeLevel = value.gradeLevel.toLowerCase();
|
|
2395
2494
|
const age = value.learnerInfo.age;
|
|
2396
|
-
if (
|
|
2495
|
+
if (["K1", "K2"].includes(gradeLevel) && age < 5) {
|
|
2397
2496
|
throw new BadRequestError6("Learner is too young for Kindergarten.");
|
|
2398
2497
|
}
|
|
2399
|
-
if (gradeLevel
|
|
2498
|
+
if (gradeLevel === "grade-1" && age < 6) {
|
|
2400
2499
|
throw new BadRequestError6("Learner is too young for Grade 1.");
|
|
2401
2500
|
}
|
|
2402
2501
|
const { father, mother, legalGuardian } = value.parentGuardianInfo;
|
|
2403
|
-
|
|
2502
|
+
const hasFatherInfo = father && (father.firstName || father.lastName);
|
|
2503
|
+
const hasMotherInfo = mother && (mother.firstName || mother.lastName);
|
|
2504
|
+
const hasGuardianInfo = legalGuardian && (legalGuardian.firstName || legalGuardian.lastName);
|
|
2505
|
+
if (!hasFatherInfo && !hasMotherInfo && !hasGuardianInfo) {
|
|
2404
2506
|
throw new BadRequestError6(
|
|
2405
2507
|
"At least one parent or legal guardian information is required."
|
|
2406
2508
|
);
|
|
2407
2509
|
}
|
|
2408
|
-
if (gradeLevel.includes("grade
|
|
2409
|
-
if (!value.seniorHighInfo) {
|
|
2510
|
+
if (gradeLevel.includes("grade-11") || gradeLevel.includes("grade-12")) {
|
|
2511
|
+
if (!value.seniorHighInfo || !value.seniorHighInfo.track || !value.seniorHighInfo.strand) {
|
|
2410
2512
|
throw new BadRequestError6(
|
|
2411
|
-
"Senior high school information is required for Grade 11 and 12."
|
|
2513
|
+
"Senior high school information (track and strand) is required for Grade 11 and 12."
|
|
2412
2514
|
);
|
|
2413
2515
|
}
|
|
2414
2516
|
}
|
|
@@ -2642,7 +2744,7 @@ function useEnrollmentService() {
|
|
|
2642
2744
|
|
|
2643
2745
|
// src/resources/enrollment/enrollment.controller.ts
|
|
2644
2746
|
import { BadRequestError as BadRequestError7, logger as logger7 } from "@eeplatform/nodejs-utils";
|
|
2645
|
-
import
|
|
2747
|
+
import Joi5 from "joi";
|
|
2646
2748
|
function useEnrollmentController() {
|
|
2647
2749
|
const {
|
|
2648
2750
|
createEnrollment: _createEnrollment,
|
|
@@ -2674,18 +2776,18 @@ function useEnrollmentController() {
|
|
|
2674
2776
|
async function updateById(req, res, next) {
|
|
2675
2777
|
const value = req.body;
|
|
2676
2778
|
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:
|
|
2779
|
+
const validation = Joi5.object({
|
|
2780
|
+
id: Joi5.string().hex().required(),
|
|
2781
|
+
value: Joi5.object({
|
|
2782
|
+
learnerInfo: Joi5.object().optional(),
|
|
2783
|
+
parentGuardianInfo: Joi5.object().optional(),
|
|
2784
|
+
addressInfo: Joi5.object().optional(),
|
|
2785
|
+
returningLearnerInfo: Joi5.object().optional(),
|
|
2786
|
+
seniorHighInfo: Joi5.object().optional(),
|
|
2787
|
+
preferredLearningModalities: Joi5.array().optional(),
|
|
2788
|
+
certification: Joi5.object().optional(),
|
|
2789
|
+
status: Joi5.string().valid("active", "pending", "approved", "rejected", "deleted").optional(),
|
|
2790
|
+
rejectionReason: Joi5.string().optional().allow("", null)
|
|
2689
2791
|
}).min(1)
|
|
2690
2792
|
});
|
|
2691
2793
|
const { error } = validation.validate({ id, value });
|
|
@@ -2704,14 +2806,14 @@ function useEnrollmentController() {
|
|
|
2704
2806
|
}
|
|
2705
2807
|
async function getAll(req, res, next) {
|
|
2706
2808
|
const query = req.query;
|
|
2707
|
-
const validation =
|
|
2708
|
-
page:
|
|
2709
|
-
limit:
|
|
2710
|
-
search:
|
|
2711
|
-
status:
|
|
2712
|
-
school:
|
|
2713
|
-
schoolYear:
|
|
2714
|
-
gradeLevelToEnroll:
|
|
2809
|
+
const validation = Joi5.object({
|
|
2810
|
+
page: Joi5.number().min(1).optional().allow("", null),
|
|
2811
|
+
limit: Joi5.number().min(1).max(100).optional().allow("", null),
|
|
2812
|
+
search: Joi5.string().optional().allow("", null),
|
|
2813
|
+
status: Joi5.string().optional().allow("", null),
|
|
2814
|
+
school: Joi5.string().hex().optional().allow("", null),
|
|
2815
|
+
schoolYear: Joi5.string().optional().allow("", null),
|
|
2816
|
+
gradeLevelToEnroll: Joi5.string().optional().allow("", null)
|
|
2715
2817
|
});
|
|
2716
2818
|
const { error } = validation.validate(query);
|
|
2717
2819
|
if (error) {
|
|
@@ -2749,7 +2851,7 @@ function useEnrollmentController() {
|
|
|
2749
2851
|
}
|
|
2750
2852
|
async function getById(req, res, next) {
|
|
2751
2853
|
const id = req.params.id ?? "";
|
|
2752
|
-
const validation =
|
|
2854
|
+
const validation = Joi5.string().hex().required();
|
|
2753
2855
|
const { error } = validation.validate(id);
|
|
2754
2856
|
if (error) {
|
|
2755
2857
|
next(new BadRequestError7(error.message));
|
|
@@ -2766,9 +2868,9 @@ function useEnrollmentController() {
|
|
|
2766
2868
|
async function getByLrn(req, res, next) {
|
|
2767
2869
|
const lrn = req.params.lrn ?? "";
|
|
2768
2870
|
const schoolYear = req.query.schoolYear;
|
|
2769
|
-
const validation =
|
|
2770
|
-
lrn:
|
|
2771
|
-
schoolYear:
|
|
2871
|
+
const validation = Joi5.object({
|
|
2872
|
+
lrn: Joi5.string().required(),
|
|
2873
|
+
schoolYear: Joi5.string().optional().allow("", null)
|
|
2772
2874
|
});
|
|
2773
2875
|
const { error } = validation.validate({ lrn, schoolYear });
|
|
2774
2876
|
if (error) {
|
|
@@ -2786,9 +2888,9 @@ function useEnrollmentController() {
|
|
|
2786
2888
|
async function deleteById(req, res, next) {
|
|
2787
2889
|
const id = req.params.id ?? "";
|
|
2788
2890
|
const deletedBy = req.body.deletedBy;
|
|
2789
|
-
const validation =
|
|
2790
|
-
id:
|
|
2791
|
-
deletedBy:
|
|
2891
|
+
const validation = Joi5.object({
|
|
2892
|
+
id: Joi5.string().hex().required(),
|
|
2893
|
+
deletedBy: Joi5.string().optional().allow("", null)
|
|
2792
2894
|
});
|
|
2793
2895
|
const { error } = validation.validate({ id, deletedBy });
|
|
2794
2896
|
if (error) {
|
|
@@ -2806,9 +2908,9 @@ function useEnrollmentController() {
|
|
|
2806
2908
|
async function getBySchoolAndYear(req, res, next) {
|
|
2807
2909
|
const school = req.params.school ?? "";
|
|
2808
2910
|
const schoolYear = req.params.schoolYear ?? "";
|
|
2809
|
-
const validation =
|
|
2810
|
-
school:
|
|
2811
|
-
schoolYear:
|
|
2911
|
+
const validation = Joi5.object({
|
|
2912
|
+
school: Joi5.string().hex().required(),
|
|
2913
|
+
schoolYear: Joi5.string().required()
|
|
2812
2914
|
});
|
|
2813
2915
|
const { error } = validation.validate({ school, schoolYear });
|
|
2814
2916
|
if (error) {
|
|
@@ -2826,9 +2928,9 @@ function useEnrollmentController() {
|
|
|
2826
2928
|
async function approve(req, res, next) {
|
|
2827
2929
|
const id = req.params.id ?? "";
|
|
2828
2930
|
const approvedBy = req.body.approvedBy;
|
|
2829
|
-
const validation =
|
|
2830
|
-
id:
|
|
2831
|
-
approvedBy:
|
|
2931
|
+
const validation = Joi5.object({
|
|
2932
|
+
id: Joi5.string().hex().required(),
|
|
2933
|
+
approvedBy: Joi5.string().required()
|
|
2832
2934
|
});
|
|
2833
2935
|
const { error } = validation.validate({ id, approvedBy });
|
|
2834
2936
|
if (error) {
|
|
@@ -2848,10 +2950,10 @@ function useEnrollmentController() {
|
|
|
2848
2950
|
const id = req.params.id ?? "";
|
|
2849
2951
|
const rejectedBy = req.body.rejectedBy;
|
|
2850
2952
|
const rejectionReason = req.body.rejectionReason;
|
|
2851
|
-
const validation =
|
|
2852
|
-
id:
|
|
2853
|
-
rejectedBy:
|
|
2854
|
-
rejectionReason:
|
|
2953
|
+
const validation = Joi5.object({
|
|
2954
|
+
id: Joi5.string().hex().required(),
|
|
2955
|
+
rejectedBy: Joi5.string().required(),
|
|
2956
|
+
rejectionReason: Joi5.string().optional().allow("", null)
|
|
2855
2957
|
});
|
|
2856
2958
|
const { error } = validation.validate({ id, rejectedBy, rejectionReason });
|
|
2857
2959
|
if (error) {
|
|
@@ -2870,9 +2972,9 @@ function useEnrollmentController() {
|
|
|
2870
2972
|
async function getStatsBySchool(req, res, next) {
|
|
2871
2973
|
const school = req.params.school ?? "";
|
|
2872
2974
|
const schoolYear = req.query.schoolYear;
|
|
2873
|
-
const validation =
|
|
2874
|
-
school:
|
|
2875
|
-
schoolYear:
|
|
2975
|
+
const validation = Joi5.object({
|
|
2976
|
+
school: Joi5.string().hex().required(),
|
|
2977
|
+
schoolYear: Joi5.string().optional().allow("", null)
|
|
2876
2978
|
});
|
|
2877
2979
|
const { error } = validation.validate({ school, schoolYear });
|
|
2878
2980
|
if (error) {
|
|
@@ -2939,26 +3041,26 @@ function useEnrollmentController() {
|
|
|
2939
3041
|
|
|
2940
3042
|
// src/resources/grade-level/grade-level.model.ts
|
|
2941
3043
|
import { BadRequestError as BadRequestError8, logger as logger8 } from "@eeplatform/nodejs-utils";
|
|
2942
|
-
import
|
|
3044
|
+
import Joi6 from "joi";
|
|
2943
3045
|
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:
|
|
3046
|
+
var schemaGradeLevel = Joi6.object({
|
|
3047
|
+
_id: Joi6.string().hex().optional(),
|
|
3048
|
+
school: Joi6.string().hex().optional(),
|
|
3049
|
+
educationLevel: Joi6.string().required(),
|
|
3050
|
+
gradeLevel: Joi6.string().required(),
|
|
3051
|
+
tracks: Joi6.array().items(Joi6.string()).optional(),
|
|
3052
|
+
trackStrands: Joi6.array().items(Joi6.string()).optional(),
|
|
3053
|
+
teachingStyle: Joi6.string().required(),
|
|
3054
|
+
maxNumberOfLearners: Joi6.number().required(),
|
|
3055
|
+
defaultStartTime: Joi6.string().optional().allow("", null),
|
|
3056
|
+
defaultEndTime: Joi6.string().optional().allow("", null),
|
|
3057
|
+
status: Joi6.string().optional().allow("", null),
|
|
3058
|
+
createdAt: Joi6.date().optional().allow("", null),
|
|
3059
|
+
updatedAt: Joi6.date().optional().allow("", null),
|
|
3060
|
+
deletedAt: Joi6.date().optional().allow("", null),
|
|
3061
|
+
createdBy: Joi6.string().optional().allow("", null),
|
|
3062
|
+
updatedBy: Joi6.string().optional().allow("", null),
|
|
3063
|
+
deletedBy: Joi6.string().optional().allow("", null)
|
|
2962
3064
|
});
|
|
2963
3065
|
function MGradeLevel(value) {
|
|
2964
3066
|
const { error } = schemaGradeLevel.validate(value);
|
|
@@ -3370,7 +3472,7 @@ function useGradeLevelRepo() {
|
|
|
3370
3472
|
|
|
3371
3473
|
// src/resources/grade-level/grade-level.controller.ts
|
|
3372
3474
|
import { BadRequestError as BadRequestError10, logger as logger10 } from "@eeplatform/nodejs-utils";
|
|
3373
|
-
import
|
|
3475
|
+
import Joi7 from "joi";
|
|
3374
3476
|
function useGradeLevelController() {
|
|
3375
3477
|
const {
|
|
3376
3478
|
getAll: _getAll,
|
|
@@ -3402,17 +3504,17 @@ function useGradeLevelController() {
|
|
|
3402
3504
|
async function updateById(req, res, next) {
|
|
3403
3505
|
const value = req.body;
|
|
3404
3506
|
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:
|
|
3507
|
+
const validation = Joi7.object({
|
|
3508
|
+
id: Joi7.string().hex().required(),
|
|
3509
|
+
value: Joi7.object({
|
|
3510
|
+
school: Joi7.string().hex().optional(),
|
|
3511
|
+
educationLevel: Joi7.string().optional(),
|
|
3512
|
+
gradeLevel: Joi7.string().optional(),
|
|
3513
|
+
teachingStyle: Joi7.string().optional(),
|
|
3514
|
+
maxTeachingHoursPerDay: Joi7.number().integer().min(0).optional(),
|
|
3515
|
+
maxTeachingHoursPerWeek: Joi7.number().integer().min(0).optional(),
|
|
3516
|
+
defaultStartTime: Joi7.string().optional().allow("", null),
|
|
3517
|
+
defaultEndTime: Joi7.string().optional().allow("", null)
|
|
3416
3518
|
}).min(1)
|
|
3417
3519
|
});
|
|
3418
3520
|
const { error } = validation.validate({ id, value });
|
|
@@ -3434,15 +3536,15 @@ function useGradeLevelController() {
|
|
|
3434
3536
|
}
|
|
3435
3537
|
async function getAll(req, res, next) {
|
|
3436
3538
|
const query = req.query;
|
|
3437
|
-
const validation =
|
|
3438
|
-
page:
|
|
3439
|
-
limit:
|
|
3440
|
-
search:
|
|
3441
|
-
educationLevel:
|
|
3442
|
-
gradeLevel:
|
|
3443
|
-
teachingStyle:
|
|
3444
|
-
school:
|
|
3445
|
-
status:
|
|
3539
|
+
const validation = Joi7.object({
|
|
3540
|
+
page: Joi7.number().min(1).optional().allow("", null),
|
|
3541
|
+
limit: Joi7.number().min(1).optional().allow("", null),
|
|
3542
|
+
search: Joi7.string().optional().allow("", null),
|
|
3543
|
+
educationLevel: Joi7.string().optional().allow("", null),
|
|
3544
|
+
gradeLevel: Joi7.string().optional().allow("", null),
|
|
3545
|
+
teachingStyle: Joi7.string().optional().allow("", null),
|
|
3546
|
+
school: Joi7.string().hex().optional().allow("", null),
|
|
3547
|
+
status: Joi7.string().optional().allow("", null)
|
|
3446
3548
|
});
|
|
3447
3549
|
const { error } = validation.validate(query);
|
|
3448
3550
|
if (error) {
|
|
@@ -3467,7 +3569,7 @@ function useGradeLevelController() {
|
|
|
3467
3569
|
const school = req.query.school ?? "";
|
|
3468
3570
|
const search = req.query.search ?? "";
|
|
3469
3571
|
try {
|
|
3470
|
-
const
|
|
3572
|
+
const gradeLevels2 = await _getAll({
|
|
3471
3573
|
page,
|
|
3472
3574
|
limit,
|
|
3473
3575
|
sort: sortObj,
|
|
@@ -3478,7 +3580,7 @@ function useGradeLevelController() {
|
|
|
3478
3580
|
school,
|
|
3479
3581
|
search
|
|
3480
3582
|
});
|
|
3481
|
-
res.json(
|
|
3583
|
+
res.json(gradeLevels2);
|
|
3482
3584
|
return;
|
|
3483
3585
|
} catch (error2) {
|
|
3484
3586
|
next(error2);
|
|
@@ -3486,8 +3588,8 @@ function useGradeLevelController() {
|
|
|
3486
3588
|
}
|
|
3487
3589
|
async function getById(req, res, next) {
|
|
3488
3590
|
const id = req.params.id;
|
|
3489
|
-
const validation =
|
|
3490
|
-
id:
|
|
3591
|
+
const validation = Joi7.object({
|
|
3592
|
+
id: Joi7.string().hex().required()
|
|
3491
3593
|
});
|
|
3492
3594
|
const { error } = validation.validate({ id });
|
|
3493
3595
|
if (error) {
|
|
@@ -3507,8 +3609,8 @@ function useGradeLevelController() {
|
|
|
3507
3609
|
}
|
|
3508
3610
|
async function deleteById(req, res, next) {
|
|
3509
3611
|
const id = req.params.id;
|
|
3510
|
-
const validation =
|
|
3511
|
-
id:
|
|
3612
|
+
const validation = Joi7.object({
|
|
3613
|
+
id: Joi7.string().hex().required()
|
|
3512
3614
|
});
|
|
3513
3615
|
const { error } = validation.validate({ id });
|
|
3514
3616
|
if (error) {
|
|
@@ -3529,9 +3631,9 @@ function useGradeLevelController() {
|
|
|
3529
3631
|
async function getByEducationLevel(req, res, next) {
|
|
3530
3632
|
const educationLevel = req.params.educationLevel;
|
|
3531
3633
|
const school = req.query.school;
|
|
3532
|
-
const validation =
|
|
3533
|
-
educationLevel:
|
|
3534
|
-
school:
|
|
3634
|
+
const validation = Joi7.object({
|
|
3635
|
+
educationLevel: Joi7.string().required(),
|
|
3636
|
+
school: Joi7.string().hex().optional().allow("", null)
|
|
3535
3637
|
});
|
|
3536
3638
|
const { error } = validation.validate({ educationLevel, school });
|
|
3537
3639
|
if (error) {
|
|
@@ -3539,10 +3641,10 @@ function useGradeLevelController() {
|
|
|
3539
3641
|
return;
|
|
3540
3642
|
}
|
|
3541
3643
|
try {
|
|
3542
|
-
const
|
|
3644
|
+
const gradeLevels2 = await _getByEducationLevel(educationLevel, school);
|
|
3543
3645
|
res.json({
|
|
3544
3646
|
message: "Successfully retrieved grade levels by education level.",
|
|
3545
|
-
data: { gradeLevels }
|
|
3647
|
+
data: { gradeLevels: gradeLevels2 }
|
|
3546
3648
|
});
|
|
3547
3649
|
return;
|
|
3548
3650
|
} catch (error2) {
|
|
@@ -3561,14 +3663,14 @@ function useGradeLevelController() {
|
|
|
3561
3663
|
|
|
3562
3664
|
// src/resources/region/region.model.ts
|
|
3563
3665
|
import { BadRequestError as BadRequestError11 } from "@eeplatform/nodejs-utils";
|
|
3564
|
-
import
|
|
3666
|
+
import Joi8 from "joi";
|
|
3565
3667
|
import { ObjectId as ObjectId7 } from "mongodb";
|
|
3566
|
-
var schemaRegion =
|
|
3567
|
-
_id:
|
|
3568
|
-
name:
|
|
3569
|
-
createdAt:
|
|
3570
|
-
updatedAt:
|
|
3571
|
-
deletedAt:
|
|
3668
|
+
var schemaRegion = Joi8.object({
|
|
3669
|
+
_id: Joi8.string().hex().optional().allow(null, ""),
|
|
3670
|
+
name: Joi8.string().min(1).max(100).required(),
|
|
3671
|
+
createdAt: Joi8.string().isoDate().optional(),
|
|
3672
|
+
updatedAt: Joi8.string().isoDate().optional(),
|
|
3673
|
+
deletedAt: Joi8.string().isoDate().optional().allow(null, "")
|
|
3572
3674
|
});
|
|
3573
3675
|
function modelRegion(value) {
|
|
3574
3676
|
const { error } = schemaRegion.validate(value);
|
|
@@ -3856,7 +3958,7 @@ function useRegionRepo() {
|
|
|
3856
3958
|
|
|
3857
3959
|
// src/resources/region/region.controller.ts
|
|
3858
3960
|
import { BadRequestError as BadRequestError13 } from "@eeplatform/nodejs-utils";
|
|
3859
|
-
import
|
|
3961
|
+
import Joi9 from "joi";
|
|
3860
3962
|
function useRegionController() {
|
|
3861
3963
|
const {
|
|
3862
3964
|
add: _add,
|
|
@@ -3886,11 +3988,11 @@ function useRegionController() {
|
|
|
3886
3988
|
}
|
|
3887
3989
|
async function getAll(req, res, next) {
|
|
3888
3990
|
const query = req.query;
|
|
3889
|
-
const validation =
|
|
3890
|
-
page:
|
|
3891
|
-
limit:
|
|
3892
|
-
search:
|
|
3893
|
-
status:
|
|
3991
|
+
const validation = Joi9.object({
|
|
3992
|
+
page: Joi9.number().min(1).optional().allow("", null),
|
|
3993
|
+
limit: Joi9.number().min(1).optional().allow("", null),
|
|
3994
|
+
search: Joi9.string().optional().allow("", null),
|
|
3995
|
+
status: Joi9.string().optional().allow("", null)
|
|
3894
3996
|
});
|
|
3895
3997
|
const { error } = validation.validate(query);
|
|
3896
3998
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -3921,8 +4023,8 @@ function useRegionController() {
|
|
|
3921
4023
|
}
|
|
3922
4024
|
async function getById(req, res, next) {
|
|
3923
4025
|
const id = req.params.id;
|
|
3924
|
-
const validation =
|
|
3925
|
-
id:
|
|
4026
|
+
const validation = Joi9.object({
|
|
4027
|
+
id: Joi9.string().hex().required()
|
|
3926
4028
|
});
|
|
3927
4029
|
const { error } = validation.validate({ id });
|
|
3928
4030
|
if (error) {
|
|
@@ -3942,8 +4044,8 @@ function useRegionController() {
|
|
|
3942
4044
|
}
|
|
3943
4045
|
async function getByName(req, res, next) {
|
|
3944
4046
|
const name = req.params.name;
|
|
3945
|
-
const validation =
|
|
3946
|
-
name:
|
|
4047
|
+
const validation = Joi9.object({
|
|
4048
|
+
name: Joi9.string().required()
|
|
3947
4049
|
});
|
|
3948
4050
|
const { error } = validation.validate({ name });
|
|
3949
4051
|
if (error) {
|
|
@@ -3964,10 +4066,10 @@ function useRegionController() {
|
|
|
3964
4066
|
async function updateField(req, res, next) {
|
|
3965
4067
|
const _id = req.params.id;
|
|
3966
4068
|
const { field, value } = req.body;
|
|
3967
|
-
const validation =
|
|
3968
|
-
_id:
|
|
3969
|
-
field:
|
|
3970
|
-
value:
|
|
4069
|
+
const validation = Joi9.object({
|
|
4070
|
+
_id: Joi9.string().hex().required(),
|
|
4071
|
+
field: Joi9.string().valid("name", "director", "directorName").required(),
|
|
4072
|
+
value: Joi9.string().required()
|
|
3971
4073
|
});
|
|
3972
4074
|
const { error } = validation.validate({ _id, field, value });
|
|
3973
4075
|
if (error) {
|
|
@@ -3984,8 +4086,8 @@ function useRegionController() {
|
|
|
3984
4086
|
}
|
|
3985
4087
|
async function deleteById(req, res, next) {
|
|
3986
4088
|
const _id = req.params.id;
|
|
3987
|
-
const validation =
|
|
3988
|
-
_id:
|
|
4089
|
+
const validation = Joi9.object({
|
|
4090
|
+
_id: Joi9.string().hex().required()
|
|
3989
4091
|
});
|
|
3990
4092
|
const { error } = validation.validate({ _id });
|
|
3991
4093
|
if (error) {
|
|
@@ -4012,26 +4114,26 @@ function useRegionController() {
|
|
|
4012
4114
|
|
|
4013
4115
|
// src/resources/division/division.model.ts
|
|
4014
4116
|
import { BadRequestError as BadRequestError14 } from "@eeplatform/nodejs-utils";
|
|
4015
|
-
import
|
|
4117
|
+
import Joi10 from "joi";
|
|
4016
4118
|
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:
|
|
4119
|
+
var schemaDivision = Joi10.object({
|
|
4120
|
+
_id: Joi10.string().hex().optional().allow(null, ""),
|
|
4121
|
+
name: Joi10.string().min(1).max(100).required(),
|
|
4122
|
+
region: Joi10.string().hex().required(),
|
|
4123
|
+
regionName: Joi10.string().min(1).max(100).required(),
|
|
4124
|
+
superintendent: Joi10.string().hex().optional().allow(null, ""),
|
|
4125
|
+
superintendentName: Joi10.string().min(1).max(100).optional().allow(null, ""),
|
|
4126
|
+
createdAt: Joi10.string().isoDate().optional(),
|
|
4127
|
+
updatedAt: Joi10.string().isoDate().optional(),
|
|
4128
|
+
deletedAt: Joi10.string().isoDate().optional().allow(null, "")
|
|
4027
4129
|
});
|
|
4028
|
-
var schemaDivisionUpdate =
|
|
4029
|
-
_id:
|
|
4030
|
-
name:
|
|
4031
|
-
region:
|
|
4032
|
-
regionName:
|
|
4033
|
-
superintendent:
|
|
4034
|
-
superintendentName:
|
|
4130
|
+
var schemaDivisionUpdate = Joi10.object({
|
|
4131
|
+
_id: Joi10.string().hex().optional().allow(null, ""),
|
|
4132
|
+
name: Joi10.string().min(1).max(100).required(),
|
|
4133
|
+
region: Joi10.string().hex().required(),
|
|
4134
|
+
regionName: Joi10.string().min(1).max(100).required(),
|
|
4135
|
+
superintendent: Joi10.string().hex().optional().allow(null, ""),
|
|
4136
|
+
superintendentName: Joi10.string().min(1).max(100).optional().allow(null, "")
|
|
4035
4137
|
});
|
|
4036
4138
|
function modelDivision(value) {
|
|
4037
4139
|
const { error } = schemaDivision.validate(value);
|
|
@@ -4386,49 +4488,49 @@ import { useRoleRepo as useRoleRepo2 } from "@eeplatform/core";
|
|
|
4386
4488
|
|
|
4387
4489
|
// src/resources/school/school.model.ts
|
|
4388
4490
|
import { BadRequestError as BadRequestError16 } from "@eeplatform/nodejs-utils";
|
|
4389
|
-
import
|
|
4491
|
+
import Joi11 from "joi";
|
|
4390
4492
|
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:
|
|
4493
|
+
var schemaSchool = Joi11.object({
|
|
4494
|
+
_id: Joi11.string().hex().optional().allow(null, ""),
|
|
4495
|
+
id: Joi11.string().min(1).max(50).required(),
|
|
4496
|
+
name: Joi11.string().min(1).max(100).required(),
|
|
4497
|
+
region: Joi11.string().hex().required(),
|
|
4498
|
+
regionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4499
|
+
division: Joi11.string().hex().required(),
|
|
4500
|
+
divisionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4501
|
+
principal: Joi11.string().hex().optional().allow(null, ""),
|
|
4502
|
+
principalName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4503
|
+
street: Joi11.string().max(200).optional().allow(null, ""),
|
|
4504
|
+
barangay: Joi11.string().max(200).optional().allow(null, ""),
|
|
4505
|
+
cityMunicipality: Joi11.string().max(100).optional().allow(null, ""),
|
|
4506
|
+
province: Joi11.string().max(100).optional().allow(null, ""),
|
|
4507
|
+
cityMunicipalityPSGC: Joi11.string().length(10).optional().allow(null, ""),
|
|
4508
|
+
postalCode: Joi11.string().max(20).optional().allow(null, ""),
|
|
4509
|
+
contactNumber: Joi11.string().max(20).optional().allow(null, ""),
|
|
4510
|
+
email: Joi11.string().email().max(100).optional().allow(null, ""),
|
|
4511
|
+
status: Joi11.string().optional().allow(null, ""),
|
|
4512
|
+
createdBy: Joi11.string().optional().allow(null, ""),
|
|
4513
|
+
createdAt: Joi11.string().isoDate().optional().allow(null, ""),
|
|
4514
|
+
updatedAt: Joi11.string().isoDate().optional().allow(null, ""),
|
|
4515
|
+
deletedAt: Joi11.string().isoDate().optional().allow(null, "")
|
|
4414
4516
|
});
|
|
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:
|
|
4517
|
+
var schemaSchoolUpdate = Joi11.object({
|
|
4518
|
+
id: Joi11.string().min(1).max(50).required(),
|
|
4519
|
+
name: Joi11.string().min(1).max(100).required(),
|
|
4520
|
+
region: Joi11.string().hex().required(),
|
|
4521
|
+
regionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4522
|
+
division: Joi11.string().hex().required(),
|
|
4523
|
+
divisionName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4524
|
+
principal: Joi11.string().hex().optional().allow(null, ""),
|
|
4525
|
+
principalName: Joi11.string().min(1).max(100).optional().allow(null, ""),
|
|
4526
|
+
street: Joi11.string().max(200).optional().allow(null, ""),
|
|
4527
|
+
barangay: Joi11.string().max(200).optional().allow(null, ""),
|
|
4528
|
+
cityMunicipality: Joi11.string().max(100).optional().allow(null, ""),
|
|
4529
|
+
province: Joi11.string().max(100).optional().allow(null, ""),
|
|
4530
|
+
cityMunicipalityPSGC: Joi11.string().length(10).optional().allow(null, ""),
|
|
4531
|
+
postalCode: Joi11.string().max(20).optional().allow(null, ""),
|
|
4532
|
+
contactNumber: Joi11.string().max(20).optional().allow(null, ""),
|
|
4533
|
+
email: Joi11.string().email().max(100).optional().allow(null, "")
|
|
4432
4534
|
});
|
|
4433
4535
|
function modelSchool(value) {
|
|
4434
4536
|
const { error } = schemaSchool.validate(value);
|
|
@@ -33365,7 +33467,7 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
|
|
|
33365
33467
|
|
|
33366
33468
|
// src/resources/school/school.controller.ts
|
|
33367
33469
|
import { BadRequestError as BadRequestError19 } from "@eeplatform/nodejs-utils";
|
|
33368
|
-
import
|
|
33470
|
+
import Joi12 from "joi";
|
|
33369
33471
|
function useSchoolController() {
|
|
33370
33472
|
const {
|
|
33371
33473
|
getAll: _getAll,
|
|
@@ -33398,16 +33500,16 @@ function useSchoolController() {
|
|
|
33398
33500
|
}
|
|
33399
33501
|
}
|
|
33400
33502
|
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:
|
|
33503
|
+
const validation = Joi12.object({
|
|
33504
|
+
page: Joi12.number().optional().allow(null, ""),
|
|
33505
|
+
limit: Joi12.number().optional().allow(null, ""),
|
|
33506
|
+
sort: Joi12.string().optional().allow(null, ""),
|
|
33507
|
+
sortOrder: Joi12.string().optional().allow(null, ""),
|
|
33508
|
+
status: Joi12.string().optional().allow(null, ""),
|
|
33509
|
+
org: Joi12.string().hex().optional().allow(null, ""),
|
|
33510
|
+
app: Joi12.string().optional().allow(null, ""),
|
|
33511
|
+
search: Joi12.string().optional().allow(null, ""),
|
|
33512
|
+
psgc: Joi12.string().optional().allow(null, "")
|
|
33411
33513
|
});
|
|
33412
33514
|
const { error } = validation.validate(req.query);
|
|
33413
33515
|
if (error) {
|
|
@@ -33445,7 +33547,7 @@ function useSchoolController() {
|
|
|
33445
33547
|
}
|
|
33446
33548
|
async function getByCreatedBy(req, res, next) {
|
|
33447
33549
|
const createdBy = req.params.createdBy;
|
|
33448
|
-
const validation =
|
|
33550
|
+
const validation = Joi12.string().hex().required();
|
|
33449
33551
|
const { error } = validation.validate(createdBy);
|
|
33450
33552
|
if (error) {
|
|
33451
33553
|
next(new BadRequestError19(`Validation error: ${error.message}`));
|
|
@@ -33462,9 +33564,9 @@ function useSchoolController() {
|
|
|
33462
33564
|
async function updateStatusById(req, res, next) {
|
|
33463
33565
|
const schoolId = req.params.id;
|
|
33464
33566
|
const status = req.params.status;
|
|
33465
|
-
const validation =
|
|
33466
|
-
id:
|
|
33467
|
-
status:
|
|
33567
|
+
const validation = Joi12.object({
|
|
33568
|
+
id: Joi12.string().hex().required(),
|
|
33569
|
+
status: Joi12.string().valid("active", "deleted", "suspended").required()
|
|
33468
33570
|
});
|
|
33469
33571
|
const { error } = validation.validate({ id: schoolId, status });
|
|
33470
33572
|
if (error) {
|
|
@@ -33497,8 +33599,8 @@ function useSchoolController() {
|
|
|
33497
33599
|
}
|
|
33498
33600
|
async function approveSchool(req, res, next) {
|
|
33499
33601
|
const schoolId = req.params.id;
|
|
33500
|
-
const validation =
|
|
33501
|
-
id:
|
|
33602
|
+
const validation = Joi12.object({
|
|
33603
|
+
id: Joi12.string().hex().required()
|
|
33502
33604
|
});
|
|
33503
33605
|
const { error } = validation.validate({ id: schoolId });
|
|
33504
33606
|
if (error) {
|
|
@@ -33521,11 +33623,11 @@ function useSchoolController() {
|
|
|
33521
33623
|
return;
|
|
33522
33624
|
}
|
|
33523
33625
|
const { region, regionName, division, divisionName } = req.body;
|
|
33524
|
-
const validation =
|
|
33525
|
-
region:
|
|
33526
|
-
regionName:
|
|
33527
|
-
division:
|
|
33528
|
-
divisionName:
|
|
33626
|
+
const validation = Joi12.object({
|
|
33627
|
+
region: Joi12.string().hex().required(),
|
|
33628
|
+
regionName: Joi12.string().min(1).required(),
|
|
33629
|
+
division: Joi12.string().hex().required(),
|
|
33630
|
+
divisionName: Joi12.string().min(1).required()
|
|
33529
33631
|
});
|
|
33530
33632
|
const { error } = validation.validate({
|
|
33531
33633
|
region,
|
|
@@ -33554,10 +33656,10 @@ function useSchoolController() {
|
|
|
33554
33656
|
async function updateFieldById(req, res, next) {
|
|
33555
33657
|
const _id = req.params.id;
|
|
33556
33658
|
const { field, value } = req.body;
|
|
33557
|
-
const validation =
|
|
33558
|
-
_id:
|
|
33559
|
-
field:
|
|
33560
|
-
value:
|
|
33659
|
+
const validation = Joi12.object({
|
|
33660
|
+
_id: Joi12.string().hex().required(),
|
|
33661
|
+
field: Joi12.string().valid("name", "director", "directorName").required(),
|
|
33662
|
+
value: Joi12.string().required()
|
|
33561
33663
|
});
|
|
33562
33664
|
const { error } = validation.validate({ _id, field, value });
|
|
33563
33665
|
if (error) {
|
|
@@ -33575,8 +33677,8 @@ function useSchoolController() {
|
|
|
33575
33677
|
async function updateById(req, res, next) {
|
|
33576
33678
|
const id = req.params.id;
|
|
33577
33679
|
const payload = req.body;
|
|
33578
|
-
const validation =
|
|
33579
|
-
id:
|
|
33680
|
+
const validation = Joi12.object({
|
|
33681
|
+
id: Joi12.string().hex().required()
|
|
33580
33682
|
});
|
|
33581
33683
|
const { error: idError } = validation.validate({ id });
|
|
33582
33684
|
if (idError) {
|
|
@@ -33598,8 +33700,8 @@ function useSchoolController() {
|
|
|
33598
33700
|
}
|
|
33599
33701
|
async function deleteById(req, res, next) {
|
|
33600
33702
|
const _id = req.params.id;
|
|
33601
|
-
const validation =
|
|
33602
|
-
_id:
|
|
33703
|
+
const validation = Joi12.object({
|
|
33704
|
+
_id: Joi12.string().hex().required()
|
|
33603
33705
|
});
|
|
33604
33706
|
const { error } = validation.validate({ _id });
|
|
33605
33707
|
if (error) {
|
|
@@ -33694,7 +33796,7 @@ function useDivisionService() {
|
|
|
33694
33796
|
|
|
33695
33797
|
// src/resources/division/division.controller.ts
|
|
33696
33798
|
import { BadRequestError as BadRequestError20 } from "@eeplatform/nodejs-utils";
|
|
33697
|
-
import
|
|
33799
|
+
import Joi13 from "joi";
|
|
33698
33800
|
function useDivisionController() {
|
|
33699
33801
|
const { add: _add, updateById: _updateById } = useDivisionService();
|
|
33700
33802
|
const {
|
|
@@ -33724,12 +33826,12 @@ function useDivisionController() {
|
|
|
33724
33826
|
}
|
|
33725
33827
|
async function getAll(req, res, next) {
|
|
33726
33828
|
const query = req.query;
|
|
33727
|
-
const validation =
|
|
33728
|
-
page:
|
|
33729
|
-
limit:
|
|
33730
|
-
search:
|
|
33731
|
-
status:
|
|
33732
|
-
region:
|
|
33829
|
+
const validation = Joi13.object({
|
|
33830
|
+
page: Joi13.number().min(1).optional().allow("", null),
|
|
33831
|
+
limit: Joi13.number().min(1).optional().allow("", null),
|
|
33832
|
+
search: Joi13.string().optional().allow("", null),
|
|
33833
|
+
status: Joi13.string().optional().allow("", null),
|
|
33834
|
+
region: Joi13.string().hex().optional().allow("", null)
|
|
33733
33835
|
});
|
|
33734
33836
|
const { error } = validation.validate(query);
|
|
33735
33837
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -33761,8 +33863,8 @@ function useDivisionController() {
|
|
|
33761
33863
|
}
|
|
33762
33864
|
async function getById(req, res, next) {
|
|
33763
33865
|
const id = req.params.id;
|
|
33764
|
-
const validation =
|
|
33765
|
-
id:
|
|
33866
|
+
const validation = Joi13.object({
|
|
33867
|
+
id: Joi13.string().hex().required()
|
|
33766
33868
|
});
|
|
33767
33869
|
const { error } = validation.validate({ id });
|
|
33768
33870
|
if (error) {
|
|
@@ -33782,8 +33884,8 @@ function useDivisionController() {
|
|
|
33782
33884
|
}
|
|
33783
33885
|
async function getByName(req, res, next) {
|
|
33784
33886
|
const name = req.params.name;
|
|
33785
|
-
const validation =
|
|
33786
|
-
name:
|
|
33887
|
+
const validation = Joi13.object({
|
|
33888
|
+
name: Joi13.string().required()
|
|
33787
33889
|
});
|
|
33788
33890
|
const { error } = validation.validate({ name });
|
|
33789
33891
|
if (error) {
|
|
@@ -33804,10 +33906,10 @@ function useDivisionController() {
|
|
|
33804
33906
|
async function updateField(req, res, next) {
|
|
33805
33907
|
const _id = req.params.id;
|
|
33806
33908
|
const { field, value } = req.body;
|
|
33807
|
-
const validation =
|
|
33808
|
-
_id:
|
|
33809
|
-
field:
|
|
33810
|
-
value:
|
|
33909
|
+
const validation = Joi13.object({
|
|
33910
|
+
_id: Joi13.string().hex().required(),
|
|
33911
|
+
field: Joi13.string().valid("name", "director", "directorName").required(),
|
|
33912
|
+
value: Joi13.string().required()
|
|
33811
33913
|
});
|
|
33812
33914
|
const { error } = validation.validate({ _id, field, value });
|
|
33813
33915
|
if (error) {
|
|
@@ -33840,8 +33942,8 @@ function useDivisionController() {
|
|
|
33840
33942
|
}
|
|
33841
33943
|
async function deleteById(req, res, next) {
|
|
33842
33944
|
const _id = req.params.id;
|
|
33843
|
-
const validation =
|
|
33844
|
-
_id:
|
|
33945
|
+
const validation = Joi13.object({
|
|
33946
|
+
_id: Joi13.string().hex().required()
|
|
33845
33947
|
});
|
|
33846
33948
|
const { error } = validation.validate({ _id });
|
|
33847
33949
|
if (error) {
|
|
@@ -33869,48 +33971,48 @@ function useDivisionController() {
|
|
|
33869
33971
|
|
|
33870
33972
|
// src/resources/asset/asset.model.ts
|
|
33871
33973
|
import { BadRequestError as BadRequestError21 } from "@eeplatform/nodejs-utils";
|
|
33872
|
-
import
|
|
33974
|
+
import Joi14 from "joi";
|
|
33873
33975
|
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:
|
|
33976
|
+
var schemaAsset = Joi14.object({
|
|
33977
|
+
_id: Joi14.string().hex().optional(),
|
|
33978
|
+
school: Joi14.string().hex().required(),
|
|
33979
|
+
asset_type: Joi14.string().required().allow("supply", "furniture-equipment", "fixed-asset"),
|
|
33980
|
+
name: Joi14.string().required(),
|
|
33981
|
+
category: Joi14.string().optional().allow("", null),
|
|
33982
|
+
type: Joi14.string().optional().allow("", null),
|
|
33983
|
+
brand: Joi14.string().optional().allow("", null),
|
|
33984
|
+
unit: Joi14.string().required(),
|
|
33985
|
+
status: Joi14.string().optional().allow("", null),
|
|
33986
|
+
createdAt: Joi14.date().optional().allow("", null),
|
|
33987
|
+
updatedAt: Joi14.date().optional().allow("", null),
|
|
33988
|
+
deletedAt: Joi14.date().optional().allow("", null),
|
|
33989
|
+
metadata: Joi14.object({
|
|
33990
|
+
title: Joi14.string().optional().allow("", null),
|
|
33991
|
+
isbn: Joi14.string().optional().allow("", null),
|
|
33992
|
+
author: Joi14.string().optional().allow("", null),
|
|
33993
|
+
edition: Joi14.string().optional().allow("", null),
|
|
33994
|
+
subject: Joi14.string().optional().allow("", null),
|
|
33995
|
+
grade_level: Joi14.number().integer().min(0).optional().allow("", null),
|
|
33996
|
+
publisher: Joi14.string().optional().allow("", null),
|
|
33997
|
+
language: Joi14.string().optional().allow("", null)
|
|
33896
33998
|
}).optional().allow(null)
|
|
33897
33999
|
});
|
|
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:
|
|
34000
|
+
var schemaAssetUpdateOption = Joi14.object({
|
|
34001
|
+
name: Joi14.string().optional().allow("", null),
|
|
34002
|
+
category: Joi14.string().optional().allow("", null),
|
|
34003
|
+
type: Joi14.string().optional().allow("", null),
|
|
34004
|
+
brand: Joi14.string().optional().allow("", null),
|
|
34005
|
+
qty: Joi14.number().integer().min(0).optional().allow("", null),
|
|
34006
|
+
unit: Joi14.string().optional().allow("", null),
|
|
34007
|
+
metadata: Joi14.object({
|
|
34008
|
+
title: Joi14.string().optional().allow("", null),
|
|
34009
|
+
isbn: Joi14.string().optional().allow("", null),
|
|
34010
|
+
author: Joi14.string().optional().allow("", null),
|
|
34011
|
+
edition: Joi14.string().optional().allow("", null),
|
|
34012
|
+
subject: Joi14.string().optional().allow("", null),
|
|
34013
|
+
grade_level: Joi14.number().integer().min(0).optional().allow("", null),
|
|
34014
|
+
publisher: Joi14.string().optional().allow("", null),
|
|
34015
|
+
language: Joi14.string().optional().allow("", null)
|
|
33914
34016
|
}).optional().allow(null)
|
|
33915
34017
|
});
|
|
33916
34018
|
function MAsset(value) {
|
|
@@ -34349,7 +34451,7 @@ function useAssetRepo() {
|
|
|
34349
34451
|
|
|
34350
34452
|
// src/resources/asset/asset.controller.ts
|
|
34351
34453
|
import { BadRequestError as BadRequestError23 } from "@eeplatform/nodejs-utils";
|
|
34352
|
-
import
|
|
34454
|
+
import Joi15 from "joi";
|
|
34353
34455
|
function useAssetController() {
|
|
34354
34456
|
const {
|
|
34355
34457
|
add: _add,
|
|
@@ -34377,13 +34479,13 @@ function useAssetController() {
|
|
|
34377
34479
|
}
|
|
34378
34480
|
async function getAll(req, res, next) {
|
|
34379
34481
|
const query = req.query;
|
|
34380
|
-
const validation =
|
|
34381
|
-
page:
|
|
34382
|
-
limit:
|
|
34383
|
-
search:
|
|
34384
|
-
status:
|
|
34385
|
-
school:
|
|
34386
|
-
asset_type:
|
|
34482
|
+
const validation = Joi15.object({
|
|
34483
|
+
page: Joi15.number().min(1).optional().allow("", null),
|
|
34484
|
+
limit: Joi15.number().min(1).optional().allow("", null),
|
|
34485
|
+
search: Joi15.string().optional().allow("", null),
|
|
34486
|
+
status: Joi15.string().optional().allow("", null),
|
|
34487
|
+
school: Joi15.string().hex().optional().allow("", null),
|
|
34488
|
+
asset_type: Joi15.string().required().allow("supply", "furniture-equipment", "fixed-asset")
|
|
34387
34489
|
});
|
|
34388
34490
|
const { error } = validation.validate(query);
|
|
34389
34491
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -34423,7 +34525,7 @@ function useAssetController() {
|
|
|
34423
34525
|
}
|
|
34424
34526
|
async function deleteById(req, res, next) {
|
|
34425
34527
|
const id = req.params.id;
|
|
34426
|
-
const validation =
|
|
34528
|
+
const validation = Joi15.string().hex().required();
|
|
34427
34529
|
const { error } = validation.validate(id);
|
|
34428
34530
|
if (error) {
|
|
34429
34531
|
next(new BadRequestError23(error.message));
|
|
@@ -34438,7 +34540,7 @@ function useAssetController() {
|
|
|
34438
34540
|
}
|
|
34439
34541
|
async function getById(req, res, next) {
|
|
34440
34542
|
const id = req.params.id;
|
|
34441
|
-
const validation =
|
|
34543
|
+
const validation = Joi15.string().hex().required();
|
|
34442
34544
|
const { error } = validation.validate(id);
|
|
34443
34545
|
if (error) {
|
|
34444
34546
|
next(new BadRequestError23(error.message));
|
|
@@ -34469,7 +34571,7 @@ function useAssetController() {
|
|
|
34469
34571
|
async function getCategories(req, res, next) {
|
|
34470
34572
|
const school = req.params.school;
|
|
34471
34573
|
const asset_type = req.params.asset_type;
|
|
34472
|
-
const validation =
|
|
34574
|
+
const validation = Joi15.string().hex().required();
|
|
34473
34575
|
const { error } = validation.validate(school);
|
|
34474
34576
|
if (error) {
|
|
34475
34577
|
next(new BadRequestError23(error.message));
|
|
@@ -34485,7 +34587,7 @@ function useAssetController() {
|
|
|
34485
34587
|
async function getTypes(req, res, next) {
|
|
34486
34588
|
const school = req.params.school;
|
|
34487
34589
|
const asset_type = req.params.asset_type;
|
|
34488
|
-
const validation =
|
|
34590
|
+
const validation = Joi15.string().hex().required();
|
|
34489
34591
|
const { error } = validation.validate(school);
|
|
34490
34592
|
if (error) {
|
|
34491
34593
|
next(new BadRequestError23(error.message));
|
|
@@ -34500,7 +34602,7 @@ function useAssetController() {
|
|
|
34500
34602
|
}
|
|
34501
34603
|
async function getUnitsBySchool(req, res, next) {
|
|
34502
34604
|
const school = req.params.school;
|
|
34503
|
-
const validation =
|
|
34605
|
+
const validation = Joi15.string().hex().required();
|
|
34504
34606
|
const { error } = validation.validate(school);
|
|
34505
34607
|
if (error) {
|
|
34506
34608
|
next(new BadRequestError23(error.message));
|
|
@@ -34527,26 +34629,26 @@ function useAssetController() {
|
|
|
34527
34629
|
|
|
34528
34630
|
// src/resources/stock-card/stock-card.model.ts
|
|
34529
34631
|
import { BadRequestError as BadRequestError24 } from "@eeplatform/nodejs-utils";
|
|
34530
|
-
import
|
|
34632
|
+
import Joi16 from "joi";
|
|
34531
34633
|
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:
|
|
34634
|
+
var schemaStockCard = Joi16.object({
|
|
34635
|
+
_id: Joi16.string().hex().optional().allow("", null),
|
|
34636
|
+
school: Joi16.string().hex().required(),
|
|
34637
|
+
item: Joi16.string().hex().required(),
|
|
34638
|
+
balance: Joi16.number().optional().allow(null, 0),
|
|
34639
|
+
qty: Joi16.number().required(),
|
|
34640
|
+
unitCost: Joi16.number().optional().allow(null, 0),
|
|
34641
|
+
totalCost: Joi16.number().optional().allow(null, 0),
|
|
34642
|
+
status: Joi16.string().optional().allow(null, ""),
|
|
34643
|
+
condition: Joi16.string().required(),
|
|
34644
|
+
supplier: Joi16.string().optional().allow("", null),
|
|
34645
|
+
location: Joi16.string().optional().allow("", null),
|
|
34646
|
+
locationName: Joi16.string().optional().allow("", null),
|
|
34647
|
+
reason: Joi16.string().optional().allow("", null),
|
|
34648
|
+
remarks: Joi16.string().optional().allow("", null),
|
|
34649
|
+
createdAt: Joi16.date().optional().allow("", null),
|
|
34650
|
+
updatedAt: Joi16.date().optional().allow("", null),
|
|
34651
|
+
deletedAt: Joi16.date().optional().allow("", null)
|
|
34550
34652
|
});
|
|
34551
34653
|
function MStockCard(value) {
|
|
34552
34654
|
const { error } = schemaStockCard.validate(value);
|
|
@@ -34845,7 +34947,7 @@ function useStockCardService() {
|
|
|
34845
34947
|
|
|
34846
34948
|
// src/resources/stock-card/stock-card.controller.ts
|
|
34847
34949
|
import { BadRequestError as BadRequestError27 } from "@eeplatform/nodejs-utils";
|
|
34848
|
-
import
|
|
34950
|
+
import Joi17 from "joi";
|
|
34849
34951
|
function useStockCardController() {
|
|
34850
34952
|
const {
|
|
34851
34953
|
getAll: _getAll,
|
|
@@ -34869,11 +34971,11 @@ function useStockCardController() {
|
|
|
34869
34971
|
}
|
|
34870
34972
|
async function getAll(req, res, next) {
|
|
34871
34973
|
const query = req.query;
|
|
34872
|
-
const validation =
|
|
34873
|
-
page:
|
|
34874
|
-
limit:
|
|
34875
|
-
school:
|
|
34876
|
-
id:
|
|
34974
|
+
const validation = Joi17.object({
|
|
34975
|
+
page: Joi17.number().min(1).optional().allow("", null),
|
|
34976
|
+
limit: Joi17.number().min(1).optional().allow("", null),
|
|
34977
|
+
school: Joi17.string().hex().optional().allow("", null),
|
|
34978
|
+
id: Joi17.string().hex().required()
|
|
34877
34979
|
});
|
|
34878
34980
|
const { error } = validation.validate(query);
|
|
34879
34981
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -34909,7 +35011,7 @@ function useStockCardController() {
|
|
|
34909
35011
|
}
|
|
34910
35012
|
async function getById(req, res, next) {
|
|
34911
35013
|
const id = req.params.id;
|
|
34912
|
-
const validation =
|
|
35014
|
+
const validation = Joi17.string().hex().required();
|
|
34913
35015
|
const { error } = validation.validate(id);
|
|
34914
35016
|
if (error) {
|
|
34915
35017
|
next(new BadRequestError27(error.message));
|
|
@@ -34924,7 +35026,7 @@ function useStockCardController() {
|
|
|
34924
35026
|
}
|
|
34925
35027
|
async function getSuppliers(req, res, next) {
|
|
34926
35028
|
const school = req.params.school;
|
|
34927
|
-
const validation =
|
|
35029
|
+
const validation = Joi17.string().hex().required();
|
|
34928
35030
|
const { error } = validation.validate(school);
|
|
34929
35031
|
if (error) {
|
|
34930
35032
|
next(new BadRequestError27(error.message));
|
|
@@ -34947,30 +35049,30 @@ function useStockCardController() {
|
|
|
34947
35049
|
|
|
34948
35050
|
// src/resources/plantilla/plantilla.model.ts
|
|
34949
35051
|
import { BadRequestError as BadRequestError28 } from "@eeplatform/nodejs-utils";
|
|
34950
|
-
import
|
|
35052
|
+
import Joi18 from "joi";
|
|
34951
35053
|
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:
|
|
35054
|
+
var schemaPlantilla = Joi18.object({
|
|
35055
|
+
_id: Joi18.string().hex().optional().allow(null, ""),
|
|
35056
|
+
org: Joi18.string().hex().required(),
|
|
35057
|
+
orgUnitCode: Joi18.string().optional().allow(null, ""),
|
|
35058
|
+
employmentType: Joi18.string().optional().allow(null, ""),
|
|
35059
|
+
personnelType: Joi18.string().required(),
|
|
35060
|
+
itemNumber: Joi18.string().required(),
|
|
35061
|
+
positionTitle: Joi18.string().required(),
|
|
35062
|
+
positionCategory: Joi18.string().required(),
|
|
35063
|
+
region: Joi18.string().hex().optional().allow(null, ""),
|
|
35064
|
+
regionName: Joi18.string().optional().allow(null, ""),
|
|
35065
|
+
division: Joi18.string().hex().optional().allow(null, ""),
|
|
35066
|
+
divisionName: Joi18.string().optional().allow(null, ""),
|
|
35067
|
+
salaryGrade: Joi18.number().required(),
|
|
35068
|
+
employeeName: Joi18.string().optional().allow(null, ""),
|
|
35069
|
+
annualSalary: Joi18.number().optional().allow(null, 0),
|
|
35070
|
+
monthlySalary: Joi18.number().optional().allow(null, 0),
|
|
35071
|
+
status: Joi18.string().required(),
|
|
35072
|
+
employee: Joi18.string().hex().optional().allow(null, ""),
|
|
35073
|
+
createdAt: Joi18.date().iso().optional().allow(null, ""),
|
|
35074
|
+
updatedAt: Joi18.date().iso().optional().allow(null, ""),
|
|
35075
|
+
deletedAt: Joi18.date().iso().optional().allow(null, "")
|
|
34974
35076
|
});
|
|
34975
35077
|
function MPlantilla(data) {
|
|
34976
35078
|
const { error } = schemaPlantilla.validate(data);
|
|
@@ -35461,7 +35563,7 @@ ${errors.slice(0, 10).join("\n")}${errors.length > 10 ? `
|
|
|
35461
35563
|
|
|
35462
35564
|
// src/resources/plantilla/plantilla.controller.ts
|
|
35463
35565
|
import { BadRequestError as BadRequestError31 } from "@eeplatform/nodejs-utils";
|
|
35464
|
-
import
|
|
35566
|
+
import Joi19 from "joi";
|
|
35465
35567
|
function usePlantillaController() {
|
|
35466
35568
|
const {
|
|
35467
35569
|
add: _addPlantilla,
|
|
@@ -35473,11 +35575,11 @@ function usePlantillaController() {
|
|
|
35473
35575
|
const { addBulk: _addBulk } = usePlantillaService();
|
|
35474
35576
|
async function createPlantilla(req, res, next) {
|
|
35475
35577
|
const value = req.body;
|
|
35476
|
-
const validation =
|
|
35477
|
-
itemNumber:
|
|
35478
|
-
positionTitle:
|
|
35479
|
-
positionCategory:
|
|
35480
|
-
status:
|
|
35578
|
+
const validation = Joi19.object({
|
|
35579
|
+
itemNumber: Joi19.string().required(),
|
|
35580
|
+
positionTitle: Joi19.string().required(),
|
|
35581
|
+
positionCategory: Joi19.string().required(),
|
|
35582
|
+
status: Joi19.string().required()
|
|
35481
35583
|
});
|
|
35482
35584
|
const { error } = validation.validate(value);
|
|
35483
35585
|
if (error) {
|
|
@@ -35507,11 +35609,11 @@ function usePlantillaController() {
|
|
|
35507
35609
|
next(new BadRequestError31("Invalid limit number."));
|
|
35508
35610
|
return;
|
|
35509
35611
|
}
|
|
35510
|
-
const validation =
|
|
35511
|
-
page:
|
|
35512
|
-
limit:
|
|
35513
|
-
search:
|
|
35514
|
-
org:
|
|
35612
|
+
const validation = Joi19.object({
|
|
35613
|
+
page: Joi19.number().min(1).optional().allow("", null),
|
|
35614
|
+
limit: Joi19.number().min(1).optional().allow("", null),
|
|
35615
|
+
search: Joi19.string().optional().allow("", null),
|
|
35616
|
+
org: Joi19.string().optional().allow("", null)
|
|
35515
35617
|
});
|
|
35516
35618
|
const { error } = validation.validate({ page, limit, search, org });
|
|
35517
35619
|
if (error) {
|
|
@@ -35533,8 +35635,8 @@ function usePlantillaController() {
|
|
|
35533
35635
|
}
|
|
35534
35636
|
async function getPlantillaById(req, res, next) {
|
|
35535
35637
|
const id = req.params.id;
|
|
35536
|
-
const validation =
|
|
35537
|
-
id:
|
|
35638
|
+
const validation = Joi19.object({
|
|
35639
|
+
id: Joi19.string().hex().required()
|
|
35538
35640
|
});
|
|
35539
35641
|
const { error } = validation.validate({ id });
|
|
35540
35642
|
if (error) {
|
|
@@ -35556,12 +35658,12 @@ function usePlantillaController() {
|
|
|
35556
35658
|
async function updatePlantilla(req, res, next) {
|
|
35557
35659
|
const id = req.params.id;
|
|
35558
35660
|
const value = req.body;
|
|
35559
|
-
const validation =
|
|
35560
|
-
id:
|
|
35561
|
-
employee:
|
|
35562
|
-
status:
|
|
35563
|
-
positionTitle:
|
|
35564
|
-
positionCategory:
|
|
35661
|
+
const validation = Joi19.object({
|
|
35662
|
+
id: Joi19.string().hex().required(),
|
|
35663
|
+
employee: Joi19.string().hex().optional().allow(null, ""),
|
|
35664
|
+
status: Joi19.string().optional(),
|
|
35665
|
+
positionTitle: Joi19.string().optional(),
|
|
35666
|
+
positionCategory: Joi19.string().optional()
|
|
35565
35667
|
});
|
|
35566
35668
|
const { error } = validation.validate({ id, ...value });
|
|
35567
35669
|
if (error) {
|
|
@@ -35582,8 +35684,8 @@ function usePlantillaController() {
|
|
|
35582
35684
|
}
|
|
35583
35685
|
async function deletePlantilla(req, res, next) {
|
|
35584
35686
|
const id = req.params.id;
|
|
35585
|
-
const validation =
|
|
35586
|
-
id:
|
|
35687
|
+
const validation = Joi19.object({
|
|
35688
|
+
id: Joi19.string().hex().required()
|
|
35587
35689
|
});
|
|
35588
35690
|
const { error } = validation.validate({ id });
|
|
35589
35691
|
if (error) {
|
|
@@ -35608,9 +35710,9 @@ function usePlantillaController() {
|
|
|
35608
35710
|
return;
|
|
35609
35711
|
}
|
|
35610
35712
|
const { region, division } = req.body;
|
|
35611
|
-
const validation =
|
|
35612
|
-
region:
|
|
35613
|
-
division:
|
|
35713
|
+
const validation = Joi19.object({
|
|
35714
|
+
region: Joi19.string().hex().optional(),
|
|
35715
|
+
division: Joi19.string().hex().optional()
|
|
35614
35716
|
});
|
|
35615
35717
|
const { error } = validation.validate({ region, division });
|
|
35616
35718
|
if (error) {
|