管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-09 ff912b5a2abd0016cc8afca66cb64d0a0190364d
src/main/java/com/lf/server/service/all/BaseUploadService.java
@@ -1,6 +1,7 @@
package com.lf.server.service.all;
import com.lf.server.entity.data.MetaEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.helper.FileHelper;
import com.lf.server.helper.PathHelper;
import com.lf.server.helper.StringHelper;
@@ -33,7 +34,7 @@
    /**
     * 查询文件
     */
    public List<MetaEntity> selectFiles(String subPath, List<String> extList) throws IOException {
    public List<MetaFileEntity> selectFiles(String subPath, List<String> extList) {
        String root = pathHelper.getConfig().getTempPath() + File.separator + subPath;
        File file = new File(root);
@@ -45,7 +46,7 @@
            return null;
        }
        List<MetaEntity> list = new ArrayList<MetaEntity>();
        List<MetaFileEntity> list = new ArrayList<>();
        for (File f : files) {
            String fileName = FileHelper.getFileName(f.getPath());
            if (null != extList) {
@@ -58,7 +59,7 @@
            double sizes = FileHelper.sizeToMb(f.length());
            String filePath = subPath + File.separator + fileName;
            MetaEntity mf = new MetaEntity();
            MetaFileEntity mf = new MetaFileEntity();
            mf.setName(fileName);
            mf.setSizes(sizes);
            mf.setPath(filePath);
@@ -80,7 +81,7 @@
    /**
     * 上传文件
     */
    public <T> List<MetaEntity> uploadData(T t, String path, HttpServletRequest req, HttpServletResponse res) throws Exception {
    public <T> List<MetaFileEntity> uploadData(T t, String path, HttpServletRequest req, HttpServletResponse res) throws Exception {
        StandardMultipartHttpServletRequest request = (StandardMultipartHttpServletRequest) req;
        req.setCharacterEncoding("utf-8");
        res.setContentType("application/json;charset=utf-8");
@@ -88,9 +89,8 @@
        if (t != null) {
            setEntity(t, request);
        }
        List<MetaEntity> list = getFiles(path, request);
        return list;
        return getFiles(path, request);
    }
    /**
@@ -133,20 +133,21 @@
    /**
     * 获取文件
     */
    public List<MetaEntity> getFiles(String subPath, StandardMultipartHttpServletRequest req) throws Exception {
        List<MetaEntity> list = new ArrayList<MetaEntity>();
    public List<MetaFileEntity> getFiles(String subPath, StandardMultipartHttpServletRequest req) throws Exception {
        List<MetaFileEntity> list = new ArrayList<>();
        String path = pathHelper.getTempPath(subPath);
        Iterator<String> iterator = req.getFileNames();
        while (iterator.hasNext()) {
            MultipartFile file = req.getFile(iterator.next());
            if (StringHelper.isEmpty(file.getOriginalFilename())) {
            if (null == file || StringHelper.isEmpty(file.getOriginalFilename())) {
                continue;
            }
            double sizes = FileHelper.sizeToMb(file.getSize());
            MetaEntity mf = new MetaEntity();
            MetaFileEntity mf = new MetaFileEntity();
            mf.setName(file.getOriginalFilename());
            double sizes = FileHelper.sizeToMb(file.getSize());
            mf.setSizes(sizes);
            mf.setPath(path + File.separator + mf.getName());
@@ -162,11 +163,11 @@
    /**
     * 删除文件
     */
    public Integer deleteFiles(List<MetaEntity> list) {
    public Integer deleteFiles(List<MetaFileEntity> list) {
        String root = pathHelper.getConfig().getTempPath();
        int count = 0;
        for (MetaEntity entity : list) {
        for (MetaFileEntity entity : list) {
            if (!StringHelper.isEmpty(entity.getPath())) {
                String file = root + File.separator + entity.getPath();