Neue Datenbank Struktur #156

Open
gelbeinhalb wants to merge 88 commits from feature/88-neue-datenbank-struktur into development
Showing only changes of commit 072021bd4c - Show all commits

View File

@@ -1,4 +1,5 @@
import 'package:clock/clock.dart'; import 'package:clock/clock.dart';
import 'package:game_tracker/data/dto/game.dart';
import 'package:game_tracker/data/dto/group.dart'; import 'package:game_tracker/data/dto/group.dart';
import 'package:game_tracker/data/dto/player.dart'; import 'package:game_tracker/data/dto/player.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
@@ -7,45 +8,49 @@ class Match {
final String id; final String id;
final DateTime createdAt; final DateTime createdAt;
final String name; final String name;
final List<Player>? players; final Game? game;
gelbeinhalb marked this conversation as resolved Outdated

Game nicht optional sondern required

Game nicht optional sondern required
final Group? group; final Group? group;
Player? winner; final List<Player>? players;
gelbeinhalb marked this conversation as resolved Outdated

Spielerliste auch nicht optional

Spielerliste auch nicht optional
final String? notes;
Match({ Match({
Review

Notes optional

Notes optional
Review

Dachte leerer String

Dachte leerer String
Review

s.o.

s.o.
String? id, String? id,
DateTime? createdAt, DateTime? createdAt,
required this.name, required this.name,
this.players, this.game,
this.group, this.group,
this.winner, this.players,
this.notes,
}) : id = id ?? const Uuid().v4(), }) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now(); createdAt = createdAt ?? clock.now();
@override @override
String toString() { String toString() {
return 'Match{\n\tid: $id,\n\tname: $name,\n\tplayers: $players,\n\tgroup: $group,\n\twinner: $winner\n}'; return 'Match{id: $id, name: $name, game: $game, group: $group, players: $players, notes: $notes}';
} }
/// Creates a Match instance from a JSON object. /// Creates a Match instance from a JSON object.
Match.fromJson(Map<String, dynamic> json) Match.fromJson(Map<String, dynamic> json)
: id = json['id'], : id = json['id'],
name = json['name'],
createdAt = DateTime.parse(json['createdAt']), createdAt = DateTime.parse(json['createdAt']),
name = json['name'],
game = json['game'] != null ? Game.fromJson(json['game']) : null,
group = json['group'] != null ? Group.fromJson(json['group']) : null,
players = json['players'] != null players = json['players'] != null
? (json['players'] as List) ? (json['players'] as List)
.map((playerJson) => Player.fromJson(playerJson)) .map((playerJson) => Player.fromJson(playerJson))
.toList() .toList()
: null, : null,
group = json['group'] != null ? Group.fromJson(json['group']) : null, notes = json['notes'];
winner = json['winner'] != null ? Player.fromJson(json['winner']) : null;
/// Converts the Match instance to a JSON object. /// Converts the Match instance to a JSON object.
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
'createdAt': createdAt.toIso8601String(), 'createdAt': createdAt.toIso8601String(),
'name': name, 'name': name,
'players': players?.map((player) => player.toJson()).toList(), 'game': game?.toJson(),
'group': group?.toJson(), 'group': group?.toJson(),
'winner': winner?.toJson(), 'players': players?.map((player) => player.toJson()).toList(),
'notes': notes,
}; };
} }