rain
2024-04-07 8310296e65e5b013829b206c630180a00ca34045
src/main/java/com/dji/sample/patches/controller/ShpToDataSourceController.java
@@ -1,24 +1,46 @@
package com.dji.sample.patches.controller;
import cn.hutool.core.io.FileUtil;
import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.patches.service.impl.ShpToDataSourceServiceImpl;
import com.dji.sample.patches.utils.ZipUtil;
import org.apache.tomcat.util.http.fileupload.UploadContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;
import static org.springframework.http.MediaType.parseMediaType;
@RestController
@RequestMapping("${url.patches.prefix}${url.patches.version}")
public class ShpToDataSourceController {
    @Autowired
    private ShpToDataSourceServiceImpl shpToDataSourceServiceImpl;
    @PostMapping("/getGeo")
    public ResponseResult getGeo (@RequestParam("file") MultipartFile file) throws IOException {
        shpToDataSourceServiceImpl.insertGeo(file);
        return  ResponseResult.success();
    public ResponseResult<List<LotInfo>> getGeo(@RequestParam("file") MultipartFile file,
                                                @RequestParam String waylineName,
                                                @RequestParam String workspaceId) throws IOException {
        List<LotInfo> list = shpToDataSourceServiceImpl.insertGeo(file, workspaceId,waylineName);
        return ResponseResult.success(list);
    }
}
    @GetMapping("/getFile")
    public ResponseEntity<Resource> download(String waylineName) throws UnsupportedEncodingException {
        return shpToDataSourceServiceImpl.backWayline(waylineName);
    }
}