| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查看文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body") |
| | | }) |
| | | @GetMapping(value = "/downloadForView") |
| | | public void downloadForView(String guid, HttpServletResponse res) { |
| | | metaService.downloadForView(guid, true, res); |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询下载文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | |
| | | WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查看文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body") |
| | | }) |
| | | @GetMapping(value = "/downloadForView") |
| | | public void downloadForView(String guid, HttpServletResponse res) { |
| | | metaService.downloadForView(guid, true, res); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查看下载文件") |
| | | @ApiOperation(value = "查看文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body") |
| | | }) |
| | |
| | | package com.lf.server.entity.all; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | |
| | | public final static String MULTIPOLYGON = "MULTIPOLYGON"; |
| | | |
| | | public static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "文件找不到")); |
| | | |
| | | /** |
| | | * 16进制 |
| | | */ |
| | |
| | | |
| | | private final static Log log = LogFactory.getLog(UploadAttachService.class); |
| | | |
| | | private static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "文件找不到")); |
| | | |
| | | /** |
| | | * 获取表名 |
| | | */ |
| | |
| | | public void download(String guid, boolean inline, HttpServletResponse res) { |
| | | try { |
| | | if (StringHelper.isEmpty(guid)) { |
| | | WebHelper.writeStr2Page(res, NO_FILE); |
| | | WebHelper.writeStr2Page(res, StaticData.NO_FILE); |
| | | return; |
| | | } |
| | | |
| | | AttachEntity entity = attachService.selectByGuid(guid); |
| | | if (entity == null) { |
| | | WebHelper.writeStr2Page(res, NO_FILE); |
| | | WebHelper.writeStr2Page(res, StaticData.NO_FILE); |
| | | return; |
| | | } |
| | | |
| | |
| | | package com.lf.server.service.data; |
| | | |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.entity.sys.AttachEntity; |
| | | import com.lf.server.helper.PathHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.mapper.data.MetaMapper; |
| | | import com.lf.server.service.all.UploadAttachService; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | @Service |
| | | public class MetaService implements MetaMapper { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | | |
| | | @Autowired |
| | | MetaMapper metaMapper; |
| | | |
| | | private final static Log log = LogFactory.getLog(MetaService.class); |
| | | |
| | | @Override |
| | | public Integer selectCount(String depcode, String dircode, Integer verid, String name) { |
| | |
| | | |
| | | return StringHelper.join(list, ";"); |
| | | } |
| | | |
| | | /** |
| | | * 查看文件 |
| | | */ |
| | | public void downloadForView(String guid, boolean inline, HttpServletResponse res) { |
| | | try { |
| | | if (StringHelper.isEmpty(guid)) { |
| | | WebHelper.writeStr2Page(res, StaticData.NO_FILE); |
| | | return; |
| | | } |
| | | |
| | | MetaEntity me = selectByGuid(guid, null); |
| | | if (me == null) { |
| | | WebHelper.writeStr2Page(res, StaticData.NO_FILE); |
| | | return; |
| | | } |
| | | |
| | | String filePath = pathHelper.getConfig().getUploadPath() + File.separator + me.getPath(); |
| | | File file = new File(filePath); |
| | | if (!file.exists() || file.isDirectory()) { |
| | | WebHelper.writeJson2Page(res, "文件不存在"); |
| | | } |
| | | |
| | | WebHelper.download(filePath, me.getName(), inline, res); |
| | | } catch (Exception ex) { |
| | | WebHelper.writeJson2Page(res, "文件下载出错"); |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |