This repository has been archived by the owner on Oct 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87bdc26
commit 943b112
Showing
25 changed files
with
365 additions
and
204 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { InternalServerException } from '../../../util/exceptions'; | ||
const pool = require('../../../util/db'); | ||
|
||
const getTimetable = async ( | ||
grade: number, | ||
classNo: number | ||
): Promise<{ | ||
monday: string, | ||
tuesday: string, | ||
wednesday: string, | ||
thursday: string, | ||
friday: string | ||
} | null> => { | ||
const getQuery="SELECT monday, tuesday, wednesday, thursday, friday FROM timetable WHERE grade = ? AND classNo = ?" | ||
// SELECT | ||
// monday, | ||
// tuesday, | ||
// wednesday, | ||
// thursday, | ||
// friday | ||
// FROM timetable | ||
// WHERE | ||
// grade = ? AND | ||
// classNo = ? | ||
try { | ||
const [rows] = await pool.query(getQuery, [grade, classNo]); | ||
if (rows.length) | ||
return rows[0]; | ||
else | ||
return null; | ||
} catch(err) { | ||
console.error(err); | ||
throw new InternalServerException(); | ||
} | ||
} | ||
|
||
export { | ||
getTimetable | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { NotFoundException } from '../../../util/exceptions'; | ||
import * as repository from './timetable.repository'; | ||
|
||
const getTimetable = async ( | ||
grade: number, | ||
classNo: number | ||
) => { | ||
const timetableInfo = await repository.getTimetable(grade, classNo); | ||
if (timetableInfo === null) { | ||
throw new NotFoundException(); | ||
} | ||
const {monday, tuesday, wednesday, thursday, friday} = timetableInfo; | ||
if (monday+tuesday+wednesday+thursday+friday == '') { | ||
throw new NotFoundException(); | ||
} | ||
return { | ||
timetable:[ | ||
!monday? null: monday.split(','), | ||
!tuesday? null: tuesday.split(','), | ||
!wednesday? null: wednesday.split(','), | ||
!thursday? null: thursday.split(','), | ||
!friday? null: friday.split(','), | ||
] | ||
} | ||
} | ||
|
||
export { | ||
getTimetable | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.