package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.request.RankRequest;
import com.caliverse.admin.domain.response.RankResponse;
import com.caliverse.admin.domain.service.RankService;
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/rank")
public class RankController {
    private final RankService rankService;

    @GetMapping("/schedule/list")
    public ResponseEntity<RankResponse> getRankingScheduleList(
            @RequestParam Map<String, String> requestParam){
        return ResponseEntity.ok().body( rankService.getList(requestParam));
    }

    @GetMapping("/schedule/detail/{id}")
    public ResponseEntity<RankResponse> getRankingScheduleDetail(
            @PathVariable("id") Long id){
        return ResponseEntity.ok().body( rankService.getDetail(id));
    }
    
    @PostMapping("/schedule")
    public ResponseEntity<RankResponse> postRankingSchedule(
            @RequestBody RankRequest rankRequest){

        return ResponseEntity.ok().body(rankService.postRankingSchedule(rankRequest));
    }
    
    @PutMapping("/schedule/{id}")
    public ResponseEntity<RankResponse> updateRankingSchedule(
            @PathVariable("id")Long id, @RequestBody RankRequest rankRequest){

        return ResponseEntity.ok().body(rankService.updateRankingSchedule(id, rankRequest));
    }
    
    @DeleteMapping("/schedule/delete")
    public ResponseEntity<RankResponse> deleteRankingSchedule(
            @RequestParam Long id){

        return ResponseEntity.ok().body(rankService.deleteRankingSchedule(id));
    }
}
