package com.interplug.qcast.biz.displayItem;

import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import com.interplug.qcast.biz.displayItem.dto.DisplayItemRequest;
import com.interplug.qcast.biz.displayItem.dto.ItemDetailResponse;
import com.interplug.qcast.biz.displayItem.dto.ItemResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/api/display-item")
@RequiredArgsConstructor
@Tag(name = "DisplayItemController", description = "전시(표시) 제품 관련 API")
public class DisplayItemController {
  private final DisplayItemService displayItemService;

  /**
   * 전시제품 정보 등록/수정
   * 
   * @param displayItemRequest
   * @throws Exception
   */
  @Operation(description = "전시제품 정보를 등록/수정한다. (동기화)")
  @PostMapping("/display-item-save")
  @ResponseStatus(HttpStatus.OK)
  public void setStoreDisplayItemSave(@RequestBody DisplayItemRequest displayItemRequest)
      throws Exception {
    displayItemService.setStoreDisplayItemSave(displayItemRequest);
  }

  /**
   * 제품 목록 조회
   * 
   * @param saleStoreId
   * @return
   * @throws Exception
   */
  @Operation(description = "제품 목록을 조회한다.")
  @GetMapping("/item-list")
  @ResponseStatus(HttpStatus.OK)
  public List<ItemResponse> getItemList(@RequestParam("saleStoreId") String saleStoreId)
      throws Exception {
    return displayItemService.getItemList(saleStoreId);
  }

  /**
   * 제품 상세 정보 조회
   * 
   * @param itemId
   * @return
   * @throws Exception
   */
  @Operation(description = "제품 상세 정보를 조회한다.")
  @GetMapping("/item-detail")
  @ResponseStatus(HttpStatus.OK)
  public ItemDetailResponse getItemDetail(@RequestParam("itemId") String itemId) throws Exception {
    return displayItemService.getItemDetail(itemId);
  }
}
