O erro aponta para o arquivo TopicoController.kt
package br.com.alura.forum.controller
import br.com.alura.forum.dto.AtualizacaoTopicoForm
import br.com.alura.forum.dto.NovoTopicoForm
import br.com.alura.forum.dto.TopicoView
import br.com.alura.forum.service.TopicoService
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.util.UriComponentsBuilder
import javax.transaction.Transactional
import javax.validation.Valid
import javax.validation.constraints.NotNull
@RestController
@RequestMapping("/topicos")
class TopicoController(private val service: TopicoService) {
@GetMapping
fun listar(): List<TopicoView> {
return service.listar()
}
@GetMapping("/{id}")
fun buscarPorId(@PathVariable id: Long): TopicoView {
return service.buscarPorId(id)
}
@PostMapping
@org.springframework.transaction.annotation.Transactional
fun cadastrar(
@RequestBody @Valid form: NovoTopicoForm,
uriBuilder: UriComponentsBuilder
): ResponseEntity<TopicoView> {
val topicoView = service.cadastrar(form)
val uri = uriBuilder.path("/topicos/${topicoView.id}").build().toUri()
return ResponseEntity.created(uri).body(topicoView)
}
@PutMapping
@org.springframework.transaction.annotation.Transactional
fun atualizar(@RequestBody @Valid form: AtualizacaoTopicoForm): ResponseEntity<TopicoView> {
val topicoView = service.atualizar(form)
return ResponseEntity.ok(topicoView)
}
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
@org.springframework.transaction.annotation.Transactional
fun deletar(@PathVariable id: Long) {
service.deletar(id)
}
}