package kr.co.vividnext.sodalive.faq import kr.co.vividnext.sodalive.common.ApiResponse import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.DeleteMapping 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 @RestController @RequestMapping("/faq") class FaqController(private val service: FaqService) { @PostMapping @PreAuthorize("hasRole('ADMIN')") fun createFaq(@RequestBody request: CreateFaqRequest) = ApiResponse.ok( service.save(request), "등록되었습니다." ) @PutMapping @PreAuthorize("hasRole('ADMIN')") fun modifyFaq(@RequestBody request: ModifyFaqRequest) = ApiResponse.ok( service.modify(request), "수정되었습니다." ) @DeleteMapping("/{id}") @PreAuthorize("hasRole('ADMIN')") fun deleteCan(@PathVariable id: Long) = ApiResponse.ok(service.delete(id), "삭제되었습니다.") @GetMapping fun getFaqList(@RequestParam("category") category: String) = ApiResponse.ok(service.getFaqList(category)) @GetMapping("/category") fun getFaqCategoryList() = ApiResponse.ok(service.getCategoryList()) }