Implements adding an item to a hunt
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
package net.halfbinary.scavengerhuntapi.controller
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import io.swagger.v3.oas.annotations.tags.Tag
|
||||
import jakarta.validation.Valid
|
||||
import net.halfbinary.scavengerhuntapi.model.HuntId
|
||||
import net.halfbinary.scavengerhuntapi.model.ItemId
|
||||
import net.halfbinary.scavengerhuntapi.model.converter.toDomain
|
||||
import net.halfbinary.scavengerhuntapi.model.converter.toResponse
|
||||
import net.halfbinary.scavengerhuntapi.model.request.ItemRequest
|
||||
import net.halfbinary.scavengerhuntapi.model.response.ItemResponse
|
||||
import net.halfbinary.scavengerhuntapi.service.HuntService
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
@@ -29,10 +33,12 @@ class ItemController(private val huntService: HuntService) {
|
||||
TODO("Get detailed information about the specified Item for the specified Hunt")
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@Tag(name = "Admin")
|
||||
@PostMapping
|
||||
@Operation(summary = "Adds new Item to specified Hunt")
|
||||
fun addItemToHunt(@PathVariable huntId: HuntId, @Valid @RequestBody body: ItemRequest) {
|
||||
TODO("Add a new item to the specified Hunt")
|
||||
fun addItemToHunt(@PathVariable huntId: HuntId, @Valid @RequestBody body: ItemRequest): ResponseEntity<ItemResponse> {
|
||||
return ResponseEntity.ok(huntService.addItemToHunt(huntId, body.toDomain()).toResponse())
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user