package com.interplug.qcast.biz.canvasStatus;

import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatus;
import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusResponse;
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 lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/canvas-management")
@RequiredArgsConstructor
@Tag(name = "CanvasStatusController", description = "Canvas 관련 API")
public class CanvasStatusController {
  private final CanvasStatusService canvasStatusService;

  @Operation(description = "계정에 해당하는 전체 견적서를 조회 한다.")
  @GetMapping("/canvas-statuses/{userId}")
  public List<CanvasStatusResponse> selectAllCanvasStatus(@PathVariable String userId) throws QcastException {
    return canvasStatusService.selectAllCanvasStatus(userId);
  }
  
  @Operation(description = "견적서를 조회 한다.")
  @GetMapping("/canvas-statuses/by-object/{objectNo}/{userId}")
  public List<CanvasStatusResponse> selectObjectNoCanvasStatus(@PathVariable String objectNo, @PathVariable String userId) throws QcastException {
    return canvasStatusService.selectObjectNoCanvasStatus(objectNo, userId);
  }
  
  @Operation(description = "견적서를 등록 한다.")
  @PostMapping("/canvas-statuses")
  @ResponseStatus(HttpStatus.CREATED)
  public Integer insertCanvasStatus(@RequestBody CanvasStatus cs) throws QcastException {
      return canvasStatusService.insertCanvasStatus(cs);
  }

  @Operation(description = "견적서를 수정 한다.")
  @PutMapping("/canvas-statuses")
  public void updateCanvasStatus(@RequestBody CanvasStatus cs) throws QcastException {
      canvasStatusService.updateCanvasStatus(cs);
  }
  
  @Operation(description = "견적서를 삭제 한다.")
  @DeleteMapping("/canvas-statuses/by-object/{objectNo}")
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public void deleteObjectNoCanvasStatus(@PathVariable String objectNo) throws QcastException {
      canvasStatusService.deleteObjectNoCanvasStatus(objectNo);
  }
  
  @Operation(description = "견적서의 이미지(템플릿)를 삭제 한다.")
  @DeleteMapping("/canvas-statuses/by-id/{id}")
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public void deleteIdCanvasStatus(@PathVariable Integer id) throws QcastException {
      canvasStatusService.deleteIdCanvasStatus(id);
  }
  
}
