package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.request.CaliumRequest;
import com.caliverse.admin.domain.response.CaliumResponse;
import com.caliverse.admin.domain.service.CaliumService;
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/calium")
public class CaliumController {

    private final CaliumService caliumService;

    // 인출 가능 칼리움 조회
    @GetMapping("/limit")
    public ResponseEntity<CaliumResponse> getLimit() {
        return ResponseEntity.ok().body(caliumService.getCaliumLimit());
    }

    // 리스트 조회
    @GetMapping("/list")
    public ResponseEntity<CaliumResponse> getList(
            @RequestParam Map<String, String> requestParam){

        return ResponseEntity.ok().body(caliumService.getList(requestParam));
    }
    // 상세 조회
//    @GetMapping("/detail/{id}")
//    public ResponseEntity<EventResponse> getDetail(
//            @PathVariable("id") Long id){
//
//        return ResponseEntity.ok().body(eventService.getDetail(id));
//    }
    @PostMapping
    public ResponseEntity<CaliumResponse> postCalium(
            @RequestBody CaliumRequest caliumRequest){

        return ResponseEntity.ok().body(caliumService.postCaliumRequest(caliumRequest));
    }

    @PostMapping("/charge")
    public ResponseEntity<CaliumResponse> postCaliumCharge(
            @RequestBody CaliumRequest caliumRequest){
        //id, cnt 같이 받아야해서 request로 받게 처리
        return ResponseEntity.ok().body(caliumService.updateCaliumCharged(caliumRequest));
    }
}
