Skip to content

Commit

Permalink
Add graph mode models
Browse files Browse the repository at this point in the history
그래프 모드에서 사용하는 모델들.
  • Loading branch information
June222 committed Oct 30, 2023
1 parent 3cfbdc1 commit 1c0a8be
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Frontend/tablet/lib/models/graph_bar_model.dart
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"]);
}
26 changes: 26 additions & 0 deletions Frontend/tablet/lib/models/graph_request_model.dart
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,
};
}
17 changes: 17 additions & 0 deletions Frontend/tablet/lib/models/graph_response_model.dart
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']);
}

0 comments on commit 1c0a8be

Please sign in to comment.