管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-03-03 0fc0c51bec7133391e9cc89c0c7d9ee34c966434
1
已修改6个文件
75 ■■■■■ 文件已修改
src/main/java/com/lf/server/controller/all/BaseQueryController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/data/MetaController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/sys/ResController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/all/StaticData.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/all/UploadAttachService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/MetaService.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/all/BaseQueryController.java
@@ -556,6 +556,16 @@
    }
    @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 = ""),
src/main/java/com/lf/server/controller/data/MetaController.java
@@ -480,4 +480,14 @@
            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);
    }
}
src/main/java/com/lf/server/controller/sys/ResController.java
@@ -301,7 +301,7 @@
    }
    @SysLog()
    @ApiOperation(value = "查看下载文件")
    @ApiOperation(value = "查看文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body")
    })
src/main/java/com/lf/server/entity/all/StaticData.java
@@ -1,5 +1,7 @@
package com.lf.server.entity.all;
import com.alibaba.fastjson.JSON;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -169,6 +171,8 @@
    public final static String MULTIPOLYGON = "MULTIPOLYGON";
    public static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "文件找不到"));
    /**
     * 16进制
     */
src/main/java/com/lf/server/service/all/UploadAttachService.java
@@ -44,8 +44,6 @@
    private final static Log log = LogFactory.getLog(UploadAttachService.class);
    private static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "文件找不到"));
    /**
     * 获取表名
     */
@@ -148,13 +146,13 @@
    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;
            }
src/main/java/com/lf/server/service/data/MetaService.java
@@ -1,11 +1,20 @@
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;
@@ -16,7 +25,12 @@
@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) {
@@ -171,4 +185,33 @@
        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);
        }
    }
}