package com.fdkankan.scene.controller;

import cn.hutool.core.io.FileTypeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.UUID;
import com.dtflys.forest.http.ForestResponse;
import com.fdkankan.common.constant.ConstantFileName;
import com.fdkankan.common.constant.ConstantFilePath;
import com.fdkankan.common.constant.ErrorCode;
import com.fdkankan.common.controller.BaseController;
import com.fdkankan.common.exception.BusinessException;
import com.fdkankan.common.response.ResultData;
import com.fdkankan.common.util.CreateObjUtil;
import com.fdkankan.scene.httpclient.FdkankanMiniClient;
import com.fdkankan.scene.service.IFileConvertService;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.file.Paths;
import javax.servlet.ServletOutputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * TODO
 * </p>
 *
 * @author dengsixing
 * @since 2022/5/17
 **/
@RestController
@RequestMapping("/service/common/convert")
public class FileConvertController extends BaseController {

    @Autowired
    private IFileConvertService fileConvertService;

    @PostMapping("/convertTxtToModeldata")
    public ResultData convertTxtToModeldata(@RequestParam("file") MultipartFile file) throws Exception{
        fileConvertService.convertTxtToModeldata(file, this.response);
        return ResultData.ok();
    }

    @PostMapping("/convertTxtToDam")
    public void convertTxtToDam(@RequestParam("file") MultipartFile file) throws Exception{
        fileConvertService.convertTxtToDam(file, this.response);
    }

    @PostMapping("/convertTxtToLzma")
    public void convertTxtToLzma(@RequestParam("file") MultipartFile file) throws Exception{
        fileConvertService.convertTxtToLzma(file, this.response);
    }

}
