Added createdAt attribute in dto classes and json schema
This commit is contained in:
@@ -13,6 +13,9 @@
|
|||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"id",
|
"id",
|
||||||
|
"createdAt",
|
||||||
"name",
|
"name",
|
||||||
"players",
|
"players",
|
||||||
"group",
|
"group",
|
||||||
@@ -45,6 +49,9 @@
|
|||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -57,19 +64,7 @@
|
|||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"createdAt": {
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"name"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
@@ -78,6 +73,7 @@
|
|||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"id",
|
"id",
|
||||||
|
"createdAt",
|
||||||
"name"
|
"name"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -86,6 +82,7 @@
|
|||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"id",
|
"id",
|
||||||
|
"createdAt",
|
||||||
"name",
|
"name",
|
||||||
"members"
|
"members"
|
||||||
]
|
]
|
||||||
@@ -101,19 +98,7 @@
|
|||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"createdAt": {
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"name"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
@@ -122,16 +107,12 @@
|
|||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"id",
|
"id",
|
||||||
|
"createdAt",
|
||||||
"name"
|
"name"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"required": [
|
|
||||||
"games",
|
|
||||||
"groups",
|
|
||||||
"players"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import 'package:uuid/uuid.dart';
|
|||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
final String id;
|
final String id;
|
||||||
|
final DateTime createdAt;
|
||||||
final String name;
|
final String name;
|
||||||
final List<Player>? players;
|
final List<Player>? players;
|
||||||
final Group? group;
|
final Group? group;
|
||||||
final String? winner;
|
final String? winner;
|
||||||
final DateTime createdAt;
|
|
||||||
|
|
||||||
Game({
|
Game({
|
||||||
String? id,
|
String? id,
|
||||||
@@ -30,6 +30,7 @@ class Game {
|
|||||||
Game.fromJson(Map<String, dynamic> json)
|
Game.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
name = json['name'],
|
name = json['name'],
|
||||||
|
createdAt = DateTime.parse(json['createdAt']),
|
||||||
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))
|
||||||
@@ -41,6 +42,7 @@ class Game {
|
|||||||
/// Converts the Game instance to a JSON object.
|
/// Converts the Game instance to a JSON object.
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
|
'createdAt': createdAt.toIso8601String(),
|
||||||
'name': name,
|
'name': name,
|
||||||
'players': players?.map((player) => player.toJson()).toList(),
|
'players': players?.map((player) => player.toJson()).toList(),
|
||||||
'group': group?.toJson(),
|
'group': group?.toJson(),
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import 'package:uuid/uuid.dart';
|
|||||||
|
|
||||||
class Group {
|
class Group {
|
||||||
final String id;
|
final String id;
|
||||||
|
final DateTime createdAt;
|
||||||
final String name;
|
final String name;
|
||||||
final List<Player> members;
|
final List<Player> members;
|
||||||
final DateTime createdAt;
|
|
||||||
|
|
||||||
Group({
|
Group({
|
||||||
String? id,
|
String? id,
|
||||||
@@ -24,6 +24,7 @@ class Group {
|
|||||||
/// Creates a Group instance from a JSON object.
|
/// Creates a Group instance from a JSON object.
|
||||||
Group.fromJson(Map<String, dynamic> json)
|
Group.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
createdAt = DateTime.parse(json['createdAt']),
|
||||||
name = json['name'],
|
name = json['name'],
|
||||||
members = (json['members'] as List)
|
members = (json['members'] as List)
|
||||||
.map((memberJson) => Player.fromJson(memberJson))
|
.map((memberJson) => Player.fromJson(memberJson))
|
||||||
@@ -32,6 +33,7 @@ class Group {
|
|||||||
/// Converts the Group instance to a JSON object.
|
/// Converts the Group instance to a JSON object.
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
|
'createdAt': createdAt.toIso8601String(),
|
||||||
'name': name,
|
'name': name,
|
||||||
'members': members.map((member) => member.toJson()).toList(),
|
'members': members.map((member) => member.toJson()).toList(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import 'package:uuid/uuid.dart';
|
|||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
final String id;
|
final String id;
|
||||||
final String name;
|
|
||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
|
final String name;
|
||||||
|
|
||||||
Player({String? id, DateTime? createdAt, required this.name})
|
Player({String? id, DateTime? createdAt, required this.name})
|
||||||
: id = id ?? const Uuid().v4(),
|
: id = id ?? const Uuid().v4(),
|
||||||
@@ -18,8 +18,13 @@ class Player {
|
|||||||
/// Creates a Player instance from a JSON object.
|
/// Creates a Player instance from a JSON object.
|
||||||
Player.fromJson(Map<String, dynamic> json)
|
Player.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
createdAt = DateTime.parse(json['createdAt']),
|
||||||
name = json['name'];
|
name = json['name'];
|
||||||
|
|
||||||
/// Converts the Player instance to a JSON object.
|
/// Converts the Player instance to a JSON object.
|
||||||
Map<String, dynamic> toJson() => {'id': id, 'name': name};
|
Map<String, dynamic> toJson() => {
|
||||||
|
'id': id,
|
||||||
|
'createdAt': createdAt.toIso8601String(),
|
||||||
|
'name': name,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user