package com.oqpo.api.web.controller.ifmng;

import com.oqpo.api.enums.SystemMessageCode;
import com.oqpo.api.service.stinfo.StoreBaseInfoService;
import com.oqpo.api.service.stockmng.StockBaseMngService;
import com.oqpo.api.service.stockmng.StockMngService;
import com.oqpo.api.web.dto.request.ifmng.BoSaleStoreInfoRequest;
import com.oqpo.api.web.dto.request.ifmng.BoStoreChgInfoRequest;
import com.oqpo.api.web.dto.request.stinfo.store.SaveStoreInfolRequest;
import com.oqpo.api.web.dto.request.stinfo.store.StorePopGridRequest;
import com.oqpo.api.web.dto.request.stinfo.store.StoreSearchGridRequest;
import com.oqpo.api.web.dto.response.GridResponse;
import com.oqpo.api.web.dto.response.SaveResponse;
import com.oqpo.api.web.dto.response.ifmng.BoStoreChgInfoResponse;
import com.oqpo.api.web.dto.response.stinfo.store.StoreInfoResponse;
import com.oqpo.api.web.dto.response.stockmng.BoSaleStoreStockResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

@Slf4j
@RestController
@RequestMapping("/api/interface")
@Api(tags = {"인터페이스 관리 (StoreController)"})
public class IfMngController {
    @Autowired
    private StoreBaseInfoService storeBaseInfoService;

    @Autowired
    private StockMngService stockMngService;

    /**
     * 설명 : 백오피스 매장변경 정보 수신
     *
     * @param boStoreChgInfoRequest
     * @return
     * @throws Exception
     */
    @ApiImplicitParams({
            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
    })
    @ApiOperation(value = "오피스 매장변경 정보 수신")
    @PostMapping("/save-item")
    public ResponseEntity<BoStoreChgInfoResponse> saveStore(@ApiIgnore String userId, @RequestBody @Valid BoStoreChgInfoRequest boStoreChgInfoRequest) throws Exception {
        return ResponseEntity.ok(storeBaseInfoService.ifBoSaveChgStore(userId, boStoreChgInfoRequest));
    }

    /**
     * 설명 : 백오피스 판매정보 수신
     *
     * @param BoSaleStoreInfoRequest
     * @return
     * @throws Exception
     */
    @ApiImplicitParams({
            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
    })
    @ApiOperation(value = "백오피스 판매정보 수신")
    @PostMapping("/save-stock")
    public ResponseEntity<BoSaleStoreStockResponse> saveStoreStock(@ApiIgnore String userId, @RequestBody @Valid BoSaleStoreInfoRequest boSaleStoreInfoRequest) throws Exception {
        return ResponseEntity.ok(stockMngService.ifBoSaveStoreStock(userId, boSaleStoreInfoRequest));
    }



}
