package roomescape.theme.web import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import roomescape.common.dto.response.CommonApiResponse import roomescape.theme.business.ThemeServiceV2 import roomescape.theme.docs.ThemeAPIV2 import java.net.URI @RestController class ThemeControllerV2( private val themeService: ThemeServiceV2, ) : ThemeAPIV2 { @GetMapping("/v2/themes") override fun findUserThemes(): ResponseEntity> { val response = themeService.findThemesForReservation() return ResponseEntity.ok(CommonApiResponse(response)) } @GetMapping("/admin/themes") override fun findAdminThemes(): ResponseEntity> { val response = themeService.findAdminThemes() return ResponseEntity.ok(CommonApiResponse(response)) } @GetMapping("/admin/themes/{id}") override fun findAdminThemeDetail(@PathVariable id: Long): ResponseEntity> { val response = themeService.findAdminThemeDetail(id) return ResponseEntity.ok(CommonApiResponse(response)) } @PostMapping("/admin/themes") override fun createTheme(themeCreateRequestV2: ThemeCreateRequestV2): ResponseEntity> { val response = themeService.createTheme(themeCreateRequestV2) return ResponseEntity.created(URI.create("/admin/themes/${response.id}")) .body(CommonApiResponse(response)) } @DeleteMapping("/admin/themes/{id}") override fun deleteTheme(@PathVariable id: Long): ResponseEntity> { themeService.deleteTheme(id) return ResponseEntity.noContent().build() } @PatchMapping("/admin/themes/{id}") override fun updateTheme( @PathVariable id: Long, themeUpdateRequest: ThemeUpdateRequest ): ResponseEntity> { themeService.updateTheme(id, themeUpdateRequest) return ResponseEntity.ok().build() } }