package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.request.WorldEventRequest;
import com.caliverse.admin.domain.response.WorldEventResponse;
import com.caliverse.admin.domain.service.WorldEventService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Tag(name = "월드이벤트", description = "월드이벤트 api")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/world-event")
public class WorldEventController {
    private final WorldEventService worldEventService;

    @GetMapping("/list")
    public ResponseEntity<WorldEventResponse> getWorldEventList(
            @RequestParam Map<String, String> requestParam){
        return ResponseEntity.ok().body( worldEventService.getList(requestParam));
    }

    @GetMapping("/detail/{id}")
    public ResponseEntity<WorldEventResponse> getWorldEventDetail(
            @PathVariable("id") Long id){
        return ResponseEntity.ok().body( worldEventService.getDetail(id));
    }
    
    @PostMapping
    public ResponseEntity<WorldEventResponse> postWorldEvent(
            @RequestBody WorldEventRequest worldEventRequest){

        return ResponseEntity.ok().body(worldEventService.postWorldEvent(worldEventRequest));
    }
    
    @PutMapping("/{id}")
    public ResponseEntity<WorldEventResponse> updateWorldEvent(
            @PathVariable("id")Long id, @RequestBody WorldEventRequest worldEventRequest){

        return ResponseEntity.ok().body(worldEventService.updateWorldEvent(id, worldEventRequest));
    }
    
    @DeleteMapping("/delete")
    public ResponseEntity<WorldEventResponse> deleteWorldEvent(
            @RequestParam Long id){

        return ResponseEntity.ok().body(worldEventService.deleteWorldEvent(id));
    }
}
