|
|
@ -2,6 +2,7 @@ package com.example.demo.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
|
|
import com.example.demo.common.ZipUtils;
|
|
|
|
import com.example.demo.domain.Dragonson;
|
|
|
|
import com.example.demo.domain.Dragonson;
|
|
|
|
import com.example.demo.domain.User;
|
|
|
|
import com.example.demo.domain.User;
|
|
|
|
import com.example.demo.mapper.DragonsonMapper;
|
|
|
|
import com.example.demo.mapper.DragonsonMapper;
|
|
|
@ -10,6 +11,7 @@ import org.apache.poi.hssf.usermodel.*;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
|
|
|
@ -24,8 +26,8 @@ public class Webneed {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
DragonsonMapper dragonsonMapper;
|
|
|
|
DragonsonMapper dragonsonMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/exceldownload")
|
|
|
|
@GetMapping("/exceldownload/{id}")
|
|
|
|
public void download(HttpServletResponse response, @RequestParam(value = "dragonid", required = false) String dragonid) throws IOException {
|
|
|
|
public void download(HttpServletResponse response, @PathVariable("id") String dragonid) throws IOException {
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
|
HSSFSheet sheet = workbook.createSheet("接龙情况");
|
|
|
|
HSSFSheet sheet = workbook.createSheet("接龙情况");
|
|
|
|
QueryWrapper<Dragonson> queryWrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<Dragonson> queryWrapper = new QueryWrapper<>();
|
|
|
@ -64,9 +66,11 @@ public class Webneed {
|
|
|
|
return "daochu";
|
|
|
|
return "daochu";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/filedownload")
|
|
|
|
@RequestMapping("/filedownload/{id}")
|
|
|
|
public String downloadfile(@RequestParam(value = "taskid", required = true) String taskid,
|
|
|
|
public String downloadfile(@PathVariable("id") String taskid,
|
|
|
|
HttpServletResponse response) throws UnsupportedEncodingException {
|
|
|
|
HttpServletResponse response) throws UnsupportedEncodingException, FileNotFoundException {
|
|
|
|
|
|
|
|
FileOutputStream fos1 = new FileOutputStream(new File( taskid+".zip"));
|
|
|
|
|
|
|
|
ZipUtils.toZip("E:\\git\\project\\src\\demo\\target\\"+taskid, fos1, true);
|
|
|
|
File scFileDir = new File("./");
|
|
|
|
File scFileDir = new File("./");
|
|
|
|
String fileName = taskid + ".zip";
|
|
|
|
String fileName = taskid + ".zip";
|
|
|
|
File fileDir = new File(scFileDir, fileName);
|
|
|
|
File fileDir = new File(scFileDir, fileName);
|
|
|
@ -90,9 +94,9 @@ public class Webneed {
|
|
|
|
os.write(buffer, 0, i);
|
|
|
|
os.write(buffer, 0, i);
|
|
|
|
i = bis.read(buffer);
|
|
|
|
i = bis.read(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println("Download the song successfully!");
|
|
|
|
System.out.println("Download successfully!");
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("Download the song failed!");
|
|
|
|
System.out.println("Download failed!");
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
if (bis != null) {
|
|
|
|
if (bis != null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|