feat: add originalSubject and originalTeacher
This commit is contained in:
parent
345397f6a3
commit
a1e506b7b2
3 changed files with 31 additions and 7 deletions
|
|
@ -2,7 +2,7 @@ import axios from 'axios'
|
||||||
import { BASE_URL, USER_AGENT } from './constants'
|
import { BASE_URL, USER_AGENT } from './constants'
|
||||||
import DataManager from './data'
|
import DataManager from './data'
|
||||||
import School from './models/School'
|
import School from './models/School'
|
||||||
import type Timetable from './models/Timetable'
|
import type { Timetable } from './models/Timetable'
|
||||||
import { encodeBase64, encodeEUCKR } from './utils/encode'
|
import { encodeBase64, encodeEUCKR } from './utils/encode'
|
||||||
import { parseResponse } from './utils/parse'
|
import { parseResponse } from './utils/parse'
|
||||||
|
|
||||||
|
|
@ -64,13 +64,26 @@ export default class Comcigan {
|
||||||
cls.slice(1).map((day, dIdx) =>
|
cls.slice(1).map((day, dIdx) =>
|
||||||
day.slice(1).map((period, pIdx) => {
|
day.slice(1).map((period, pIdx) => {
|
||||||
const p = period.toString()
|
const p = period.toString()
|
||||||
|
const changed =
|
||||||
|
period !== original[gIdx + 1][cIdx + 1][dIdx + 1][pIdx + 1]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subject: subjects[Number(p.slice(0, p.length - teachersLen - 1))],
|
subject: subjects[Number(p.slice(0, p.length - teachersLen - 1))],
|
||||||
teacher: teachers[Number(p.slice(-teachersLen))],
|
teacher: teachers[Number(p.slice(-teachersLen))],
|
||||||
changed:
|
changed,
|
||||||
period !== original[gIdx + 1][cIdx + 1][dIdx + 1][pIdx + 1],
|
...(changed
|
||||||
|
? {
|
||||||
|
originalSubject:
|
||||||
|
subjects[
|
||||||
|
original[gIdx + 1][cIdx + 1][dIdx + 1][pIdx + 1]
|
||||||
|
],
|
||||||
|
originalTeacher:
|
||||||
|
teachers[
|
||||||
|
original[gIdx + 1][cIdx + 1][dIdx + 1][pIdx + 1]
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
: {}),
|
||||||
|
} as Timetable
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import Comcigan from '../client'
|
import Comcigan from '../client'
|
||||||
import Fetcher from './Fetcher'
|
import Fetcher from './Fetcher'
|
||||||
import type Region from './Region'
|
import type Region from './Region'
|
||||||
import type Timetable from './Timetable'
|
import type { Timetable } from './Timetable'
|
||||||
|
|
||||||
interface ISchool {
|
interface ISchool {
|
||||||
/** 학교 코드 */
|
/** 학교 코드 */
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,19 @@
|
||||||
export default interface Timetable {
|
export type Timetable = {
|
||||||
/** 과목 */
|
/** 과목 */
|
||||||
subject: string
|
subject: string
|
||||||
/** 교사 */
|
/** 교사 */
|
||||||
teacher: string
|
teacher: string
|
||||||
/** 변경 여부 */
|
/** 변경 여부 */
|
||||||
changed: boolean
|
changed: boolean
|
||||||
|
} & (
|
||||||
|
| {
|
||||||
|
changed: true
|
||||||
|
/** 변경 전 과목 */
|
||||||
|
originalSubject: string
|
||||||
|
/** 변경 전 교사 */
|
||||||
|
originalTeacher: string
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
changed: false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue