package com.glxp.mipsdl.controller;

import com.glxp.mipsdl.client.ClientProcessor;
import com.glxp.mipsdl.res.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Collections;
import java.util.List;

/**
 * 上传文件接口
 */
@Slf4j
@RestController
public class UdiInfoUploadController {

    /**
     * 产品信息导入
     *
     * @param thirdSys
     * @return
     */
    @PostMapping("/udiwms/erp/pi/upload")
    public BaseResponse uploadPi(@RequestParam("file") MultipartFile file, @RequestParam("thirdSys") String thirdSys) {
        return ClientProcessor.getFileClient().uploadPi(Collections.singletonList(file), thirdSys);
    }

    /**
     * 往来单位导入
     *
     * @param files
     * @param thirdSys
     * @return
     */
    @PostMapping("/udiwms/erp/corp/upload")
    public BaseResponse uploadCorps(@RequestParam("file") List<MultipartFile> files, @RequestParam("thirdSys") String thirdSys) {
        return ClientProcessor.getFileClient().uploadCorps(files, thirdSys);
    }

    /**
     * 库存产品信息上传
     *
     * @param files
     * @param thirdSys
     * @return
     */
    @PostMapping("/udiwms/erp/invpi/upload")
    public BaseResponse uploadInvPi(@RequestParam("file") List<MultipartFile> files, @RequestParam("thirdSys") String thirdSys) {
        return ClientProcessor.getFileClient().uploadInvPi(files, thirdSys);
    }

    /**
     * 业务单据上传
     *
     * @param files
     * @param thirdSys
     * @return
     */
    @PostMapping("/udiwms/erp/order/upload")
    public BaseResponse uploadOrders(@RequestParam("file") List<MultipartFile> files, @RequestParam("thirdSys") String thirdSys) {
        return ClientProcessor.getFileClient().uploadOrders(files, thirdSys);
    }

}
