package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.request.RewardEventRequest;
import com.caliverse.admin.domain.response.RewardEventResponse;
import com.caliverse.admin.domain.service.RewardEventService;
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/event")
public class RewardEventController {

    private final RewardEventService rewardEventService;
    // 리스트 조회
    @GetMapping("/list")
    public ResponseEntity<RewardEventResponse> getList(
            @RequestParam Map<String, String> requestParam){

        return ResponseEntity.ok().body(rewardEventService.getList(requestParam));
    }
    // 상세 조회
    @GetMapping("/detail/{id}")
    public ResponseEntity<RewardEventResponse> getDetail(
            @PathVariable("id") Long id){

        return ResponseEntity.ok().body(rewardEventService.getDetail(id));
    }
    @PostMapping
    public ResponseEntity<RewardEventResponse> postEvent(
            @RequestBody RewardEventRequest rewardEventRequest){

        return ResponseEntity.ok().body(rewardEventService.postEvent(rewardEventRequest));
    }
    @PutMapping("/{id}")
    public ResponseEntity<RewardEventResponse> updateEvent(
            @PathVariable("id")Long id, @RequestBody RewardEventRequest rewardEventRequest){

        return ResponseEntity.ok().body(rewardEventService.updateEvent(id, rewardEventRequest));
    }
    @DeleteMapping("/delete")
    public ResponseEntity<RewardEventResponse> deleteEvent(
            @RequestBody RewardEventRequest rewardEventRequest){

        return ResponseEntity.ok().body(rewardEventService.deleteEvent(rewardEventRequest));
    }
    @PostMapping("/item")
    public ResponseEntity<RewardEventResponse> getItem(
            @RequestBody Map<String, String> item) {
        return ResponseEntity.ok().body(rewardEventService.getMetaItem(item.get("item")));
    }
}
