package com.interplug.qcast.biz.canvasSetting;

import com.interplug.qcast.biz.canvasSetting.dto.CanvasSettingInfo;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/canvas-management")
@RequiredArgsConstructor
@Tag(name = "CanvasSettingController", description = "Canvas Setting 관련 API")
public class CanvasSettingController {
  private final CanvasSettingService canvasSettingService;
  
  @Operation(description = "Canvas Setting 정보를 조회 한다.")
  @GetMapping("/canvas-settings/by-object/{objectNo}")
  public CanvasSettingInfo selectCanvasSetting(@PathVariable String objectNo) {
	  	  
	  log.debug("Setting 조회 ::::: " + objectNo);
	  
	  return canvasSettingService.selectCanvasSetting(objectNo);
  }
  
  @Operation(description = "Canvas Setting 정보를 등록 한다.")
  @PostMapping("/canvas-settings")
  @ResponseStatus(HttpStatus.CREATED)
  public Map<String, String> insertCanvasSetting(@RequestBody CanvasSettingInfo csi) {
	  
	  log.debug("Setting 등록 ::::: " + csi.getObjectNo());
	  
      return canvasSettingService.insertCanvasSetting(csi);
  }

  @Operation(description = "Canvas Setting 정보를 수정 한다.")
  @PutMapping("/canvas-settings")
  public void updateCanvasStatus(@RequestBody CanvasSettingInfo csi) {
	  
	  log.debug("Setting 수정 ::::: " + csi.getObjectNo());
	  
	  canvasSettingService.updateCanvasSetting(csi);
  }
  
}
