@eeplatform/basic-edu 1.3.9 → 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 +12 -0
- package/dist/index.d.ts +51 -35
- package/dist/index.js +597 -490
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +597 -490
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1844,7 +1844,7 @@ var addressSchema = import_joi3.default.object({
|
|
|
1844
1844
|
sitio: import_joi3.default.string().optional().allow("", null),
|
|
1845
1845
|
barangay: import_joi3.default.string().required(),
|
|
1846
1846
|
municipalityCity: import_joi3.default.string().required(),
|
|
1847
|
-
province: import_joi3.default.string().
|
|
1847
|
+
province: import_joi3.default.string().optional().allow("", null),
|
|
1848
1848
|
country: import_joi3.default.string().optional().allow("", null),
|
|
1849
1849
|
zipCode: import_joi3.default.string().optional().allow("", null)
|
|
1850
1850
|
});
|
|
@@ -1855,93 +1855,98 @@ var personContactSchema = import_joi3.default.object({
|
|
|
1855
1855
|
contactNumber: import_joi3.default.string().optional().allow("", null)
|
|
1856
1856
|
});
|
|
1857
1857
|
var learnerInfoSchema = import_joi3.default.object({
|
|
1858
|
+
psaBirthCertificateNo: import_joi3.default.string().optional().allow("", null),
|
|
1858
1859
|
lrn: import_joi3.default.string().optional().allow("", null),
|
|
1859
1860
|
lastName: import_joi3.default.string().required(),
|
|
1860
1861
|
firstName: import_joi3.default.string().required(),
|
|
1861
1862
|
middleName: import_joi3.default.string().optional().allow("", null),
|
|
1862
1863
|
extensionName: import_joi3.default.string().optional().allow("", null),
|
|
1863
|
-
birthDate: import_joi3.default.string().
|
|
1864
|
-
sex: import_joi3.default.string().
|
|
1864
|
+
birthDate: import_joi3.default.string().required(),
|
|
1865
|
+
sex: import_joi3.default.string().required(),
|
|
1866
|
+
// Changed to accept any string to match frontend
|
|
1865
1867
|
age: import_joi3.default.number().integer().min(0).max(150).required(),
|
|
1866
|
-
placeOfBirth: import_joi3.default.
|
|
1867
|
-
|
|
1868
|
-
province: import_joi3.default.string().optional().allow("", null),
|
|
1869
|
-
country: import_joi3.default.string().optional().allow("", null)
|
|
1870
|
-
}).optional(),
|
|
1868
|
+
placeOfBirth: import_joi3.default.string().required(),
|
|
1869
|
+
// Made required to match frontend
|
|
1871
1870
|
motherTongue: import_joi3.default.string().optional().allow("", null),
|
|
1872
|
-
|
|
1873
|
-
disabilityTypes: import_joi3.default.array().items(
|
|
1874
|
-
import_joi3.default.string().valid(
|
|
1875
|
-
"Visual Impairment",
|
|
1876
|
-
"Visual Impairment(Blind)",
|
|
1877
|
-
"Visual Impairment(Low Vision)",
|
|
1878
|
-
"Hearing Impairment",
|
|
1879
|
-
"Learning Disability",
|
|
1880
|
-
"Intellectual Disability",
|
|
1881
|
-
"Autism Spectrum Disorder",
|
|
1882
|
-
"Emotional-Behavioral Disorder",
|
|
1883
|
-
"Orthopedic/Physical Handicap",
|
|
1884
|
-
"Speech/Language Disorder",
|
|
1885
|
-
"Cerebral Palsy",
|
|
1886
|
-
"Special Health Problem/Chronic Disease",
|
|
1887
|
-
"Multiple Disorder",
|
|
1888
|
-
"Cancer"
|
|
1889
|
-
)
|
|
1890
|
-
).optional(),
|
|
1891
|
-
otherDisabilityDetails: import_joi3.default.string().optional().allow("", null),
|
|
1892
|
-
isIndigenous: import_joi3.default.boolean().optional(),
|
|
1871
|
+
fourPsHouseholdId: import_joi3.default.string().optional().allow("", null),
|
|
1893
1872
|
indigenousCommunity: import_joi3.default.string().optional().allow("", null),
|
|
1894
|
-
|
|
1895
|
-
|
|
1873
|
+
withDisability: import_joi3.default.boolean().required(),
|
|
1874
|
+
// Added to match frontend
|
|
1875
|
+
disabilities: import_joi3.default.array().items(import_joi3.default.string()).optional(),
|
|
1876
|
+
// Changed from disabilityTypes to disabilities
|
|
1877
|
+
otherDisabilityDetails: import_joi3.default.string().optional().allow("", null)
|
|
1896
1878
|
});
|
|
1879
|
+
var gradeLevels = [
|
|
1880
|
+
"K1",
|
|
1881
|
+
"K2",
|
|
1882
|
+
"grade-1",
|
|
1883
|
+
"grade-2",
|
|
1884
|
+
"grade-3",
|
|
1885
|
+
"grade-4",
|
|
1886
|
+
"grade-5",
|
|
1887
|
+
"grade-6",
|
|
1888
|
+
"grade-7",
|
|
1889
|
+
"grade-8",
|
|
1890
|
+
"grade-9",
|
|
1891
|
+
"grade-10",
|
|
1892
|
+
"grade-11",
|
|
1893
|
+
"grade-12"
|
|
1894
|
+
];
|
|
1897
1895
|
var schemaEnrollment = import_joi3.default.object({
|
|
1898
|
-
_id: import_joi3.default.string().
|
|
1899
|
-
region: import_joi3.default.string().
|
|
1900
|
-
|
|
1901
|
-
|
|
1896
|
+
_id: import_joi3.default.string().optional(),
|
|
1897
|
+
region: import_joi3.default.string().required(),
|
|
1898
|
+
// Changed from hex to string to match frontend
|
|
1899
|
+
regionName: import_joi3.default.string().optional().allow("", null),
|
|
1900
|
+
province: import_joi3.default.string().optional().allow("", null),
|
|
1901
|
+
// Made required to match frontend
|
|
1902
|
+
cityMunicipality: import_joi3.default.string().required(),
|
|
1903
|
+
// Made required to match frontend
|
|
1904
|
+
division: import_joi3.default.string().required(),
|
|
1905
|
+
// Changed from hex to string to match frontend
|
|
1906
|
+
divisionName: import_joi3.default.string().optional().allow("", null),
|
|
1907
|
+
school: import_joi3.default.string().required(),
|
|
1908
|
+
// Changed from hex to string to match frontend
|
|
1909
|
+
schoolName: import_joi3.default.string().optional().allow("", null),
|
|
1910
|
+
// Added to match frontend
|
|
1902
1911
|
schoolYear: import_joi3.default.string().required(),
|
|
1903
|
-
|
|
1912
|
+
gradeLevel: import_joi3.default.string().valid(...gradeLevels).required(),
|
|
1913
|
+
returningLearner: import_joi3.default.boolean().required(),
|
|
1914
|
+
// Added to match frontend
|
|
1904
1915
|
learnerInfo: learnerInfoSchema.required(),
|
|
1905
1916
|
parentGuardianInfo: import_joi3.default.object({
|
|
1906
|
-
father: personContactSchema.
|
|
1907
|
-
|
|
1908
|
-
|
|
1917
|
+
father: personContactSchema.required(),
|
|
1918
|
+
// Made required to match frontend
|
|
1919
|
+
mother: personContactSchema.required(),
|
|
1920
|
+
// Made required to match frontend
|
|
1921
|
+
legalGuardian: personContactSchema.required()
|
|
1922
|
+
// Made required to match frontend
|
|
1909
1923
|
}).required(),
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1924
|
+
address: import_joi3.default.object({
|
|
1925
|
+
// Changed from addressInfo to address
|
|
1926
|
+
current: addressSchema.required(),
|
|
1927
|
+
// Changed from currentAddress to current
|
|
1928
|
+
permanent: addressSchema.required(),
|
|
1929
|
+
// Changed from permanentAddress to permanent and made required
|
|
1913
1930
|
sameAsCurrent: import_joi3.default.boolean().optional()
|
|
1914
1931
|
}).required(),
|
|
1915
1932
|
returningLearnerInfo: import_joi3.default.object({
|
|
1916
|
-
lastGradeLevelCompleted: import_joi3.default.string().
|
|
1917
|
-
lastSchoolYearCompleted: import_joi3.default.string().
|
|
1918
|
-
lastSchoolAttended: import_joi3.default.string().
|
|
1919
|
-
lastSchoolId: import_joi3.default.string().optional().allow("", null)
|
|
1920
|
-
isReturningLearner: import_joi3.default.boolean().required(),
|
|
1921
|
-
isTransferIn: import_joi3.default.boolean().required()
|
|
1933
|
+
lastGradeLevelCompleted: import_joi3.default.string().optional().allow("", null),
|
|
1934
|
+
lastSchoolYearCompleted: import_joi3.default.string().optional().allow("", null),
|
|
1935
|
+
lastSchoolAttended: import_joi3.default.string().optional().allow("", null),
|
|
1936
|
+
lastSchoolId: import_joi3.default.string().optional().allow("", null)
|
|
1922
1937
|
}).optional(),
|
|
1923
1938
|
seniorHighInfo: import_joi3.default.object({
|
|
1924
|
-
semester: import_joi3.default.string().
|
|
1925
|
-
track: import_joi3.default.string().
|
|
1926
|
-
strand: import_joi3.default.string().
|
|
1939
|
+
semester: import_joi3.default.string().optional().allow("", null),
|
|
1940
|
+
track: import_joi3.default.string().optional().allow("", null),
|
|
1941
|
+
strand: import_joi3.default.string().optional().allow("", null)
|
|
1927
1942
|
}).optional(),
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
"Online",
|
|
1933
|
-
"Radio-Based Instruction",
|
|
1934
|
-
"Educational Television",
|
|
1935
|
-
"Blended",
|
|
1936
|
-
"Homeschooling"
|
|
1937
|
-
)
|
|
1938
|
-
).optional(),
|
|
1939
|
-
certification: import_joi3.default.object({
|
|
1940
|
-
certifiedBy: import_joi3.default.string().required(),
|
|
1941
|
-
date: import_joi3.default.string().isoDate().required(),
|
|
1942
|
-
consentGiven: import_joi3.default.boolean().required()
|
|
1943
|
-
}).required(),
|
|
1943
|
+
alternativeLearningOptions: import_joi3.default.array().items(import_joi3.default.string()).optional(),
|
|
1944
|
+
// Added to match frontend
|
|
1945
|
+
isCertifiedAndConsented: import_joi3.default.boolean().required(),
|
|
1946
|
+
// Simplified certification to match frontend
|
|
1944
1947
|
status: import_joi3.default.string().optional().allow("", null),
|
|
1948
|
+
remarks: import_joi3.default.string().optional().allow("", null),
|
|
1949
|
+
// Added to match frontend
|
|
1945
1950
|
rejectionReason: import_joi3.default.string().optional().allow("", null),
|
|
1946
1951
|
createdAt: import_joi3.default.date().optional().allow("", null),
|
|
1947
1952
|
updatedAt: import_joi3.default.date().optional().allow("", null),
|
|
@@ -1963,42 +1968,34 @@ function MEnrollment(value) {
|
|
|
1963
1968
|
throw new import_nodejs_utils4.BadRequestError("Invalid _id format");
|
|
1964
1969
|
}
|
|
1965
1970
|
}
|
|
1966
|
-
if (typeof value.region === "string") {
|
|
1967
|
-
try {
|
|
1968
|
-
value.region = new import_mongodb3.ObjectId(value.region);
|
|
1969
|
-
} catch (error2) {
|
|
1970
|
-
throw new import_nodejs_utils4.BadRequestError("Invalid region format");
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
if (typeof value.sdo === "string") {
|
|
1974
|
-
try {
|
|
1975
|
-
value.sdo = new import_mongodb3.ObjectId(value.sdo);
|
|
1976
|
-
} catch (error2) {
|
|
1977
|
-
throw new import_nodejs_utils4.BadRequestError("Invalid sdo format");
|
|
1978
|
-
}
|
|
1979
|
-
}
|
|
1980
|
-
if (typeof value.school === "string") {
|
|
1981
|
-
try {
|
|
1982
|
-
value.school = new import_mongodb3.ObjectId(value.school);
|
|
1983
|
-
} catch (error2) {
|
|
1984
|
-
throw new import_nodejs_utils4.BadRequestError("Invalid school format");
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
1971
|
return {
|
|
1988
1972
|
_id: value._id ?? void 0,
|
|
1989
1973
|
region: value.region,
|
|
1990
|
-
|
|
1974
|
+
regionName: value.regionName ?? "",
|
|
1975
|
+
province: value.province ?? "",
|
|
1976
|
+
cityMunicipality: value.cityMunicipality ?? "",
|
|
1977
|
+
division: value.division,
|
|
1978
|
+
divisionName: value.divisionName ?? "",
|
|
1991
1979
|
school: value.school,
|
|
1980
|
+
schoolName: value.schoolName ?? "",
|
|
1981
|
+
// Added to match frontend
|
|
1992
1982
|
schoolYear: value.schoolYear ?? "",
|
|
1993
|
-
|
|
1983
|
+
gradeLevel: value.gradeLevel ?? "",
|
|
1984
|
+
returningLearner: value.returningLearner ?? false,
|
|
1985
|
+
// Added to match frontend
|
|
1994
1986
|
learnerInfo: value.learnerInfo,
|
|
1995
1987
|
parentGuardianInfo: value.parentGuardianInfo,
|
|
1996
|
-
|
|
1988
|
+
address: value.address,
|
|
1989
|
+
// Changed from addressInfo to address
|
|
1997
1990
|
returningLearnerInfo: value.returningLearnerInfo,
|
|
1998
1991
|
seniorHighInfo: value.seniorHighInfo,
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
1992
|
+
alternativeLearningOptions: value.alternativeLearningOptions ?? [],
|
|
1993
|
+
// Added to match frontend
|
|
1994
|
+
isCertifiedAndConsented: value.isCertifiedAndConsented ?? true,
|
|
1995
|
+
// Simplified certification
|
|
1996
|
+
status: value.status ?? "pending",
|
|
1997
|
+
remarks: value.remarks ?? "",
|
|
1998
|
+
// Added to match frontend
|
|
2002
1999
|
rejectionReason: value.rejectionReason ?? "",
|
|
2003
2000
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
2004
2001
|
updatedAt: value.updatedAt ?? "",
|
|
@@ -2012,28 +2009,18 @@ function MEnrollment(value) {
|
|
|
2012
2009
|
// src/resources/enrollment/enrollment.repository.ts
|
|
2013
2010
|
var import_nodejs_utils5 = require("@eeplatform/nodejs-utils");
|
|
2014
2011
|
var import_mongodb4 = require("mongodb");
|
|
2012
|
+
var import_joi4 = __toESM(require("joi"));
|
|
2015
2013
|
function useEnrollmentRepo() {
|
|
2016
2014
|
const db = import_nodejs_utils5.useAtlas.getDb();
|
|
2017
2015
|
if (!db) {
|
|
2018
2016
|
throw new Error("Unable to connect to server.");
|
|
2019
2017
|
}
|
|
2020
|
-
const namespace_collection = "school.enrollments";
|
|
2018
|
+
const namespace_collection = "deped.school.enrollments";
|
|
2021
2019
|
const collection = db.collection(namespace_collection);
|
|
2022
2020
|
const { getCache, setCache, delNamespace } = (0, import_nodejs_utils5.useCache)(namespace_collection);
|
|
2023
2021
|
async function createIndexes() {
|
|
2024
2022
|
try {
|
|
2025
2023
|
await collection.createIndexes([
|
|
2026
|
-
{
|
|
2027
|
-
key: {
|
|
2028
|
-
school: 1,
|
|
2029
|
-
schoolYear: 1,
|
|
2030
|
-
"learnerInfo.lrn": 1,
|
|
2031
|
-
status: 1
|
|
2032
|
-
},
|
|
2033
|
-
unique: true,
|
|
2034
|
-
partialFilterExpression: { status: "active" },
|
|
2035
|
-
name: "unique_enrollment_index"
|
|
2036
|
-
},
|
|
2037
2024
|
{ key: { status: 1 } },
|
|
2038
2025
|
{ key: { school: 1, status: 1 } },
|
|
2039
2026
|
{ key: { "learnerInfo.lrn": 1 } },
|
|
@@ -2122,11 +2109,7 @@ function useEnrollmentRepo() {
|
|
|
2122
2109
|
status
|
|
2123
2110
|
};
|
|
2124
2111
|
if (school) {
|
|
2125
|
-
|
|
2126
|
-
query.school = new import_mongodb4.ObjectId(school);
|
|
2127
|
-
} catch (error) {
|
|
2128
|
-
throw new import_nodejs_utils5.BadRequestError("Invalid school ID format.");
|
|
2129
|
-
}
|
|
2112
|
+
query.school = school;
|
|
2130
2113
|
}
|
|
2131
2114
|
if (schoolYear) {
|
|
2132
2115
|
query.schoolYear = schoolYear;
|
|
@@ -2180,6 +2163,7 @@ function useEnrollmentRepo() {
|
|
|
2180
2163
|
from: "admin.schools",
|
|
2181
2164
|
localField: "school",
|
|
2182
2165
|
foreignField: "_id",
|
|
2166
|
+
// School collection still uses ObjectId, we'll need to convert during lookup
|
|
2183
2167
|
as: "schoolInfo"
|
|
2184
2168
|
}
|
|
2185
2169
|
},
|
|
@@ -2188,15 +2172,19 @@ function useEnrollmentRepo() {
|
|
|
2188
2172
|
from: "admin.regions",
|
|
2189
2173
|
localField: "region",
|
|
2190
2174
|
foreignField: "_id",
|
|
2175
|
+
// Region collection still uses ObjectId, we'll need to convert during lookup
|
|
2191
2176
|
as: "regionInfo"
|
|
2192
2177
|
}
|
|
2193
2178
|
},
|
|
2194
2179
|
{
|
|
2195
2180
|
$lookup: {
|
|
2196
2181
|
from: "admin.divisions",
|
|
2197
|
-
localField: "
|
|
2182
|
+
localField: "division",
|
|
2183
|
+
// Changed from sdo to division to match frontend
|
|
2198
2184
|
foreignField: "_id",
|
|
2199
|
-
|
|
2185
|
+
// Division collection still uses ObjectId, we'll need to convert during lookup
|
|
2186
|
+
as: "divisionInfo"
|
|
2187
|
+
// Changed from sdoInfo to divisionInfo
|
|
2200
2188
|
}
|
|
2201
2189
|
},
|
|
2202
2190
|
{ $sort: sort },
|
|
@@ -2265,7 +2253,7 @@ function useEnrollmentRepo() {
|
|
|
2265
2253
|
async function getByLrn(lrn, schoolYear) {
|
|
2266
2254
|
const query = {
|
|
2267
2255
|
"learnerInfo.lrn": lrn,
|
|
2268
|
-
status: "
|
|
2256
|
+
status: "accepted"
|
|
2269
2257
|
};
|
|
2270
2258
|
if (schoolYear) {
|
|
2271
2259
|
query.schoolYear = schoolYear;
|
|
@@ -2335,12 +2323,8 @@ function useEnrollmentRepo() {
|
|
|
2335
2323
|
}
|
|
2336
2324
|
}
|
|
2337
2325
|
async function getBySchoolAndYear(school, schoolYear) {
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
school = new import_mongodb4.ObjectId(school);
|
|
2341
|
-
}
|
|
2342
|
-
} catch (error) {
|
|
2343
|
-
throw new import_nodejs_utils5.BadRequestError("Invalid school ID format.");
|
|
2326
|
+
if (typeof school === "object") {
|
|
2327
|
+
school = school.toString();
|
|
2344
2328
|
}
|
|
2345
2329
|
const query = {
|
|
2346
2330
|
school,
|
|
@@ -2380,6 +2364,110 @@ function useEnrollmentRepo() {
|
|
|
2380
2364
|
);
|
|
2381
2365
|
}
|
|
2382
2366
|
}
|
|
2367
|
+
async function getByApplicantInfo({
|
|
2368
|
+
school = "",
|
|
2369
|
+
schoolYear = "",
|
|
2370
|
+
gradeLevel = "",
|
|
2371
|
+
firstName = "",
|
|
2372
|
+
lastName = "",
|
|
2373
|
+
middleName = "",
|
|
2374
|
+
birthDate = "",
|
|
2375
|
+
placeOfBirth = ""
|
|
2376
|
+
} = {}) {
|
|
2377
|
+
const validation = import_joi4.default.object({
|
|
2378
|
+
school: import_joi4.default.string().required(),
|
|
2379
|
+
schoolYear: import_joi4.default.string().required(),
|
|
2380
|
+
gradeLevel: import_joi4.default.string().required(),
|
|
2381
|
+
firstName: import_joi4.default.string().required(),
|
|
2382
|
+
lastName: import_joi4.default.string().required(),
|
|
2383
|
+
middleName: import_joi4.default.string().optional().allow("", null),
|
|
2384
|
+
birthDate: import_joi4.default.string().required(),
|
|
2385
|
+
placeOfBirth: import_joi4.default.string().required()
|
|
2386
|
+
});
|
|
2387
|
+
const { error } = validation.validate({
|
|
2388
|
+
school,
|
|
2389
|
+
schoolYear,
|
|
2390
|
+
gradeLevel,
|
|
2391
|
+
firstName,
|
|
2392
|
+
lastName,
|
|
2393
|
+
middleName,
|
|
2394
|
+
birthDate,
|
|
2395
|
+
placeOfBirth
|
|
2396
|
+
});
|
|
2397
|
+
if (error) {
|
|
2398
|
+
throw new import_nodejs_utils5.BadRequestError(`Validation error: ${error.message}`);
|
|
2399
|
+
}
|
|
2400
|
+
const query = {
|
|
2401
|
+
school,
|
|
2402
|
+
schoolYear,
|
|
2403
|
+
gradeLevel,
|
|
2404
|
+
"learnerInfo.firstName": {
|
|
2405
|
+
$regex: `^${firstName}$`,
|
|
2406
|
+
$options: "i"
|
|
2407
|
+
},
|
|
2408
|
+
"learnerInfo.lastName": {
|
|
2409
|
+
$regex: `^${lastName}$`,
|
|
2410
|
+
$options: "i"
|
|
2411
|
+
},
|
|
2412
|
+
"learnerInfo.birthDate": birthDate,
|
|
2413
|
+
"learnerInfo.placeOfBirth": {
|
|
2414
|
+
$regex: `^${placeOfBirth}$`,
|
|
2415
|
+
$options: "i"
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
const cacheKeyOptions = {
|
|
2419
|
+
school,
|
|
2420
|
+
schoolYear,
|
|
2421
|
+
gradeLevel,
|
|
2422
|
+
firstName,
|
|
2423
|
+
lastName,
|
|
2424
|
+
birthDate,
|
|
2425
|
+
placeOfBirth
|
|
2426
|
+
};
|
|
2427
|
+
if (middleName && middleName.trim() !== "") {
|
|
2428
|
+
query["learnerInfo.middleName"] = {
|
|
2429
|
+
$regex: `^${middleName}$`,
|
|
2430
|
+
$options: "i"
|
|
2431
|
+
};
|
|
2432
|
+
cacheKeyOptions.middleName = middleName;
|
|
2433
|
+
}
|
|
2434
|
+
const cacheKey = (0, import_nodejs_utils5.makeCacheKey)(namespace_collection, cacheKeyOptions);
|
|
2435
|
+
const cachedData = await getCache(cacheKey);
|
|
2436
|
+
if (cachedData) {
|
|
2437
|
+
import_nodejs_utils5.logger.log({
|
|
2438
|
+
level: "info",
|
|
2439
|
+
message: `Cache hit for enrollment by applicant info: ${cacheKey}`
|
|
2440
|
+
});
|
|
2441
|
+
return cachedData;
|
|
2442
|
+
}
|
|
2443
|
+
try {
|
|
2444
|
+
const data = await collection.findOne({
|
|
2445
|
+
...query,
|
|
2446
|
+
status: "accepted"
|
|
2447
|
+
});
|
|
2448
|
+
const length = await collection.countDocuments({
|
|
2449
|
+
...query,
|
|
2450
|
+
status: { $nin: ["accepted", "deleted"] }
|
|
2451
|
+
});
|
|
2452
|
+
const result = { accepted: data ? true : false, length };
|
|
2453
|
+
setCache(cacheKey, result, 600).then(() => {
|
|
2454
|
+
import_nodejs_utils5.logger.log({
|
|
2455
|
+
level: "info",
|
|
2456
|
+
message: `Cache set for enrollment by applicant info: ${cacheKey}`
|
|
2457
|
+
});
|
|
2458
|
+
}).catch((err) => {
|
|
2459
|
+
import_nodejs_utils5.logger.log({
|
|
2460
|
+
level: "error",
|
|
2461
|
+
message: `Failed to set cache for enrollment by applicant info: ${err.message}`
|
|
2462
|
+
});
|
|
2463
|
+
});
|
|
2464
|
+
return result;
|
|
2465
|
+
} catch (error2) {
|
|
2466
|
+
throw new import_nodejs_utils5.InternalServerError(
|
|
2467
|
+
"Failed to get enrollment by applicant info."
|
|
2468
|
+
);
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2383
2471
|
return {
|
|
2384
2472
|
createIndexes,
|
|
2385
2473
|
add,
|
|
@@ -2388,6 +2476,7 @@ function useEnrollmentRepo() {
|
|
|
2388
2476
|
getById,
|
|
2389
2477
|
getByLrn,
|
|
2390
2478
|
deleteById,
|
|
2479
|
+
getByApplicantInfo,
|
|
2391
2480
|
getBySchoolAndYear
|
|
2392
2481
|
};
|
|
2393
2482
|
}
|
|
@@ -2402,39 +2491,52 @@ function useEnrollmentService() {
|
|
|
2402
2491
|
getById: _getById,
|
|
2403
2492
|
getByLrn: _getByLrn,
|
|
2404
2493
|
deleteById: _deleteById,
|
|
2405
|
-
getBySchoolAndYear: _getBySchoolAndYear
|
|
2494
|
+
getBySchoolAndYear: _getBySchoolAndYear,
|
|
2495
|
+
getByApplicantInfo: _getByApplicantInfo
|
|
2406
2496
|
} = useEnrollmentRepo();
|
|
2407
2497
|
async function createEnrollment(value) {
|
|
2408
2498
|
try {
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2499
|
+
const applicantInfo = await _getByApplicantInfo({
|
|
2500
|
+
firstName: value.learnerInfo.firstName,
|
|
2501
|
+
lastName: value.learnerInfo.lastName,
|
|
2502
|
+
middleName: value.learnerInfo.middleName,
|
|
2503
|
+
birthDate: value.learnerInfo.birthDate,
|
|
2504
|
+
placeOfBirth: value.learnerInfo.placeOfBirth,
|
|
2505
|
+
gradeLevel: value.gradeLevel,
|
|
2506
|
+
schoolYear: value.schoolYear,
|
|
2507
|
+
school: value.school
|
|
2508
|
+
});
|
|
2509
|
+
if (applicantInfo.accepted) {
|
|
2510
|
+
throw new import_nodejs_utils6.BadRequestError(
|
|
2511
|
+
"This applicant already has an accepted application for the same school year and grade level."
|
|
2413
2512
|
);
|
|
2414
|
-
if (existingEnrollment) {
|
|
2415
|
-
throw new import_nodejs_utils6.BadRequestError(
|
|
2416
|
-
"Learner is already enrolled for this school year."
|
|
2417
|
-
);
|
|
2418
|
-
}
|
|
2419
2513
|
}
|
|
2420
|
-
|
|
2514
|
+
if (applicantInfo.length >= 3) {
|
|
2515
|
+
throw new import_nodejs_utils6.BadRequestError(
|
|
2516
|
+
"This applicant has already submitted applications to 3 schools for the same school year and grade level. Maximum limit reached."
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
2519
|
+
const gradeLevel = value.gradeLevel.toLowerCase();
|
|
2421
2520
|
const age = value.learnerInfo.age;
|
|
2422
|
-
if (
|
|
2521
|
+
if (["K1", "K2"].includes(gradeLevel) && age < 5) {
|
|
2423
2522
|
throw new import_nodejs_utils6.BadRequestError("Learner is too young for Kindergarten.");
|
|
2424
2523
|
}
|
|
2425
|
-
if (gradeLevel
|
|
2524
|
+
if (gradeLevel === "grade-1" && age < 6) {
|
|
2426
2525
|
throw new import_nodejs_utils6.BadRequestError("Learner is too young for Grade 1.");
|
|
2427
2526
|
}
|
|
2428
2527
|
const { father, mother, legalGuardian } = value.parentGuardianInfo;
|
|
2429
|
-
|
|
2528
|
+
const hasFatherInfo = father && (father.firstName || father.lastName);
|
|
2529
|
+
const hasMotherInfo = mother && (mother.firstName || mother.lastName);
|
|
2530
|
+
const hasGuardianInfo = legalGuardian && (legalGuardian.firstName || legalGuardian.lastName);
|
|
2531
|
+
if (!hasFatherInfo && !hasMotherInfo && !hasGuardianInfo) {
|
|
2430
2532
|
throw new import_nodejs_utils6.BadRequestError(
|
|
2431
2533
|
"At least one parent or legal guardian information is required."
|
|
2432
2534
|
);
|
|
2433
2535
|
}
|
|
2434
|
-
if (gradeLevel.includes("grade
|
|
2435
|
-
if (!value.seniorHighInfo) {
|
|
2536
|
+
if (gradeLevel.includes("grade-11") || gradeLevel.includes("grade-12")) {
|
|
2537
|
+
if (!value.seniorHighInfo || !value.seniorHighInfo.track || !value.seniorHighInfo.strand) {
|
|
2436
2538
|
throw new import_nodejs_utils6.BadRequestError(
|
|
2437
|
-
"Senior high school information is required for Grade 11 and 12."
|
|
2539
|
+
"Senior high school information (track and strand) is required for Grade 11 and 12."
|
|
2438
2540
|
);
|
|
2439
2541
|
}
|
|
2440
2542
|
}
|
|
@@ -2668,7 +2770,7 @@ function useEnrollmentService() {
|
|
|
2668
2770
|
|
|
2669
2771
|
// src/resources/enrollment/enrollment.controller.ts
|
|
2670
2772
|
var import_nodejs_utils7 = require("@eeplatform/nodejs-utils");
|
|
2671
|
-
var
|
|
2773
|
+
var import_joi5 = __toESM(require("joi"));
|
|
2672
2774
|
function useEnrollmentController() {
|
|
2673
2775
|
const {
|
|
2674
2776
|
createEnrollment: _createEnrollment,
|
|
@@ -2700,18 +2802,18 @@ function useEnrollmentController() {
|
|
|
2700
2802
|
async function updateById(req, res, next) {
|
|
2701
2803
|
const value = req.body;
|
|
2702
2804
|
const id = req.params.id ?? "";
|
|
2703
|
-
const validation =
|
|
2704
|
-
id:
|
|
2705
|
-
value:
|
|
2706
|
-
learnerInfo:
|
|
2707
|
-
parentGuardianInfo:
|
|
2708
|
-
addressInfo:
|
|
2709
|
-
returningLearnerInfo:
|
|
2710
|
-
seniorHighInfo:
|
|
2711
|
-
preferredLearningModalities:
|
|
2712
|
-
certification:
|
|
2713
|
-
status:
|
|
2714
|
-
rejectionReason:
|
|
2805
|
+
const validation = import_joi5.default.object({
|
|
2806
|
+
id: import_joi5.default.string().hex().required(),
|
|
2807
|
+
value: import_joi5.default.object({
|
|
2808
|
+
learnerInfo: import_joi5.default.object().optional(),
|
|
2809
|
+
parentGuardianInfo: import_joi5.default.object().optional(),
|
|
2810
|
+
addressInfo: import_joi5.default.object().optional(),
|
|
2811
|
+
returningLearnerInfo: import_joi5.default.object().optional(),
|
|
2812
|
+
seniorHighInfo: import_joi5.default.object().optional(),
|
|
2813
|
+
preferredLearningModalities: import_joi5.default.array().optional(),
|
|
2814
|
+
certification: import_joi5.default.object().optional(),
|
|
2815
|
+
status: import_joi5.default.string().valid("active", "pending", "approved", "rejected", "deleted").optional(),
|
|
2816
|
+
rejectionReason: import_joi5.default.string().optional().allow("", null)
|
|
2715
2817
|
}).min(1)
|
|
2716
2818
|
});
|
|
2717
2819
|
const { error } = validation.validate({ id, value });
|
|
@@ -2730,14 +2832,14 @@ function useEnrollmentController() {
|
|
|
2730
2832
|
}
|
|
2731
2833
|
async function getAll(req, res, next) {
|
|
2732
2834
|
const query = req.query;
|
|
2733
|
-
const validation =
|
|
2734
|
-
page:
|
|
2735
|
-
limit:
|
|
2736
|
-
search:
|
|
2737
|
-
status:
|
|
2738
|
-
school:
|
|
2739
|
-
schoolYear:
|
|
2740
|
-
gradeLevelToEnroll:
|
|
2835
|
+
const validation = import_joi5.default.object({
|
|
2836
|
+
page: import_joi5.default.number().min(1).optional().allow("", null),
|
|
2837
|
+
limit: import_joi5.default.number().min(1).max(100).optional().allow("", null),
|
|
2838
|
+
search: import_joi5.default.string().optional().allow("", null),
|
|
2839
|
+
status: import_joi5.default.string().optional().allow("", null),
|
|
2840
|
+
school: import_joi5.default.string().hex().optional().allow("", null),
|
|
2841
|
+
schoolYear: import_joi5.default.string().optional().allow("", null),
|
|
2842
|
+
gradeLevelToEnroll: import_joi5.default.string().optional().allow("", null)
|
|
2741
2843
|
});
|
|
2742
2844
|
const { error } = validation.validate(query);
|
|
2743
2845
|
if (error) {
|
|
@@ -2775,7 +2877,7 @@ function useEnrollmentController() {
|
|
|
2775
2877
|
}
|
|
2776
2878
|
async function getById(req, res, next) {
|
|
2777
2879
|
const id = req.params.id ?? "";
|
|
2778
|
-
const validation =
|
|
2880
|
+
const validation = import_joi5.default.string().hex().required();
|
|
2779
2881
|
const { error } = validation.validate(id);
|
|
2780
2882
|
if (error) {
|
|
2781
2883
|
next(new import_nodejs_utils7.BadRequestError(error.message));
|
|
@@ -2792,9 +2894,9 @@ function useEnrollmentController() {
|
|
|
2792
2894
|
async function getByLrn(req, res, next) {
|
|
2793
2895
|
const lrn = req.params.lrn ?? "";
|
|
2794
2896
|
const schoolYear = req.query.schoolYear;
|
|
2795
|
-
const validation =
|
|
2796
|
-
lrn:
|
|
2797
|
-
schoolYear:
|
|
2897
|
+
const validation = import_joi5.default.object({
|
|
2898
|
+
lrn: import_joi5.default.string().required(),
|
|
2899
|
+
schoolYear: import_joi5.default.string().optional().allow("", null)
|
|
2798
2900
|
});
|
|
2799
2901
|
const { error } = validation.validate({ lrn, schoolYear });
|
|
2800
2902
|
if (error) {
|
|
@@ -2812,9 +2914,9 @@ function useEnrollmentController() {
|
|
|
2812
2914
|
async function deleteById(req, res, next) {
|
|
2813
2915
|
const id = req.params.id ?? "";
|
|
2814
2916
|
const deletedBy = req.body.deletedBy;
|
|
2815
|
-
const validation =
|
|
2816
|
-
id:
|
|
2817
|
-
deletedBy:
|
|
2917
|
+
const validation = import_joi5.default.object({
|
|
2918
|
+
id: import_joi5.default.string().hex().required(),
|
|
2919
|
+
deletedBy: import_joi5.default.string().optional().allow("", null)
|
|
2818
2920
|
});
|
|
2819
2921
|
const { error } = validation.validate({ id, deletedBy });
|
|
2820
2922
|
if (error) {
|
|
@@ -2832,9 +2934,9 @@ function useEnrollmentController() {
|
|
|
2832
2934
|
async function getBySchoolAndYear(req, res, next) {
|
|
2833
2935
|
const school = req.params.school ?? "";
|
|
2834
2936
|
const schoolYear = req.params.schoolYear ?? "";
|
|
2835
|
-
const validation =
|
|
2836
|
-
school:
|
|
2837
|
-
schoolYear:
|
|
2937
|
+
const validation = import_joi5.default.object({
|
|
2938
|
+
school: import_joi5.default.string().hex().required(),
|
|
2939
|
+
schoolYear: import_joi5.default.string().required()
|
|
2838
2940
|
});
|
|
2839
2941
|
const { error } = validation.validate({ school, schoolYear });
|
|
2840
2942
|
if (error) {
|
|
@@ -2852,9 +2954,9 @@ function useEnrollmentController() {
|
|
|
2852
2954
|
async function approve(req, res, next) {
|
|
2853
2955
|
const id = req.params.id ?? "";
|
|
2854
2956
|
const approvedBy = req.body.approvedBy;
|
|
2855
|
-
const validation =
|
|
2856
|
-
id:
|
|
2857
|
-
approvedBy:
|
|
2957
|
+
const validation = import_joi5.default.object({
|
|
2958
|
+
id: import_joi5.default.string().hex().required(),
|
|
2959
|
+
approvedBy: import_joi5.default.string().required()
|
|
2858
2960
|
});
|
|
2859
2961
|
const { error } = validation.validate({ id, approvedBy });
|
|
2860
2962
|
if (error) {
|
|
@@ -2874,10 +2976,10 @@ function useEnrollmentController() {
|
|
|
2874
2976
|
const id = req.params.id ?? "";
|
|
2875
2977
|
const rejectedBy = req.body.rejectedBy;
|
|
2876
2978
|
const rejectionReason = req.body.rejectionReason;
|
|
2877
|
-
const validation =
|
|
2878
|
-
id:
|
|
2879
|
-
rejectedBy:
|
|
2880
|
-
rejectionReason:
|
|
2979
|
+
const validation = import_joi5.default.object({
|
|
2980
|
+
id: import_joi5.default.string().hex().required(),
|
|
2981
|
+
rejectedBy: import_joi5.default.string().required(),
|
|
2982
|
+
rejectionReason: import_joi5.default.string().optional().allow("", null)
|
|
2881
2983
|
});
|
|
2882
2984
|
const { error } = validation.validate({ id, rejectedBy, rejectionReason });
|
|
2883
2985
|
if (error) {
|
|
@@ -2896,9 +2998,9 @@ function useEnrollmentController() {
|
|
|
2896
2998
|
async function getStatsBySchool(req, res, next) {
|
|
2897
2999
|
const school = req.params.school ?? "";
|
|
2898
3000
|
const schoolYear = req.query.schoolYear;
|
|
2899
|
-
const validation =
|
|
2900
|
-
school:
|
|
2901
|
-
schoolYear:
|
|
3001
|
+
const validation = import_joi5.default.object({
|
|
3002
|
+
school: import_joi5.default.string().hex().required(),
|
|
3003
|
+
schoolYear: import_joi5.default.string().optional().allow("", null)
|
|
2902
3004
|
});
|
|
2903
3005
|
const { error } = validation.validate({ school, schoolYear });
|
|
2904
3006
|
if (error) {
|
|
@@ -2965,26 +3067,26 @@ function useEnrollmentController() {
|
|
|
2965
3067
|
|
|
2966
3068
|
// src/resources/grade-level/grade-level.model.ts
|
|
2967
3069
|
var import_nodejs_utils8 = require("@eeplatform/nodejs-utils");
|
|
2968
|
-
var
|
|
3070
|
+
var import_joi6 = __toESM(require("joi"));
|
|
2969
3071
|
var import_mongodb5 = require("mongodb");
|
|
2970
|
-
var schemaGradeLevel =
|
|
2971
|
-
_id:
|
|
2972
|
-
school:
|
|
2973
|
-
educationLevel:
|
|
2974
|
-
gradeLevel:
|
|
2975
|
-
tracks:
|
|
2976
|
-
trackStrands:
|
|
2977
|
-
teachingStyle:
|
|
2978
|
-
maxNumberOfLearners:
|
|
2979
|
-
defaultStartTime:
|
|
2980
|
-
defaultEndTime:
|
|
2981
|
-
status:
|
|
2982
|
-
createdAt:
|
|
2983
|
-
updatedAt:
|
|
2984
|
-
deletedAt:
|
|
2985
|
-
createdBy:
|
|
2986
|
-
updatedBy:
|
|
2987
|
-
deletedBy:
|
|
3072
|
+
var schemaGradeLevel = import_joi6.default.object({
|
|
3073
|
+
_id: import_joi6.default.string().hex().optional(),
|
|
3074
|
+
school: import_joi6.default.string().hex().optional(),
|
|
3075
|
+
educationLevel: import_joi6.default.string().required(),
|
|
3076
|
+
gradeLevel: import_joi6.default.string().required(),
|
|
3077
|
+
tracks: import_joi6.default.array().items(import_joi6.default.string()).optional(),
|
|
3078
|
+
trackStrands: import_joi6.default.array().items(import_joi6.default.string()).optional(),
|
|
3079
|
+
teachingStyle: import_joi6.default.string().required(),
|
|
3080
|
+
maxNumberOfLearners: import_joi6.default.number().required(),
|
|
3081
|
+
defaultStartTime: import_joi6.default.string().optional().allow("", null),
|
|
3082
|
+
defaultEndTime: import_joi6.default.string().optional().allow("", null),
|
|
3083
|
+
status: import_joi6.default.string().optional().allow("", null),
|
|
3084
|
+
createdAt: import_joi6.default.date().optional().allow("", null),
|
|
3085
|
+
updatedAt: import_joi6.default.date().optional().allow("", null),
|
|
3086
|
+
deletedAt: import_joi6.default.date().optional().allow("", null),
|
|
3087
|
+
createdBy: import_joi6.default.string().optional().allow("", null),
|
|
3088
|
+
updatedBy: import_joi6.default.string().optional().allow("", null),
|
|
3089
|
+
deletedBy: import_joi6.default.string().optional().allow("", null)
|
|
2988
3090
|
});
|
|
2989
3091
|
function MGradeLevel(value) {
|
|
2990
3092
|
const { error } = schemaGradeLevel.validate(value);
|
|
@@ -3387,7 +3489,7 @@ function useGradeLevelRepo() {
|
|
|
3387
3489
|
|
|
3388
3490
|
// src/resources/grade-level/grade-level.controller.ts
|
|
3389
3491
|
var import_nodejs_utils10 = require("@eeplatform/nodejs-utils");
|
|
3390
|
-
var
|
|
3492
|
+
var import_joi7 = __toESM(require("joi"));
|
|
3391
3493
|
function useGradeLevelController() {
|
|
3392
3494
|
const {
|
|
3393
3495
|
getAll: _getAll,
|
|
@@ -3419,17 +3521,17 @@ function useGradeLevelController() {
|
|
|
3419
3521
|
async function updateById(req, res, next) {
|
|
3420
3522
|
const value = req.body;
|
|
3421
3523
|
const id = req.params.id ?? "";
|
|
3422
|
-
const validation =
|
|
3423
|
-
id:
|
|
3424
|
-
value:
|
|
3425
|
-
school:
|
|
3426
|
-
educationLevel:
|
|
3427
|
-
gradeLevel:
|
|
3428
|
-
teachingStyle:
|
|
3429
|
-
maxTeachingHoursPerDay:
|
|
3430
|
-
maxTeachingHoursPerWeek:
|
|
3431
|
-
defaultStartTime:
|
|
3432
|
-
defaultEndTime:
|
|
3524
|
+
const validation = import_joi7.default.object({
|
|
3525
|
+
id: import_joi7.default.string().hex().required(),
|
|
3526
|
+
value: import_joi7.default.object({
|
|
3527
|
+
school: import_joi7.default.string().hex().optional(),
|
|
3528
|
+
educationLevel: import_joi7.default.string().optional(),
|
|
3529
|
+
gradeLevel: import_joi7.default.string().optional(),
|
|
3530
|
+
teachingStyle: import_joi7.default.string().optional(),
|
|
3531
|
+
maxTeachingHoursPerDay: import_joi7.default.number().integer().min(0).optional(),
|
|
3532
|
+
maxTeachingHoursPerWeek: import_joi7.default.number().integer().min(0).optional(),
|
|
3533
|
+
defaultStartTime: import_joi7.default.string().optional().allow("", null),
|
|
3534
|
+
defaultEndTime: import_joi7.default.string().optional().allow("", null)
|
|
3433
3535
|
}).min(1)
|
|
3434
3536
|
});
|
|
3435
3537
|
const { error } = validation.validate({ id, value });
|
|
@@ -3451,15 +3553,15 @@ function useGradeLevelController() {
|
|
|
3451
3553
|
}
|
|
3452
3554
|
async function getAll(req, res, next) {
|
|
3453
3555
|
const query = req.query;
|
|
3454
|
-
const validation =
|
|
3455
|
-
page:
|
|
3456
|
-
limit:
|
|
3457
|
-
search:
|
|
3458
|
-
educationLevel:
|
|
3459
|
-
gradeLevel:
|
|
3460
|
-
teachingStyle:
|
|
3461
|
-
school:
|
|
3462
|
-
status:
|
|
3556
|
+
const validation = import_joi7.default.object({
|
|
3557
|
+
page: import_joi7.default.number().min(1).optional().allow("", null),
|
|
3558
|
+
limit: import_joi7.default.number().min(1).optional().allow("", null),
|
|
3559
|
+
search: import_joi7.default.string().optional().allow("", null),
|
|
3560
|
+
educationLevel: import_joi7.default.string().optional().allow("", null),
|
|
3561
|
+
gradeLevel: import_joi7.default.string().optional().allow("", null),
|
|
3562
|
+
teachingStyle: import_joi7.default.string().optional().allow("", null),
|
|
3563
|
+
school: import_joi7.default.string().hex().optional().allow("", null),
|
|
3564
|
+
status: import_joi7.default.string().optional().allow("", null)
|
|
3463
3565
|
});
|
|
3464
3566
|
const { error } = validation.validate(query);
|
|
3465
3567
|
if (error) {
|
|
@@ -3484,7 +3586,7 @@ function useGradeLevelController() {
|
|
|
3484
3586
|
const school = req.query.school ?? "";
|
|
3485
3587
|
const search = req.query.search ?? "";
|
|
3486
3588
|
try {
|
|
3487
|
-
const
|
|
3589
|
+
const gradeLevels2 = await _getAll({
|
|
3488
3590
|
page,
|
|
3489
3591
|
limit,
|
|
3490
3592
|
sort: sortObj,
|
|
@@ -3495,7 +3597,7 @@ function useGradeLevelController() {
|
|
|
3495
3597
|
school,
|
|
3496
3598
|
search
|
|
3497
3599
|
});
|
|
3498
|
-
res.json(
|
|
3600
|
+
res.json(gradeLevels2);
|
|
3499
3601
|
return;
|
|
3500
3602
|
} catch (error2) {
|
|
3501
3603
|
next(error2);
|
|
@@ -3503,8 +3605,8 @@ function useGradeLevelController() {
|
|
|
3503
3605
|
}
|
|
3504
3606
|
async function getById(req, res, next) {
|
|
3505
3607
|
const id = req.params.id;
|
|
3506
|
-
const validation =
|
|
3507
|
-
id:
|
|
3608
|
+
const validation = import_joi7.default.object({
|
|
3609
|
+
id: import_joi7.default.string().hex().required()
|
|
3508
3610
|
});
|
|
3509
3611
|
const { error } = validation.validate({ id });
|
|
3510
3612
|
if (error) {
|
|
@@ -3524,8 +3626,8 @@ function useGradeLevelController() {
|
|
|
3524
3626
|
}
|
|
3525
3627
|
async function deleteById(req, res, next) {
|
|
3526
3628
|
const id = req.params.id;
|
|
3527
|
-
const validation =
|
|
3528
|
-
id:
|
|
3629
|
+
const validation = import_joi7.default.object({
|
|
3630
|
+
id: import_joi7.default.string().hex().required()
|
|
3529
3631
|
});
|
|
3530
3632
|
const { error } = validation.validate({ id });
|
|
3531
3633
|
if (error) {
|
|
@@ -3546,9 +3648,9 @@ function useGradeLevelController() {
|
|
|
3546
3648
|
async function getByEducationLevel(req, res, next) {
|
|
3547
3649
|
const educationLevel = req.params.educationLevel;
|
|
3548
3650
|
const school = req.query.school;
|
|
3549
|
-
const validation =
|
|
3550
|
-
educationLevel:
|
|
3551
|
-
school:
|
|
3651
|
+
const validation = import_joi7.default.object({
|
|
3652
|
+
educationLevel: import_joi7.default.string().required(),
|
|
3653
|
+
school: import_joi7.default.string().hex().optional().allow("", null)
|
|
3552
3654
|
});
|
|
3553
3655
|
const { error } = validation.validate({ educationLevel, school });
|
|
3554
3656
|
if (error) {
|
|
@@ -3556,10 +3658,10 @@ function useGradeLevelController() {
|
|
|
3556
3658
|
return;
|
|
3557
3659
|
}
|
|
3558
3660
|
try {
|
|
3559
|
-
const
|
|
3661
|
+
const gradeLevels2 = await _getByEducationLevel(educationLevel, school);
|
|
3560
3662
|
res.json({
|
|
3561
3663
|
message: "Successfully retrieved grade levels by education level.",
|
|
3562
|
-
data: { gradeLevels }
|
|
3664
|
+
data: { gradeLevels: gradeLevels2 }
|
|
3563
3665
|
});
|
|
3564
3666
|
return;
|
|
3565
3667
|
} catch (error2) {
|
|
@@ -3578,14 +3680,14 @@ function useGradeLevelController() {
|
|
|
3578
3680
|
|
|
3579
3681
|
// src/resources/region/region.model.ts
|
|
3580
3682
|
var import_nodejs_utils11 = require("@eeplatform/nodejs-utils");
|
|
3581
|
-
var
|
|
3683
|
+
var import_joi8 = __toESM(require("joi"));
|
|
3582
3684
|
var import_mongodb7 = require("mongodb");
|
|
3583
|
-
var schemaRegion =
|
|
3584
|
-
_id:
|
|
3585
|
-
name:
|
|
3586
|
-
createdAt:
|
|
3587
|
-
updatedAt:
|
|
3588
|
-
deletedAt:
|
|
3685
|
+
var schemaRegion = import_joi8.default.object({
|
|
3686
|
+
_id: import_joi8.default.string().hex().optional().allow(null, ""),
|
|
3687
|
+
name: import_joi8.default.string().min(1).max(100).required(),
|
|
3688
|
+
createdAt: import_joi8.default.string().isoDate().optional(),
|
|
3689
|
+
updatedAt: import_joi8.default.string().isoDate().optional(),
|
|
3690
|
+
deletedAt: import_joi8.default.string().isoDate().optional().allow(null, "")
|
|
3589
3691
|
});
|
|
3590
3692
|
function modelRegion(value) {
|
|
3591
3693
|
const { error } = schemaRegion.validate(value);
|
|
@@ -3864,7 +3966,7 @@ function useRegionRepo() {
|
|
|
3864
3966
|
|
|
3865
3967
|
// src/resources/region/region.controller.ts
|
|
3866
3968
|
var import_nodejs_utils13 = require("@eeplatform/nodejs-utils");
|
|
3867
|
-
var
|
|
3969
|
+
var import_joi9 = __toESM(require("joi"));
|
|
3868
3970
|
function useRegionController() {
|
|
3869
3971
|
const {
|
|
3870
3972
|
add: _add,
|
|
@@ -3894,11 +3996,11 @@ function useRegionController() {
|
|
|
3894
3996
|
}
|
|
3895
3997
|
async function getAll(req, res, next) {
|
|
3896
3998
|
const query = req.query;
|
|
3897
|
-
const validation =
|
|
3898
|
-
page:
|
|
3899
|
-
limit:
|
|
3900
|
-
search:
|
|
3901
|
-
status:
|
|
3999
|
+
const validation = import_joi9.default.object({
|
|
4000
|
+
page: import_joi9.default.number().min(1).optional().allow("", null),
|
|
4001
|
+
limit: import_joi9.default.number().min(1).optional().allow("", null),
|
|
4002
|
+
search: import_joi9.default.string().optional().allow("", null),
|
|
4003
|
+
status: import_joi9.default.string().optional().allow("", null)
|
|
3902
4004
|
});
|
|
3903
4005
|
const { error } = validation.validate(query);
|
|
3904
4006
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -3929,8 +4031,8 @@ function useRegionController() {
|
|
|
3929
4031
|
}
|
|
3930
4032
|
async function getById(req, res, next) {
|
|
3931
4033
|
const id = req.params.id;
|
|
3932
|
-
const validation =
|
|
3933
|
-
id:
|
|
4034
|
+
const validation = import_joi9.default.object({
|
|
4035
|
+
id: import_joi9.default.string().hex().required()
|
|
3934
4036
|
});
|
|
3935
4037
|
const { error } = validation.validate({ id });
|
|
3936
4038
|
if (error) {
|
|
@@ -3950,8 +4052,8 @@ function useRegionController() {
|
|
|
3950
4052
|
}
|
|
3951
4053
|
async function getByName(req, res, next) {
|
|
3952
4054
|
const name = req.params.name;
|
|
3953
|
-
const validation =
|
|
3954
|
-
name:
|
|
4055
|
+
const validation = import_joi9.default.object({
|
|
4056
|
+
name: import_joi9.default.string().required()
|
|
3955
4057
|
});
|
|
3956
4058
|
const { error } = validation.validate({ name });
|
|
3957
4059
|
if (error) {
|
|
@@ -3972,10 +4074,10 @@ function useRegionController() {
|
|
|
3972
4074
|
async function updateField(req, res, next) {
|
|
3973
4075
|
const _id = req.params.id;
|
|
3974
4076
|
const { field, value } = req.body;
|
|
3975
|
-
const validation =
|
|
3976
|
-
_id:
|
|
3977
|
-
field:
|
|
3978
|
-
value:
|
|
4077
|
+
const validation = import_joi9.default.object({
|
|
4078
|
+
_id: import_joi9.default.string().hex().required(),
|
|
4079
|
+
field: import_joi9.default.string().valid("name", "director", "directorName").required(),
|
|
4080
|
+
value: import_joi9.default.string().required()
|
|
3979
4081
|
});
|
|
3980
4082
|
const { error } = validation.validate({ _id, field, value });
|
|
3981
4083
|
if (error) {
|
|
@@ -3992,8 +4094,8 @@ function useRegionController() {
|
|
|
3992
4094
|
}
|
|
3993
4095
|
async function deleteById(req, res, next) {
|
|
3994
4096
|
const _id = req.params.id;
|
|
3995
|
-
const validation =
|
|
3996
|
-
_id:
|
|
4097
|
+
const validation = import_joi9.default.object({
|
|
4098
|
+
_id: import_joi9.default.string().hex().required()
|
|
3997
4099
|
});
|
|
3998
4100
|
const { error } = validation.validate({ _id });
|
|
3999
4101
|
if (error) {
|
|
@@ -4020,26 +4122,26 @@ function useRegionController() {
|
|
|
4020
4122
|
|
|
4021
4123
|
// src/resources/division/division.model.ts
|
|
4022
4124
|
var import_nodejs_utils14 = require("@eeplatform/nodejs-utils");
|
|
4023
|
-
var
|
|
4125
|
+
var import_joi10 = __toESM(require("joi"));
|
|
4024
4126
|
var import_mongodb9 = require("mongodb");
|
|
4025
|
-
var schemaDivision =
|
|
4026
|
-
_id:
|
|
4027
|
-
name:
|
|
4028
|
-
region:
|
|
4029
|
-
regionName:
|
|
4030
|
-
superintendent:
|
|
4031
|
-
superintendentName:
|
|
4032
|
-
createdAt:
|
|
4033
|
-
updatedAt:
|
|
4034
|
-
deletedAt:
|
|
4127
|
+
var schemaDivision = import_joi10.default.object({
|
|
4128
|
+
_id: import_joi10.default.string().hex().optional().allow(null, ""),
|
|
4129
|
+
name: import_joi10.default.string().min(1).max(100).required(),
|
|
4130
|
+
region: import_joi10.default.string().hex().required(),
|
|
4131
|
+
regionName: import_joi10.default.string().min(1).max(100).required(),
|
|
4132
|
+
superintendent: import_joi10.default.string().hex().optional().allow(null, ""),
|
|
4133
|
+
superintendentName: import_joi10.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4134
|
+
createdAt: import_joi10.default.string().isoDate().optional(),
|
|
4135
|
+
updatedAt: import_joi10.default.string().isoDate().optional(),
|
|
4136
|
+
deletedAt: import_joi10.default.string().isoDate().optional().allow(null, "")
|
|
4035
4137
|
});
|
|
4036
|
-
var schemaDivisionUpdate =
|
|
4037
|
-
_id:
|
|
4038
|
-
name:
|
|
4039
|
-
region:
|
|
4040
|
-
regionName:
|
|
4041
|
-
superintendent:
|
|
4042
|
-
superintendentName:
|
|
4138
|
+
var schemaDivisionUpdate = import_joi10.default.object({
|
|
4139
|
+
_id: import_joi10.default.string().hex().optional().allow(null, ""),
|
|
4140
|
+
name: import_joi10.default.string().min(1).max(100).required(),
|
|
4141
|
+
region: import_joi10.default.string().hex().required(),
|
|
4142
|
+
regionName: import_joi10.default.string().min(1).max(100).required(),
|
|
4143
|
+
superintendent: import_joi10.default.string().hex().optional().allow(null, ""),
|
|
4144
|
+
superintendentName: import_joi10.default.string().min(1).max(100).optional().allow(null, "")
|
|
4043
4145
|
});
|
|
4044
4146
|
function modelDivision(value) {
|
|
4045
4147
|
const { error } = schemaDivision.validate(value);
|
|
@@ -4385,49 +4487,49 @@ var import_core2 = require("@eeplatform/core");
|
|
|
4385
4487
|
|
|
4386
4488
|
// src/resources/school/school.model.ts
|
|
4387
4489
|
var import_nodejs_utils16 = require("@eeplatform/nodejs-utils");
|
|
4388
|
-
var
|
|
4490
|
+
var import_joi11 = __toESM(require("joi"));
|
|
4389
4491
|
var import_mongodb11 = require("mongodb");
|
|
4390
|
-
var schemaSchool =
|
|
4391
|
-
_id:
|
|
4392
|
-
id:
|
|
4393
|
-
name:
|
|
4394
|
-
region:
|
|
4395
|
-
regionName:
|
|
4396
|
-
division:
|
|
4397
|
-
divisionName:
|
|
4398
|
-
principal:
|
|
4399
|
-
principalName:
|
|
4400
|
-
street:
|
|
4401
|
-
barangay:
|
|
4402
|
-
cityMunicipality:
|
|
4403
|
-
province:
|
|
4404
|
-
cityMunicipalityPSGC:
|
|
4405
|
-
postalCode:
|
|
4406
|
-
contactNumber:
|
|
4407
|
-
email:
|
|
4408
|
-
status:
|
|
4409
|
-
createdBy:
|
|
4410
|
-
createdAt:
|
|
4411
|
-
updatedAt:
|
|
4412
|
-
deletedAt:
|
|
4492
|
+
var schemaSchool = import_joi11.default.object({
|
|
4493
|
+
_id: import_joi11.default.string().hex().optional().allow(null, ""),
|
|
4494
|
+
id: import_joi11.default.string().min(1).max(50).required(),
|
|
4495
|
+
name: import_joi11.default.string().min(1).max(100).required(),
|
|
4496
|
+
region: import_joi11.default.string().hex().required(),
|
|
4497
|
+
regionName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4498
|
+
division: import_joi11.default.string().hex().required(),
|
|
4499
|
+
divisionName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4500
|
+
principal: import_joi11.default.string().hex().optional().allow(null, ""),
|
|
4501
|
+
principalName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4502
|
+
street: import_joi11.default.string().max(200).optional().allow(null, ""),
|
|
4503
|
+
barangay: import_joi11.default.string().max(200).optional().allow(null, ""),
|
|
4504
|
+
cityMunicipality: import_joi11.default.string().max(100).optional().allow(null, ""),
|
|
4505
|
+
province: import_joi11.default.string().max(100).optional().allow(null, ""),
|
|
4506
|
+
cityMunicipalityPSGC: import_joi11.default.string().length(10).optional().allow(null, ""),
|
|
4507
|
+
postalCode: import_joi11.default.string().max(20).optional().allow(null, ""),
|
|
4508
|
+
contactNumber: import_joi11.default.string().max(20).optional().allow(null, ""),
|
|
4509
|
+
email: import_joi11.default.string().email().max(100).optional().allow(null, ""),
|
|
4510
|
+
status: import_joi11.default.string().optional().allow(null, ""),
|
|
4511
|
+
createdBy: import_joi11.default.string().optional().allow(null, ""),
|
|
4512
|
+
createdAt: import_joi11.default.string().isoDate().optional().allow(null, ""),
|
|
4513
|
+
updatedAt: import_joi11.default.string().isoDate().optional().allow(null, ""),
|
|
4514
|
+
deletedAt: import_joi11.default.string().isoDate().optional().allow(null, "")
|
|
4413
4515
|
});
|
|
4414
|
-
var schemaSchoolUpdate =
|
|
4415
|
-
id:
|
|
4416
|
-
name:
|
|
4417
|
-
region:
|
|
4418
|
-
regionName:
|
|
4419
|
-
division:
|
|
4420
|
-
divisionName:
|
|
4421
|
-
principal:
|
|
4422
|
-
principalName:
|
|
4423
|
-
street:
|
|
4424
|
-
barangay:
|
|
4425
|
-
cityMunicipality:
|
|
4426
|
-
province:
|
|
4427
|
-
cityMunicipalityPSGC:
|
|
4428
|
-
postalCode:
|
|
4429
|
-
contactNumber:
|
|
4430
|
-
email:
|
|
4516
|
+
var schemaSchoolUpdate = import_joi11.default.object({
|
|
4517
|
+
id: import_joi11.default.string().min(1).max(50).required(),
|
|
4518
|
+
name: import_joi11.default.string().min(1).max(100).required(),
|
|
4519
|
+
region: import_joi11.default.string().hex().required(),
|
|
4520
|
+
regionName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4521
|
+
division: import_joi11.default.string().hex().required(),
|
|
4522
|
+
divisionName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4523
|
+
principal: import_joi11.default.string().hex().optional().allow(null, ""),
|
|
4524
|
+
principalName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4525
|
+
street: import_joi11.default.string().max(200).optional().allow(null, ""),
|
|
4526
|
+
barangay: import_joi11.default.string().max(200).optional().allow(null, ""),
|
|
4527
|
+
cityMunicipality: import_joi11.default.string().max(100).optional().allow(null, ""),
|
|
4528
|
+
province: import_joi11.default.string().max(100).optional().allow(null, ""),
|
|
4529
|
+
cityMunicipalityPSGC: import_joi11.default.string().length(10).optional().allow(null, ""),
|
|
4530
|
+
postalCode: import_joi11.default.string().max(20).optional().allow(null, ""),
|
|
4531
|
+
contactNumber: import_joi11.default.string().max(20).optional().allow(null, ""),
|
|
4532
|
+
email: import_joi11.default.string().email().max(100).optional().allow(null, "")
|
|
4431
4533
|
});
|
|
4432
4534
|
function modelSchool(value) {
|
|
4433
4535
|
const { error } = schemaSchool.validate(value);
|
|
@@ -4505,7 +4607,6 @@ function useSchoolRepo() {
|
|
|
4505
4607
|
{ key: { name: 1 } },
|
|
4506
4608
|
{ key: { createdAt: 1 } },
|
|
4507
4609
|
{ key: { name: "text" } },
|
|
4508
|
-
{ key: { cityMunicipalityPSGC: 1 }, unique: true, name: "unique_psgc" },
|
|
4509
4610
|
{ key: { id: 1, status: 1 }, unique: true, name: "unique_school_id" }
|
|
4510
4611
|
]);
|
|
4511
4612
|
} catch (error) {
|
|
@@ -33283,14 +33384,20 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
|
|
|
33283
33384
|
session.startTransaction();
|
|
33284
33385
|
const school = schools[i];
|
|
33285
33386
|
try {
|
|
33286
|
-
|
|
33287
|
-
|
|
33288
|
-
|
|
33289
|
-
|
|
33387
|
+
let provincePSGC = "";
|
|
33388
|
+
if (school.province) {
|
|
33389
|
+
const provinceData = await getPSGCByName({
|
|
33390
|
+
name: school.province,
|
|
33391
|
+
type: "Prov"
|
|
33392
|
+
});
|
|
33393
|
+
if (provinceData) {
|
|
33394
|
+
provincePSGC = provinceData.code ?? "";
|
|
33395
|
+
}
|
|
33396
|
+
}
|
|
33290
33397
|
const cityMunPSGC = await getPSGCByName({
|
|
33291
33398
|
name: school.cityMunicipality ?? "",
|
|
33292
33399
|
type: "City",
|
|
33293
|
-
prefix: provincePSGC ? provincePSGC.
|
|
33400
|
+
prefix: provincePSGC ? provincePSGC.toString().slice(0, 5) : ""
|
|
33294
33401
|
});
|
|
33295
33402
|
if (!cityMunPSGC) {
|
|
33296
33403
|
throw new import_nodejs_utils18.BadRequestError(
|
|
@@ -33345,7 +33452,7 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
|
|
|
33345
33452
|
|
|
33346
33453
|
// src/resources/school/school.controller.ts
|
|
33347
33454
|
var import_nodejs_utils19 = require("@eeplatform/nodejs-utils");
|
|
33348
|
-
var
|
|
33455
|
+
var import_joi12 = __toESM(require("joi"));
|
|
33349
33456
|
function useSchoolController() {
|
|
33350
33457
|
const {
|
|
33351
33458
|
getAll: _getAll,
|
|
@@ -33378,16 +33485,16 @@ function useSchoolController() {
|
|
|
33378
33485
|
}
|
|
33379
33486
|
}
|
|
33380
33487
|
async function getAll(req, res, next) {
|
|
33381
|
-
const validation =
|
|
33382
|
-
page:
|
|
33383
|
-
limit:
|
|
33384
|
-
sort:
|
|
33385
|
-
sortOrder:
|
|
33386
|
-
status:
|
|
33387
|
-
org:
|
|
33388
|
-
app:
|
|
33389
|
-
search:
|
|
33390
|
-
psgc:
|
|
33488
|
+
const validation = import_joi12.default.object({
|
|
33489
|
+
page: import_joi12.default.number().optional().allow(null, ""),
|
|
33490
|
+
limit: import_joi12.default.number().optional().allow(null, ""),
|
|
33491
|
+
sort: import_joi12.default.string().optional().allow(null, ""),
|
|
33492
|
+
sortOrder: import_joi12.default.string().optional().allow(null, ""),
|
|
33493
|
+
status: import_joi12.default.string().optional().allow(null, ""),
|
|
33494
|
+
org: import_joi12.default.string().hex().optional().allow(null, ""),
|
|
33495
|
+
app: import_joi12.default.string().optional().allow(null, ""),
|
|
33496
|
+
search: import_joi12.default.string().optional().allow(null, ""),
|
|
33497
|
+
psgc: import_joi12.default.string().optional().allow(null, "")
|
|
33391
33498
|
});
|
|
33392
33499
|
const { error } = validation.validate(req.query);
|
|
33393
33500
|
if (error) {
|
|
@@ -33425,7 +33532,7 @@ function useSchoolController() {
|
|
|
33425
33532
|
}
|
|
33426
33533
|
async function getByCreatedBy(req, res, next) {
|
|
33427
33534
|
const createdBy = req.params.createdBy;
|
|
33428
|
-
const validation =
|
|
33535
|
+
const validation = import_joi12.default.string().hex().required();
|
|
33429
33536
|
const { error } = validation.validate(createdBy);
|
|
33430
33537
|
if (error) {
|
|
33431
33538
|
next(new import_nodejs_utils19.BadRequestError(`Validation error: ${error.message}`));
|
|
@@ -33442,9 +33549,9 @@ function useSchoolController() {
|
|
|
33442
33549
|
async function updateStatusById(req, res, next) {
|
|
33443
33550
|
const schoolId = req.params.id;
|
|
33444
33551
|
const status = req.params.status;
|
|
33445
|
-
const validation =
|
|
33446
|
-
id:
|
|
33447
|
-
status:
|
|
33552
|
+
const validation = import_joi12.default.object({
|
|
33553
|
+
id: import_joi12.default.string().hex().required(),
|
|
33554
|
+
status: import_joi12.default.string().valid("active", "deleted", "suspended").required()
|
|
33448
33555
|
});
|
|
33449
33556
|
const { error } = validation.validate({ id: schoolId, status });
|
|
33450
33557
|
if (error) {
|
|
@@ -33477,8 +33584,8 @@ function useSchoolController() {
|
|
|
33477
33584
|
}
|
|
33478
33585
|
async function approveSchool(req, res, next) {
|
|
33479
33586
|
const schoolId = req.params.id;
|
|
33480
|
-
const validation =
|
|
33481
|
-
id:
|
|
33587
|
+
const validation = import_joi12.default.object({
|
|
33588
|
+
id: import_joi12.default.string().hex().required()
|
|
33482
33589
|
});
|
|
33483
33590
|
const { error } = validation.validate({ id: schoolId });
|
|
33484
33591
|
if (error) {
|
|
@@ -33501,11 +33608,11 @@ function useSchoolController() {
|
|
|
33501
33608
|
return;
|
|
33502
33609
|
}
|
|
33503
33610
|
const { region, regionName, division, divisionName } = req.body;
|
|
33504
|
-
const validation =
|
|
33505
|
-
region:
|
|
33506
|
-
regionName:
|
|
33507
|
-
division:
|
|
33508
|
-
divisionName:
|
|
33611
|
+
const validation = import_joi12.default.object({
|
|
33612
|
+
region: import_joi12.default.string().hex().required(),
|
|
33613
|
+
regionName: import_joi12.default.string().min(1).required(),
|
|
33614
|
+
division: import_joi12.default.string().hex().required(),
|
|
33615
|
+
divisionName: import_joi12.default.string().min(1).required()
|
|
33509
33616
|
});
|
|
33510
33617
|
const { error } = validation.validate({
|
|
33511
33618
|
region,
|
|
@@ -33534,10 +33641,10 @@ function useSchoolController() {
|
|
|
33534
33641
|
async function updateFieldById(req, res, next) {
|
|
33535
33642
|
const _id = req.params.id;
|
|
33536
33643
|
const { field, value } = req.body;
|
|
33537
|
-
const validation =
|
|
33538
|
-
_id:
|
|
33539
|
-
field:
|
|
33540
|
-
value:
|
|
33644
|
+
const validation = import_joi12.default.object({
|
|
33645
|
+
_id: import_joi12.default.string().hex().required(),
|
|
33646
|
+
field: import_joi12.default.string().valid("name", "director", "directorName").required(),
|
|
33647
|
+
value: import_joi12.default.string().required()
|
|
33541
33648
|
});
|
|
33542
33649
|
const { error } = validation.validate({ _id, field, value });
|
|
33543
33650
|
if (error) {
|
|
@@ -33555,8 +33662,8 @@ function useSchoolController() {
|
|
|
33555
33662
|
async function updateById(req, res, next) {
|
|
33556
33663
|
const id = req.params.id;
|
|
33557
33664
|
const payload = req.body;
|
|
33558
|
-
const validation =
|
|
33559
|
-
id:
|
|
33665
|
+
const validation = import_joi12.default.object({
|
|
33666
|
+
id: import_joi12.default.string().hex().required()
|
|
33560
33667
|
});
|
|
33561
33668
|
const { error: idError } = validation.validate({ id });
|
|
33562
33669
|
if (idError) {
|
|
@@ -33578,8 +33685,8 @@ function useSchoolController() {
|
|
|
33578
33685
|
}
|
|
33579
33686
|
async function deleteById(req, res, next) {
|
|
33580
33687
|
const _id = req.params.id;
|
|
33581
|
-
const validation =
|
|
33582
|
-
_id:
|
|
33688
|
+
const validation = import_joi12.default.object({
|
|
33689
|
+
_id: import_joi12.default.string().hex().required()
|
|
33583
33690
|
});
|
|
33584
33691
|
const { error } = validation.validate({ _id });
|
|
33585
33692
|
if (error) {
|
|
@@ -33674,7 +33781,7 @@ function useDivisionService() {
|
|
|
33674
33781
|
|
|
33675
33782
|
// src/resources/division/division.controller.ts
|
|
33676
33783
|
var import_nodejs_utils21 = require("@eeplatform/nodejs-utils");
|
|
33677
|
-
var
|
|
33784
|
+
var import_joi13 = __toESM(require("joi"));
|
|
33678
33785
|
function useDivisionController() {
|
|
33679
33786
|
const { add: _add, updateById: _updateById } = useDivisionService();
|
|
33680
33787
|
const {
|
|
@@ -33704,12 +33811,12 @@ function useDivisionController() {
|
|
|
33704
33811
|
}
|
|
33705
33812
|
async function getAll(req, res, next) {
|
|
33706
33813
|
const query = req.query;
|
|
33707
|
-
const validation =
|
|
33708
|
-
page:
|
|
33709
|
-
limit:
|
|
33710
|
-
search:
|
|
33711
|
-
status:
|
|
33712
|
-
region:
|
|
33814
|
+
const validation = import_joi13.default.object({
|
|
33815
|
+
page: import_joi13.default.number().min(1).optional().allow("", null),
|
|
33816
|
+
limit: import_joi13.default.number().min(1).optional().allow("", null),
|
|
33817
|
+
search: import_joi13.default.string().optional().allow("", null),
|
|
33818
|
+
status: import_joi13.default.string().optional().allow("", null),
|
|
33819
|
+
region: import_joi13.default.string().hex().optional().allow("", null)
|
|
33713
33820
|
});
|
|
33714
33821
|
const { error } = validation.validate(query);
|
|
33715
33822
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -33741,8 +33848,8 @@ function useDivisionController() {
|
|
|
33741
33848
|
}
|
|
33742
33849
|
async function getById(req, res, next) {
|
|
33743
33850
|
const id = req.params.id;
|
|
33744
|
-
const validation =
|
|
33745
|
-
id:
|
|
33851
|
+
const validation = import_joi13.default.object({
|
|
33852
|
+
id: import_joi13.default.string().hex().required()
|
|
33746
33853
|
});
|
|
33747
33854
|
const { error } = validation.validate({ id });
|
|
33748
33855
|
if (error) {
|
|
@@ -33762,8 +33869,8 @@ function useDivisionController() {
|
|
|
33762
33869
|
}
|
|
33763
33870
|
async function getByName(req, res, next) {
|
|
33764
33871
|
const name = req.params.name;
|
|
33765
|
-
const validation =
|
|
33766
|
-
name:
|
|
33872
|
+
const validation = import_joi13.default.object({
|
|
33873
|
+
name: import_joi13.default.string().required()
|
|
33767
33874
|
});
|
|
33768
33875
|
const { error } = validation.validate({ name });
|
|
33769
33876
|
if (error) {
|
|
@@ -33784,10 +33891,10 @@ function useDivisionController() {
|
|
|
33784
33891
|
async function updateField(req, res, next) {
|
|
33785
33892
|
const _id = req.params.id;
|
|
33786
33893
|
const { field, value } = req.body;
|
|
33787
|
-
const validation =
|
|
33788
|
-
_id:
|
|
33789
|
-
field:
|
|
33790
|
-
value:
|
|
33894
|
+
const validation = import_joi13.default.object({
|
|
33895
|
+
_id: import_joi13.default.string().hex().required(),
|
|
33896
|
+
field: import_joi13.default.string().valid("name", "director", "directorName").required(),
|
|
33897
|
+
value: import_joi13.default.string().required()
|
|
33791
33898
|
});
|
|
33792
33899
|
const { error } = validation.validate({ _id, field, value });
|
|
33793
33900
|
if (error) {
|
|
@@ -33820,8 +33927,8 @@ function useDivisionController() {
|
|
|
33820
33927
|
}
|
|
33821
33928
|
async function deleteById(req, res, next) {
|
|
33822
33929
|
const _id = req.params.id;
|
|
33823
|
-
const validation =
|
|
33824
|
-
_id:
|
|
33930
|
+
const validation = import_joi13.default.object({
|
|
33931
|
+
_id: import_joi13.default.string().hex().required()
|
|
33825
33932
|
});
|
|
33826
33933
|
const { error } = validation.validate({ _id });
|
|
33827
33934
|
if (error) {
|
|
@@ -33849,48 +33956,48 @@ function useDivisionController() {
|
|
|
33849
33956
|
|
|
33850
33957
|
// src/resources/asset/asset.model.ts
|
|
33851
33958
|
var import_nodejs_utils22 = require("@eeplatform/nodejs-utils");
|
|
33852
|
-
var
|
|
33959
|
+
var import_joi14 = __toESM(require("joi"));
|
|
33853
33960
|
var import_mongodb13 = require("mongodb");
|
|
33854
|
-
var schemaAsset =
|
|
33855
|
-
_id:
|
|
33856
|
-
school:
|
|
33857
|
-
asset_type:
|
|
33858
|
-
name:
|
|
33859
|
-
category:
|
|
33860
|
-
type:
|
|
33861
|
-
brand:
|
|
33862
|
-
unit:
|
|
33863
|
-
status:
|
|
33864
|
-
createdAt:
|
|
33865
|
-
updatedAt:
|
|
33866
|
-
deletedAt:
|
|
33867
|
-
metadata:
|
|
33868
|
-
title:
|
|
33869
|
-
isbn:
|
|
33870
|
-
author:
|
|
33871
|
-
edition:
|
|
33872
|
-
subject:
|
|
33873
|
-
grade_level:
|
|
33874
|
-
publisher:
|
|
33875
|
-
language:
|
|
33961
|
+
var schemaAsset = import_joi14.default.object({
|
|
33962
|
+
_id: import_joi14.default.string().hex().optional(),
|
|
33963
|
+
school: import_joi14.default.string().hex().required(),
|
|
33964
|
+
asset_type: import_joi14.default.string().required().allow("supply", "furniture-equipment", "fixed-asset"),
|
|
33965
|
+
name: import_joi14.default.string().required(),
|
|
33966
|
+
category: import_joi14.default.string().optional().allow("", null),
|
|
33967
|
+
type: import_joi14.default.string().optional().allow("", null),
|
|
33968
|
+
brand: import_joi14.default.string().optional().allow("", null),
|
|
33969
|
+
unit: import_joi14.default.string().required(),
|
|
33970
|
+
status: import_joi14.default.string().optional().allow("", null),
|
|
33971
|
+
createdAt: import_joi14.default.date().optional().allow("", null),
|
|
33972
|
+
updatedAt: import_joi14.default.date().optional().allow("", null),
|
|
33973
|
+
deletedAt: import_joi14.default.date().optional().allow("", null),
|
|
33974
|
+
metadata: import_joi14.default.object({
|
|
33975
|
+
title: import_joi14.default.string().optional().allow("", null),
|
|
33976
|
+
isbn: import_joi14.default.string().optional().allow("", null),
|
|
33977
|
+
author: import_joi14.default.string().optional().allow("", null),
|
|
33978
|
+
edition: import_joi14.default.string().optional().allow("", null),
|
|
33979
|
+
subject: import_joi14.default.string().optional().allow("", null),
|
|
33980
|
+
grade_level: import_joi14.default.number().integer().min(0).optional().allow("", null),
|
|
33981
|
+
publisher: import_joi14.default.string().optional().allow("", null),
|
|
33982
|
+
language: import_joi14.default.string().optional().allow("", null)
|
|
33876
33983
|
}).optional().allow(null)
|
|
33877
33984
|
});
|
|
33878
|
-
var schemaAssetUpdateOption =
|
|
33879
|
-
name:
|
|
33880
|
-
category:
|
|
33881
|
-
type:
|
|
33882
|
-
brand:
|
|
33883
|
-
qty:
|
|
33884
|
-
unit:
|
|
33885
|
-
metadata:
|
|
33886
|
-
title:
|
|
33887
|
-
isbn:
|
|
33888
|
-
author:
|
|
33889
|
-
edition:
|
|
33890
|
-
subject:
|
|
33891
|
-
grade_level:
|
|
33892
|
-
publisher:
|
|
33893
|
-
language:
|
|
33985
|
+
var schemaAssetUpdateOption = import_joi14.default.object({
|
|
33986
|
+
name: import_joi14.default.string().optional().allow("", null),
|
|
33987
|
+
category: import_joi14.default.string().optional().allow("", null),
|
|
33988
|
+
type: import_joi14.default.string().optional().allow("", null),
|
|
33989
|
+
brand: import_joi14.default.string().optional().allow("", null),
|
|
33990
|
+
qty: import_joi14.default.number().integer().min(0).optional().allow("", null),
|
|
33991
|
+
unit: import_joi14.default.string().optional().allow("", null),
|
|
33992
|
+
metadata: import_joi14.default.object({
|
|
33993
|
+
title: import_joi14.default.string().optional().allow("", null),
|
|
33994
|
+
isbn: import_joi14.default.string().optional().allow("", null),
|
|
33995
|
+
author: import_joi14.default.string().optional().allow("", null),
|
|
33996
|
+
edition: import_joi14.default.string().optional().allow("", null),
|
|
33997
|
+
subject: import_joi14.default.string().optional().allow("", null),
|
|
33998
|
+
grade_level: import_joi14.default.number().integer().min(0).optional().allow("", null),
|
|
33999
|
+
publisher: import_joi14.default.string().optional().allow("", null),
|
|
34000
|
+
language: import_joi14.default.string().optional().allow("", null)
|
|
33894
34001
|
}).optional().allow(null)
|
|
33895
34002
|
});
|
|
33896
34003
|
function MAsset(value) {
|
|
@@ -34322,7 +34429,7 @@ function useAssetRepo() {
|
|
|
34322
34429
|
|
|
34323
34430
|
// src/resources/asset/asset.controller.ts
|
|
34324
34431
|
var import_nodejs_utils24 = require("@eeplatform/nodejs-utils");
|
|
34325
|
-
var
|
|
34432
|
+
var import_joi15 = __toESM(require("joi"));
|
|
34326
34433
|
function useAssetController() {
|
|
34327
34434
|
const {
|
|
34328
34435
|
add: _add,
|
|
@@ -34350,13 +34457,13 @@ function useAssetController() {
|
|
|
34350
34457
|
}
|
|
34351
34458
|
async function getAll(req, res, next) {
|
|
34352
34459
|
const query = req.query;
|
|
34353
|
-
const validation =
|
|
34354
|
-
page:
|
|
34355
|
-
limit:
|
|
34356
|
-
search:
|
|
34357
|
-
status:
|
|
34358
|
-
school:
|
|
34359
|
-
asset_type:
|
|
34460
|
+
const validation = import_joi15.default.object({
|
|
34461
|
+
page: import_joi15.default.number().min(1).optional().allow("", null),
|
|
34462
|
+
limit: import_joi15.default.number().min(1).optional().allow("", null),
|
|
34463
|
+
search: import_joi15.default.string().optional().allow("", null),
|
|
34464
|
+
status: import_joi15.default.string().optional().allow("", null),
|
|
34465
|
+
school: import_joi15.default.string().hex().optional().allow("", null),
|
|
34466
|
+
asset_type: import_joi15.default.string().required().allow("supply", "furniture-equipment", "fixed-asset")
|
|
34360
34467
|
});
|
|
34361
34468
|
const { error } = validation.validate(query);
|
|
34362
34469
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -34396,7 +34503,7 @@ function useAssetController() {
|
|
|
34396
34503
|
}
|
|
34397
34504
|
async function deleteById(req, res, next) {
|
|
34398
34505
|
const id = req.params.id;
|
|
34399
|
-
const validation =
|
|
34506
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34400
34507
|
const { error } = validation.validate(id);
|
|
34401
34508
|
if (error) {
|
|
34402
34509
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34411,7 +34518,7 @@ function useAssetController() {
|
|
|
34411
34518
|
}
|
|
34412
34519
|
async function getById(req, res, next) {
|
|
34413
34520
|
const id = req.params.id;
|
|
34414
|
-
const validation =
|
|
34521
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34415
34522
|
const { error } = validation.validate(id);
|
|
34416
34523
|
if (error) {
|
|
34417
34524
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34442,7 +34549,7 @@ function useAssetController() {
|
|
|
34442
34549
|
async function getCategories(req, res, next) {
|
|
34443
34550
|
const school = req.params.school;
|
|
34444
34551
|
const asset_type = req.params.asset_type;
|
|
34445
|
-
const validation =
|
|
34552
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34446
34553
|
const { error } = validation.validate(school);
|
|
34447
34554
|
if (error) {
|
|
34448
34555
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34458,7 +34565,7 @@ function useAssetController() {
|
|
|
34458
34565
|
async function getTypes(req, res, next) {
|
|
34459
34566
|
const school = req.params.school;
|
|
34460
34567
|
const asset_type = req.params.asset_type;
|
|
34461
|
-
const validation =
|
|
34568
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34462
34569
|
const { error } = validation.validate(school);
|
|
34463
34570
|
if (error) {
|
|
34464
34571
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34473,7 +34580,7 @@ function useAssetController() {
|
|
|
34473
34580
|
}
|
|
34474
34581
|
async function getUnitsBySchool(req, res, next) {
|
|
34475
34582
|
const school = req.params.school;
|
|
34476
|
-
const validation =
|
|
34583
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34477
34584
|
const { error } = validation.validate(school);
|
|
34478
34585
|
if (error) {
|
|
34479
34586
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34500,26 +34607,26 @@ function useAssetController() {
|
|
|
34500
34607
|
|
|
34501
34608
|
// src/resources/stock-card/stock-card.model.ts
|
|
34502
34609
|
var import_nodejs_utils25 = require("@eeplatform/nodejs-utils");
|
|
34503
|
-
var
|
|
34610
|
+
var import_joi16 = __toESM(require("joi"));
|
|
34504
34611
|
var import_mongodb15 = require("mongodb");
|
|
34505
|
-
var schemaStockCard =
|
|
34506
|
-
_id:
|
|
34507
|
-
school:
|
|
34508
|
-
item:
|
|
34509
|
-
balance:
|
|
34510
|
-
qty:
|
|
34511
|
-
unitCost:
|
|
34512
|
-
totalCost:
|
|
34513
|
-
status:
|
|
34514
|
-
condition:
|
|
34515
|
-
supplier:
|
|
34516
|
-
location:
|
|
34517
|
-
locationName:
|
|
34518
|
-
reason:
|
|
34519
|
-
remarks:
|
|
34520
|
-
createdAt:
|
|
34521
|
-
updatedAt:
|
|
34522
|
-
deletedAt:
|
|
34612
|
+
var schemaStockCard = import_joi16.default.object({
|
|
34613
|
+
_id: import_joi16.default.string().hex().optional().allow("", null),
|
|
34614
|
+
school: import_joi16.default.string().hex().required(),
|
|
34615
|
+
item: import_joi16.default.string().hex().required(),
|
|
34616
|
+
balance: import_joi16.default.number().optional().allow(null, 0),
|
|
34617
|
+
qty: import_joi16.default.number().required(),
|
|
34618
|
+
unitCost: import_joi16.default.number().optional().allow(null, 0),
|
|
34619
|
+
totalCost: import_joi16.default.number().optional().allow(null, 0),
|
|
34620
|
+
status: import_joi16.default.string().optional().allow(null, ""),
|
|
34621
|
+
condition: import_joi16.default.string().required(),
|
|
34622
|
+
supplier: import_joi16.default.string().optional().allow("", null),
|
|
34623
|
+
location: import_joi16.default.string().optional().allow("", null),
|
|
34624
|
+
locationName: import_joi16.default.string().optional().allow("", null),
|
|
34625
|
+
reason: import_joi16.default.string().optional().allow("", null),
|
|
34626
|
+
remarks: import_joi16.default.string().optional().allow("", null),
|
|
34627
|
+
createdAt: import_joi16.default.date().optional().allow("", null),
|
|
34628
|
+
updatedAt: import_joi16.default.date().optional().allow("", null),
|
|
34629
|
+
deletedAt: import_joi16.default.date().optional().allow("", null)
|
|
34523
34630
|
});
|
|
34524
34631
|
function MStockCard(value) {
|
|
34525
34632
|
const { error } = schemaStockCard.validate(value);
|
|
@@ -34807,7 +34914,7 @@ function useStockCardService() {
|
|
|
34807
34914
|
|
|
34808
34915
|
// src/resources/stock-card/stock-card.controller.ts
|
|
34809
34916
|
var import_nodejs_utils28 = require("@eeplatform/nodejs-utils");
|
|
34810
|
-
var
|
|
34917
|
+
var import_joi17 = __toESM(require("joi"));
|
|
34811
34918
|
function useStockCardController() {
|
|
34812
34919
|
const {
|
|
34813
34920
|
getAll: _getAll,
|
|
@@ -34831,11 +34938,11 @@ function useStockCardController() {
|
|
|
34831
34938
|
}
|
|
34832
34939
|
async function getAll(req, res, next) {
|
|
34833
34940
|
const query = req.query;
|
|
34834
|
-
const validation =
|
|
34835
|
-
page:
|
|
34836
|
-
limit:
|
|
34837
|
-
school:
|
|
34838
|
-
id:
|
|
34941
|
+
const validation = import_joi17.default.object({
|
|
34942
|
+
page: import_joi17.default.number().min(1).optional().allow("", null),
|
|
34943
|
+
limit: import_joi17.default.number().min(1).optional().allow("", null),
|
|
34944
|
+
school: import_joi17.default.string().hex().optional().allow("", null),
|
|
34945
|
+
id: import_joi17.default.string().hex().required()
|
|
34839
34946
|
});
|
|
34840
34947
|
const { error } = validation.validate(query);
|
|
34841
34948
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -34871,7 +34978,7 @@ function useStockCardController() {
|
|
|
34871
34978
|
}
|
|
34872
34979
|
async function getById(req, res, next) {
|
|
34873
34980
|
const id = req.params.id;
|
|
34874
|
-
const validation =
|
|
34981
|
+
const validation = import_joi17.default.string().hex().required();
|
|
34875
34982
|
const { error } = validation.validate(id);
|
|
34876
34983
|
if (error) {
|
|
34877
34984
|
next(new import_nodejs_utils28.BadRequestError(error.message));
|
|
@@ -34886,7 +34993,7 @@ function useStockCardController() {
|
|
|
34886
34993
|
}
|
|
34887
34994
|
async function getSuppliers(req, res, next) {
|
|
34888
34995
|
const school = req.params.school;
|
|
34889
|
-
const validation =
|
|
34996
|
+
const validation = import_joi17.default.string().hex().required();
|
|
34890
34997
|
const { error } = validation.validate(school);
|
|
34891
34998
|
if (error) {
|
|
34892
34999
|
next(new import_nodejs_utils28.BadRequestError(error.message));
|
|
@@ -34909,30 +35016,30 @@ function useStockCardController() {
|
|
|
34909
35016
|
|
|
34910
35017
|
// src/resources/plantilla/plantilla.model.ts
|
|
34911
35018
|
var import_nodejs_utils29 = require("@eeplatform/nodejs-utils");
|
|
34912
|
-
var
|
|
35019
|
+
var import_joi18 = __toESM(require("joi"));
|
|
34913
35020
|
var import_mongodb17 = require("mongodb");
|
|
34914
|
-
var schemaPlantilla =
|
|
34915
|
-
_id:
|
|
34916
|
-
org:
|
|
34917
|
-
orgUnitCode:
|
|
34918
|
-
employmentType:
|
|
34919
|
-
personnelType:
|
|
34920
|
-
itemNumber:
|
|
34921
|
-
positionTitle:
|
|
34922
|
-
positionCategory:
|
|
34923
|
-
region:
|
|
34924
|
-
regionName:
|
|
34925
|
-
division:
|
|
34926
|
-
divisionName:
|
|
34927
|
-
salaryGrade:
|
|
34928
|
-
employeeName:
|
|
34929
|
-
annualSalary:
|
|
34930
|
-
monthlySalary:
|
|
34931
|
-
status:
|
|
34932
|
-
employee:
|
|
34933
|
-
createdAt:
|
|
34934
|
-
updatedAt:
|
|
34935
|
-
deletedAt:
|
|
35021
|
+
var schemaPlantilla = import_joi18.default.object({
|
|
35022
|
+
_id: import_joi18.default.string().hex().optional().allow(null, ""),
|
|
35023
|
+
org: import_joi18.default.string().hex().required(),
|
|
35024
|
+
orgUnitCode: import_joi18.default.string().optional().allow(null, ""),
|
|
35025
|
+
employmentType: import_joi18.default.string().optional().allow(null, ""),
|
|
35026
|
+
personnelType: import_joi18.default.string().required(),
|
|
35027
|
+
itemNumber: import_joi18.default.string().required(),
|
|
35028
|
+
positionTitle: import_joi18.default.string().required(),
|
|
35029
|
+
positionCategory: import_joi18.default.string().required(),
|
|
35030
|
+
region: import_joi18.default.string().hex().optional().allow(null, ""),
|
|
35031
|
+
regionName: import_joi18.default.string().optional().allow(null, ""),
|
|
35032
|
+
division: import_joi18.default.string().hex().optional().allow(null, ""),
|
|
35033
|
+
divisionName: import_joi18.default.string().optional().allow(null, ""),
|
|
35034
|
+
salaryGrade: import_joi18.default.number().required(),
|
|
35035
|
+
employeeName: import_joi18.default.string().optional().allow(null, ""),
|
|
35036
|
+
annualSalary: import_joi18.default.number().optional().allow(null, 0),
|
|
35037
|
+
monthlySalary: import_joi18.default.number().optional().allow(null, 0),
|
|
35038
|
+
status: import_joi18.default.string().required(),
|
|
35039
|
+
employee: import_joi18.default.string().hex().optional().allow(null, ""),
|
|
35040
|
+
createdAt: import_joi18.default.date().iso().optional().allow(null, ""),
|
|
35041
|
+
updatedAt: import_joi18.default.date().iso().optional().allow(null, ""),
|
|
35042
|
+
deletedAt: import_joi18.default.date().iso().optional().allow(null, "")
|
|
34936
35043
|
});
|
|
34937
35044
|
function MPlantilla(data) {
|
|
34938
35045
|
const { error } = schemaPlantilla.validate(data);
|
|
@@ -35414,7 +35521,7 @@ ${errors.slice(0, 10).join("\n")}${errors.length > 10 ? `
|
|
|
35414
35521
|
|
|
35415
35522
|
// src/resources/plantilla/plantilla.controller.ts
|
|
35416
35523
|
var import_nodejs_utils32 = require("@eeplatform/nodejs-utils");
|
|
35417
|
-
var
|
|
35524
|
+
var import_joi19 = __toESM(require("joi"));
|
|
35418
35525
|
function usePlantillaController() {
|
|
35419
35526
|
const {
|
|
35420
35527
|
add: _addPlantilla,
|
|
@@ -35426,11 +35533,11 @@ function usePlantillaController() {
|
|
|
35426
35533
|
const { addBulk: _addBulk } = usePlantillaService();
|
|
35427
35534
|
async function createPlantilla(req, res, next) {
|
|
35428
35535
|
const value = req.body;
|
|
35429
|
-
const validation =
|
|
35430
|
-
itemNumber:
|
|
35431
|
-
positionTitle:
|
|
35432
|
-
positionCategory:
|
|
35433
|
-
status:
|
|
35536
|
+
const validation = import_joi19.default.object({
|
|
35537
|
+
itemNumber: import_joi19.default.string().required(),
|
|
35538
|
+
positionTitle: import_joi19.default.string().required(),
|
|
35539
|
+
positionCategory: import_joi19.default.string().required(),
|
|
35540
|
+
status: import_joi19.default.string().required()
|
|
35434
35541
|
});
|
|
35435
35542
|
const { error } = validation.validate(value);
|
|
35436
35543
|
if (error) {
|
|
@@ -35460,11 +35567,11 @@ function usePlantillaController() {
|
|
|
35460
35567
|
next(new import_nodejs_utils32.BadRequestError("Invalid limit number."));
|
|
35461
35568
|
return;
|
|
35462
35569
|
}
|
|
35463
|
-
const validation =
|
|
35464
|
-
page:
|
|
35465
|
-
limit:
|
|
35466
|
-
search:
|
|
35467
|
-
org:
|
|
35570
|
+
const validation = import_joi19.default.object({
|
|
35571
|
+
page: import_joi19.default.number().min(1).optional().allow("", null),
|
|
35572
|
+
limit: import_joi19.default.number().min(1).optional().allow("", null),
|
|
35573
|
+
search: import_joi19.default.string().optional().allow("", null),
|
|
35574
|
+
org: import_joi19.default.string().optional().allow("", null)
|
|
35468
35575
|
});
|
|
35469
35576
|
const { error } = validation.validate({ page, limit, search, org });
|
|
35470
35577
|
if (error) {
|
|
@@ -35486,8 +35593,8 @@ function usePlantillaController() {
|
|
|
35486
35593
|
}
|
|
35487
35594
|
async function getPlantillaById(req, res, next) {
|
|
35488
35595
|
const id = req.params.id;
|
|
35489
|
-
const validation =
|
|
35490
|
-
id:
|
|
35596
|
+
const validation = import_joi19.default.object({
|
|
35597
|
+
id: import_joi19.default.string().hex().required()
|
|
35491
35598
|
});
|
|
35492
35599
|
const { error } = validation.validate({ id });
|
|
35493
35600
|
if (error) {
|
|
@@ -35509,12 +35616,12 @@ function usePlantillaController() {
|
|
|
35509
35616
|
async function updatePlantilla(req, res, next) {
|
|
35510
35617
|
const id = req.params.id;
|
|
35511
35618
|
const value = req.body;
|
|
35512
|
-
const validation =
|
|
35513
|
-
id:
|
|
35514
|
-
employee:
|
|
35515
|
-
status:
|
|
35516
|
-
positionTitle:
|
|
35517
|
-
positionCategory:
|
|
35619
|
+
const validation = import_joi19.default.object({
|
|
35620
|
+
id: import_joi19.default.string().hex().required(),
|
|
35621
|
+
employee: import_joi19.default.string().hex().optional().allow(null, ""),
|
|
35622
|
+
status: import_joi19.default.string().optional(),
|
|
35623
|
+
positionTitle: import_joi19.default.string().optional(),
|
|
35624
|
+
positionCategory: import_joi19.default.string().optional()
|
|
35518
35625
|
});
|
|
35519
35626
|
const { error } = validation.validate({ id, ...value });
|
|
35520
35627
|
if (error) {
|
|
@@ -35535,8 +35642,8 @@ function usePlantillaController() {
|
|
|
35535
35642
|
}
|
|
35536
35643
|
async function deletePlantilla(req, res, next) {
|
|
35537
35644
|
const id = req.params.id;
|
|
35538
|
-
const validation =
|
|
35539
|
-
id:
|
|
35645
|
+
const validation = import_joi19.default.object({
|
|
35646
|
+
id: import_joi19.default.string().hex().required()
|
|
35540
35647
|
});
|
|
35541
35648
|
const { error } = validation.validate({ id });
|
|
35542
35649
|
if (error) {
|
|
@@ -35561,9 +35668,9 @@ function usePlantillaController() {
|
|
|
35561
35668
|
return;
|
|
35562
35669
|
}
|
|
35563
35670
|
const { region, division } = req.body;
|
|
35564
|
-
const validation =
|
|
35565
|
-
region:
|
|
35566
|
-
division:
|
|
35671
|
+
const validation = import_joi19.default.object({
|
|
35672
|
+
region: import_joi19.default.string().hex().optional(),
|
|
35673
|
+
division: import_joi19.default.string().hex().optional()
|
|
35567
35674
|
});
|
|
35568
35675
|
const { error } = validation.validate({ region, division });
|
|
35569
35676
|
if (error) {
|