package com.youchain.businessdata.rest;

import com.alibaba.fastjson.JSONObject;
import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.businessdata.service.AsnDetailService;
import com.youchain.businessdata.service.PickDetailService;
import com.youchain.exception.handler.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
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.RestController;

@RestController
@RequiredArgsConstructor
@Api(tags = "接口日志")
@RequestMapping("/synq/resources")
public class InterfaceController {
    private final AsnDetailService asnDetailService;
    private final PickDetailService pickDetailService;
    @PostMapping("/importAsnApi")
    @Log("接收SAP入库单")
    @ApiOperation("接收SAP入库单")
    @AnonymousAccess
    public ResponseEntity<Object> importAsnApi(@RequestBody JSONObject jsonObject) {
        asnDetailService.importAsnApi(jsonObject);
        return new ResponseEntity<>(ApiResult.success("",""), HttpStatus.OK);
    }
    @PostMapping("/importPtApi")
    @Log("接收SAP入库单")
    @ApiOperation("接收SAP入库单")
    @AnonymousAccess
    public ResponseEntity<Object> importPtApi(@RequestBody JSONObject jsonObject) {
        ApiResult apiResult = pickDetailService.importPtApi(jsonObject);
        return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
    }
}
