@eeplatform/basic-edu 1.3.10 → 1.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +51 -33
- package/dist/index.js +588 -507
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +588 -507
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.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,100 @@ 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
|
-
|
|
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
|
+
schoolId: import_joi3.default.string().required(),
|
|
1908
|
+
// Changed from hex to string to match frontend
|
|
1901
1909
|
school: import_joi3.default.string().hex().required(),
|
|
1910
|
+
// Added to match frontend
|
|
1911
|
+
schoolName: import_joi3.default.string().required(),
|
|
1912
|
+
// Added to match frontend
|
|
1902
1913
|
schoolYear: import_joi3.default.string().required(),
|
|
1903
|
-
|
|
1914
|
+
gradeLevel: import_joi3.default.string().valid(...gradeLevels).required(),
|
|
1915
|
+
returningLearner: import_joi3.default.boolean().required(),
|
|
1916
|
+
// Added to match frontend
|
|
1904
1917
|
learnerInfo: learnerInfoSchema.required(),
|
|
1905
1918
|
parentGuardianInfo: import_joi3.default.object({
|
|
1906
|
-
father: personContactSchema.
|
|
1907
|
-
|
|
1908
|
-
|
|
1919
|
+
father: personContactSchema.required(),
|
|
1920
|
+
// Made required to match frontend
|
|
1921
|
+
mother: personContactSchema.required(),
|
|
1922
|
+
// Made required to match frontend
|
|
1923
|
+
legalGuardian: personContactSchema.required()
|
|
1924
|
+
// Made required to match frontend
|
|
1909
1925
|
}).required(),
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1926
|
+
address: import_joi3.default.object({
|
|
1927
|
+
// Changed from addressInfo to address
|
|
1928
|
+
current: addressSchema.required(),
|
|
1929
|
+
// Changed from currentAddress to current
|
|
1930
|
+
permanent: addressSchema.required(),
|
|
1931
|
+
// Changed from permanentAddress to permanent and made required
|
|
1913
1932
|
sameAsCurrent: import_joi3.default.boolean().optional()
|
|
1914
1933
|
}).required(),
|
|
1915
1934
|
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()
|
|
1935
|
+
lastGradeLevelCompleted: import_joi3.default.string().optional().allow("", null),
|
|
1936
|
+
lastSchoolYearCompleted: import_joi3.default.string().optional().allow("", null),
|
|
1937
|
+
lastSchoolAttended: import_joi3.default.string().optional().allow("", null),
|
|
1938
|
+
lastSchoolId: import_joi3.default.string().optional().allow("", null)
|
|
1922
1939
|
}).optional(),
|
|
1923
1940
|
seniorHighInfo: import_joi3.default.object({
|
|
1924
|
-
semester: import_joi3.default.string().
|
|
1925
|
-
track: import_joi3.default.string().
|
|
1926
|
-
strand: import_joi3.default.string().
|
|
1941
|
+
semester: import_joi3.default.string().optional().allow("", null),
|
|
1942
|
+
track: import_joi3.default.string().optional().allow("", null),
|
|
1943
|
+
strand: import_joi3.default.string().optional().allow("", null)
|
|
1927
1944
|
}).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(),
|
|
1945
|
+
alternativeLearningOptions: import_joi3.default.array().items(import_joi3.default.string()).optional(),
|
|
1946
|
+
// Added to match frontend
|
|
1947
|
+
isCertifiedAndConsented: import_joi3.default.boolean().required(),
|
|
1948
|
+
// Simplified certification to match frontend
|
|
1944
1949
|
status: import_joi3.default.string().optional().allow("", null),
|
|
1950
|
+
remarks: import_joi3.default.string().optional().allow("", null),
|
|
1951
|
+
// Added to match frontend
|
|
1945
1952
|
rejectionReason: import_joi3.default.string().optional().allow("", null),
|
|
1946
1953
|
createdAt: import_joi3.default.date().optional().allow("", null),
|
|
1947
1954
|
updatedAt: import_joi3.default.date().optional().allow("", null),
|
|
@@ -1963,42 +1970,35 @@ function MEnrollment(value) {
|
|
|
1963
1970
|
throw new import_nodejs_utils4.BadRequestError("Invalid _id format");
|
|
1964
1971
|
}
|
|
1965
1972
|
}
|
|
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
1973
|
return {
|
|
1988
1974
|
_id: value._id ?? void 0,
|
|
1989
1975
|
region: value.region,
|
|
1990
|
-
|
|
1976
|
+
regionName: value.regionName ?? "",
|
|
1977
|
+
province: value.province ?? "",
|
|
1978
|
+
cityMunicipality: value.cityMunicipality ?? "",
|
|
1979
|
+
division: value.division,
|
|
1980
|
+
divisionName: value.divisionName ?? "",
|
|
1991
1981
|
school: value.school,
|
|
1982
|
+
schoolId: value.schoolId,
|
|
1983
|
+
schoolName: value.schoolName ?? "",
|
|
1984
|
+
// Added to match frontend
|
|
1992
1985
|
schoolYear: value.schoolYear ?? "",
|
|
1993
|
-
|
|
1986
|
+
gradeLevel: value.gradeLevel ?? "",
|
|
1987
|
+
returningLearner: value.returningLearner ?? false,
|
|
1988
|
+
// Added to match frontend
|
|
1994
1989
|
learnerInfo: value.learnerInfo,
|
|
1995
1990
|
parentGuardianInfo: value.parentGuardianInfo,
|
|
1996
|
-
|
|
1991
|
+
address: value.address,
|
|
1992
|
+
// Changed from addressInfo to address
|
|
1997
1993
|
returningLearnerInfo: value.returningLearnerInfo,
|
|
1998
1994
|
seniorHighInfo: value.seniorHighInfo,
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
1995
|
+
alternativeLearningOptions: value.alternativeLearningOptions ?? [],
|
|
1996
|
+
// Added to match frontend
|
|
1997
|
+
isCertifiedAndConsented: value.isCertifiedAndConsented ?? true,
|
|
1998
|
+
// Simplified certification
|
|
1999
|
+
status: value.status ?? "pending",
|
|
2000
|
+
remarks: value.remarks ?? "",
|
|
2001
|
+
// Added to match frontend
|
|
2002
2002
|
rejectionReason: value.rejectionReason ?? "",
|
|
2003
2003
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
2004
2004
|
updatedAt: value.updatedAt ?? "",
|
|
@@ -2012,28 +2012,18 @@ function MEnrollment(value) {
|
|
|
2012
2012
|
// src/resources/enrollment/enrollment.repository.ts
|
|
2013
2013
|
var import_nodejs_utils5 = require("@eeplatform/nodejs-utils");
|
|
2014
2014
|
var import_mongodb4 = require("mongodb");
|
|
2015
|
+
var import_joi4 = __toESM(require("joi"));
|
|
2015
2016
|
function useEnrollmentRepo() {
|
|
2016
2017
|
const db = import_nodejs_utils5.useAtlas.getDb();
|
|
2017
2018
|
if (!db) {
|
|
2018
2019
|
throw new Error("Unable to connect to server.");
|
|
2019
2020
|
}
|
|
2020
|
-
const namespace_collection = "school.enrollments";
|
|
2021
|
+
const namespace_collection = "deped.school.enrollments";
|
|
2021
2022
|
const collection = db.collection(namespace_collection);
|
|
2022
2023
|
const { getCache, setCache, delNamespace } = (0, import_nodejs_utils5.useCache)(namespace_collection);
|
|
2023
2024
|
async function createIndexes() {
|
|
2024
2025
|
try {
|
|
2025
2026
|
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
2027
|
{ key: { status: 1 } },
|
|
2038
2028
|
{ key: { school: 1, status: 1 } },
|
|
2039
2029
|
{ key: { "learnerInfo.lrn": 1 } },
|
|
@@ -2125,7 +2115,7 @@ function useEnrollmentRepo() {
|
|
|
2125
2115
|
try {
|
|
2126
2116
|
query.school = new import_mongodb4.ObjectId(school);
|
|
2127
2117
|
} catch (error) {
|
|
2128
|
-
throw new import_nodejs_utils5.BadRequestError("Invalid school ID
|
|
2118
|
+
throw new import_nodejs_utils5.BadRequestError("Invalid school ID.");
|
|
2129
2119
|
}
|
|
2130
2120
|
}
|
|
2131
2121
|
if (schoolYear) {
|
|
@@ -2173,36 +2163,13 @@ function useEnrollmentRepo() {
|
|
|
2173
2163
|
});
|
|
2174
2164
|
return cached;
|
|
2175
2165
|
}
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2178
|
-
{
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
as: "schoolInfo"
|
|
2184
|
-
}
|
|
2185
|
-
},
|
|
2186
|
-
{
|
|
2187
|
-
$lookup: {
|
|
2188
|
-
from: "admin.regions",
|
|
2189
|
-
localField: "region",
|
|
2190
|
-
foreignField: "_id",
|
|
2191
|
-
as: "regionInfo"
|
|
2192
|
-
}
|
|
2193
|
-
},
|
|
2194
|
-
{
|
|
2195
|
-
$lookup: {
|
|
2196
|
-
from: "admin.divisions",
|
|
2197
|
-
localField: "sdo",
|
|
2198
|
-
foreignField: "_id",
|
|
2199
|
-
as: "sdoInfo"
|
|
2200
|
-
}
|
|
2201
|
-
},
|
|
2202
|
-
{ $sort: sort },
|
|
2203
|
-
{ $skip: page * limit },
|
|
2204
|
-
{ $limit: limit }
|
|
2205
|
-
]).toArray();
|
|
2166
|
+
const pipeline = [{ $match: query }];
|
|
2167
|
+
if (Object.keys(sort).length) {
|
|
2168
|
+
pipeline.push({ $sort: sort });
|
|
2169
|
+
}
|
|
2170
|
+
pipeline.push({ $skip: page * limit });
|
|
2171
|
+
pipeline.push({ $limit: limit });
|
|
2172
|
+
const items = await collection.aggregate(pipeline).toArray();
|
|
2206
2173
|
const length = await collection.countDocuments(query);
|
|
2207
2174
|
const data = (0, import_nodejs_utils5.paginate)(items, page, limit, length);
|
|
2208
2175
|
setCache(cacheKey, data, 600).then(() => {
|
|
@@ -2265,7 +2232,7 @@ function useEnrollmentRepo() {
|
|
|
2265
2232
|
async function getByLrn(lrn, schoolYear) {
|
|
2266
2233
|
const query = {
|
|
2267
2234
|
"learnerInfo.lrn": lrn,
|
|
2268
|
-
status: "
|
|
2235
|
+
status: "accepted"
|
|
2269
2236
|
};
|
|
2270
2237
|
if (schoolYear) {
|
|
2271
2238
|
query.schoolYear = schoolYear;
|
|
@@ -2335,12 +2302,8 @@ function useEnrollmentRepo() {
|
|
|
2335
2302
|
}
|
|
2336
2303
|
}
|
|
2337
2304
|
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.");
|
|
2305
|
+
if (typeof school === "object") {
|
|
2306
|
+
school = school.toString();
|
|
2344
2307
|
}
|
|
2345
2308
|
const query = {
|
|
2346
2309
|
school,
|
|
@@ -2380,6 +2343,110 @@ function useEnrollmentRepo() {
|
|
|
2380
2343
|
);
|
|
2381
2344
|
}
|
|
2382
2345
|
}
|
|
2346
|
+
async function getByApplicantInfo({
|
|
2347
|
+
school = "",
|
|
2348
|
+
schoolYear = "",
|
|
2349
|
+
gradeLevel = "",
|
|
2350
|
+
firstName = "",
|
|
2351
|
+
lastName = "",
|
|
2352
|
+
middleName = "",
|
|
2353
|
+
birthDate = "",
|
|
2354
|
+
placeOfBirth = ""
|
|
2355
|
+
} = {}) {
|
|
2356
|
+
const validation = import_joi4.default.object({
|
|
2357
|
+
school: import_joi4.default.string().required(),
|
|
2358
|
+
schoolYear: import_joi4.default.string().required(),
|
|
2359
|
+
gradeLevel: import_joi4.default.string().required(),
|
|
2360
|
+
firstName: import_joi4.default.string().required(),
|
|
2361
|
+
lastName: import_joi4.default.string().required(),
|
|
2362
|
+
middleName: import_joi4.default.string().optional().allow("", null),
|
|
2363
|
+
birthDate: import_joi4.default.string().required(),
|
|
2364
|
+
placeOfBirth: import_joi4.default.string().required()
|
|
2365
|
+
});
|
|
2366
|
+
const { error } = validation.validate({
|
|
2367
|
+
school,
|
|
2368
|
+
schoolYear,
|
|
2369
|
+
gradeLevel,
|
|
2370
|
+
firstName,
|
|
2371
|
+
lastName,
|
|
2372
|
+
middleName,
|
|
2373
|
+
birthDate,
|
|
2374
|
+
placeOfBirth
|
|
2375
|
+
});
|
|
2376
|
+
if (error) {
|
|
2377
|
+
throw new import_nodejs_utils5.BadRequestError(`Validation error: ${error.message}`);
|
|
2378
|
+
}
|
|
2379
|
+
const query = {
|
|
2380
|
+
school,
|
|
2381
|
+
schoolYear,
|
|
2382
|
+
gradeLevel,
|
|
2383
|
+
"learnerInfo.firstName": {
|
|
2384
|
+
$regex: `^${firstName}$`,
|
|
2385
|
+
$options: "i"
|
|
2386
|
+
},
|
|
2387
|
+
"learnerInfo.lastName": {
|
|
2388
|
+
$regex: `^${lastName}$`,
|
|
2389
|
+
$options: "i"
|
|
2390
|
+
},
|
|
2391
|
+
"learnerInfo.birthDate": birthDate,
|
|
2392
|
+
"learnerInfo.placeOfBirth": {
|
|
2393
|
+
$regex: `^${placeOfBirth}$`,
|
|
2394
|
+
$options: "i"
|
|
2395
|
+
}
|
|
2396
|
+
};
|
|
2397
|
+
const cacheKeyOptions = {
|
|
2398
|
+
school,
|
|
2399
|
+
schoolYear,
|
|
2400
|
+
gradeLevel,
|
|
2401
|
+
firstName,
|
|
2402
|
+
lastName,
|
|
2403
|
+
birthDate,
|
|
2404
|
+
placeOfBirth
|
|
2405
|
+
};
|
|
2406
|
+
if (middleName && middleName.trim() !== "") {
|
|
2407
|
+
query["learnerInfo.middleName"] = {
|
|
2408
|
+
$regex: `^${middleName}$`,
|
|
2409
|
+
$options: "i"
|
|
2410
|
+
};
|
|
2411
|
+
cacheKeyOptions.middleName = middleName;
|
|
2412
|
+
}
|
|
2413
|
+
const cacheKey = (0, import_nodejs_utils5.makeCacheKey)(namespace_collection, cacheKeyOptions);
|
|
2414
|
+
const cachedData = await getCache(cacheKey);
|
|
2415
|
+
if (cachedData) {
|
|
2416
|
+
import_nodejs_utils5.logger.log({
|
|
2417
|
+
level: "info",
|
|
2418
|
+
message: `Cache hit for enrollment by applicant info: ${cacheKey}`
|
|
2419
|
+
});
|
|
2420
|
+
return cachedData;
|
|
2421
|
+
}
|
|
2422
|
+
try {
|
|
2423
|
+
const data = await collection.findOne({
|
|
2424
|
+
...query,
|
|
2425
|
+
status: "accepted"
|
|
2426
|
+
});
|
|
2427
|
+
const length = await collection.countDocuments({
|
|
2428
|
+
...query,
|
|
2429
|
+
status: { $nin: ["accepted", "deleted"] }
|
|
2430
|
+
});
|
|
2431
|
+
const result = { accepted: data ? true : false, length };
|
|
2432
|
+
setCache(cacheKey, result, 600).then(() => {
|
|
2433
|
+
import_nodejs_utils5.logger.log({
|
|
2434
|
+
level: "info",
|
|
2435
|
+
message: `Cache set for enrollment by applicant info: ${cacheKey}`
|
|
2436
|
+
});
|
|
2437
|
+
}).catch((err) => {
|
|
2438
|
+
import_nodejs_utils5.logger.log({
|
|
2439
|
+
level: "error",
|
|
2440
|
+
message: `Failed to set cache for enrollment by applicant info: ${err.message}`
|
|
2441
|
+
});
|
|
2442
|
+
});
|
|
2443
|
+
return result;
|
|
2444
|
+
} catch (error2) {
|
|
2445
|
+
throw new import_nodejs_utils5.InternalServerError(
|
|
2446
|
+
"Failed to get enrollment by applicant info."
|
|
2447
|
+
);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2383
2450
|
return {
|
|
2384
2451
|
createIndexes,
|
|
2385
2452
|
add,
|
|
@@ -2388,6 +2455,7 @@ function useEnrollmentRepo() {
|
|
|
2388
2455
|
getById,
|
|
2389
2456
|
getByLrn,
|
|
2390
2457
|
deleteById,
|
|
2458
|
+
getByApplicantInfo,
|
|
2391
2459
|
getBySchoolAndYear
|
|
2392
2460
|
};
|
|
2393
2461
|
}
|
|
@@ -2402,39 +2470,52 @@ function useEnrollmentService() {
|
|
|
2402
2470
|
getById: _getById,
|
|
2403
2471
|
getByLrn: _getByLrn,
|
|
2404
2472
|
deleteById: _deleteById,
|
|
2405
|
-
getBySchoolAndYear: _getBySchoolAndYear
|
|
2473
|
+
getBySchoolAndYear: _getBySchoolAndYear,
|
|
2474
|
+
getByApplicantInfo: _getByApplicantInfo
|
|
2406
2475
|
} = useEnrollmentRepo();
|
|
2407
2476
|
async function createEnrollment(value) {
|
|
2408
2477
|
try {
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2478
|
+
const applicantInfo = await _getByApplicantInfo({
|
|
2479
|
+
firstName: value.learnerInfo.firstName,
|
|
2480
|
+
lastName: value.learnerInfo.lastName,
|
|
2481
|
+
middleName: value.learnerInfo.middleName,
|
|
2482
|
+
birthDate: value.learnerInfo.birthDate,
|
|
2483
|
+
placeOfBirth: value.learnerInfo.placeOfBirth,
|
|
2484
|
+
gradeLevel: value.gradeLevel,
|
|
2485
|
+
schoolYear: value.schoolYear,
|
|
2486
|
+
school: value.schoolId
|
|
2487
|
+
});
|
|
2488
|
+
if (applicantInfo.accepted) {
|
|
2489
|
+
throw new import_nodejs_utils6.BadRequestError(
|
|
2490
|
+
"This applicant already has an accepted application for the same school year and grade level."
|
|
2491
|
+
);
|
|
2492
|
+
}
|
|
2493
|
+
if (applicantInfo.length >= 3) {
|
|
2494
|
+
throw new import_nodejs_utils6.BadRequestError(
|
|
2495
|
+
"This applicant has already submitted applications to 3 schools for the same school year and grade level. Maximum limit reached."
|
|
2413
2496
|
);
|
|
2414
|
-
if (existingEnrollment) {
|
|
2415
|
-
throw new import_nodejs_utils6.BadRequestError(
|
|
2416
|
-
"Learner is already enrolled for this school year."
|
|
2417
|
-
);
|
|
2418
|
-
}
|
|
2419
2497
|
}
|
|
2420
|
-
const gradeLevel = value.
|
|
2498
|
+
const gradeLevel = value.gradeLevel.toLowerCase();
|
|
2421
2499
|
const age = value.learnerInfo.age;
|
|
2422
|
-
if (
|
|
2500
|
+
if (["K1", "K2"].includes(gradeLevel) && age < 5) {
|
|
2423
2501
|
throw new import_nodejs_utils6.BadRequestError("Learner is too young for Kindergarten.");
|
|
2424
2502
|
}
|
|
2425
|
-
if (gradeLevel
|
|
2503
|
+
if (gradeLevel === "grade-1" && age < 6) {
|
|
2426
2504
|
throw new import_nodejs_utils6.BadRequestError("Learner is too young for Grade 1.");
|
|
2427
2505
|
}
|
|
2428
2506
|
const { father, mother, legalGuardian } = value.parentGuardianInfo;
|
|
2429
|
-
|
|
2507
|
+
const hasFatherInfo = father && (father.firstName || father.lastName);
|
|
2508
|
+
const hasMotherInfo = mother && (mother.firstName || mother.lastName);
|
|
2509
|
+
const hasGuardianInfo = legalGuardian && (legalGuardian.firstName || legalGuardian.lastName);
|
|
2510
|
+
if (!hasFatherInfo && !hasMotherInfo && !hasGuardianInfo) {
|
|
2430
2511
|
throw new import_nodejs_utils6.BadRequestError(
|
|
2431
2512
|
"At least one parent or legal guardian information is required."
|
|
2432
2513
|
);
|
|
2433
2514
|
}
|
|
2434
|
-
if (gradeLevel.includes("grade
|
|
2435
|
-
if (!value.seniorHighInfo) {
|
|
2515
|
+
if (gradeLevel.includes("grade-11") || gradeLevel.includes("grade-12")) {
|
|
2516
|
+
if (!value.seniorHighInfo || !value.seniorHighInfo.track || !value.seniorHighInfo.strand) {
|
|
2436
2517
|
throw new import_nodejs_utils6.BadRequestError(
|
|
2437
|
-
"Senior high school information is required for Grade 11 and 12."
|
|
2518
|
+
"Senior high school information (track and strand) is required for Grade 11 and 12."
|
|
2438
2519
|
);
|
|
2439
2520
|
}
|
|
2440
2521
|
}
|
|
@@ -2668,7 +2749,7 @@ function useEnrollmentService() {
|
|
|
2668
2749
|
|
|
2669
2750
|
// src/resources/enrollment/enrollment.controller.ts
|
|
2670
2751
|
var import_nodejs_utils7 = require("@eeplatform/nodejs-utils");
|
|
2671
|
-
var
|
|
2752
|
+
var import_joi5 = __toESM(require("joi"));
|
|
2672
2753
|
function useEnrollmentController() {
|
|
2673
2754
|
const {
|
|
2674
2755
|
createEnrollment: _createEnrollment,
|
|
@@ -2700,18 +2781,18 @@ function useEnrollmentController() {
|
|
|
2700
2781
|
async function updateById(req, res, next) {
|
|
2701
2782
|
const value = req.body;
|
|
2702
2783
|
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:
|
|
2784
|
+
const validation = import_joi5.default.object({
|
|
2785
|
+
id: import_joi5.default.string().hex().required(),
|
|
2786
|
+
value: import_joi5.default.object({
|
|
2787
|
+
learnerInfo: import_joi5.default.object().optional(),
|
|
2788
|
+
parentGuardianInfo: import_joi5.default.object().optional(),
|
|
2789
|
+
addressInfo: import_joi5.default.object().optional(),
|
|
2790
|
+
returningLearnerInfo: import_joi5.default.object().optional(),
|
|
2791
|
+
seniorHighInfo: import_joi5.default.object().optional(),
|
|
2792
|
+
preferredLearningModalities: import_joi5.default.array().optional(),
|
|
2793
|
+
certification: import_joi5.default.object().optional(),
|
|
2794
|
+
status: import_joi5.default.string().valid("active", "pending", "approved", "rejected", "deleted").optional(),
|
|
2795
|
+
rejectionReason: import_joi5.default.string().optional().allow("", null)
|
|
2715
2796
|
}).min(1)
|
|
2716
2797
|
});
|
|
2717
2798
|
const { error } = validation.validate({ id, value });
|
|
@@ -2730,14 +2811,14 @@ function useEnrollmentController() {
|
|
|
2730
2811
|
}
|
|
2731
2812
|
async function getAll(req, res, next) {
|
|
2732
2813
|
const query = req.query;
|
|
2733
|
-
const validation =
|
|
2734
|
-
page:
|
|
2735
|
-
limit:
|
|
2736
|
-
search:
|
|
2737
|
-
status:
|
|
2738
|
-
school:
|
|
2739
|
-
schoolYear:
|
|
2740
|
-
gradeLevelToEnroll:
|
|
2814
|
+
const validation = import_joi5.default.object({
|
|
2815
|
+
page: import_joi5.default.number().min(1).optional().allow("", null),
|
|
2816
|
+
limit: import_joi5.default.number().min(1).max(100).optional().allow("", null),
|
|
2817
|
+
search: import_joi5.default.string().optional().allow("", null),
|
|
2818
|
+
status: import_joi5.default.string().optional().allow("", null),
|
|
2819
|
+
school: import_joi5.default.string().hex().optional().allow("", null),
|
|
2820
|
+
schoolYear: import_joi5.default.string().optional().allow("", null),
|
|
2821
|
+
gradeLevelToEnroll: import_joi5.default.string().optional().allow("", null)
|
|
2741
2822
|
});
|
|
2742
2823
|
const { error } = validation.validate(query);
|
|
2743
2824
|
if (error) {
|
|
@@ -2775,7 +2856,7 @@ function useEnrollmentController() {
|
|
|
2775
2856
|
}
|
|
2776
2857
|
async function getById(req, res, next) {
|
|
2777
2858
|
const id = req.params.id ?? "";
|
|
2778
|
-
const validation =
|
|
2859
|
+
const validation = import_joi5.default.string().hex().required();
|
|
2779
2860
|
const { error } = validation.validate(id);
|
|
2780
2861
|
if (error) {
|
|
2781
2862
|
next(new import_nodejs_utils7.BadRequestError(error.message));
|
|
@@ -2792,9 +2873,9 @@ function useEnrollmentController() {
|
|
|
2792
2873
|
async function getByLrn(req, res, next) {
|
|
2793
2874
|
const lrn = req.params.lrn ?? "";
|
|
2794
2875
|
const schoolYear = req.query.schoolYear;
|
|
2795
|
-
const validation =
|
|
2796
|
-
lrn:
|
|
2797
|
-
schoolYear:
|
|
2876
|
+
const validation = import_joi5.default.object({
|
|
2877
|
+
lrn: import_joi5.default.string().required(),
|
|
2878
|
+
schoolYear: import_joi5.default.string().optional().allow("", null)
|
|
2798
2879
|
});
|
|
2799
2880
|
const { error } = validation.validate({ lrn, schoolYear });
|
|
2800
2881
|
if (error) {
|
|
@@ -2812,9 +2893,9 @@ function useEnrollmentController() {
|
|
|
2812
2893
|
async function deleteById(req, res, next) {
|
|
2813
2894
|
const id = req.params.id ?? "";
|
|
2814
2895
|
const deletedBy = req.body.deletedBy;
|
|
2815
|
-
const validation =
|
|
2816
|
-
id:
|
|
2817
|
-
deletedBy:
|
|
2896
|
+
const validation = import_joi5.default.object({
|
|
2897
|
+
id: import_joi5.default.string().hex().required(),
|
|
2898
|
+
deletedBy: import_joi5.default.string().optional().allow("", null)
|
|
2818
2899
|
});
|
|
2819
2900
|
const { error } = validation.validate({ id, deletedBy });
|
|
2820
2901
|
if (error) {
|
|
@@ -2832,9 +2913,9 @@ function useEnrollmentController() {
|
|
|
2832
2913
|
async function getBySchoolAndYear(req, res, next) {
|
|
2833
2914
|
const school = req.params.school ?? "";
|
|
2834
2915
|
const schoolYear = req.params.schoolYear ?? "";
|
|
2835
|
-
const validation =
|
|
2836
|
-
school:
|
|
2837
|
-
schoolYear:
|
|
2916
|
+
const validation = import_joi5.default.object({
|
|
2917
|
+
school: import_joi5.default.string().hex().required(),
|
|
2918
|
+
schoolYear: import_joi5.default.string().required()
|
|
2838
2919
|
});
|
|
2839
2920
|
const { error } = validation.validate({ school, schoolYear });
|
|
2840
2921
|
if (error) {
|
|
@@ -2852,9 +2933,9 @@ function useEnrollmentController() {
|
|
|
2852
2933
|
async function approve(req, res, next) {
|
|
2853
2934
|
const id = req.params.id ?? "";
|
|
2854
2935
|
const approvedBy = req.body.approvedBy;
|
|
2855
|
-
const validation =
|
|
2856
|
-
id:
|
|
2857
|
-
approvedBy:
|
|
2936
|
+
const validation = import_joi5.default.object({
|
|
2937
|
+
id: import_joi5.default.string().hex().required(),
|
|
2938
|
+
approvedBy: import_joi5.default.string().required()
|
|
2858
2939
|
});
|
|
2859
2940
|
const { error } = validation.validate({ id, approvedBy });
|
|
2860
2941
|
if (error) {
|
|
@@ -2874,10 +2955,10 @@ function useEnrollmentController() {
|
|
|
2874
2955
|
const id = req.params.id ?? "";
|
|
2875
2956
|
const rejectedBy = req.body.rejectedBy;
|
|
2876
2957
|
const rejectionReason = req.body.rejectionReason;
|
|
2877
|
-
const validation =
|
|
2878
|
-
id:
|
|
2879
|
-
rejectedBy:
|
|
2880
|
-
rejectionReason:
|
|
2958
|
+
const validation = import_joi5.default.object({
|
|
2959
|
+
id: import_joi5.default.string().hex().required(),
|
|
2960
|
+
rejectedBy: import_joi5.default.string().required(),
|
|
2961
|
+
rejectionReason: import_joi5.default.string().optional().allow("", null)
|
|
2881
2962
|
});
|
|
2882
2963
|
const { error } = validation.validate({ id, rejectedBy, rejectionReason });
|
|
2883
2964
|
if (error) {
|
|
@@ -2896,9 +2977,9 @@ function useEnrollmentController() {
|
|
|
2896
2977
|
async function getStatsBySchool(req, res, next) {
|
|
2897
2978
|
const school = req.params.school ?? "";
|
|
2898
2979
|
const schoolYear = req.query.schoolYear;
|
|
2899
|
-
const validation =
|
|
2900
|
-
school:
|
|
2901
|
-
schoolYear:
|
|
2980
|
+
const validation = import_joi5.default.object({
|
|
2981
|
+
school: import_joi5.default.string().hex().required(),
|
|
2982
|
+
schoolYear: import_joi5.default.string().optional().allow("", null)
|
|
2902
2983
|
});
|
|
2903
2984
|
const { error } = validation.validate({ school, schoolYear });
|
|
2904
2985
|
if (error) {
|
|
@@ -2965,26 +3046,26 @@ function useEnrollmentController() {
|
|
|
2965
3046
|
|
|
2966
3047
|
// src/resources/grade-level/grade-level.model.ts
|
|
2967
3048
|
var import_nodejs_utils8 = require("@eeplatform/nodejs-utils");
|
|
2968
|
-
var
|
|
3049
|
+
var import_joi6 = __toESM(require("joi"));
|
|
2969
3050
|
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:
|
|
3051
|
+
var schemaGradeLevel = import_joi6.default.object({
|
|
3052
|
+
_id: import_joi6.default.string().hex().optional(),
|
|
3053
|
+
school: import_joi6.default.string().hex().optional(),
|
|
3054
|
+
educationLevel: import_joi6.default.string().required(),
|
|
3055
|
+
gradeLevel: import_joi6.default.string().required(),
|
|
3056
|
+
tracks: import_joi6.default.array().items(import_joi6.default.string()).optional(),
|
|
3057
|
+
trackStrands: import_joi6.default.array().items(import_joi6.default.string()).optional(),
|
|
3058
|
+
teachingStyle: import_joi6.default.string().required(),
|
|
3059
|
+
maxNumberOfLearners: import_joi6.default.number().required(),
|
|
3060
|
+
defaultStartTime: import_joi6.default.string().optional().allow("", null),
|
|
3061
|
+
defaultEndTime: import_joi6.default.string().optional().allow("", null),
|
|
3062
|
+
status: import_joi6.default.string().optional().allow("", null),
|
|
3063
|
+
createdAt: import_joi6.default.date().optional().allow("", null),
|
|
3064
|
+
updatedAt: import_joi6.default.date().optional().allow("", null),
|
|
3065
|
+
deletedAt: import_joi6.default.date().optional().allow("", null),
|
|
3066
|
+
createdBy: import_joi6.default.string().optional().allow("", null),
|
|
3067
|
+
updatedBy: import_joi6.default.string().optional().allow("", null),
|
|
3068
|
+
deletedBy: import_joi6.default.string().optional().allow("", null)
|
|
2988
3069
|
});
|
|
2989
3070
|
function MGradeLevel(value) {
|
|
2990
3071
|
const { error } = schemaGradeLevel.validate(value);
|
|
@@ -3387,7 +3468,7 @@ function useGradeLevelRepo() {
|
|
|
3387
3468
|
|
|
3388
3469
|
// src/resources/grade-level/grade-level.controller.ts
|
|
3389
3470
|
var import_nodejs_utils10 = require("@eeplatform/nodejs-utils");
|
|
3390
|
-
var
|
|
3471
|
+
var import_joi7 = __toESM(require("joi"));
|
|
3391
3472
|
function useGradeLevelController() {
|
|
3392
3473
|
const {
|
|
3393
3474
|
getAll: _getAll,
|
|
@@ -3419,17 +3500,17 @@ function useGradeLevelController() {
|
|
|
3419
3500
|
async function updateById(req, res, next) {
|
|
3420
3501
|
const value = req.body;
|
|
3421
3502
|
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:
|
|
3503
|
+
const validation = import_joi7.default.object({
|
|
3504
|
+
id: import_joi7.default.string().hex().required(),
|
|
3505
|
+
value: import_joi7.default.object({
|
|
3506
|
+
school: import_joi7.default.string().hex().optional(),
|
|
3507
|
+
educationLevel: import_joi7.default.string().optional(),
|
|
3508
|
+
gradeLevel: import_joi7.default.string().optional(),
|
|
3509
|
+
teachingStyle: import_joi7.default.string().optional(),
|
|
3510
|
+
maxTeachingHoursPerDay: import_joi7.default.number().integer().min(0).optional(),
|
|
3511
|
+
maxTeachingHoursPerWeek: import_joi7.default.number().integer().min(0).optional(),
|
|
3512
|
+
defaultStartTime: import_joi7.default.string().optional().allow("", null),
|
|
3513
|
+
defaultEndTime: import_joi7.default.string().optional().allow("", null)
|
|
3433
3514
|
}).min(1)
|
|
3434
3515
|
});
|
|
3435
3516
|
const { error } = validation.validate({ id, value });
|
|
@@ -3451,15 +3532,15 @@ function useGradeLevelController() {
|
|
|
3451
3532
|
}
|
|
3452
3533
|
async function getAll(req, res, next) {
|
|
3453
3534
|
const query = req.query;
|
|
3454
|
-
const validation =
|
|
3455
|
-
page:
|
|
3456
|
-
limit:
|
|
3457
|
-
search:
|
|
3458
|
-
educationLevel:
|
|
3459
|
-
gradeLevel:
|
|
3460
|
-
teachingStyle:
|
|
3461
|
-
school:
|
|
3462
|
-
status:
|
|
3535
|
+
const validation = import_joi7.default.object({
|
|
3536
|
+
page: import_joi7.default.number().min(1).optional().allow("", null),
|
|
3537
|
+
limit: import_joi7.default.number().min(1).optional().allow("", null),
|
|
3538
|
+
search: import_joi7.default.string().optional().allow("", null),
|
|
3539
|
+
educationLevel: import_joi7.default.string().optional().allow("", null),
|
|
3540
|
+
gradeLevel: import_joi7.default.string().optional().allow("", null),
|
|
3541
|
+
teachingStyle: import_joi7.default.string().optional().allow("", null),
|
|
3542
|
+
school: import_joi7.default.string().hex().optional().allow("", null),
|
|
3543
|
+
status: import_joi7.default.string().optional().allow("", null)
|
|
3463
3544
|
});
|
|
3464
3545
|
const { error } = validation.validate(query);
|
|
3465
3546
|
if (error) {
|
|
@@ -3484,7 +3565,7 @@ function useGradeLevelController() {
|
|
|
3484
3565
|
const school = req.query.school ?? "";
|
|
3485
3566
|
const search = req.query.search ?? "";
|
|
3486
3567
|
try {
|
|
3487
|
-
const
|
|
3568
|
+
const gradeLevels2 = await _getAll({
|
|
3488
3569
|
page,
|
|
3489
3570
|
limit,
|
|
3490
3571
|
sort: sortObj,
|
|
@@ -3495,7 +3576,7 @@ function useGradeLevelController() {
|
|
|
3495
3576
|
school,
|
|
3496
3577
|
search
|
|
3497
3578
|
});
|
|
3498
|
-
res.json(
|
|
3579
|
+
res.json(gradeLevels2);
|
|
3499
3580
|
return;
|
|
3500
3581
|
} catch (error2) {
|
|
3501
3582
|
next(error2);
|
|
@@ -3503,8 +3584,8 @@ function useGradeLevelController() {
|
|
|
3503
3584
|
}
|
|
3504
3585
|
async function getById(req, res, next) {
|
|
3505
3586
|
const id = req.params.id;
|
|
3506
|
-
const validation =
|
|
3507
|
-
id:
|
|
3587
|
+
const validation = import_joi7.default.object({
|
|
3588
|
+
id: import_joi7.default.string().hex().required()
|
|
3508
3589
|
});
|
|
3509
3590
|
const { error } = validation.validate({ id });
|
|
3510
3591
|
if (error) {
|
|
@@ -3524,8 +3605,8 @@ function useGradeLevelController() {
|
|
|
3524
3605
|
}
|
|
3525
3606
|
async function deleteById(req, res, next) {
|
|
3526
3607
|
const id = req.params.id;
|
|
3527
|
-
const validation =
|
|
3528
|
-
id:
|
|
3608
|
+
const validation = import_joi7.default.object({
|
|
3609
|
+
id: import_joi7.default.string().hex().required()
|
|
3529
3610
|
});
|
|
3530
3611
|
const { error } = validation.validate({ id });
|
|
3531
3612
|
if (error) {
|
|
@@ -3546,9 +3627,9 @@ function useGradeLevelController() {
|
|
|
3546
3627
|
async function getByEducationLevel(req, res, next) {
|
|
3547
3628
|
const educationLevel = req.params.educationLevel;
|
|
3548
3629
|
const school = req.query.school;
|
|
3549
|
-
const validation =
|
|
3550
|
-
educationLevel:
|
|
3551
|
-
school:
|
|
3630
|
+
const validation = import_joi7.default.object({
|
|
3631
|
+
educationLevel: import_joi7.default.string().required(),
|
|
3632
|
+
school: import_joi7.default.string().hex().optional().allow("", null)
|
|
3552
3633
|
});
|
|
3553
3634
|
const { error } = validation.validate({ educationLevel, school });
|
|
3554
3635
|
if (error) {
|
|
@@ -3556,10 +3637,10 @@ function useGradeLevelController() {
|
|
|
3556
3637
|
return;
|
|
3557
3638
|
}
|
|
3558
3639
|
try {
|
|
3559
|
-
const
|
|
3640
|
+
const gradeLevels2 = await _getByEducationLevel(educationLevel, school);
|
|
3560
3641
|
res.json({
|
|
3561
3642
|
message: "Successfully retrieved grade levels by education level.",
|
|
3562
|
-
data: { gradeLevels }
|
|
3643
|
+
data: { gradeLevels: gradeLevels2 }
|
|
3563
3644
|
});
|
|
3564
3645
|
return;
|
|
3565
3646
|
} catch (error2) {
|
|
@@ -3578,14 +3659,14 @@ function useGradeLevelController() {
|
|
|
3578
3659
|
|
|
3579
3660
|
// src/resources/region/region.model.ts
|
|
3580
3661
|
var import_nodejs_utils11 = require("@eeplatform/nodejs-utils");
|
|
3581
|
-
var
|
|
3662
|
+
var import_joi8 = __toESM(require("joi"));
|
|
3582
3663
|
var import_mongodb7 = require("mongodb");
|
|
3583
|
-
var schemaRegion =
|
|
3584
|
-
_id:
|
|
3585
|
-
name:
|
|
3586
|
-
createdAt:
|
|
3587
|
-
updatedAt:
|
|
3588
|
-
deletedAt:
|
|
3664
|
+
var schemaRegion = import_joi8.default.object({
|
|
3665
|
+
_id: import_joi8.default.string().hex().optional().allow(null, ""),
|
|
3666
|
+
name: import_joi8.default.string().min(1).max(100).required(),
|
|
3667
|
+
createdAt: import_joi8.default.string().isoDate().optional(),
|
|
3668
|
+
updatedAt: import_joi8.default.string().isoDate().optional(),
|
|
3669
|
+
deletedAt: import_joi8.default.string().isoDate().optional().allow(null, "")
|
|
3589
3670
|
});
|
|
3590
3671
|
function modelRegion(value) {
|
|
3591
3672
|
const { error } = schemaRegion.validate(value);
|
|
@@ -3864,7 +3945,7 @@ function useRegionRepo() {
|
|
|
3864
3945
|
|
|
3865
3946
|
// src/resources/region/region.controller.ts
|
|
3866
3947
|
var import_nodejs_utils13 = require("@eeplatform/nodejs-utils");
|
|
3867
|
-
var
|
|
3948
|
+
var import_joi9 = __toESM(require("joi"));
|
|
3868
3949
|
function useRegionController() {
|
|
3869
3950
|
const {
|
|
3870
3951
|
add: _add,
|
|
@@ -3894,11 +3975,11 @@ function useRegionController() {
|
|
|
3894
3975
|
}
|
|
3895
3976
|
async function getAll(req, res, next) {
|
|
3896
3977
|
const query = req.query;
|
|
3897
|
-
const validation =
|
|
3898
|
-
page:
|
|
3899
|
-
limit:
|
|
3900
|
-
search:
|
|
3901
|
-
status:
|
|
3978
|
+
const validation = import_joi9.default.object({
|
|
3979
|
+
page: import_joi9.default.number().min(1).optional().allow("", null),
|
|
3980
|
+
limit: import_joi9.default.number().min(1).optional().allow("", null),
|
|
3981
|
+
search: import_joi9.default.string().optional().allow("", null),
|
|
3982
|
+
status: import_joi9.default.string().optional().allow("", null)
|
|
3902
3983
|
});
|
|
3903
3984
|
const { error } = validation.validate(query);
|
|
3904
3985
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -3929,8 +4010,8 @@ function useRegionController() {
|
|
|
3929
4010
|
}
|
|
3930
4011
|
async function getById(req, res, next) {
|
|
3931
4012
|
const id = req.params.id;
|
|
3932
|
-
const validation =
|
|
3933
|
-
id:
|
|
4013
|
+
const validation = import_joi9.default.object({
|
|
4014
|
+
id: import_joi9.default.string().hex().required()
|
|
3934
4015
|
});
|
|
3935
4016
|
const { error } = validation.validate({ id });
|
|
3936
4017
|
if (error) {
|
|
@@ -3950,8 +4031,8 @@ function useRegionController() {
|
|
|
3950
4031
|
}
|
|
3951
4032
|
async function getByName(req, res, next) {
|
|
3952
4033
|
const name = req.params.name;
|
|
3953
|
-
const validation =
|
|
3954
|
-
name:
|
|
4034
|
+
const validation = import_joi9.default.object({
|
|
4035
|
+
name: import_joi9.default.string().required()
|
|
3955
4036
|
});
|
|
3956
4037
|
const { error } = validation.validate({ name });
|
|
3957
4038
|
if (error) {
|
|
@@ -3972,10 +4053,10 @@ function useRegionController() {
|
|
|
3972
4053
|
async function updateField(req, res, next) {
|
|
3973
4054
|
const _id = req.params.id;
|
|
3974
4055
|
const { field, value } = req.body;
|
|
3975
|
-
const validation =
|
|
3976
|
-
_id:
|
|
3977
|
-
field:
|
|
3978
|
-
value:
|
|
4056
|
+
const validation = import_joi9.default.object({
|
|
4057
|
+
_id: import_joi9.default.string().hex().required(),
|
|
4058
|
+
field: import_joi9.default.string().valid("name", "director", "directorName").required(),
|
|
4059
|
+
value: import_joi9.default.string().required()
|
|
3979
4060
|
});
|
|
3980
4061
|
const { error } = validation.validate({ _id, field, value });
|
|
3981
4062
|
if (error) {
|
|
@@ -3992,8 +4073,8 @@ function useRegionController() {
|
|
|
3992
4073
|
}
|
|
3993
4074
|
async function deleteById(req, res, next) {
|
|
3994
4075
|
const _id = req.params.id;
|
|
3995
|
-
const validation =
|
|
3996
|
-
_id:
|
|
4076
|
+
const validation = import_joi9.default.object({
|
|
4077
|
+
_id: import_joi9.default.string().hex().required()
|
|
3997
4078
|
});
|
|
3998
4079
|
const { error } = validation.validate({ _id });
|
|
3999
4080
|
if (error) {
|
|
@@ -4020,26 +4101,26 @@ function useRegionController() {
|
|
|
4020
4101
|
|
|
4021
4102
|
// src/resources/division/division.model.ts
|
|
4022
4103
|
var import_nodejs_utils14 = require("@eeplatform/nodejs-utils");
|
|
4023
|
-
var
|
|
4104
|
+
var import_joi10 = __toESM(require("joi"));
|
|
4024
4105
|
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:
|
|
4106
|
+
var schemaDivision = import_joi10.default.object({
|
|
4107
|
+
_id: import_joi10.default.string().hex().optional().allow(null, ""),
|
|
4108
|
+
name: import_joi10.default.string().min(1).max(100).required(),
|
|
4109
|
+
region: import_joi10.default.string().hex().required(),
|
|
4110
|
+
regionName: import_joi10.default.string().min(1).max(100).required(),
|
|
4111
|
+
superintendent: import_joi10.default.string().hex().optional().allow(null, ""),
|
|
4112
|
+
superintendentName: import_joi10.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4113
|
+
createdAt: import_joi10.default.string().isoDate().optional(),
|
|
4114
|
+
updatedAt: import_joi10.default.string().isoDate().optional(),
|
|
4115
|
+
deletedAt: import_joi10.default.string().isoDate().optional().allow(null, "")
|
|
4035
4116
|
});
|
|
4036
|
-
var schemaDivisionUpdate =
|
|
4037
|
-
_id:
|
|
4038
|
-
name:
|
|
4039
|
-
region:
|
|
4040
|
-
regionName:
|
|
4041
|
-
superintendent:
|
|
4042
|
-
superintendentName:
|
|
4117
|
+
var schemaDivisionUpdate = import_joi10.default.object({
|
|
4118
|
+
_id: import_joi10.default.string().hex().optional().allow(null, ""),
|
|
4119
|
+
name: import_joi10.default.string().min(1).max(100).required(),
|
|
4120
|
+
region: import_joi10.default.string().hex().required(),
|
|
4121
|
+
regionName: import_joi10.default.string().min(1).max(100).required(),
|
|
4122
|
+
superintendent: import_joi10.default.string().hex().optional().allow(null, ""),
|
|
4123
|
+
superintendentName: import_joi10.default.string().min(1).max(100).optional().allow(null, "")
|
|
4043
4124
|
});
|
|
4044
4125
|
function modelDivision(value) {
|
|
4045
4126
|
const { error } = schemaDivision.validate(value);
|
|
@@ -4385,49 +4466,49 @@ var import_core2 = require("@eeplatform/core");
|
|
|
4385
4466
|
|
|
4386
4467
|
// src/resources/school/school.model.ts
|
|
4387
4468
|
var import_nodejs_utils16 = require("@eeplatform/nodejs-utils");
|
|
4388
|
-
var
|
|
4469
|
+
var import_joi11 = __toESM(require("joi"));
|
|
4389
4470
|
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:
|
|
4471
|
+
var schemaSchool = import_joi11.default.object({
|
|
4472
|
+
_id: import_joi11.default.string().hex().optional().allow(null, ""),
|
|
4473
|
+
id: import_joi11.default.string().min(1).max(50).required(),
|
|
4474
|
+
name: import_joi11.default.string().min(1).max(100).required(),
|
|
4475
|
+
region: import_joi11.default.string().hex().required(),
|
|
4476
|
+
regionName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4477
|
+
division: import_joi11.default.string().hex().required(),
|
|
4478
|
+
divisionName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4479
|
+
principal: import_joi11.default.string().hex().optional().allow(null, ""),
|
|
4480
|
+
principalName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4481
|
+
street: import_joi11.default.string().max(200).optional().allow(null, ""),
|
|
4482
|
+
barangay: import_joi11.default.string().max(200).optional().allow(null, ""),
|
|
4483
|
+
cityMunicipality: import_joi11.default.string().max(100).optional().allow(null, ""),
|
|
4484
|
+
province: import_joi11.default.string().max(100).optional().allow(null, ""),
|
|
4485
|
+
cityMunicipalityPSGC: import_joi11.default.string().length(10).optional().allow(null, ""),
|
|
4486
|
+
postalCode: import_joi11.default.string().max(20).optional().allow(null, ""),
|
|
4487
|
+
contactNumber: import_joi11.default.string().max(20).optional().allow(null, ""),
|
|
4488
|
+
email: import_joi11.default.string().email().max(100).optional().allow(null, ""),
|
|
4489
|
+
status: import_joi11.default.string().optional().allow(null, ""),
|
|
4490
|
+
createdBy: import_joi11.default.string().optional().allow(null, ""),
|
|
4491
|
+
createdAt: import_joi11.default.string().isoDate().optional().allow(null, ""),
|
|
4492
|
+
updatedAt: import_joi11.default.string().isoDate().optional().allow(null, ""),
|
|
4493
|
+
deletedAt: import_joi11.default.string().isoDate().optional().allow(null, "")
|
|
4413
4494
|
});
|
|
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:
|
|
4495
|
+
var schemaSchoolUpdate = import_joi11.default.object({
|
|
4496
|
+
id: import_joi11.default.string().min(1).max(50).required(),
|
|
4497
|
+
name: import_joi11.default.string().min(1).max(100).required(),
|
|
4498
|
+
region: import_joi11.default.string().hex().required(),
|
|
4499
|
+
regionName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4500
|
+
division: import_joi11.default.string().hex().required(),
|
|
4501
|
+
divisionName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4502
|
+
principal: import_joi11.default.string().hex().optional().allow(null, ""),
|
|
4503
|
+
principalName: import_joi11.default.string().min(1).max(100).optional().allow(null, ""),
|
|
4504
|
+
street: import_joi11.default.string().max(200).optional().allow(null, ""),
|
|
4505
|
+
barangay: import_joi11.default.string().max(200).optional().allow(null, ""),
|
|
4506
|
+
cityMunicipality: import_joi11.default.string().max(100).optional().allow(null, ""),
|
|
4507
|
+
province: import_joi11.default.string().max(100).optional().allow(null, ""),
|
|
4508
|
+
cityMunicipalityPSGC: import_joi11.default.string().length(10).optional().allow(null, ""),
|
|
4509
|
+
postalCode: import_joi11.default.string().max(20).optional().allow(null, ""),
|
|
4510
|
+
contactNumber: import_joi11.default.string().max(20).optional().allow(null, ""),
|
|
4511
|
+
email: import_joi11.default.string().email().max(100).optional().allow(null, "")
|
|
4431
4512
|
});
|
|
4432
4513
|
function modelSchool(value) {
|
|
4433
4514
|
const { error } = schemaSchool.validate(value);
|
|
@@ -33350,7 +33431,7 @@ ${errors.slice(0, 5).join("\n")}${errors.length > 5 ? `
|
|
|
33350
33431
|
|
|
33351
33432
|
// src/resources/school/school.controller.ts
|
|
33352
33433
|
var import_nodejs_utils19 = require("@eeplatform/nodejs-utils");
|
|
33353
|
-
var
|
|
33434
|
+
var import_joi12 = __toESM(require("joi"));
|
|
33354
33435
|
function useSchoolController() {
|
|
33355
33436
|
const {
|
|
33356
33437
|
getAll: _getAll,
|
|
@@ -33383,16 +33464,16 @@ function useSchoolController() {
|
|
|
33383
33464
|
}
|
|
33384
33465
|
}
|
|
33385
33466
|
async function getAll(req, res, next) {
|
|
33386
|
-
const validation =
|
|
33387
|
-
page:
|
|
33388
|
-
limit:
|
|
33389
|
-
sort:
|
|
33390
|
-
sortOrder:
|
|
33391
|
-
status:
|
|
33392
|
-
org:
|
|
33393
|
-
app:
|
|
33394
|
-
search:
|
|
33395
|
-
psgc:
|
|
33467
|
+
const validation = import_joi12.default.object({
|
|
33468
|
+
page: import_joi12.default.number().optional().allow(null, ""),
|
|
33469
|
+
limit: import_joi12.default.number().optional().allow(null, ""),
|
|
33470
|
+
sort: import_joi12.default.string().optional().allow(null, ""),
|
|
33471
|
+
sortOrder: import_joi12.default.string().optional().allow(null, ""),
|
|
33472
|
+
status: import_joi12.default.string().optional().allow(null, ""),
|
|
33473
|
+
org: import_joi12.default.string().hex().optional().allow(null, ""),
|
|
33474
|
+
app: import_joi12.default.string().optional().allow(null, ""),
|
|
33475
|
+
search: import_joi12.default.string().optional().allow(null, ""),
|
|
33476
|
+
psgc: import_joi12.default.string().optional().allow(null, "")
|
|
33396
33477
|
});
|
|
33397
33478
|
const { error } = validation.validate(req.query);
|
|
33398
33479
|
if (error) {
|
|
@@ -33430,7 +33511,7 @@ function useSchoolController() {
|
|
|
33430
33511
|
}
|
|
33431
33512
|
async function getByCreatedBy(req, res, next) {
|
|
33432
33513
|
const createdBy = req.params.createdBy;
|
|
33433
|
-
const validation =
|
|
33514
|
+
const validation = import_joi12.default.string().hex().required();
|
|
33434
33515
|
const { error } = validation.validate(createdBy);
|
|
33435
33516
|
if (error) {
|
|
33436
33517
|
next(new import_nodejs_utils19.BadRequestError(`Validation error: ${error.message}`));
|
|
@@ -33447,9 +33528,9 @@ function useSchoolController() {
|
|
|
33447
33528
|
async function updateStatusById(req, res, next) {
|
|
33448
33529
|
const schoolId = req.params.id;
|
|
33449
33530
|
const status = req.params.status;
|
|
33450
|
-
const validation =
|
|
33451
|
-
id:
|
|
33452
|
-
status:
|
|
33531
|
+
const validation = import_joi12.default.object({
|
|
33532
|
+
id: import_joi12.default.string().hex().required(),
|
|
33533
|
+
status: import_joi12.default.string().valid("active", "deleted", "suspended").required()
|
|
33453
33534
|
});
|
|
33454
33535
|
const { error } = validation.validate({ id: schoolId, status });
|
|
33455
33536
|
if (error) {
|
|
@@ -33482,8 +33563,8 @@ function useSchoolController() {
|
|
|
33482
33563
|
}
|
|
33483
33564
|
async function approveSchool(req, res, next) {
|
|
33484
33565
|
const schoolId = req.params.id;
|
|
33485
|
-
const validation =
|
|
33486
|
-
id:
|
|
33566
|
+
const validation = import_joi12.default.object({
|
|
33567
|
+
id: import_joi12.default.string().hex().required()
|
|
33487
33568
|
});
|
|
33488
33569
|
const { error } = validation.validate({ id: schoolId });
|
|
33489
33570
|
if (error) {
|
|
@@ -33506,11 +33587,11 @@ function useSchoolController() {
|
|
|
33506
33587
|
return;
|
|
33507
33588
|
}
|
|
33508
33589
|
const { region, regionName, division, divisionName } = req.body;
|
|
33509
|
-
const validation =
|
|
33510
|
-
region:
|
|
33511
|
-
regionName:
|
|
33512
|
-
division:
|
|
33513
|
-
divisionName:
|
|
33590
|
+
const validation = import_joi12.default.object({
|
|
33591
|
+
region: import_joi12.default.string().hex().required(),
|
|
33592
|
+
regionName: import_joi12.default.string().min(1).required(),
|
|
33593
|
+
division: import_joi12.default.string().hex().required(),
|
|
33594
|
+
divisionName: import_joi12.default.string().min(1).required()
|
|
33514
33595
|
});
|
|
33515
33596
|
const { error } = validation.validate({
|
|
33516
33597
|
region,
|
|
@@ -33539,10 +33620,10 @@ function useSchoolController() {
|
|
|
33539
33620
|
async function updateFieldById(req, res, next) {
|
|
33540
33621
|
const _id = req.params.id;
|
|
33541
33622
|
const { field, value } = req.body;
|
|
33542
|
-
const validation =
|
|
33543
|
-
_id:
|
|
33544
|
-
field:
|
|
33545
|
-
value:
|
|
33623
|
+
const validation = import_joi12.default.object({
|
|
33624
|
+
_id: import_joi12.default.string().hex().required(),
|
|
33625
|
+
field: import_joi12.default.string().valid("name", "director", "directorName").required(),
|
|
33626
|
+
value: import_joi12.default.string().required()
|
|
33546
33627
|
});
|
|
33547
33628
|
const { error } = validation.validate({ _id, field, value });
|
|
33548
33629
|
if (error) {
|
|
@@ -33560,8 +33641,8 @@ function useSchoolController() {
|
|
|
33560
33641
|
async function updateById(req, res, next) {
|
|
33561
33642
|
const id = req.params.id;
|
|
33562
33643
|
const payload = req.body;
|
|
33563
|
-
const validation =
|
|
33564
|
-
id:
|
|
33644
|
+
const validation = import_joi12.default.object({
|
|
33645
|
+
id: import_joi12.default.string().hex().required()
|
|
33565
33646
|
});
|
|
33566
33647
|
const { error: idError } = validation.validate({ id });
|
|
33567
33648
|
if (idError) {
|
|
@@ -33583,8 +33664,8 @@ function useSchoolController() {
|
|
|
33583
33664
|
}
|
|
33584
33665
|
async function deleteById(req, res, next) {
|
|
33585
33666
|
const _id = req.params.id;
|
|
33586
|
-
const validation =
|
|
33587
|
-
_id:
|
|
33667
|
+
const validation = import_joi12.default.object({
|
|
33668
|
+
_id: import_joi12.default.string().hex().required()
|
|
33588
33669
|
});
|
|
33589
33670
|
const { error } = validation.validate({ _id });
|
|
33590
33671
|
if (error) {
|
|
@@ -33679,7 +33760,7 @@ function useDivisionService() {
|
|
|
33679
33760
|
|
|
33680
33761
|
// src/resources/division/division.controller.ts
|
|
33681
33762
|
var import_nodejs_utils21 = require("@eeplatform/nodejs-utils");
|
|
33682
|
-
var
|
|
33763
|
+
var import_joi13 = __toESM(require("joi"));
|
|
33683
33764
|
function useDivisionController() {
|
|
33684
33765
|
const { add: _add, updateById: _updateById } = useDivisionService();
|
|
33685
33766
|
const {
|
|
@@ -33709,12 +33790,12 @@ function useDivisionController() {
|
|
|
33709
33790
|
}
|
|
33710
33791
|
async function getAll(req, res, next) {
|
|
33711
33792
|
const query = req.query;
|
|
33712
|
-
const validation =
|
|
33713
|
-
page:
|
|
33714
|
-
limit:
|
|
33715
|
-
search:
|
|
33716
|
-
status:
|
|
33717
|
-
region:
|
|
33793
|
+
const validation = import_joi13.default.object({
|
|
33794
|
+
page: import_joi13.default.number().min(1).optional().allow("", null),
|
|
33795
|
+
limit: import_joi13.default.number().min(1).optional().allow("", null),
|
|
33796
|
+
search: import_joi13.default.string().optional().allow("", null),
|
|
33797
|
+
status: import_joi13.default.string().optional().allow("", null),
|
|
33798
|
+
region: import_joi13.default.string().hex().optional().allow("", null)
|
|
33718
33799
|
});
|
|
33719
33800
|
const { error } = validation.validate(query);
|
|
33720
33801
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -33746,8 +33827,8 @@ function useDivisionController() {
|
|
|
33746
33827
|
}
|
|
33747
33828
|
async function getById(req, res, next) {
|
|
33748
33829
|
const id = req.params.id;
|
|
33749
|
-
const validation =
|
|
33750
|
-
id:
|
|
33830
|
+
const validation = import_joi13.default.object({
|
|
33831
|
+
id: import_joi13.default.string().hex().required()
|
|
33751
33832
|
});
|
|
33752
33833
|
const { error } = validation.validate({ id });
|
|
33753
33834
|
if (error) {
|
|
@@ -33767,8 +33848,8 @@ function useDivisionController() {
|
|
|
33767
33848
|
}
|
|
33768
33849
|
async function getByName(req, res, next) {
|
|
33769
33850
|
const name = req.params.name;
|
|
33770
|
-
const validation =
|
|
33771
|
-
name:
|
|
33851
|
+
const validation = import_joi13.default.object({
|
|
33852
|
+
name: import_joi13.default.string().required()
|
|
33772
33853
|
});
|
|
33773
33854
|
const { error } = validation.validate({ name });
|
|
33774
33855
|
if (error) {
|
|
@@ -33789,10 +33870,10 @@ function useDivisionController() {
|
|
|
33789
33870
|
async function updateField(req, res, next) {
|
|
33790
33871
|
const _id = req.params.id;
|
|
33791
33872
|
const { field, value } = req.body;
|
|
33792
|
-
const validation =
|
|
33793
|
-
_id:
|
|
33794
|
-
field:
|
|
33795
|
-
value:
|
|
33873
|
+
const validation = import_joi13.default.object({
|
|
33874
|
+
_id: import_joi13.default.string().hex().required(),
|
|
33875
|
+
field: import_joi13.default.string().valid("name", "director", "directorName").required(),
|
|
33876
|
+
value: import_joi13.default.string().required()
|
|
33796
33877
|
});
|
|
33797
33878
|
const { error } = validation.validate({ _id, field, value });
|
|
33798
33879
|
if (error) {
|
|
@@ -33825,8 +33906,8 @@ function useDivisionController() {
|
|
|
33825
33906
|
}
|
|
33826
33907
|
async function deleteById(req, res, next) {
|
|
33827
33908
|
const _id = req.params.id;
|
|
33828
|
-
const validation =
|
|
33829
|
-
_id:
|
|
33909
|
+
const validation = import_joi13.default.object({
|
|
33910
|
+
_id: import_joi13.default.string().hex().required()
|
|
33830
33911
|
});
|
|
33831
33912
|
const { error } = validation.validate({ _id });
|
|
33832
33913
|
if (error) {
|
|
@@ -33854,48 +33935,48 @@ function useDivisionController() {
|
|
|
33854
33935
|
|
|
33855
33936
|
// src/resources/asset/asset.model.ts
|
|
33856
33937
|
var import_nodejs_utils22 = require("@eeplatform/nodejs-utils");
|
|
33857
|
-
var
|
|
33938
|
+
var import_joi14 = __toESM(require("joi"));
|
|
33858
33939
|
var import_mongodb13 = require("mongodb");
|
|
33859
|
-
var schemaAsset =
|
|
33860
|
-
_id:
|
|
33861
|
-
school:
|
|
33862
|
-
asset_type:
|
|
33863
|
-
name:
|
|
33864
|
-
category:
|
|
33865
|
-
type:
|
|
33866
|
-
brand:
|
|
33867
|
-
unit:
|
|
33868
|
-
status:
|
|
33869
|
-
createdAt:
|
|
33870
|
-
updatedAt:
|
|
33871
|
-
deletedAt:
|
|
33872
|
-
metadata:
|
|
33873
|
-
title:
|
|
33874
|
-
isbn:
|
|
33875
|
-
author:
|
|
33876
|
-
edition:
|
|
33877
|
-
subject:
|
|
33878
|
-
grade_level:
|
|
33879
|
-
publisher:
|
|
33880
|
-
language:
|
|
33940
|
+
var schemaAsset = import_joi14.default.object({
|
|
33941
|
+
_id: import_joi14.default.string().hex().optional(),
|
|
33942
|
+
school: import_joi14.default.string().hex().required(),
|
|
33943
|
+
asset_type: import_joi14.default.string().required().allow("supply", "furniture-equipment", "fixed-asset"),
|
|
33944
|
+
name: import_joi14.default.string().required(),
|
|
33945
|
+
category: import_joi14.default.string().optional().allow("", null),
|
|
33946
|
+
type: import_joi14.default.string().optional().allow("", null),
|
|
33947
|
+
brand: import_joi14.default.string().optional().allow("", null),
|
|
33948
|
+
unit: import_joi14.default.string().required(),
|
|
33949
|
+
status: import_joi14.default.string().optional().allow("", null),
|
|
33950
|
+
createdAt: import_joi14.default.date().optional().allow("", null),
|
|
33951
|
+
updatedAt: import_joi14.default.date().optional().allow("", null),
|
|
33952
|
+
deletedAt: import_joi14.default.date().optional().allow("", null),
|
|
33953
|
+
metadata: import_joi14.default.object({
|
|
33954
|
+
title: import_joi14.default.string().optional().allow("", null),
|
|
33955
|
+
isbn: import_joi14.default.string().optional().allow("", null),
|
|
33956
|
+
author: import_joi14.default.string().optional().allow("", null),
|
|
33957
|
+
edition: import_joi14.default.string().optional().allow("", null),
|
|
33958
|
+
subject: import_joi14.default.string().optional().allow("", null),
|
|
33959
|
+
grade_level: import_joi14.default.number().integer().min(0).optional().allow("", null),
|
|
33960
|
+
publisher: import_joi14.default.string().optional().allow("", null),
|
|
33961
|
+
language: import_joi14.default.string().optional().allow("", null)
|
|
33881
33962
|
}).optional().allow(null)
|
|
33882
33963
|
});
|
|
33883
|
-
var schemaAssetUpdateOption =
|
|
33884
|
-
name:
|
|
33885
|
-
category:
|
|
33886
|
-
type:
|
|
33887
|
-
brand:
|
|
33888
|
-
qty:
|
|
33889
|
-
unit:
|
|
33890
|
-
metadata:
|
|
33891
|
-
title:
|
|
33892
|
-
isbn:
|
|
33893
|
-
author:
|
|
33894
|
-
edition:
|
|
33895
|
-
subject:
|
|
33896
|
-
grade_level:
|
|
33897
|
-
publisher:
|
|
33898
|
-
language:
|
|
33964
|
+
var schemaAssetUpdateOption = import_joi14.default.object({
|
|
33965
|
+
name: import_joi14.default.string().optional().allow("", null),
|
|
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
|
+
qty: import_joi14.default.number().integer().min(0).optional().allow("", null),
|
|
33970
|
+
unit: import_joi14.default.string().optional().allow("", null),
|
|
33971
|
+
metadata: import_joi14.default.object({
|
|
33972
|
+
title: import_joi14.default.string().optional().allow("", null),
|
|
33973
|
+
isbn: import_joi14.default.string().optional().allow("", null),
|
|
33974
|
+
author: import_joi14.default.string().optional().allow("", null),
|
|
33975
|
+
edition: import_joi14.default.string().optional().allow("", null),
|
|
33976
|
+
subject: import_joi14.default.string().optional().allow("", null),
|
|
33977
|
+
grade_level: import_joi14.default.number().integer().min(0).optional().allow("", null),
|
|
33978
|
+
publisher: import_joi14.default.string().optional().allow("", null),
|
|
33979
|
+
language: import_joi14.default.string().optional().allow("", null)
|
|
33899
33980
|
}).optional().allow(null)
|
|
33900
33981
|
});
|
|
33901
33982
|
function MAsset(value) {
|
|
@@ -34327,7 +34408,7 @@ function useAssetRepo() {
|
|
|
34327
34408
|
|
|
34328
34409
|
// src/resources/asset/asset.controller.ts
|
|
34329
34410
|
var import_nodejs_utils24 = require("@eeplatform/nodejs-utils");
|
|
34330
|
-
var
|
|
34411
|
+
var import_joi15 = __toESM(require("joi"));
|
|
34331
34412
|
function useAssetController() {
|
|
34332
34413
|
const {
|
|
34333
34414
|
add: _add,
|
|
@@ -34355,13 +34436,13 @@ function useAssetController() {
|
|
|
34355
34436
|
}
|
|
34356
34437
|
async function getAll(req, res, next) {
|
|
34357
34438
|
const query = req.query;
|
|
34358
|
-
const validation =
|
|
34359
|
-
page:
|
|
34360
|
-
limit:
|
|
34361
|
-
search:
|
|
34362
|
-
status:
|
|
34363
|
-
school:
|
|
34364
|
-
asset_type:
|
|
34439
|
+
const validation = import_joi15.default.object({
|
|
34440
|
+
page: import_joi15.default.number().min(1).optional().allow("", null),
|
|
34441
|
+
limit: import_joi15.default.number().min(1).optional().allow("", null),
|
|
34442
|
+
search: import_joi15.default.string().optional().allow("", null),
|
|
34443
|
+
status: import_joi15.default.string().optional().allow("", null),
|
|
34444
|
+
school: import_joi15.default.string().hex().optional().allow("", null),
|
|
34445
|
+
asset_type: import_joi15.default.string().required().allow("supply", "furniture-equipment", "fixed-asset")
|
|
34365
34446
|
});
|
|
34366
34447
|
const { error } = validation.validate(query);
|
|
34367
34448
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -34401,7 +34482,7 @@ function useAssetController() {
|
|
|
34401
34482
|
}
|
|
34402
34483
|
async function deleteById(req, res, next) {
|
|
34403
34484
|
const id = req.params.id;
|
|
34404
|
-
const validation =
|
|
34485
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34405
34486
|
const { error } = validation.validate(id);
|
|
34406
34487
|
if (error) {
|
|
34407
34488
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34416,7 +34497,7 @@ function useAssetController() {
|
|
|
34416
34497
|
}
|
|
34417
34498
|
async function getById(req, res, next) {
|
|
34418
34499
|
const id = req.params.id;
|
|
34419
|
-
const validation =
|
|
34500
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34420
34501
|
const { error } = validation.validate(id);
|
|
34421
34502
|
if (error) {
|
|
34422
34503
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34447,7 +34528,7 @@ function useAssetController() {
|
|
|
34447
34528
|
async function getCategories(req, res, next) {
|
|
34448
34529
|
const school = req.params.school;
|
|
34449
34530
|
const asset_type = req.params.asset_type;
|
|
34450
|
-
const validation =
|
|
34531
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34451
34532
|
const { error } = validation.validate(school);
|
|
34452
34533
|
if (error) {
|
|
34453
34534
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34463,7 +34544,7 @@ function useAssetController() {
|
|
|
34463
34544
|
async function getTypes(req, res, next) {
|
|
34464
34545
|
const school = req.params.school;
|
|
34465
34546
|
const asset_type = req.params.asset_type;
|
|
34466
|
-
const validation =
|
|
34547
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34467
34548
|
const { error } = validation.validate(school);
|
|
34468
34549
|
if (error) {
|
|
34469
34550
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34478,7 +34559,7 @@ function useAssetController() {
|
|
|
34478
34559
|
}
|
|
34479
34560
|
async function getUnitsBySchool(req, res, next) {
|
|
34480
34561
|
const school = req.params.school;
|
|
34481
|
-
const validation =
|
|
34562
|
+
const validation = import_joi15.default.string().hex().required();
|
|
34482
34563
|
const { error } = validation.validate(school);
|
|
34483
34564
|
if (error) {
|
|
34484
34565
|
next(new import_nodejs_utils24.BadRequestError(error.message));
|
|
@@ -34505,26 +34586,26 @@ function useAssetController() {
|
|
|
34505
34586
|
|
|
34506
34587
|
// src/resources/stock-card/stock-card.model.ts
|
|
34507
34588
|
var import_nodejs_utils25 = require("@eeplatform/nodejs-utils");
|
|
34508
|
-
var
|
|
34589
|
+
var import_joi16 = __toESM(require("joi"));
|
|
34509
34590
|
var import_mongodb15 = require("mongodb");
|
|
34510
|
-
var schemaStockCard =
|
|
34511
|
-
_id:
|
|
34512
|
-
school:
|
|
34513
|
-
item:
|
|
34514
|
-
balance:
|
|
34515
|
-
qty:
|
|
34516
|
-
unitCost:
|
|
34517
|
-
totalCost:
|
|
34518
|
-
status:
|
|
34519
|
-
condition:
|
|
34520
|
-
supplier:
|
|
34521
|
-
location:
|
|
34522
|
-
locationName:
|
|
34523
|
-
reason:
|
|
34524
|
-
remarks:
|
|
34525
|
-
createdAt:
|
|
34526
|
-
updatedAt:
|
|
34527
|
-
deletedAt:
|
|
34591
|
+
var schemaStockCard = import_joi16.default.object({
|
|
34592
|
+
_id: import_joi16.default.string().hex().optional().allow("", null),
|
|
34593
|
+
school: import_joi16.default.string().hex().required(),
|
|
34594
|
+
item: import_joi16.default.string().hex().required(),
|
|
34595
|
+
balance: import_joi16.default.number().optional().allow(null, 0),
|
|
34596
|
+
qty: import_joi16.default.number().required(),
|
|
34597
|
+
unitCost: import_joi16.default.number().optional().allow(null, 0),
|
|
34598
|
+
totalCost: import_joi16.default.number().optional().allow(null, 0),
|
|
34599
|
+
status: import_joi16.default.string().optional().allow(null, ""),
|
|
34600
|
+
condition: import_joi16.default.string().required(),
|
|
34601
|
+
supplier: import_joi16.default.string().optional().allow("", null),
|
|
34602
|
+
location: import_joi16.default.string().optional().allow("", null),
|
|
34603
|
+
locationName: import_joi16.default.string().optional().allow("", null),
|
|
34604
|
+
reason: import_joi16.default.string().optional().allow("", null),
|
|
34605
|
+
remarks: import_joi16.default.string().optional().allow("", null),
|
|
34606
|
+
createdAt: import_joi16.default.date().optional().allow("", null),
|
|
34607
|
+
updatedAt: import_joi16.default.date().optional().allow("", null),
|
|
34608
|
+
deletedAt: import_joi16.default.date().optional().allow("", null)
|
|
34528
34609
|
});
|
|
34529
34610
|
function MStockCard(value) {
|
|
34530
34611
|
const { error } = schemaStockCard.validate(value);
|
|
@@ -34812,7 +34893,7 @@ function useStockCardService() {
|
|
|
34812
34893
|
|
|
34813
34894
|
// src/resources/stock-card/stock-card.controller.ts
|
|
34814
34895
|
var import_nodejs_utils28 = require("@eeplatform/nodejs-utils");
|
|
34815
|
-
var
|
|
34896
|
+
var import_joi17 = __toESM(require("joi"));
|
|
34816
34897
|
function useStockCardController() {
|
|
34817
34898
|
const {
|
|
34818
34899
|
getAll: _getAll,
|
|
@@ -34836,11 +34917,11 @@ function useStockCardController() {
|
|
|
34836
34917
|
}
|
|
34837
34918
|
async function getAll(req, res, next) {
|
|
34838
34919
|
const query = req.query;
|
|
34839
|
-
const validation =
|
|
34840
|
-
page:
|
|
34841
|
-
limit:
|
|
34842
|
-
school:
|
|
34843
|
-
id:
|
|
34920
|
+
const validation = import_joi17.default.object({
|
|
34921
|
+
page: import_joi17.default.number().min(1).optional().allow("", null),
|
|
34922
|
+
limit: import_joi17.default.number().min(1).optional().allow("", null),
|
|
34923
|
+
school: import_joi17.default.string().hex().optional().allow("", null),
|
|
34924
|
+
id: import_joi17.default.string().hex().required()
|
|
34844
34925
|
});
|
|
34845
34926
|
const { error } = validation.validate(query);
|
|
34846
34927
|
const page = typeof req.query.page === "string" ? Number(req.query.page) : 1;
|
|
@@ -34876,7 +34957,7 @@ function useStockCardController() {
|
|
|
34876
34957
|
}
|
|
34877
34958
|
async function getById(req, res, next) {
|
|
34878
34959
|
const id = req.params.id;
|
|
34879
|
-
const validation =
|
|
34960
|
+
const validation = import_joi17.default.string().hex().required();
|
|
34880
34961
|
const { error } = validation.validate(id);
|
|
34881
34962
|
if (error) {
|
|
34882
34963
|
next(new import_nodejs_utils28.BadRequestError(error.message));
|
|
@@ -34891,7 +34972,7 @@ function useStockCardController() {
|
|
|
34891
34972
|
}
|
|
34892
34973
|
async function getSuppliers(req, res, next) {
|
|
34893
34974
|
const school = req.params.school;
|
|
34894
|
-
const validation =
|
|
34975
|
+
const validation = import_joi17.default.string().hex().required();
|
|
34895
34976
|
const { error } = validation.validate(school);
|
|
34896
34977
|
if (error) {
|
|
34897
34978
|
next(new import_nodejs_utils28.BadRequestError(error.message));
|
|
@@ -34914,30 +34995,30 @@ function useStockCardController() {
|
|
|
34914
34995
|
|
|
34915
34996
|
// src/resources/plantilla/plantilla.model.ts
|
|
34916
34997
|
var import_nodejs_utils29 = require("@eeplatform/nodejs-utils");
|
|
34917
|
-
var
|
|
34998
|
+
var import_joi18 = __toESM(require("joi"));
|
|
34918
34999
|
var import_mongodb17 = require("mongodb");
|
|
34919
|
-
var schemaPlantilla =
|
|
34920
|
-
_id:
|
|
34921
|
-
org:
|
|
34922
|
-
orgUnitCode:
|
|
34923
|
-
employmentType:
|
|
34924
|
-
personnelType:
|
|
34925
|
-
itemNumber:
|
|
34926
|
-
positionTitle:
|
|
34927
|
-
positionCategory:
|
|
34928
|
-
region:
|
|
34929
|
-
regionName:
|
|
34930
|
-
division:
|
|
34931
|
-
divisionName:
|
|
34932
|
-
salaryGrade:
|
|
34933
|
-
employeeName:
|
|
34934
|
-
annualSalary:
|
|
34935
|
-
monthlySalary:
|
|
34936
|
-
status:
|
|
34937
|
-
employee:
|
|
34938
|
-
createdAt:
|
|
34939
|
-
updatedAt:
|
|
34940
|
-
deletedAt:
|
|
35000
|
+
var schemaPlantilla = import_joi18.default.object({
|
|
35001
|
+
_id: import_joi18.default.string().hex().optional().allow(null, ""),
|
|
35002
|
+
org: import_joi18.default.string().hex().required(),
|
|
35003
|
+
orgUnitCode: import_joi18.default.string().optional().allow(null, ""),
|
|
35004
|
+
employmentType: import_joi18.default.string().optional().allow(null, ""),
|
|
35005
|
+
personnelType: import_joi18.default.string().required(),
|
|
35006
|
+
itemNumber: import_joi18.default.string().required(),
|
|
35007
|
+
positionTitle: import_joi18.default.string().required(),
|
|
35008
|
+
positionCategory: import_joi18.default.string().required(),
|
|
35009
|
+
region: import_joi18.default.string().hex().optional().allow(null, ""),
|
|
35010
|
+
regionName: import_joi18.default.string().optional().allow(null, ""),
|
|
35011
|
+
division: import_joi18.default.string().hex().optional().allow(null, ""),
|
|
35012
|
+
divisionName: import_joi18.default.string().optional().allow(null, ""),
|
|
35013
|
+
salaryGrade: import_joi18.default.number().required(),
|
|
35014
|
+
employeeName: import_joi18.default.string().optional().allow(null, ""),
|
|
35015
|
+
annualSalary: import_joi18.default.number().optional().allow(null, 0),
|
|
35016
|
+
monthlySalary: import_joi18.default.number().optional().allow(null, 0),
|
|
35017
|
+
status: import_joi18.default.string().required(),
|
|
35018
|
+
employee: import_joi18.default.string().hex().optional().allow(null, ""),
|
|
35019
|
+
createdAt: import_joi18.default.date().iso().optional().allow(null, ""),
|
|
35020
|
+
updatedAt: import_joi18.default.date().iso().optional().allow(null, ""),
|
|
35021
|
+
deletedAt: import_joi18.default.date().iso().optional().allow(null, "")
|
|
34941
35022
|
});
|
|
34942
35023
|
function MPlantilla(data) {
|
|
34943
35024
|
const { error } = schemaPlantilla.validate(data);
|
|
@@ -35419,7 +35500,7 @@ ${errors.slice(0, 10).join("\n")}${errors.length > 10 ? `
|
|
|
35419
35500
|
|
|
35420
35501
|
// src/resources/plantilla/plantilla.controller.ts
|
|
35421
35502
|
var import_nodejs_utils32 = require("@eeplatform/nodejs-utils");
|
|
35422
|
-
var
|
|
35503
|
+
var import_joi19 = __toESM(require("joi"));
|
|
35423
35504
|
function usePlantillaController() {
|
|
35424
35505
|
const {
|
|
35425
35506
|
add: _addPlantilla,
|
|
@@ -35431,11 +35512,11 @@ function usePlantillaController() {
|
|
|
35431
35512
|
const { addBulk: _addBulk } = usePlantillaService();
|
|
35432
35513
|
async function createPlantilla(req, res, next) {
|
|
35433
35514
|
const value = req.body;
|
|
35434
|
-
const validation =
|
|
35435
|
-
itemNumber:
|
|
35436
|
-
positionTitle:
|
|
35437
|
-
positionCategory:
|
|
35438
|
-
status:
|
|
35515
|
+
const validation = import_joi19.default.object({
|
|
35516
|
+
itemNumber: import_joi19.default.string().required(),
|
|
35517
|
+
positionTitle: import_joi19.default.string().required(),
|
|
35518
|
+
positionCategory: import_joi19.default.string().required(),
|
|
35519
|
+
status: import_joi19.default.string().required()
|
|
35439
35520
|
});
|
|
35440
35521
|
const { error } = validation.validate(value);
|
|
35441
35522
|
if (error) {
|
|
@@ -35465,11 +35546,11 @@ function usePlantillaController() {
|
|
|
35465
35546
|
next(new import_nodejs_utils32.BadRequestError("Invalid limit number."));
|
|
35466
35547
|
return;
|
|
35467
35548
|
}
|
|
35468
|
-
const validation =
|
|
35469
|
-
page:
|
|
35470
|
-
limit:
|
|
35471
|
-
search:
|
|
35472
|
-
org:
|
|
35549
|
+
const validation = import_joi19.default.object({
|
|
35550
|
+
page: import_joi19.default.number().min(1).optional().allow("", null),
|
|
35551
|
+
limit: import_joi19.default.number().min(1).optional().allow("", null),
|
|
35552
|
+
search: import_joi19.default.string().optional().allow("", null),
|
|
35553
|
+
org: import_joi19.default.string().optional().allow("", null)
|
|
35473
35554
|
});
|
|
35474
35555
|
const { error } = validation.validate({ page, limit, search, org });
|
|
35475
35556
|
if (error) {
|
|
@@ -35491,8 +35572,8 @@ function usePlantillaController() {
|
|
|
35491
35572
|
}
|
|
35492
35573
|
async function getPlantillaById(req, res, next) {
|
|
35493
35574
|
const id = req.params.id;
|
|
35494
|
-
const validation =
|
|
35495
|
-
id:
|
|
35575
|
+
const validation = import_joi19.default.object({
|
|
35576
|
+
id: import_joi19.default.string().hex().required()
|
|
35496
35577
|
});
|
|
35497
35578
|
const { error } = validation.validate({ id });
|
|
35498
35579
|
if (error) {
|
|
@@ -35514,12 +35595,12 @@ function usePlantillaController() {
|
|
|
35514
35595
|
async function updatePlantilla(req, res, next) {
|
|
35515
35596
|
const id = req.params.id;
|
|
35516
35597
|
const value = req.body;
|
|
35517
|
-
const validation =
|
|
35518
|
-
id:
|
|
35519
|
-
employee:
|
|
35520
|
-
status:
|
|
35521
|
-
positionTitle:
|
|
35522
|
-
positionCategory:
|
|
35598
|
+
const validation = import_joi19.default.object({
|
|
35599
|
+
id: import_joi19.default.string().hex().required(),
|
|
35600
|
+
employee: import_joi19.default.string().hex().optional().allow(null, ""),
|
|
35601
|
+
status: import_joi19.default.string().optional(),
|
|
35602
|
+
positionTitle: import_joi19.default.string().optional(),
|
|
35603
|
+
positionCategory: import_joi19.default.string().optional()
|
|
35523
35604
|
});
|
|
35524
35605
|
const { error } = validation.validate({ id, ...value });
|
|
35525
35606
|
if (error) {
|
|
@@ -35540,8 +35621,8 @@ function usePlantillaController() {
|
|
|
35540
35621
|
}
|
|
35541
35622
|
async function deletePlantilla(req, res, next) {
|
|
35542
35623
|
const id = req.params.id;
|
|
35543
|
-
const validation =
|
|
35544
|
-
id:
|
|
35624
|
+
const validation = import_joi19.default.object({
|
|
35625
|
+
id: import_joi19.default.string().hex().required()
|
|
35545
35626
|
});
|
|
35546
35627
|
const { error } = validation.validate({ id });
|
|
35547
35628
|
if (error) {
|
|
@@ -35566,9 +35647,9 @@ function usePlantillaController() {
|
|
|
35566
35647
|
return;
|
|
35567
35648
|
}
|
|
35568
35649
|
const { region, division } = req.body;
|
|
35569
|
-
const validation =
|
|
35570
|
-
region:
|
|
35571
|
-
division:
|
|
35650
|
+
const validation = import_joi19.default.object({
|
|
35651
|
+
region: import_joi19.default.string().hex().optional(),
|
|
35652
|
+
division: import_joi19.default.string().hex().optional()
|
|
35572
35653
|
});
|
|
35573
35654
|
const { error } = validation.validate({ region, division });
|
|
35574
35655
|
if (error) {
|