Skip to content

Commit

Permalink
Backend/Enhancement/Changes-and-requests-given-by-teams (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetkudu authored Dec 24, 2023
1 parent cbc2a5c commit 6e25682
Show file tree
Hide file tree
Showing 16 changed files with 200 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
package com.gamelounge.backend.constant

enum class GameGenre {
RPG,
STRATEGY,
SHOOTER,
SPORTS_AND_RACING,
FIGHTING,
RGP,
Strategy,
Shooter,
Sports,
Fighting,
MOBA,
EMPTY
Action,
Adventure,
Simulation,
Horror,
Empty
}

enum class GamePlatform {
XBOX,
COMPUTER,
Computer,
PS, // PlayStation
ONBOARD,
EMPTY
Onboard,
Mobile,
Empty
}

enum class NumberOfPlayers {
SINGLE,
TEAMS,
MULTIPLE,
Single,
Teams,
Multiplayer,
MMO, // Massively Multiplayer Online
EMPTY
Empty
}

enum class UniverseInfo {
MEDIEVAL,
FANTASY,
SCIFI,
CYBERPUNK,
HISTORICAL,
CONTEMPORARY,
POST_APOCALYPTIC,
ALTERNATE_REALITY,
EMPTY
Medieval,
Fantasy,
SciFi,
Cyberpunk,
Historical,
Contemporary,
PostApocalyptic,
AlternateReality,
Empty
}

enum class GameMechanics {
TURN_BASED,
CHANCE_BASED,
EMPTY
TurnBased,
ChangeBased,
RealTime,
Empty
// Add more mechanics as needed
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package com.gamelounge.backend.constant
object S3Constants {
const val PROFILE_PICTURE_DIRECTORY = "https://game-lounge-storage.s3.eu-north-1.amazonaws.com/profile-pictures/"
const val GAME_PICTURE_DIRECTORY = "https://game-lounge-storage.s3.eu-north-1.amazonaws.com/game-pictures/"
const val EDITED_GAME_PICTURE_DIRECTORY = "https://game-lounge-storage.s3.eu-north-1.amazonaws.com/edited-game-pictures/"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gamelounge.backend.controller


import com.gamelounge.backend.entity.UserGameRating
import com.gamelounge.backend.middleware.SessionAuth
import com.gamelounge.backend.model.DTO.GameDTO
import com.gamelounge.backend.model.request.CreateGameRequest
Expand All @@ -10,6 +12,7 @@ import com.gamelounge.backend.model.request.*
import com.gamelounge.backend.model.response.ResponseMessage
import com.gamelounge.backend.service.GameService
import com.gamelounge.backend.util.ConverterDTO
import io.swagger.v3.core.util.Json
import com.gamelounge.backend.util.ConverterDTO.convertBulkToGameDTO
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
Expand Down Expand Up @@ -67,6 +70,13 @@ class GameController(
return ResponseEntity.ok(gameDTO)
}

@GetMapping("/{id}/getRating")
fun getRating(@CookieValue("SESSIONID") sessionId: UUID, @PathVariable id: Long): ResponseEntity<UserGameRatingDTO> {
val userGameRating = gameService.getRating(sessionId, id)
val userGameRatingDTO = ConverterDTO.convertToUserInfoGameRatingDTO(userGameRating)
return ResponseEntity.ok(userGameRatingDTO)
}

@GetMapping("/rated")
fun getGamesRatedByUser(@CookieValue("SESSIONID") sessionId: UUID): ResponseEntity<List<UserGameRatingDTO>> {
val userGameRatingDTOs = gameService.getRatedGamesByUser(sessionId)
Expand All @@ -83,10 +93,10 @@ class GameController(
@ResponseStatus(HttpStatus.CREATED)
fun createEditingRequest(@CookieValue("SESSIONID") sessionId: UUID,
@RequestPart("request") editedGame: CreateEditingRequest,
@RequestPart("image") image: MultipartFile?,
@RequestPart("image") editedImage: MultipartFile?,
@PathVariable id: Long
): ResponseEntity<ResponseMessage> {
gameService.createEditingRequest(sessionId, editedGame, image, id)
gameService.createEditingRequest(sessionId, editedGame, editedImage, id)
return ResponseEntity.ok(ResponseMessage(message = "Editing game was requested successfully."))
}

Expand Down
17 changes: 12 additions & 5 deletions app/backend/src/main/kotlin/com/gamelounge/backend/entity/Game.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,24 @@ class Game(

var title: String = "",
var description: String = "",

@ElementCollection(targetClass = GameGenre::class)
@Enumerated(EnumType.STRING)
var genre: GameGenre = GameGenre.EMPTY,
@CollectionTable(name = "game_genres", joinColumns = [JoinColumn(name = "gameId")])
var genres: Set<GameGenre> = emptySet(),

@ElementCollection(targetClass = GamePlatform::class)
@Enumerated(EnumType.STRING)
var platform: GamePlatform = GamePlatform.EMPTY,
@CollectionTable(name = "game_platforms", joinColumns = [JoinColumn(name = "gameId")])
var platforms: Set<GamePlatform> = emptySet(),

@Enumerated(EnumType.STRING)
var playerNumber: NumberOfPlayers = NumberOfPlayers.EMPTY,
var playerNumber: NumberOfPlayers = NumberOfPlayers.Empty,
var releaseYear: Int = 0,
@Enumerated(EnumType.STRING)
var universe: UniverseInfo = UniverseInfo.EMPTY,
var universe: UniverseInfo = UniverseInfo.Empty,
@Enumerated(EnumType.STRING)
var mechanics: GameMechanics = GameMechanics.EMPTY,
var mechanics: GameMechanics = GameMechanics.Empty,
var playtime: String = "",
var totalRating: Int = 0,
var countRating: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@ class RequestedEditingGame(
val gameId: Long = 0,
var title: String = "",
var description: String = "",

@ElementCollection(targetClass = GameGenre::class)
@Enumerated(EnumType.STRING)
var genre: GameGenre = GameGenre.EMPTY,
@CollectionTable(name = "edited_game_genres", joinColumns = [JoinColumn(name = "gameId")])
var genres: Set<GameGenre> = emptySet(),

@ElementCollection(targetClass = GamePlatform::class)
@Enumerated(EnumType.STRING)
var platform: GamePlatform = GamePlatform.EMPTY,
@CollectionTable(name = "edited_game_platforms", joinColumns = [JoinColumn(name = "gameId")])
var platforms: Set<GamePlatform> = emptySet(),

@Enumerated(EnumType.STRING)
var playerNumber: NumberOfPlayers = NumberOfPlayers.EMPTY,
var playerNumber: NumberOfPlayers = NumberOfPlayers.Empty,
var releaseYear: Int = 0,
@Enumerated(EnumType.STRING)
var universe: UniverseInfo = UniverseInfo.EMPTY,
var universe: UniverseInfo = UniverseInfo.Empty,
@Enumerated(EnumType.STRING)
var mechanics: GameMechanics = GameMechanics.EMPTY,
var mechanics: GameMechanics = GameMechanics.Empty,
var playtime: String = "",
var creationDate: Instant = Instant.now(),
var gamePicture: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ data class EditedGameDTO(
var gameId: Long = 0,
var title: String = "",
var description: String = "",
var genre: GameGenre = GameGenre.EMPTY,
var platform: GamePlatform = GamePlatform.EMPTY,
var playerNumber: NumberOfPlayers = NumberOfPlayers.EMPTY,
val genres: List<GameGenre>,
val platforms: List<GamePlatform>,
var playerNumber: NumberOfPlayers = NumberOfPlayers.Empty,
var releaseYear: Int = 0,
var universe: UniverseInfo = UniverseInfo.EMPTY,
var mechanics: GameMechanics = GameMechanics.EMPTY,
var universe: UniverseInfo = UniverseInfo.Empty,
var mechanics: GameMechanics = GameMechanics.Empty,
var playtime: String = "",
var creationDate: Instant? = null,
var gamePicture: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ data class GameDTO(
var gameId: Long = 0,
var title: String = "",
var description: String = "",
var genre: GameGenre = GameGenre.EMPTY,
var platform: GamePlatform = GamePlatform.EMPTY,
val genres: List<GameGenre>,
val platforms: List<GamePlatform>,
var characters: List<CharacterDTO>,
var playerNumber: NumberOfPlayers = NumberOfPlayers.EMPTY,
var playerNumber: NumberOfPlayers = NumberOfPlayers.Empty,
var releaseYear: Int = 0,
var universe: UniverseInfo = UniverseInfo.EMPTY,
var mechanics: GameMechanics = GameMechanics.EMPTY,
var universe: UniverseInfo = UniverseInfo.Empty,
var mechanics: GameMechanics = GameMechanics.Empty,
var playtime: String = "",
var totalRating: Int,
var countRating: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ data class UserDTO(
var tags: List<TagDTO>? = null,
var followers: List<UserDTO>? = null,
var isVisible: Boolean = false,
var isDeleted: Boolean = false,
var isAdmin: Boolean = false
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package com.gamelounge.backend.model.DTO

class UserGameRatingDTO (
var user: UserDTO,
var game: GameDTO,
var rating: Int
)

data class UserGameRatingDTO(
var gameDTO: GameDTO,
var score: Int
)

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class CreateEditingRequest(
val gameId: Long = 0,
val title: String,
val description: String,
val genre: GameGenre,
val platform: GamePlatform,
val genres: List<String>,
val platforms: List<String>,
val playerNumber: NumberOfPlayers,
val releaseYear: Int,
val universe: UniverseInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import com.gamelounge.backend.constant.GameMechanics
class CreateGameRequest(
val title: String,
val description: String,
val genre: GameGenre,
val platform: GamePlatform,
val genres: List<String>,
val platforms: List<String>,
val playerNumber: NumberOfPlayers,
val releaseYear: Int,
val universe: UniverseInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import com.gamelounge.backend.constant.GameMechanics
class UpdateGameRequest(
val title: String,
val description: String,
val genre: GameGenre,
val platform: GamePlatform,
val genres: List<String>,
val platforms: List<String>,
val playerNumber: NumberOfPlayers,
val releaseYear: Int,
val universe: UniverseInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ data class GetUserInfoResponse(
val profilePicture: String? = null,
val about: String? = null,
val isAdmin: Boolean = false,
val isVisible: Boolean = false,
val isDeleted: Boolean = false,
val tags: List<TagDTO>? = null,
val title: String? = null,
val company: String? = null,
Expand Down
Loading

0 comments on commit 6e25682

Please sign in to comment.