Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/bounswe/bounswe2023group6
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
otaliptus committed Dec 25, 2023
2 parents 2b0d326 + ad61938 commit 0a2f69f
Show file tree
Hide file tree
Showing 15 changed files with 776 additions and 74 deletions.
4 changes: 2 additions & 2 deletions app/mobile/lib/data/models/character_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Character {
characterId: json['characterId'],
name: json['name'],
description: json['description'],
gameId: json['gameId'],
gameId: json['gameID'],
);
}

Expand All @@ -25,7 +25,7 @@ class Character {
'characterId': characterId,
'title': name,
'description': description,
'gameId': gameId,
'gameID': gameId,
};
}
}
37 changes: 37 additions & 0 deletions app/mobile/lib/data/models/dto/game/character_create_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:mobile/data/models/dto/base_dto_object.dart';
import 'package:mobile/utils/service_validation_util.dart';

class CharacterCreateRequest extends BaseDTOObject<CharacterCreateRequest> {
String name;
String description;


CharacterCreateRequest({
required this.name,
required this.description,

});

@override
void validate() {
ValidationUtil.validate(name, ValidationPolicy.stringNotEmptyValidation());
ValidationUtil.validate(
description, ValidationPolicy.stringNotEmptyValidation());
}

factory CharacterCreateRequest.fromJson(Map<String, dynamic> json) =>
CharacterCreateRequest(
name: json["name"],
description: json["description"],
);

@override
Map<String, dynamic> toJson() => {
"name": name,
"description": description,
};

@override
CharacterCreateRequest fromJson(Map<String, dynamic> json) =>
CharacterCreateRequest.fromJson(json);
}
61 changes: 61 additions & 0 deletions app/mobile/lib/data/models/dto/lfg/lfg_create_dto_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:mobile/data/models/dto/base_dto_object.dart';
import 'package:mobile/utils/service_validation_util.dart';

class LFGCreateDTORequest extends BaseDTOObject<LFGCreateDTORequest> {
String title;
String description;
String requiredPlatform;
String requiredLanguage;
bool micCamRequirement;
int memberCapacity;
int? gameId;
List<String> tags;

LFGCreateDTORequest({
required this.title,
required this.description,
required this.requiredPlatform,
required this.requiredLanguage,
required this.micCamRequirement,
required this.memberCapacity,
required this.gameId,
required this.tags,
});

@override
void validate() {
ValidationUtil.validate(title, ValidationPolicy.stringNotEmptyValidation());
ValidationUtil.validate(
description, ValidationPolicy.stringNotEmptyValidation());
}

factory LFGCreateDTORequest.fromJson(Map<String, dynamic> json) =>
LFGCreateDTORequest(
title: json["title"],
description: json["description"],
requiredPlatform: json["requiredPlatform"],
requiredLanguage: json["requiredLanguage"],
micCamRequirement: json["micCamRequirement"],
memberCapacity: json["memberCapacity"],
gameId: json["gameId"],
tags: json["tags"] != null
? List<String>.from(json["tags"].map((x) => x))
: [],
);

@override
Map<String, dynamic> toJson() => {
"title": title,
"description": description,
"requiredPlatform": requiredPlatform,
"requiredLanguage": requiredLanguage,
"micCamRequirement": micCamRequirement,
"memberCapacity": memberCapacity,
"gameId": gameId,
"tags": tags,
};

@override
LFGCreateDTORequest fromJson(Map<String, dynamic> json) =>
LFGCreateDTORequest.fromJson(json);
}
25 changes: 25 additions & 0 deletions app/mobile/lib/data/models/dto/lfg/lfg_response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:mobile/data/models/character_model.dart';
import 'package:mobile/data/models/dto/base_dto_object.dart';
import 'package:mobile/data/models/game_model.dart';
import 'package:mobile/data/models/lfg_model.dart';

class LFGDTOResponse extends BaseDTOObject<LFGDTOResponse> {
LFG? lfg;

LFGDTOResponse({
this.lfg,
});

@override
void validate() {}

factory LFGDTOResponse.fromJson(Map<String, dynamic> json) =>
LFGDTOResponse(lfg: LFG.fromJson(json));

@override
Map<String, dynamic> toJson() => lfg!.toJson();

@override
LFGDTOResponse fromJson(Map<String, dynamic> json) =>
LFGDTOResponse.fromJson(json);
}
33 changes: 33 additions & 0 deletions app/mobile/lib/data/models/dto/lfg/mutliple_lfg_dto_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:mobile/data/models/dto/base_dto_object.dart';
import 'package:mobile/data/models/dto/game/game_response.dart';
import 'package:mobile/data/models/dto/lfg/lfg_response.dart';

class MultipleLFGAsDTO extends BaseDTOObject<MultipleLFGAsDTO> {
List<LFGDTOResponse>? lfgs;

MultipleLFGAsDTO({
this.lfgs,
});

@override
void validate() {
for (var lfg in lfgs!) {
lfg.validate();
}
}

factory MultipleLFGAsDTO.fromJson(Map<String, dynamic> json) =>
MultipleLFGAsDTO(
lfgs: List<LFGDTOResponse>.from(
json["response"].map((x) => LFGDTOResponse.fromJson(x))),
);

@override
Map<String, dynamic> toJson() => {
"response": List<dynamic>.from(lfgs!.map((x) => x.toJson())),
};

@override
MultipleLFGAsDTO fromJson(Map<String, dynamic> json) =>
MultipleLFGAsDTO.fromJson(json);
}
7 changes: 5 additions & 2 deletions app/mobile/lib/data/models/game_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class Game {
this.developers,
this.similarGameList = const [],
this.relatedPosts = const [],
this.status
this.status,
this.characters,
});

factory Game.fromJson(Map<String, dynamic> json) {
Expand All @@ -64,7 +65,8 @@ class Game {
averageRating: json['averageRating'],
creationDate: json['creationDate'],
gamePicture: json['gamePicture'],
status: json['status']
status: json['status'],
characters: json['characters'] != null ? List<Character>.from(json["characters"].map((x) => Character.fromJson(x))) : []
);
}

Expand All @@ -85,6 +87,7 @@ class Game {
'creationDate': creationDate,
'gamePicture': gamePicture,
'status': status,
'characters': characters,
};
}
}
45 changes: 43 additions & 2 deletions app/mobile/lib/data/models/lfg_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class LFG extends Content {
dislikes = 0,
comments = 0,
List<Comment> commentList = const [],

this.requiredPlatform,
this.requiredLanguage,
this.micCamRequirement,
Expand All @@ -44,10 +43,52 @@ class LFG extends Content {
tags: tags,
relatedGameId: relatedGameId,
);

Future<void> loadLfgSocialData() async {
LFGService lfgService = LFGService();
likeIds = await lfgService.getLikedUsers(id);
dislikeIds = await lfgService.getDislikedUsers(id);
}

factory LFG.fromJson(Map<String, dynamic> json) {
print(json);
return LFG(
id: json['lfgId'],
title: json['title'],
description: json['description'],
ownerUserId: json["user"]["userId"],
ownerUsername: json["user"]["username"],
ownerProfileImage: json["user"]["profilePicture"] ?? "",
creationDate: DateTime.parse(json['creationDate']),
tags: json["tags"] != null
? List<String>.from(json["tags"].map((x) => x["name"]))
: [],
relatedGameId:
json['relatedGame'] != null ? json['relatedGame']["gameId"] : null,
requiredPlatform: json['requiredPlatform'],
requiredLanguage: json['requiredLanguage'],
micCamRequirement: json['micCamRequirement'],
memberCapacity: json['memberCapacity']);
}

Map<String, dynamic> toJson() {
return {
"id": id,
"description": content,
"title": title,
"ownerUserId": ownerUserId,
"ownerUsername": ownerUsername,
"ownerProfileImage": ownerProfileImage,
"tags": tags,
"relatedGameId": relatedGameId,
"likes": likes,
"dislikes": dislikes,
"comments": comments,
"commentList": commentList,
"requiredPlatform": requiredPlatform,
"requiredLanguage": requiredLanguage,
"micCamRequirement": micCamRequirement,
"memberCapacity": memberCapacity
};
}
}
Loading

0 comments on commit 0a2f69f

Please sign in to comment.