forked from pnucse-capstone/capstone-2023-1-02
-
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
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
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,17 @@ | ||
class GraphBarModel { | ||
final String date; | ||
final int class_one_num; | ||
final int class_two_num; | ||
final int class_three_num; | ||
final int class_four_num; | ||
|
||
GraphBarModel(this.class_one_num, this.class_two_num, this.class_three_num, | ||
this.class_four_num, this.date); | ||
|
||
static GraphBarModel fromJson(Map<String, dynamic> jsonData) => GraphBarModel( | ||
jsonData["num_class_one"], | ||
jsonData["num_class_two"], | ||
jsonData["num_class_three"], | ||
jsonData["num_class_four"], | ||
jsonData["date"]); | ||
} |
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,26 @@ | ||
// mysql로 보낼 데이터 클래스 모델(DTO) | ||
class GraphRequestModel { | ||
final String dateStart; | ||
final String dateEnd; | ||
|
||
GraphRequestModel({ | ||
required this.dateStart, | ||
required this.dateEnd, | ||
}); | ||
|
||
// DatePicker에서 설정한 값으로 클래스 생성 | ||
static GraphRequestModel fromDateTime( | ||
DateTime dateTimeStart, DateTime dateTimeEnd) { | ||
var dts = "${dateTimeStart.toString().split(' ')[0]} 00:00:00"; | ||
var dte = "${dateTimeEnd.toString().split(' ')[0]} 23:59:59"; | ||
return GraphRequestModel(dateStart: dts, dateEnd: dte); | ||
} | ||
|
||
// json에 전달할 형태로 변환 | ||
// [주의] | ||
// 전달할 때는 jsonEncode(model.toJson())로 전달하여야함. | ||
Map<String, dynamic> toJson() => { | ||
"localDateTimeStart": dateStart, | ||
"localDateTimeEnd": dateEnd, | ||
}; | ||
} |
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,17 @@ | ||
// Mysql 서버에서 데이터를 받는 모델 클래스 (DTO) | ||
class GraphResponseModel { | ||
final int code; | ||
final String msg; | ||
final dynamic data; | ||
|
||
GraphResponseModel({ | ||
required this.code, | ||
required this.msg, | ||
required this.data, | ||
}); | ||
|
||
// json(Map)형태에서 바로 생성하는 static method. | ||
static GraphResponseModel fromJson(Map<String, dynamic> jsonData) => | ||
GraphResponseModel( | ||
code: jsonData["code"], msg: jsonData['msg'], data: jsonData['data']); | ||
} |