Implements photo review endpoint
This commit is contained in:
@@ -2,21 +2,25 @@ 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.PhotoId
|
||||
import net.halfbinary.scavengerhuntapi.model.request.ReviewPhotoRequest
|
||||
import net.halfbinary.scavengerhuntapi.service.PhotoService
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.PatchMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admin")
|
||||
class AdminController {
|
||||
class AdminController(private val photoService: PhotoService) {
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@Tag(name = "Admin")
|
||||
@PostMapping("/admin/photo/{photoId}")
|
||||
@PatchMapping("/photo/{photoId}")
|
||||
@Operation(summary = "Sets a review status for the specified photo")
|
||||
fun reviewPhoto(@PathVariable photoId: PhotoId) {
|
||||
TODO("Set a review status for the specified photo, and update the photo record's status change timestamp")
|
||||
fun reviewPhoto(@PathVariable photoId: PhotoId, @Valid @RequestBody request: ReviewPhotoRequest) {
|
||||
photoService.updatePhotoStatus(photoId, request.status)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user