Skip to content

Commit

Permalink
Update AnnotationController.kt (cors)
Browse files Browse the repository at this point in the history
  • Loading branch information
otaliptus authored Dec 25, 2023
1 parent e95c4c6 commit 2974b0f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ class AnnotationController(
private val annotationService: AnnotationService
) {
@PostMapping("parse-selector")
@CrossOrigin(origins = ["*"])
fun parseSelector(@RequestBody selector: SelectorDto): ResponseEntity<String> {

return ResponseEntity.ok("test")
}
@PostMapping("/create")
@CrossOrigin(origins = ["*"])
fun createAnnotation(@RequestBody annotationDto: AnnotationDto): ResponseEntity<AnnotationDto> {

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

@GetMapping("/{id}")
@CrossOrigin(origins = ["*"])
fun getAnnotation(@PathVariable id: String): ResponseEntity<AnnotationDto> {
val annotation = annotationService.getAnnotation(id) ?: return ResponseEntity(HttpStatus.NOT_FOUND)

Expand All @@ -37,18 +40,20 @@ class AnnotationController(
}

@PostMapping("/get-annotations-by-target")
@CrossOrigin(origins = ["*"])
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 = ["*"])
fun deleteAnnotation(@PathVariable id: String): ResponseEntity<Void> {
return if (annotationService.deleteAnnotation(id)) {
ResponseEntity<Void>(HttpStatus.NO_CONTENT)
} else {
ResponseEntity<Void>(HttpStatus.NOT_FOUND)
}
}
}
}

0 comments on commit 2974b0f

Please sign in to comment.