Skip to content

Commit ca07082

Browse files
committed
fix: SKBJ can be null
1 parent 6cd1d9d commit ca07082

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/adapters/nju_undergrad/course/getcourse.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ impl interfaces::courses::Course {
136136
notes: vec![
137137
format!("班级: {}", self.JXBMC),
138138
format!("教师: {}", self.JSHS.unwrap_or_else(|| "未知".to_string())),
139-
format!("上课班级: {}", self.SKBJ),
139+
format!(
140+
"上课班级: {}",
141+
self.SKBJ.unwrap_or_else(|| "未知".to_string())
142+
),
140143
],
141144
}
142145
}

src/adapters/nju_undergrad/course/interfaces/courses.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ use map_macro::hash_map;
77
use reqwest_middleware::ClientWithMiddleware;
88
use serde::Deserialize;
99
use serde_with::{DisplayFromStr, serde_as};
10+
use tracing::{debug, error};
1011

11-
#[derive(Deserialize)]
12+
#[derive(Deserialize, Debug)]
1213
pub struct Response {
1314
pub datas: Data,
1415
pub code: String,
1516
}
1617

17-
#[derive(Deserialize)]
18+
#[derive(Deserialize, Debug)]
1819
pub struct Data {
1920
pub cxxszhxqkb: Cxxszhxqkb,
2021
}
2122

22-
#[derive(Deserialize)]
23+
#[derive(Deserialize, Debug)]
2324
pub struct Cxxszhxqkb {
2425
pub pageSize: i32,
2526
pub pageNumber: i32,
@@ -28,7 +29,7 @@ pub struct Cxxszhxqkb {
2829
}
2930

3031
#[serde_as]
31-
#[derive(Deserialize)]
32+
#[derive(Deserialize, Debug)]
3233
pub struct Course {
3334
/// Course name
3435
pub KCM: String,
@@ -43,7 +44,7 @@ pub struct Course {
4344
/// Class e.g. 形势与政策16班"
4445
pub JXBMC: String,
4546
/// Classes that attend this class e.g. "2022计算机学院计算机科学与技术(拔尖计划),2022计算机学院信息与计算科学(强基计划),2022计算机学院金融工程(计算机金融实验班),2022计算机学院计算机科学与技术"
46-
pub SKBJ: String,
47+
pub SKBJ: Option<String>,
4748
/// Course days display name e.g. "周二 5-6节 3周, 7周, 11周, 15周 仙Ⅰ-106"
4849
pub YPSJDD: String,
4950
/// Course days display name without spaces e.g. "周二 5-6节 3周,7周,11周,15周 仙Ⅰ-106"

0 commit comments

Comments
 (0)