/* * Copyright (c) 2023. yo-saito. All Rights Reserved. */ package net.piedpiper.bremer.controller.api import jakarta.validation.Valid import net.piedpiper.bremer.entity.AudioEntity import net.piedpiper.bremer.model.PlaylistAudioResponse import net.piedpiper.bremer.model.PlaylistListResponse import net.piedpiper.bremer.model.PlaylistRequest import net.piedpiper.bremer.service.app.PlaylistAppService import org.springframework.beans.factory.annotation.Qualifier import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.PutMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController import java.util.UUID @RestController @RequestMapping("bremer/api/playlist") class PlaylistApiController( @Qualifier("bremer.service.PlaylistAppService") private val playlistAppService: PlaylistAppService, ) { @GetMapping fun getAll(): ResponseEntity<PlaylistListResponse> = ResponseEntity.ok(playlistAppService.getAllPlaylists()) @GetMapping("{slug}") fun get(@PathVariable("slug") slug: String): ResponseEntity<PlaylistAudioResponse> = ResponseEntity.ok(playlistAppService.getPlaylist(slug)) @PostMapping fun create( @Valid @RequestBody request: PlaylistRequest ): ResponseEntity<PlaylistAudioResponse> = ResponseEntity.ok(playlistAppService.createPlaylist(request)) @PutMapping("{slug}") fun update( @PathVariable("slug") slug: String, @Valid @RequestBody request: PlaylistRequest ): ResponseEntity<PlaylistAudioResponse> = ResponseEntity.ok(playlistAppService.updatePlaylist(slug, request)) }