package com.interplug.qcast.biz.canvasBasicSetting;

import com.interplug.qcast.biz.canvasBasicSetting.dto.CanvasBasicSettingInfo;
import com.interplug.qcast.biz.canvasBasicSetting.dto.CanvasBasicSettingResponse;
import com.interplug.qcast.biz.canvasBasicSetting.dto.RoofAllocationSettingInfo;
import com.interplug.qcast.config.Exception.QcastException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/canvas-management")
@RequiredArgsConstructor
@Tag(name = "CanvasBasicSettingController", description = "Canvas Basic Setting 관련 API")
public class CanvasBasicSettingController {
  private final CanvasBasicSettingService canvasBasicSettingService;

  @Operation(description = "Canvas Basic Setting 정보를 조회 한다.")
  @GetMapping("/canvas-basic-settings/by-object/{objectNo}/{planNo}")
  public List<CanvasBasicSettingResponse> selectCanvasBasicSetting(@PathVariable String objectNo, @PathVariable Integer planNo)
	throws QcastException {
	  	  
	  log.debug("Basic Setting 조회 ::::: " + objectNo + " : " + planNo);
	  
	  return canvasBasicSettingService.selectCanvasBasicSetting(objectNo, planNo);
  }
  
  @Operation(description = "Canvas Basic Setting 정보를 등록 한다.")
  @PostMapping("/canvas-basic-settings")
  @ResponseStatus(HttpStatus.CREATED)
  public Map<String, String> insertCanvasBasicSetting(@RequestBody CanvasBasicSettingInfo csi) throws QcastException {
	  
	  log.debug("Basic Setting 등록 ::::: " + csi.getObjectNo());
	  
      return canvasBasicSettingService.insertCanvasBasicSetting(csi);
  }
  
  @Operation(description = "Canvas Basic Setting 정보를 삭제 한다.")
  @DeleteMapping("/canvas-basic-settings/delete-basic-settings/{objectNo}/{planNo}")
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public void deleteCanvasBasicSetting(@PathVariable String objectNo, @PathVariable Integer planNo) throws QcastException {
	  
	  log.debug("Basic Setting 삭제 ::::: " + objectNo + " : " + planNo);
	  
	  canvasBasicSettingService.deleteCanvasBasicSetting(objectNo, planNo);
  }
  
  @Operation(description = "지붕면 할당 정보를 등록 한다.")
  @PostMapping("/roof-allocation-settings")
  @ResponseStatus(HttpStatus.CREATED)
  public Map<String, String> insertRoofAllocSetting(@RequestBody RoofAllocationSettingInfo rasi) throws QcastException {

	  log.debug("지붕면 할당 등록 ::::: " + rasi.getObjectNo());

      return canvasBasicSettingService.insertRoofAllocSetting(rasi);
  }

  @Operation(description = "Canvas 지붕재추가 Setting 정보를 삭제 한다.")
  @DeleteMapping("/canvas-basic-settings/delete-RoofMaterials/{objectNo}/{planNo}")
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public void deleteRoofMaterialsAdd(@PathVariable String objectNo, @PathVariable Integer planNo) throws QcastException {
	  canvasBasicSettingService.deleteRoofMaterialsAdd(objectNo, planNo);
  }
  
}
