| | |
| | | package com.vci.ubcs.resource.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.vci.ubcs.resource.dto.FileObjectDTO; |
| | | import com.vci.ubcs.resource.dto.FileReleaseDTO; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | |
| | | * @return 执行结果,只有下载失败的时候才会这样 |
| | | */ |
| | | @RequestMapping(value = "/downloadFilesByOids",method = {RequestMethod.GET,RequestMethod.POST}) |
| | | public String downloadFilesByOids(@RequestParam String fileOids, HttpServletResponse response){ |
| | | public void downloadFilesByOids(@RequestParam String fileOids, HttpServletResponse response) throws IOException { |
| | | try{ |
| | | //ControllerUtil.writeFileToResponse(response,excelName); |
| | | FileDownloadUtil.downloadFile(response, fileService.downloadFileByOids(VciBaseUtil.str2List(fileOids))); |
| | | }catch (Throwable e){ |
| | | return JSON.toJSONString(R.fail(LangBaseUtil.getErrorMsg(e))); |
| | | //如果出错,把错误信息写到text |
| | | String msg = LangBaseUtil.getErrorMsg(e); |
| | | if(StringUtils.isBlank(msg)){ |
| | | msg = "未知错误"; |
| | | } |
| | | //因为设置了响应contentType,所以这儿不能再直接返回R了,可能会导致报错 |
| | | return JSON.toJSONString(R.success("下载完成")) ; |
| | | ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null); |
| | | } |
| | | } |
| | | |
| | | /** |