-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from B3-3iL-DLW/refactor/refactor-data-layer-api
Refactor/refactor data layer api
- Loading branch information
Showing
34 changed files
with
504 additions
and
246 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
13 changes: 13 additions & 0 deletions
13
frontend/app_student/lib/api/class_groups/entities/class_group_entity.dart
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,13 @@ | ||
class ClassGroupEntity { | ||
final String file; | ||
final String name; | ||
|
||
ClassGroupEntity({required this.file, required this.name}); | ||
|
||
factory ClassGroupEntity.fromJson(Map<String, dynamic> json) { | ||
return ClassGroupEntity( | ||
file: json['file'], | ||
name: json['name'], | ||
); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
frontend/app_student/lib/api/class_groups/models/class_group_model.dart
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,10 @@ | ||
import '../entities/class_group_entity.dart'; | ||
|
||
class ClassGroupModel { | ||
final ClassGroupEntity classGroup; | ||
|
||
ClassGroupModel({required this.classGroup}); | ||
|
||
String get name => classGroup.name; | ||
String get file => classGroup.file; | ||
} |
16 changes: 16 additions & 0 deletions
16
frontend/app_student/lib/api/class_groups/repositories/class_group_repository.dart
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,16 @@ | ||
import 'package:app_student/api/class_groups/entities/class_group_entity.dart'; | ||
import 'package:app_student/api/api_service.dart'; | ||
import 'package:app_student/api/class_groups/models/class_group_model.dart'; | ||
|
||
class ClassGroupRepository { | ||
final ApiService apiService; | ||
|
||
ClassGroupRepository({required this.apiService}); | ||
|
||
Future<List<ClassGroupModel>> getClasses() { | ||
return apiService.getData('/api/classes', (item) { | ||
final entity = ClassGroupEntity.fromJson(item); | ||
return ClassGroupModel(classGroup: entity); | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
frontend/app_student/lib/api/classes/repositories/class_repository.dart
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
frontend/app_student/lib/api/day_schedule/entities/day_schedule.dart
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
frontend/app_student/lib/api/day_schedule/entities/day_schedule_entity.dart
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,27 @@ | ||
import '../../events/entities/event_entity.dart'; | ||
|
||
class DayScheduleEntity { | ||
final DateTime date; | ||
final int jour; | ||
final List<EventEntity> events; | ||
|
||
DayScheduleEntity({ | ||
required this.date, | ||
required this.jour, | ||
required this.events, | ||
}); | ||
|
||
factory DayScheduleEntity.fromJson(Map<String, dynamic> json) { | ||
var eventsFromJson = json['events'] as List; | ||
List<EventEntity> eventsList = | ||
eventsFromJson.map((i) => EventEntity.fromJson(i)).toList(); | ||
|
||
DateTime date = DateTime.parse(json['date']); | ||
|
||
return DayScheduleEntity( | ||
date: date, | ||
jour: json['jour'], | ||
events: eventsList, | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
frontend/app_student/lib/api/day_schedule/models/day_schedule_model.dart
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,14 @@ | ||
import '../../events/entities/event_entity.dart'; | ||
import '../entities/day_schedule_entity.dart'; | ||
|
||
class DayScheduleModel { | ||
final DayScheduleEntity entity; | ||
|
||
DayScheduleModel({required this.entity}); | ||
|
||
DateTime get date => entity.date; | ||
|
||
int get jour => entity.jour; | ||
|
||
List<EventEntity> get events => entity.events; | ||
} |
6 changes: 3 additions & 3 deletions
6
frontend/app_student/lib/api/day_schedule/repositories/day_schedule.dart
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import 'package:app_student/api/api_service.dart'; | ||
import '../entities/day_schedule.dart'; | ||
import '../entities/day_schedule_entity.dart'; | ||
|
||
class DayScheduleRepository { | ||
final String className; | ||
final ApiService apiService; | ||
|
||
DayScheduleRepository({required this.className, required this.apiService}); | ||
|
||
Future<List<DaySchedule>> getDaySchedules($className) { | ||
Future<List<DayScheduleEntity>> getDaySchedule($className) { | ||
return apiService.getData('/api/timetable?class_param=$className', | ||
(item) => DaySchedule.fromJson(item)); | ||
(item) => DayScheduleEntity.fromJson(item)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
frontend/app_student/lib/api/event_hours/entities/event_hours_entity.dart
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,16 @@ | ||
class EventHoursEntity { | ||
final String startAt; | ||
final String endAt; | ||
|
||
EventHoursEntity({ | ||
required this.startAt, | ||
required this.endAt, | ||
}); | ||
|
||
factory EventHoursEntity.fromJson(Map<String, dynamic> json) { | ||
return EventHoursEntity( | ||
startAt: json['startAt'], | ||
endAt: json['endAt'], | ||
); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
frontend/app_student/lib/api/event_hours/models/event_hours_model.dart
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,10 @@ | ||
import '../entities/event_hours_entity.dart'; | ||
|
||
class EventHoursModel { | ||
final EventHoursEntity entity; | ||
|
||
EventHoursModel({required this.entity}); | ||
|
||
String get startAt => entity.startAt; | ||
String get endAt => entity.endAt; | ||
} |
33 changes: 33 additions & 0 deletions
33
frontend/app_student/lib/api/events/entities/event_entity.dart
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,33 @@ | ||
import '../../event_hours/entities/event_hours_entity.dart'; | ||
|
||
class EventEntity { | ||
final int id; | ||
final int creneau; | ||
final String activite; | ||
final String couleur; | ||
final EventHoursEntity horaires; | ||
final String salle; | ||
final bool visio; | ||
|
||
EventEntity({ | ||
required this.id, | ||
required this.creneau, | ||
required this.activite, | ||
required this.couleur, | ||
required this.horaires, | ||
required this.salle, | ||
required this.visio, | ||
}); | ||
|
||
factory EventEntity.fromJson(Map<String, dynamic> json) { | ||
return EventEntity( | ||
creneau: json['creneau'] ?? 'null', | ||
activite: json['activite'] ?? 'null', | ||
id: json['id'] ?? 'null', | ||
couleur: json['couleur'] ?? 'null', | ||
horaires: EventHoursEntity.fromJson(json['horaire']), | ||
salle: json['salle'] ?? 'null', | ||
visio: json['visio'] ?? false, | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
frontend/app_student/lib/api/events/models/event_model.dart
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,15 @@ | ||
import '../../event_hours/models/event_hours_model.dart'; | ||
import '../entities/event_entity.dart'; | ||
|
||
class EventModel { | ||
final EventEntity entity; | ||
|
||
EventModel({required this.entity}); | ||
|
||
int get id => entity.id; | ||
int get creneau => entity.creneau; | ||
String get activite => entity.activite; | ||
String get couleur => entity.couleur; | ||
EventHoursModel get horaires => EventHoursModel(entity: entity.horaires); | ||
String get salle => entity.salle; | ||
} |
14 changes: 14 additions & 0 deletions
14
frontend/app_student/lib/api/users/entities/user_entity.dart
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,14 @@ | ||
import 'package:app_student/api/class_groups/entities/class_group_entity.dart'; | ||
|
||
class UserEntity { | ||
final String ine; | ||
final String firstName; | ||
final DateTime birthDate; | ||
final ClassGroupEntity? classGroup; | ||
|
||
UserEntity( | ||
{required this.ine, | ||
required this.firstName, | ||
required this.birthDate, | ||
this.classGroup}); | ||
} |
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,11 @@ | ||
import '../entities/user_entity.dart'; | ||
|
||
class UserModel { | ||
final UserEntity entity; | ||
|
||
UserModel({required this.entity}); | ||
|
||
String get file => entity.ine; | ||
String get name => entity.firstName; | ||
DateTime get birthDate => entity.birthDate; | ||
} |
21 changes: 21 additions & 0 deletions
21
frontend/app_student/lib/api/week_schedule/entities/week_schedule_entity.dart
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,21 @@ | ||
import 'package:app_student/api/day_schedule/entities/day_schedule_entity.dart'; | ||
|
||
class WeekScheduleEntity { | ||
final String code; | ||
final List<DayScheduleEntity> daySchedules; | ||
|
||
WeekScheduleEntity({ | ||
required this.code, | ||
required this.daySchedules, | ||
}); | ||
|
||
factory WeekScheduleEntity.fromJson(Map<String, dynamic> json) { | ||
return WeekScheduleEntity( | ||
code: json['code'], | ||
daySchedules: (json['DaySchedule'] as List<dynamic>) | ||
.map((daySchedule) => | ||
DayScheduleEntity.fromJson(daySchedule as Map<String, dynamic>)) | ||
.toList(), | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
frontend/app_student/lib/api/week_schedule/models/week_schedule_model.dart
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,14 @@ | ||
import 'package:app_student/api/day_schedule/entities/day_schedule_entity.dart'; | ||
|
||
import '../entities/week_schedule_entity.dart'; | ||
|
||
class WeekScheduleModel { | ||
final WeekScheduleEntity weekSchedule; | ||
|
||
WeekScheduleModel({ | ||
required this.weekSchedule, | ||
}); | ||
|
||
String get code => weekSchedule.code; | ||
List<DayScheduleEntity> get daySchedules => weekSchedule.daySchedules; | ||
} |
16 changes: 16 additions & 0 deletions
16
frontend/app_student/lib/api/week_schedule/repositories/week_schedule_repositories.dart
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,16 @@ | ||
import 'package:app_student/api/api_service.dart'; | ||
import 'package:app_student/api/week_schedule/entities/week_schedule_entity.dart'; | ||
import 'package:app_student/api/week_schedule/models/week_schedule_model.dart'; | ||
|
||
class WeekScheduleRepository { | ||
final ApiService apiService; | ||
|
||
WeekScheduleRepository({required this.apiService, required String className}); | ||
|
||
Future<List<WeekScheduleModel>> getWeeksSchedule(className) { | ||
return apiService.getData('/api/timetable?class_param=$className', (item) { | ||
final entity = WeekScheduleEntity.fromJson(item); | ||
return WeekScheduleModel(weekSchedule: entity); | ||
}); | ||
} | ||
} |
Oops, something went wrong.