package com.caliverse.admin.domain.api;

import org.springframework.http.ResponseEntity;
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;

import com.caliverse.admin.domain.request.NoticeRequest;
import com.caliverse.admin.domain.response.NoticeResponse;
import com.caliverse.admin.domain.service.NoticeService;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@Tag(name = "공지사항", description = "공지사항 메뉴 api 입니다.")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/notice")
public class NoticeController {
    private final NoticeService noticeService;

    // 인게임 메시지 조회
    @GetMapping("/list")
    public ResponseEntity<NoticeResponse> getNoticeList(){
        return ResponseEntity.ok().body( noticeService.getNoticeList());
    }
    // 인게임 메시지 상세 조회
    @GetMapping("/detail/{id}")
    public ResponseEntity<NoticeResponse> getNoticeDetail(
            @PathVariable("id") Long id){
        return ResponseEntity.ok().body( noticeService.getNoticeDetail(id));
    }

    //인게임 메시지 등록
    @PostMapping
    public ResponseEntity<NoticeResponse> postInGameMessage(
            @RequestBody NoticeRequest noticeRequest){
        return ResponseEntity.ok().body( noticeService.postInGameMessage(noticeRequest));
    }
    //인게임 메시지 수정
    @PutMapping("/{id}")
    public ResponseEntity<NoticeResponse> updateInGameMessage(
            @PathVariable("id")Long id,@RequestBody NoticeRequest noticeRequest){
        return ResponseEntity.ok().body( noticeService.updateInGameMessage(id,noticeRequest));
    }

    //인게임 메시지 선택 삭제
    @DeleteMapping
    public ResponseEntity<NoticeResponse> deleteInGameMessage(
            @RequestBody NoticeRequest noticeRequest){
        return ResponseEntity.ok().body( noticeService.deleteInGameMessage(noticeRequest));
    }
}
