|
@@ -12,34 +12,46 @@ import cn.com.qmth.examcloud.core.print.common.Result;
|
|
|
import cn.com.qmth.examcloud.core.print.common.upyun.UpYunClient;
|
|
|
import cn.com.qmth.examcloud.core.print.common.upyun.UpYunProperty;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
|
+import cn.com.qmth.examcloud.core.print.common.utils.FileUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
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.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.File;
|
|
|
|
|
|
/**
|
|
|
- * 文件上传相关接口
|
|
|
+ * 常用相关接口
|
|
|
*
|
|
|
* @author: fengdesheng
|
|
|
* @since: 2018/11/01
|
|
|
*/
|
|
|
@RestController
|
|
|
-@Api(tags = "文件上传相关接口")
|
|
|
-@RequestMapping("${$rmp.ctrl.print}/upload")
|
|
|
-public class UploadController extends ControllerSupport {
|
|
|
- private static final Logger log = LoggerFactory.getLogger(UploadController.class);
|
|
|
+@Api(tags = "常用相关接口")
|
|
|
+@RequestMapping("${$rmp.ctrl.print}/common")
|
|
|
+public class CommonController extends ControllerSupport {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
|
|
@Autowired
|
|
|
private UpYunClient upYunClient;
|
|
|
|
|
|
- @PostMapping
|
|
|
+ @GetMapping("/download")
|
|
|
+ @ApiOperation(value = "下载文件")
|
|
|
+ public void download(@RequestParam String filePath) throws Exception {
|
|
|
+ File file = upYunClient.download(filePath);
|
|
|
+ final String fileName = FileUtils.getFileName(filePath);
|
|
|
+ if (file != null) {
|
|
|
+ super.exportFile(fileName, file);
|
|
|
+ } else {
|
|
|
+ super.exportFile("404", new byte[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/upload")
|
|
|
@ApiOperation(value = "上传文件")
|
|
|
public Result upload(HttpServletRequest request) throws Exception {
|
|
|
MultipartFile file = null;
|