| | |
| | | package com.product.file.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.product.common.lang.StringUtils; |
| | | import com.product.core.config.CoreConst; |
| | | import com.product.core.controller.support.AbstractBaseController; |
| | | import com.product.core.entity.FieldSetEntity; |
| | | import com.product.core.entity.RequestParameterEntity; |
| | | import com.product.core.exception.BaseException; |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.file.config.CmnConst; |
| | | import com.product.file.config.FileCode; |
| | | import com.product.file.service.FileManagerService; |
| | | import com.product.module.sys.version.ApiVersion; |
| | |
| | | return error(FileCode.UPLOAD_FILE_FAIL.getValue(), FileCode.UPLOAD_FILE_FAIL.getText()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 下载文件或者在线预览 |
| | | * |
| | | * @return 结果 |
| | | */ |
| | | @RequestMapping(value = "/get-file-content/{version}", method = RequestMethod.GET) |
| | | @ApiVersion(1) |
| | | public String getFileContents(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | FieldSetEntity fse = null; |
| | | String uuid = request.getParameter(CoreConst.UUID); |
| | | String onlineView = request.getParameter(CmnConst.NEED_ONLINE_VIEW); |
| | | |
| | | if (StringUtils.isEmpty(uuid)) { |
| | | SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText()); |
| | | } |
| | | fse=new FieldSetEntity(); |
| | | fse.setTableName(CmnConst.PRODUCT_SYS_ATTACHMENTS); |
| | | fse.setValue(CoreConst.UUID, uuid); |
| | | fse.setValue(CmnConst.NEED_ONLINE_VIEW, onlineView); |
| | | SpringMVCContextHolder.getSystemLogger().info("通过GET请求获取附件内容"); |
| | | // 正式代码 |
| | | fileManagerService.getFileContent(fse, response); |
| | | return OK(); |
| | | } catch (Exception e) { |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | e.printStackTrace(); |
| | | return error(FileCode.GET_FILE_CONTENT_FAIL.getValue(), FileCode.GET_FILE_CONTENT_FAIL.getText()); |
| | | } |
| | | } |
| | | /** |
| | | * 下载文件或者在线预览 |
| | | * |