xieb
2024-04-08 ff968e2cfb132eb86c70e94e99b9937a8a7b15e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 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<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);
    }
}