|
@@ -12,6 +12,7 @@ import com.hssx.cloudmodel.service.UserService;
|
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
|
import com.hssx.cloudmodel.util.PageUtil;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -38,6 +39,7 @@ import java.util.zip.ZipOutputStream;
|
|
|
* @since 2019-08-07
|
|
|
*/
|
|
|
@Controller
|
|
|
+@Slf4j
|
|
|
@RequestMapping("/mouldfile")
|
|
|
public class MouldFileController {
|
|
|
|
|
@@ -50,6 +52,43 @@ public class MouldFileController {
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 模具文档的下载
|
|
|
+ * id 所要下载的文件id ,
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/download/{id}")
|
|
|
+ public HttpRespMsg download(@PathVariable("id") Integer id,
|
|
|
+ HttpServletRequest request,HttpServletResponse resp) throws IOException {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ MouldFile model = mouldFileService.getById(id);// 文件实体
|
|
|
+ msg.data = model;
|
|
|
+ FileInputStream fis = null;
|
|
|
+ try {
|
|
|
+ String fileName = model.getFileName();
|
|
|
+ String filePath = path+model.getFileUrl().substring("/upload/".length());
|
|
|
+ fis = new FileInputStream(filePath);
|
|
|
+ resp.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
+ resp.setCharacterEncoding("UTF-8");
|
|
|
+ resp.setHeader("Content-Disposition",
|
|
|
+ "attachment;filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
|
|
|
+ byte[] b = new byte[1024];
|
|
|
+ int len;
|
|
|
+ while ((len = fis.read(b)) > 0) {
|
|
|
+ resp.getOutputStream().write(b, 0, len);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ msg.setError("文件[ {} ]下载错误");
|
|
|
+ } finally {
|
|
|
+ resp.getOutputStream().flush();
|
|
|
+ resp.getOutputStream().close();
|
|
|
+ fis.close();
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
/**
|
|
|
* 模具文档的上传
|
|
|
* 参数: token 用户身份凭证,
|
|
@@ -129,7 +168,7 @@ public class MouldFileController {
|
|
|
@RequestMapping("/list")
|
|
|
@ResponseBody
|
|
|
public HttpRespMsg list(@RequestParam Integer mouldId, @RequestParam Integer blongType, UserVO userVO) {
|
|
|
- HttpRespMsg msg = mouldFileService.getFileList(mouldId, blongType, userVO);
|
|
|
+ HttpRespMsg msg = mouldFileService.getFileList(mouldId, blongType, userVO,path);
|
|
|
return msg;
|
|
|
}
|
|
|
|