package com.jwipc.order.api.controller;

import com.jwipc.api.dto.ApiResult;
import com.jwipc.log.annotation.ApiOperateLog;
import com.jwipc.log.constant.ApiDirection;
import com.jwipc.log.constant.ThirdSysType;
import com.jwipc.order.api.dto.CreateDeliveryOrderDTO;
import com.jwipc.order.api.dto.CreatePurchaseOrderDTO;
import com.jwipc.order.api.dto.UpdateDevPlanDTO;
import com.jwipc.order.api.logic.CreatePurchaseOrderLogic;
import com.jwipc.order.api.logic.UpdateDevPlanLogic;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/sap/api/")
@RequiredArgsConstructor
@Slf4j
public class CreatePurchaseOrderApiController {
    private final CreatePurchaseOrderLogic createPurchaseOrderLogic;
    private final UpdateDevPlanLogic updateDevPlanLogic;

    @PostMapping("createPurchaseOrder")
    public ApiResult createPurchaseOrder(@RequestBody CreatePurchaseOrderDTO createPurchaseOrderDTO) {
        return createPurchaseOrderLogic.createPurchaseOrder(createPurchaseOrderDTO);
    }

    @PostMapping("createDeliveryOrder")
    @ApiOperateLog(code = "createDeliveryOrder",name = "退货采购订单推送", direction = ApiDirection.OTHER_TO_SRM, thirdSysType = ThirdSysType.MES)
    public ApiResult createDeliveryOrder(@RequestBody CreateDeliveryOrderDTO createDeliveryOrderDTO) {
        return createPurchaseOrderLogic.CreateDeliveryOrder(createDeliveryOrderDTO);
    }

    @PostMapping("updateDevPlan")
    public ApiResult updateDevPlan(@RequestBody UpdateDevPlanDTO updateDevPlanDTO) {
        return updateDevPlanLogic.processor(updateDevPlanDTO);
    }
}
