서비스 공지사항 API 추가

This commit is contained in:
2023-08-02 16:46:56 +09:00
parent 0c106540cd
commit baad5653e8
7 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package kr.co.vividnext.sodalive.notice
import kr.co.vividnext.sodalive.common.ApiResponse
import org.springframework.data.domain.Pageable
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.RestController
@RestController
@RequestMapping("/notice")
class ServiceNoticeController(private val service: ServiceNoticeService) {
@PostMapping
@PreAuthorize("hasRole('ADMIN')")
fun createNotice(@RequestBody request: CreateNoticeRequest) = ApiResponse.ok(
service.save(request),
"등록되었습니다."
)
@PutMapping
@PreAuthorize("hasRole('ADMIN')")
fun updateNotice(@RequestBody request: UpdateNoticeRequest) = ApiResponse.ok(
service.update(request),
"수정되었습니다."
)
@DeleteMapping("/{id}")
@PreAuthorize("hasRole('ADMIN')")
fun deleteCoin(@PathVariable id: Long) = ApiResponse.ok(service.delete(id), "삭제되었습니다.")
@GetMapping
fun getNoticeList(pageable: Pageable, timezone: String) = ApiResponse.ok(service.getNoticeList(pageable, timezone))
}