Skip to content

Commit

Permalink
Merge pull request #673 from bounswe/frontend/enhancement/add-annotat…
Browse files Browse the repository at this point in the history
…ions

[Frontend] Implement text annotation
  • Loading branch information
beyzabektan authored Dec 25, 2023
2 parents dc95dba + e51db48 commit 3bba58d
Show file tree
Hide file tree
Showing 14 changed files with 792 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AnnotationServiceApplication {
return object : WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000", "http://game-lounge.com")
.allowedOrigins("http://localhost:3000", "http://game-lounge.com", "http://167.99.242.175")
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowCredentials(true)
.allowedHeaders("*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class AnnotationController(
private val annotationService: AnnotationService
) {
@PostMapping("parse-selector")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com", "http://167.99.242.175"])
fun parseSelector(@RequestBody selector: SelectorDto): ResponseEntity<String> {

return ResponseEntity.ok("test")
}
@PostMapping("/create")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com", "http://167.99.242.175"])
fun createAnnotation(@RequestBody annotationDto: AnnotationDto): ResponseEntity<AnnotationDto> {

val responseAnnotation = DtoConverter
Expand All @@ -30,7 +30,7 @@ class AnnotationController(
}

@GetMapping("/{id}")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com", "http://167.99.242.175"])
fun getAnnotation(@PathVariable id: String): ResponseEntity<AnnotationDto> {
val annotation = annotationService.getAnnotation(id) ?: return ResponseEntity(HttpStatus.NOT_FOUND)

Expand All @@ -40,15 +40,15 @@ class AnnotationController(
}

@PostMapping("/get-annotations-by-target")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com", "http://167.99.242.175"])
fun getAnnotationsByTarget(@RequestBody request: GetAnnotationsByTargetIdRequest): ResponseEntity<List<AnnotationDto>> {
val annotations = annotationService.getAnnotationsByTarget(request.targetId)
val responseAnnotationList = annotations.map { DtoConverter.convertAnnotationToAnnotationDto(it) }
return ResponseEntity.ok(responseAnnotationList)
}

@DeleteMapping("/{id}")
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com"])
@CrossOrigin(origins = ["http://localhost:3000", "http://game-lounge.com", "http://167.99.242.175"])
fun deleteAnnotation(@PathVariable id: String): ResponseEntity<Void> {
return if (annotationService.deleteAnnotation(id)) {
ResponseEntity<Void>(HttpStatus.NO_CONTENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class CreateEditingRequest(
val description: String,
val genres: List<String>,
val platforms: List<String>,
val playerNumber: NumberOfPlayers,
val playerNumber: String,
val releaseYear: Int,
val universe: UniverseInfo,
val mechanics: GameMechanics,
val universe: String,
val mechanics: String,
val playtime: String,
var totalRating: Int,
var countRating: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.gamelounge.backend.service

import com.gamelounge.backend.constant.GameGenre
import com.gamelounge.backend.constant.GamePlatform
import com.gamelounge.backend.constant.*
import com.gamelounge.backend.entity.*
import com.gamelounge.backend.exception.*
import com.gamelounge.backend.middleware.SessionAuth
Expand Down Expand Up @@ -86,17 +85,19 @@ class GameService(

// Convert platform strings to GamePlatform enum values
val platforms = editedGame.platforms.map { GamePlatform.valueOf(it) }.toMutableSet()

val playernumber = NumberOfPlayers.valueOf(editedGame.playerNumber)
var universe = UniverseInfo.valueOf(editedGame.universe)
var gamemechanics = GameMechanics.valueOf(editedGame.mechanics)
val requestEditingGame = RequestedEditingGame(
gameId = gameId,
title = editedGame.title,
description = editedGame.description,
genres = genres,
platforms = platforms,
playerNumber = editedGame.playerNumber,
playerNumber = playernumber,
releaseYear = editedGame.releaseYear,
universe = editedGame.universe,
mechanics = editedGame.mechanics,
universe = universe,
mechanics = gamemechanics,
playtime = editedGame.playtime,
)
//editedGameRepository.save(requestEditingGame) // save to get gameId for image name
Expand Down
Loading

0 comments on commit 3bba58d

Please sign in to comment.