Parcourir la source

Add 添加oss文件服务

Yue il y a 2 ans
Parent
commit
41d4aed94e
34 fichiers modifiés avec 1622 ajouts et 16 suppressions
  1. 8 0
      SERVER/YanZhongXYH/pom.xml
  2. 49 0
      SERVER/YanZhongXYH/script/sql/File.sql
  3. 1 0
      SERVER/YanZhongXYH/script/sql/XYHSQL.sql
  4. 16 4
      SERVER/YanZhongXYH/xyh-common/src/main/java/cn/xyh/common/config/VberConfig.java
  5. 6 1
      SERVER/YanZhongXYH/xyh-generator/src/main/java/cn/xyh/generator/service/impl/GenEmptyService.java
  6. 29 0
      SERVER/YanZhongXYH/xyh-oss/pom.xml
  7. 63 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/common/constants/ExplorerConstants.java
  8. 7 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/common/utils/Tools.java
  9. 114 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/controller/OssFileController.java
  10. 122 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/core/file/OFile.java
  11. 58 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/core/file/OFileInfo.java
  12. 14 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/core/file/vo/UploadFileVo.java
  13. 109 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/OssFile.java
  14. 33 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/OssFileShort.java
  15. 115 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/bo/OssFileBo.java
  16. 39 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/bo/OssFileShortBo.java
  17. 38 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/vo/OssFileShortVo.java
  18. 113 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/vo/OssFileVo.java
  19. 17 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/mapper/OssFileMapper.java
  20. 17 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/mapper/OssFileShortMapper.java
  21. 63 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/service/IOssFileService.java
  22. 49 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/service/IOssFileShortService.java
  23. 331 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/service/impl/OssFileServiceImpl.java
  24. 109 0
      SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/service/impl/OssFileShortServiceImpl.java
  25. 30 0
      SERVER/YanZhongXYH/xyh-oss/src/main/resources/mapper/oss/OssFileMapper.xml
  26. 13 0
      SERVER/YanZhongXYH/xyh-oss/src/main/resources/mapper/oss/OssFileShortMapper.xml
  27. 4 0
      SERVER/YanZhongXYH/xyh-system/pom.xml
  28. 8 9
      SERVER/YanZhongXYH/xyh-system/src/main/java/cn/xyh/amActivity/domain/AmActivity.java
  29. 1 0
      SERVER/YanZhongXYH/xyh-system/src/main/java/cn/xyh/amActivity/domain/bo/AmActivityBo.java
  30. 1 0
      SERVER/YanZhongXYH/xyh-system/src/main/java/cn/xyh/amActivity/domain/vo/AmActivityVo.java
  31. 36 2
      SERVER/YanZhongXYH/xyh-system/src/main/java/cn/xyh/amActivity/service/impl/AmActivityServiceImpl.java
  32. 1 0
      SERVER/YanZhongXYH/xyh-system/src/main/resources/mapper/amActivity/AmActivityMapper.xml
  33. 3 0
      UI/XYH.VUE/src/views/amActivity/activity/index.vue
  34. 5 0
      UI/XYH.VUE/vite.config.ts

+ 8 - 0
SERVER/YanZhongXYH/pom.xml

@@ -15,6 +15,7 @@
     <modules>
         <module>xyh-common</module>
         <module>xyh-framework</module>
+        <module>xyh-oss</module>
         <module>xyh-system</module>
         <module>xyh-generator</module>
         <module>xyh-extend</module>
@@ -306,6 +307,13 @@
                 <version>${revision}</version>
             </dependency>
 
+            <!-- 文件模块-->
+            <dependency>
+                <groupId>com.xyh</groupId>
+                <artifactId>xyh-oss</artifactId>
+                <version>${revision}</version>
+            </dependency>
+
             <!-- 系统模块-->
             <dependency>
                 <groupId>com.xyh</groupId>

+ 49 - 0
SERVER/YanZhongXYH/script/sql/File.sql

@@ -0,0 +1,49 @@
+-- ----------------------------
+-- Table structure for oss_file_short
+-- ----------------------------
+DROP TABLE IF EXISTS oss_file_short;
+CREATE TABLE oss_file_short
+(
+    short_url varchar(255) NOT NULL,
+    url       varchar(255) NULL DEFAULT NULL,
+    PRIMARY KEY (short_url) USING BTREE,
+    UNIQUE INDEX short_url_index (short_url) USING BTREE
+) ENGINE = InnoDB
+  CHARACTER SET = utf8
+  COLLATE = utf8_general_ci
+  ROW_FORMAT = DYNAMIC;
+
+-- ----------------------------
+-- Table structure for oss_file
+-- ----------------------------
+DROP TABLE IF EXISTS oss_file;
+CREATE TABLE oss_file
+(
+    id          bigint(20)   NOT NULL,
+    pid         varchar(11)  NULL DEFAULT NULL,
+    x_path      varchar(255) NULL DEFAULT NULL,
+    x_code      varchar(255) NULL DEFAULT NULL,
+    alias       varchar(255) NULL DEFAULT NULL,
+    object_id   varchar(255) NULL DEFAULT NULL,
+    ico         varchar(10)  NULL DEFAULT NULL,
+    f_name      varchar(255) NULL DEFAULT NULL,
+    f_type      varchar(10)  NULL DEFAULT NULL,
+    f_ext       varchar(10)  NULL DEFAULT NULL,
+    f_size      bigint(20)   NULL DEFAULT NULL,
+    f_group     varchar(255) NULL DEFAULT NULL,
+    fs_group    varchar(255) NULL DEFAULT NULL,
+    u_name      varchar(255) NULL DEFAULT NULL,
+    create_by   varchar(64)       default '' comment '创建者',
+    create_time datetime comment '创建时间',
+    update_by   varchar(64)       default '' comment '更新者',
+    update_time datetime comment '更新时间',
+    remark      varchar(500)      default null comment '备注',
+    PRIMARY KEY (id) USING BTREE,
+    INDEX index_f_type (f_type) USING BTREE,
+    INDEX index_f_ext (f_ext) USING BTREE,
+    INDEX index_uname (u_name) USING BTREE,
+    INDEX index_f_name (f_name) USING BTREE
+) ENGINE = InnoDB
+  CHARACTER SET = utf8
+  COLLATE = utf8_unicode_ci
+  ROW_FORMAT = DYNAMIC;

+ 1 - 0
SERVER/YanZhongXYH/script/sql/XYHSQL.sql

@@ -164,6 +164,7 @@ create table am_activity
     is_head       char(1)      default '0' comment '是否头条(0否 1是)',
     is_hot        char(1)      default '0' comment '是否Hot(0否 1是)',
     is_sys        char(1)      default '0' comment '是否平台发布(0否 1是)',
+    images        varchar(1000) comment '图片短链',
     create_by     varchar(64)  default '' comment '创建者',
     create_time   datetime comment '创建时间',
     update_by     varchar(64)  default '' comment '更新者',

+ 16 - 4
SERVER/YanZhongXYH/xyh-common/src/main/java/cn/xyh/common/config/VberConfig.java

@@ -79,28 +79,40 @@ public class VberConfig {
      * 获取上传路径
      */
     public static String getUploadPath() {
-        return getProfile() + "/upload";
+        return getProfile() + "/upload/";
+    }
+
+    public static String getRootPath() {
+        return getProfile() + "/ftp/";
+    }
+
+    public static String getUserRootPath() {
+        return getProfile() + "/ftp/users/";
+    }
+
+    public static String getFilesDepotPath() {
+        return getProfile() + "/ftp/files/";
     }
 
     /**
      * 获取活动图片上传路径
      */
     public static String getActivityPath() {
-        return getProfile() + "/alumnus/activity";
+        return getProfile() + "/alumnus/activity/";
     }
 
     /**
      * 获取资讯图片上传路径
      */
     public static String getNewsPath() {
-        return getProfile() + "/alumnus/news";
+        return getProfile() + "/alumnus/news/";
     }
 
     /**
      * 获取互助图片上传路径
      */
     public static String getHelpPath() {
-        return getProfile() + "/alumnus/help";
+        return getProfile() + "/alumnus/help/";
     }
 
     public void setAddressEnabled(boolean addressEnabled) {

+ 6 - 1
SERVER/YanZhongXYH/xyh-generator/src/main/java/cn/xyh/generator/service/impl/GenEmptyService.java

@@ -9,7 +9,7 @@ import java.util.Map;
  * @author Yue
  */
 @Service
-public class GenEmptyService implements IConfigService, IOrgService, IDictService, IUserService, ISensitiveService {
+public class GenEmptyService implements IConfigService, IOrgService, IDictService, IUserService, ISensitiveService, ICategoryService {
     @Override
     public String getConfigValue(String configKey) {
         return null;
@@ -44,4 +44,9 @@ public class GenEmptyService implements IConfigService, IOrgService, IDictServic
     public String selectUserNameById(Long userId) {
         return null;
     }
+
+    @Override
+    public String selectNameById(Long id) {
+        return null;
+    }
 }

+ 29 - 0
SERVER/YanZhongXYH/xyh-oss/pom.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.xyh</groupId>
+        <artifactId>YanZhongXYH</artifactId>
+        <version>${revision}</version>
+    </parent>
+
+    <artifactId>xyh-oss</artifactId>
+    <name>${project.artifactId}</name>
+    <description>oss文件模块</description>
+
+    <dependencies>
+        <!-- 通用工具-->
+        <dependency>
+            <groupId>com.xyh</groupId>
+            <artifactId>xyh-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+            <version>20.1.0</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+</project>

+ 63 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/common/constants/ExplorerConstants.java

@@ -0,0 +1,63 @@
+package cn.xyh.oss.common.constants;
+
+/**
+ * 资源管理器常量定义
+ *
+ * @author Tanyongde
+ */
+public class ExplorerConstants {
+
+    /**
+     * 进度监听前缀
+     */
+    public static final String PROGRESS_KEY_SUFF = "upload_";
+
+    /**
+     * 文件类型文件夹
+     */
+    public static final String FILE_TYPE_DIR = "DIR";
+    /**
+     * 文件类型文件
+     */
+    public static final String FILE_TYPE_FILE = "FILE";
+
+    /**
+     * 文件分组 用户组
+     */
+    public static final String FILE_GROUP_USERS = "USERS";
+    /**
+     * 文件分组 资源组
+     */
+    public static final String FILE_GROUP_PUBLIC = "PUBLIC";
+
+
+    /**
+     * 已生效
+     */
+    public static final String ENABLE = "1";
+
+    /**
+     * 未生效
+     */
+    public static final String DISABLE = "0";
+    /**
+     * 匿名用户
+     */
+    public final static String ANONYMOUS = "anonymous";
+    /**
+     * 只读权限
+     */
+    public final static int PERMISSION_READ = 1;
+    /**
+     * 可读可写权限
+     */
+    public final static int PERMISSION_WRITE = 2;
+    /**
+     * 删除权限
+     */
+    public final static int PERMISSION_DELETE = 3;
+    /**
+     * Redis服务配置地址名称
+     */
+    public static String REDIS_REF_HOSTS = "redis_ref_hosts";
+}

+ 7 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/common/utils/Tools.java

@@ -0,0 +1,7 @@
+package cn.xyh.oss.common.utils;
+
+public class Tools {
+    public static String calMd5(String str) {
+        return "";
+    }
+}

+ 114 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/controller/OssFileController.java

@@ -0,0 +1,114 @@
+package cn.xyh.oss.controller;
+
+import cn.dev33.satoken.annotation.SaIgnore;
+import cn.xyh.common.core.controller.BaseController;
+import cn.xyh.common.core.domain.R;
+import cn.xyh.oss.core.file.vo.UploadFileVo;
+import cn.xyh.oss.domain.OssFile;
+import cn.xyh.oss.service.IOssFileService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * oss
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/oss")
+public class OssFileController extends BaseController {
+
+    private final IOssFileService ossFileService;
+
+    /**
+     * 查询文件
+     */
+    @SaIgnore
+    @GetMapping("/preview/{url}")
+    public R<Object> preview(@PathVariable String url, HttpServletResponse response) throws IOException {
+        OssFile file = ossFileService.preview(url);
+        if (file == null) {
+            return R.fail("文件不存在!");
+        }
+        if (ossFileService.download(file.getObjectId(), response.getOutputStream())) {
+            return R.ok();
+        }
+        return R.fail("文件不能获取!");
+    }
+
+    @GetMapping("/upload/{path}")
+    public R<UploadFileVo> upload(@RequestPart("file") MultipartFile file, @PathVariable(name = "path", required = false) String path) {
+        if (path.isEmpty()) {
+            path = "common";
+        }
+        return ossFileService.upload(file, path);
+    }
+
+    ///**
+    // * 查询oss列表
+    // */
+    //@GetMapping("/list")
+    //public TableDataInfo<OssFileVo> list(OssFileBo bo, PageQuery pageQuery) {
+    //    return ossFileService.queryPageList(bo, pageQuery);
+    //}
+    //
+    ///**
+    // * 导出oss列表
+    // */
+    //@Log(title = "oss", businessType = BusinessType.EXPORT)
+    //@PostMapping("/export")
+    //public void export(OssFileBo bo, HttpServletResponse response) {
+    //    List<OssFileVo> list = ossFileService.queryList(bo);
+    //    ExcelUtil.exportExcel(list, "oss", OssFileVo.class, response);
+    //}
+    //
+    ///**
+    // * 获取oss详细信息
+    // *
+    // * @param id 主键
+    // */
+    //@GetMapping("/{id}")
+    //public R<OssFileVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable String id) {
+    //    return R.ok(ossFileService.queryById(id));
+    //}
+    //
+    ///**
+    // * 新增oss
+    // */
+    //@Log(title = "oss", businessType = BusinessType.INSERT)
+    //@RepeatSubmit()
+    //@PostMapping()
+    //public R<Void> add(@Validated(AddGroup.class) @RequestBody OssFileBo bo) {
+    //    return toAjax(ossFileService.insertByBo(bo));
+    //}
+    //
+    ///**
+    // * 修改oss
+    // */
+    //@Log(title = "oss", businessType = BusinessType.UPDATE)
+    //@RepeatSubmit()
+    //@PutMapping()
+    //public R<Void> edit(@Validated(EditGroup.class) @RequestBody OssFileBo bo) {
+    //    return toAjax(ossFileService.updateByBo(bo));
+    //}
+    //
+    ///**
+    // * 删除oss
+    // *
+    // * @param ids 主键串
+    // */
+    //@Log(title = "oss", businessType = BusinessType.DELETE)
+    //@DeleteMapping("/{ids}")
+    //public R<Void> remove(@NotEmpty(message = "主键不能为空")
+    //                      @PathVariable String[] ids) {
+    //    return toAjax(ossFileService.deleteWithValidByIds(Arrays.asList(ids), true));
+    //}
+}

+ 122 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/core/file/OFile.java

@@ -0,0 +1,122 @@
+package cn.xyh.oss.core.file;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.crypto.SecureUtil;
+
+import java.io.*;
+import java.util.ArrayList;
+
+public class OFile extends File {
+    private static final long serialVersionUID = 1L;
+    private OFileInfo fileInfo = new OFileInfo();
+    private boolean isOfile = false;
+
+    public OFile(String pathname) {
+        super(pathname);
+        isOfile = isOFile();
+    }
+
+    public static void main(String[] args) {
+        OFile test = new OFile("D:\\ftptest\\test\\qq\\com\\test@qq.com\\nginx-0.7.9.tar.gz");
+        System.out.println(test.save("D:/ftptest/"));
+        //System.out.println(test.read());
+    }
+
+    @Override
+    public OFile[] listFiles() {
+        String[] files = list();
+        OFile[] fs = null;
+        if (files != null) {
+            int n = files.length;
+            fs = new OFile[n];
+            for (int i = 0; i < n; i++) {
+                fs[i] = new OFile(getPath() + "/" + files[i]);
+            }
+        }
+        return fs;
+    }
+
+    @Override
+    public OFile[] listFiles(FilenameFilter filter) {
+        String[] ss = list();
+        if (ss == null) return null;
+        ArrayList<OFile> v = new ArrayList<OFile>();
+        for (int i = 0; i < ss.length; i++) {
+            if ((filter == null) || filter.accept(this, ss[i])) {
+                v.add(new OFile(getPath() + "/" + ss[i]));
+            }
+        }
+        return (OFile[]) (v.toArray(new File[v.size()]));
+    }
+
+    /**
+     * 取文件大小
+     */
+    @Override
+    public long length() {
+        if (fileInfo.length == null) {
+            if (fileInfo.realFile() != null) {
+                return fileInfo.realFile().length();
+            }
+        } else {
+            return fileInfo.length;
+        }
+        return super.length();
+    }
+
+    public String getRealFilePath() {
+        if (fileInfo == null || fileInfo.canonicalPath == null) {
+            return getPath();
+        }
+        return fileInfo.canonicalPath;
+    }
+
+    /**
+     * 保存文件(分离)
+     *
+     * @param root
+     * @return
+     */
+    public boolean save(String root) {
+        boolean mvok = false;
+        try {
+            if (isOfile) throw new IOException("已经是优化体, 不能更新到仓库.");
+            String sha1 = SecureUtil.sha1(this);
+            fileInfo.realFile = new File(String.format("%s/%s/%s", root, sha1.replaceAll("(.{3})", "$1/"), sha1));
+            fileInfo.fileCode = sha1;
+            if (!fileInfo.realFile().exists()) {
+                fileInfo.realFile().getParentFile().mkdirs();
+                FileUtil.move(this, fileInfo.realFile(), true);
+            }
+            mvok = true;
+        } catch (Exception e) {
+            // e.printStackTrace();
+
+        }
+        return mvok;
+    }
+
+    public boolean read() {
+        ObjectInputStream in = null;
+        try {
+            in = new ObjectInputStream(new FileInputStream(this));
+            fileInfo = (OFileInfo) (in.readObject());
+            in.close();
+            return true;
+        } catch (Exception e) {
+            if (in != null) try {
+                in.close();
+            } catch (IOException e1) {
+            }
+        }
+        return false;
+    }
+
+    private boolean isOFile() {
+        return (this.length() < 1024 && read());
+    }
+
+    public OFileInfo getInfo() {
+        return this.fileInfo;
+    }
+}

+ 58 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/core/file/OFileInfo.java

@@ -0,0 +1,58 @@
+package cn.xyh.oss.core.file;
+
+import java.io.*;
+
+public class OFileInfo implements Externalizable {
+    private static final long serialVersionUID = 1L;
+
+    File realFile = null;
+    @lombok.Getter
+    String fileCode = null;
+    String canonicalPath = null;
+    Long length = null;
+
+    public OFileInfo() {
+    }
+
+    /**
+     * 获取真实文件
+     *
+     * @return
+     */
+    File realFile() {
+        if (realFile == null) {
+            if (canonicalPath == null) {
+                return null;
+            }
+            realFile = new File(canonicalPath);
+        }
+        return realFile;
+    }
+
+    String filecode() {
+        //try {
+        //    if (fileCode == null) {
+        //        //fileCode = MD5.asHex(MD5.getHash(realFile));
+        //        fileCode = SecureUtil.sha1(realFile);
+        //    }
+        //} catch (IOException e) {
+        //    fileCode = null;
+        //}
+        return fileCode;
+    }
+
+    @Override
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        this.canonicalPath = (String) in.readObject();
+        this.length = (Long) in.readObject();
+        this.fileCode = (String) in.readObject();
+    }
+
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(realFile.getCanonicalPath());
+        out.writeObject(realFile.length());
+        out.writeObject(fileCode);
+    }
+
+}

+ 14 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/core/file/vo/UploadFileVo.java

@@ -0,0 +1,14 @@
+package cn.xyh.oss.core.file.vo;
+
+import lombok.Data;
+
+@Data
+public class UploadFileVo {
+
+    private String originalName;
+    private String name;
+    private String url;
+    private Long size;
+    private String type;
+    private Long last; //最后修改时间
+}

+ 109 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/OssFile.java

@@ -0,0 +1,109 @@
+package cn.xyh.oss.domain;
+
+import cn.xyh.common.core.domain.BaseEntity;
+import cn.xyh.oss.common.constants.ExplorerConstants;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * oss对象 oss_file
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("oss_file")
+public class OssFile extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    @TableId("id")
+    private Long id;
+    /**
+     *
+     */
+    private Long pid;
+    /**
+     *
+     */
+    private String xPath;
+    /**
+     *
+     */
+    private String xCode;
+    /**
+     *
+     */
+    private String alias;
+    /**
+     *
+     */
+    private String objectId;
+    /**
+     *
+     */
+    private String ico;
+    /**
+     *
+     */
+    private String fName;
+    /**
+     *
+     */
+    private String fType;
+    /**
+     *
+     */
+    private String fExt;
+    /**
+     *
+     */
+    private Long fSize;
+    /**
+     *
+     */
+    private String fGroup;
+    /**
+     *
+     */
+    private String fsGroup;
+    /**
+     *
+     */
+    private String uName;
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public static OssFile Create(String path) {
+        OssFile file = new OssFile();
+        path = path.replaceAll("/$", "");
+        if (path.isEmpty()) {
+            path = "/";
+        }
+        int s = path.lastIndexOf("/");
+        String xPath = path.substring(0, s + 1);
+        String fName = path.substring(s + 1);
+        file.setXPath(xPath);
+        file.setFName(fName);
+
+        if (!fName.contains(".")) {
+            String fType = ExplorerConstants.FILE_TYPE_DIR;
+            file.setFType(fType);
+        } else {
+            String fExt = fName.substring(fName.lastIndexOf(".") + 1);
+            String fType = ExplorerConstants.FILE_TYPE_FILE;
+            file.setFType(fType);
+            file.setFExt(fExt);
+        }
+        return file;
+    }
+
+}

+ 33 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/OssFileShort.java

@@ -0,0 +1,33 @@
+package cn.xyh.oss.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * oss_file_short对象 oss_file_short
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@Data
+@TableName("oss_file_short")
+public class OssFileShort implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    /**
+     *
+     */
+    private String shortUrl;
+    /**
+     *
+     */
+    private String url;
+
+    public OssFileShort(String shortUrl, String url) {
+        this.shortUrl = shortUrl;
+        this.url = url;
+    }
+
+}

+ 115 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/bo/OssFileBo.java

@@ -0,0 +1,115 @@
+package cn.xyh.oss.domain.bo;
+
+import cn.xyh.common.core.domain.BaseEntity;
+import cn.xyh.common.core.validate.AddGroup;
+import cn.xyh.common.core.validate.EditGroup;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * oss业务对象 oss_file
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+
+public class OssFileBo extends BaseEntity {
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {EditGroup.class})
+    private Long id;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private Long pid;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String xPath;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String xCode;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String alias;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String objectId;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String ico;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String fName;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String fType;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String fExt;
+
+    /**
+     *
+     */
+    @NotNull(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private Long fSize;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String fGroup;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String fsGroup;
+
+    /**
+     *
+     */
+    @NotBlank(message = "不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String uName;
+
+    /**
+     * 备注
+     */
+    @NotBlank(message = "备注不能为空", groups = {AddGroup.class, EditGroup.class})
+    private String remark;
+
+
+}

+ 39 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/bo/OssFileShortBo.java

@@ -0,0 +1,39 @@
+package cn.xyh.oss.domain.bo;
+
+import cn.xyh.common.core.validate.AddGroup;
+import cn.xyh.common.core.validate.EditGroup;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.*;
+
+import java.util.Date;
+
+import cn.xyh.common.core.domain.BaseEntity;
+
+/**
+ * oss_file_short业务对象 oss_file_short
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+
+public class OssFileShortBo extends BaseEntity {
+
+            /**
+             * 
+             */
+                @NotBlank(message = "不能为空", groups = { EditGroup.class })
+        private String shortUrl;
+
+            /**
+             * 
+             */
+                @NotBlank(message = "不能为空", groups = { AddGroup.class, EditGroup.class })
+        private String url;
+
+
+}

+ 38 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/vo/OssFileShortVo.java

@@ -0,0 +1,38 @@
+package cn.xyh.oss.domain.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import cn.xyh.common.annotation.ExcelDictFormat;
+import cn.xyh.common.convert.ExcelDictConvert;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * oss_file_short视图对象 oss_file_short
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@Data
+@ExcelIgnoreUnannotated
+public class OssFileShortVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+            /**
+             * 
+             */
+            @ExcelProperty(value = "")
+        private String shortUrl;
+
+            /**
+             * 
+             */
+            @ExcelProperty(value = "")
+        private String url;
+
+
+}

+ 113 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/domain/vo/OssFileVo.java

@@ -0,0 +1,113 @@
+package cn.xyh.oss.domain.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * oss视图对象 oss_file
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@Data
+@ExcelIgnoreUnannotated
+public class OssFileVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Long id;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Long pid;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String xPath;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String xCode;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String alias;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String objectId;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String ico;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String fName;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String fType;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String fExt;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Long fSize;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String fGroup;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String fsGroup;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private String uName;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注")
+    private String remark;
+
+
+}

+ 17 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/mapper/OssFileMapper.java

@@ -0,0 +1,17 @@
+package cn.xyh.oss.mapper;
+
+import cn.xyh.oss.domain.OssFile;
+import cn.xyh.oss.domain.vo.OssFileVo;
+import cn.xyh.common.core.mapper.BaseMapperPlus;
+import org.springframework.stereotype.Repository;
+
+/**
+ * ossMapper接口
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@Repository
+public interface OssFileMapper extends BaseMapperPlus<OssFileMapper, OssFile, OssFileVo> {
+
+}

+ 17 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/mapper/OssFileShortMapper.java

@@ -0,0 +1,17 @@
+package cn.xyh.oss.mapper;
+
+import cn.xyh.oss.domain.OssFileShort;
+import cn.xyh.oss.domain.vo.OssFileShortVo;
+import cn.xyh.common.core.mapper.BaseMapperPlus;
+import org.springframework.stereotype.Repository;
+
+/**
+ * oss_file_shortMapper接口
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@Repository
+public interface OssFileShortMapper extends BaseMapperPlus<OssFileShortMapper, OssFileShort, OssFileShortVo> {
+
+}

+ 63 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/service/IOssFileService.java

@@ -0,0 +1,63 @@
+package cn.xyh.oss.service;
+
+import cn.xyh.common.core.domain.R;
+import cn.xyh.oss.core.file.vo.UploadFileVo;
+import cn.xyh.oss.domain.OssFile;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.OutputStream;
+import java.util.List;
+
+/**
+ * ossService接口
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+public interface IOssFileService {
+
+    OssFile preview(String shortUrl);
+
+    Boolean download(String objectId, OutputStream out);
+
+    /**
+     * 上传文件
+     *
+     * @param files 文件
+     * @param path  文件路径
+     * @return
+     */
+    R<List<UploadFileVo>> upload(MultipartFile[] files, String path);
+
+    R<UploadFileVo> upload(MultipartFile file, String path);
+
+    ///**
+    // * 查询oss
+    // */
+    //OssFileVo queryById(String id);
+    //
+    ///**
+    // * 查询oss列表
+    // */
+    //TableDataInfo<OssFileVo> queryPageList(OssFileBo bo, PageQuery pageQuery);
+    //
+    ///**
+    // * 查询oss列表
+    // */
+    //List<OssFileVo> queryList(OssFileBo bo);
+    //
+    ///**
+    // * 新增oss
+    // */
+    //Boolean insertByBo(OssFileBo bo);
+    //
+    ///**
+    // * 修改oss
+    // */
+    //Boolean updateByBo(OssFileBo bo);
+    //
+    ///**
+    // * 校验并批量删除oss信息
+    // */
+    //Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
+}

+ 49 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/service/IOssFileShortService.java

@@ -0,0 +1,49 @@
+package cn.xyh.oss.service;
+
+import cn.xyh.oss.domain.OssFileShort;
+import cn.xyh.oss.domain.vo.OssFileShortVo;
+import cn.xyh.oss.domain.bo.OssFileShortBo;
+    import cn.xyh.common.core.page.TableDataInfo;
+    import cn.xyh.common.core.domain.PageQuery;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * oss_file_shortService接口
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+public interface IOssFileShortService {
+
+    /**
+     * 查询oss_file_short
+     */
+        OssFileShortVo queryById(String shortUrl);
+
+        /**
+         * 查询oss_file_short列表
+         */
+        TableDataInfo<OssFileShortVo> queryPageList(OssFileShortBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询oss_file_short列表
+     */
+    List<OssFileShortVo> queryList(OssFileShortBo bo);
+
+    /**
+     * 新增oss_file_short
+     */
+    Boolean insertByBo(OssFileShortBo bo);
+
+    /**
+     * 修改oss_file_short
+     */
+    Boolean updateByBo(OssFileShortBo bo);
+
+    /**
+     * 校验并批量删除oss_file_short信息
+     */
+    Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
+}

+ 331 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/service/impl/OssFileServiceImpl.java

@@ -0,0 +1,331 @@
+package cn.xyh.oss.service.impl;
+
+import cn.hutool.crypto.SecureUtil;
+import cn.xyh.common.config.VberConfig;
+import cn.xyh.common.core.domain.R;
+import cn.xyh.common.exception.ServiceException;
+import cn.xyh.common.helper.LoginHelper;
+import cn.xyh.common.utils.EncryptUtils;
+import cn.xyh.common.utils.StringUtils;
+import cn.xyh.common.utils.file.FileUtils;
+import cn.xyh.oss.common.constants.ExplorerConstants;
+import cn.xyh.oss.core.file.OFile;
+import cn.xyh.oss.core.file.vo.UploadFileVo;
+import cn.xyh.oss.domain.OssFile;
+import cn.xyh.oss.domain.OssFileShort;
+import cn.xyh.oss.mapper.OssFileMapper;
+import cn.xyh.oss.mapper.OssFileShortMapper;
+import cn.xyh.oss.service.IOssFileService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * ossService业务层处理
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@RequiredArgsConstructor
+@Service
+public class OssFileServiceImpl implements IOssFileService {
+
+    private final static String KEY = "IWBNETVBERYUEVBIWBYUNNET";
+    private final OssFileMapper baseMapper;
+    private final OssFileShortMapper shortMapper;
+
+    private static String getUnionDateTimeId() {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssSSS");
+        return sdf.format(new Date()) + (new Random().nextInt(9000) + 10000);
+    }
+
+
+    @Override
+    public OssFile preview(String shortUrl) {
+        OssFileShort sFile = shortMapper.selectOne(new LambdaQueryWrapper<OssFileShort>().eq(OssFileShort::getShortUrl, shortUrl));
+        if (sFile == null) {
+            throw new ServiceException("无效的短链接");
+        }
+        String url = EncryptUtils.decryptByAes(sFile.getUrl(), KEY);
+        String[] info = url.split("\\|");
+        String uName = info[0];
+        String objectId = info[1];
+        String fName = info[2].replaceAll("/", "");
+        return baseMapper.selectOne(new LambdaQueryWrapper<OssFile>()
+                .eq(OssFile::getFName, fName)
+                .eq(OssFile::getUName, uName)
+                .eq(OssFile::getObjectId, objectId));
+    }
+
+    @Override
+    public Boolean download(String objectId, OutputStream out) {
+        String realPath = VberConfig.getFilesDepotPath() + objectId.replaceAll("(.{3})", "$1/") + "/" + objectId;
+        OutputStream toClient = new BufferedOutputStream(out);
+        try {
+            RandomAccessFile raf = new RandomAccessFile(realPath, "r");
+            byte[] bytes = new byte[1024];
+            int size = 0;
+            try {
+                while ((size = raf.read(bytes, 0, bytes.length)) != -1) {
+                    toClient.write(bytes, 0, size);
+                    toClient.flush();
+                }
+            } finally {
+                toClient.close();
+                raf.close();
+            }
+
+        } catch (IOException e) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public R<UploadFileVo> upload(MultipartFile file, String path) {
+        Map<String, File> uploads = new HashMap<String, File>();
+
+        try {
+            final int bufferSize = 1024 * 100;
+            InputStream stream = file.getInputStream();
+            String fileName = file.getOriginalFilename();
+            File dir = new File(VberConfig.getUploadPath());
+            if (!dir.exists()) {
+                dir.mkdirs();
+            }
+            String filePath = VberConfig.getUploadPath() + getUnionDateTimeId() + ".temp";
+            File f = new File(filePath);
+            OutputStream bos = new FileOutputStream(f);
+            int bytesRead = 0;
+            byte[] buffer = new byte[bufferSize];
+            while ((bytesRead = stream.read(buffer, 0, bufferSize)) != -1) {
+                bos.write(buffer, 0, bytesRead);
+            }
+            bos.close();
+            stream.close();
+            uploads.put(fileName, f);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        R<List<UploadFileVo>> res = upload(ExplorerConstants.FILE_GROUP_USERS, LoginHelper.getUsername(), path, uploads);
+        if (res.getCode() == R.FAIL) {
+            return R.fail(res.getMsg());
+        }
+        return R.ok(res.getData().get(0));
+    }
+
+
+    @Override
+    public R<List<UploadFileVo>> upload(MultipartFile[] files, String path) {
+        Map<String, File> uploads = new HashMap<String, File>();
+        final int bufferSize = 1024 * 100;
+
+        for (MultipartFile file : files) {
+            try {
+                InputStream stream = file.getInputStream();
+                String fileName = file.getOriginalFilename();
+                File dir = new File(VberConfig.getUploadPath());
+                if (!dir.exists()) {
+                    dir.mkdirs();
+                }
+                String filePath = VberConfig.getUploadPath() + getUnionDateTimeId() + ".temp";
+                File f = new File(filePath);
+                OutputStream bos = new FileOutputStream(f);
+                int bytesRead = 0;
+                byte[] buffer = new byte[bufferSize];
+                while ((bytesRead = stream.read(buffer, 0, bufferSize)) != -1) {
+                    bos.write(buffer, 0, bytesRead);
+                }
+                bos.close();
+                stream.close();
+                uploads.put(fileName, f);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        return upload(ExplorerConstants.FILE_GROUP_USERS, LoginHelper.getUsername(), path, uploads);
+    }
+
+
+    private R<List<UploadFileVo>> upload(String group, String uname, String path, Map<String, File> files) {
+        List<String> errors = new ArrayList<String>();
+        List<UploadFileVo> result = new ArrayList<>();
+        List<OssFileShort> urls = new ArrayList<OssFileShort>();
+        for (String fileName : files.keySet()) {
+            File src = files.get(fileName);
+            fileName = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + "_" + fileName;
+            String realPath = VberConfig.getUserRootPath() + uname.replaceAll("@|\\.", "/") + "/" + path + "/";
+            File uDir = new File(realPath.replaceAll("//", "/"));
+            if (!uDir.exists()) {
+                uDir.mkdirs();
+            }
+            OFile f = new OFile(src.getPath());
+            FileUtils.copyFile(src.getAbsolutePath(), realPath + fileName);
+            f.save(VberConfig.getFilesDepotPath());
+            String objectId = f.getInfo().getFileCode();
+
+            R res = createFile(group, uname, path + fileName, objectId, new File(realPath + fileName));
+            if (res.getCode() == R.FAIL) {
+                errors.add(res.getMsg());
+                continue;
+            }
+            String url = EncryptUtils.encryptByAes(uname + "|" + objectId + "|" + path + "/" + fileName, KEY);
+
+            String short_url = SecureUtil.md5(url);
+            urls.add(new OssFileShort(short_url, url));
+            String ext = fileName.substring(fileName.lastIndexOf("."));
+
+            UploadFileVo vo = new UploadFileVo();
+            vo.setOriginalName(path + fileName);
+            vo.setName(fileName);
+            vo.setUrl(short_url);
+            vo.setSize(f.length());
+            vo.setType(ext);
+            vo.setLast(f.lastModified());
+
+
+            result.add(vo);
+        }
+        if (urls.size() > 0) {
+            shortMapper.insertBatch(urls);
+        }
+        if (errors.size() > 0) {
+            return R.fail("有文件上传失败:" + StringUtils.joinWith(",", errors));
+        }
+
+        return R.ok(result);
+    }
+
+    private R createFile(String group, String uname, String path, String objectId, File file) {
+        OssFile oFile = OssFile.Create(path);
+        oFile.setObjectId(objectId);
+        oFile.setFGroup(group);
+        oFile.setUName(uname);
+        if (null != file && file.isFile()) {
+            oFile.setFSize(file.length());
+            oFile.setUpdateTime(new Date(file.lastModified()));
+        }
+        OssFile parent = null;
+        if (StringUtils.isNotEmpty(oFile.getXPath())) {
+            parent = baseMapper.selectOne(new LambdaQueryWrapper<OssFile>()
+                    .eq(StringUtils.isNotEmpty(group), OssFile::getFGroup, group)
+                    .eq(StringUtils.isNotEmpty(uname), OssFile::getUName, uname)
+                    .and(StringUtils.isNotEmpty(oFile.getXPath()), w -> {
+                        OssFile p = OssFile.Create(oFile.getXPath());
+                        w.eq(OssFile::getXPath, p.getXPath())
+                                .eq(OssFile::getFName, p.getFName());
+                    })
+            );
+        }
+        if (null != parent) {
+            oFile.setPid(parent.getId());
+            oFile.setXCode(parent.getXCode() + oFile.getPid() + "/");
+        } else {
+            oFile.setPid(0L);
+            oFile.setXCode("/");
+        }
+        if (baseMapper.exists(new LambdaQueryWrapper<OssFile>()
+                .eq(OssFile::getFName, oFile.getFName())
+                .eq(OssFile::getFGroup, oFile.getFGroup())
+                .eq(OssFile::getUName, oFile.getUName())
+                .eq(OssFile::getXPath, oFile.getXPath())
+        )) {
+            return R.fail("[" + file.getName() + "]文件已存在");
+        }
+        return baseMapper.insert(oFile) > 0 ? R.ok() : R.fail("[" + file.getName() + "]保存数据库失败");
+    }
+
+    ///**
+    // * 查询oss
+    // */
+    //@Override
+    //public OssFileVo queryById(String id) {
+    //    return baseMapper.selectVoById(id);
+    //}
+    ///**
+    // * 查询oss列表
+    // */
+    //@Override
+    //public TableDataInfo<OssFileVo> queryPageList(OssFileBo bo, PageQuery pageQuery) {
+    //    LambdaQueryWrapper<OssFile> lqw = buildQueryWrapper(bo);
+    //    Page<OssFileVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+    //    return TableDataInfo.build(result);
+    //}
+    //
+    ///**
+    // * 查询oss列表
+    // */
+    //@Override
+    //public List<OssFileVo> queryList(OssFileBo bo) {
+    //    LambdaQueryWrapper<OssFile> lqw = buildQueryWrapper(bo);
+    //    return baseMapper.selectVoList(lqw);
+    //}
+    //
+    //private LambdaQueryWrapper<OssFile> buildQueryWrapper(OssFileBo bo) {
+    //    Map<String, Object> params = bo.getParams();
+    //    LambdaQueryWrapper<OssFile> lqw = Wrappers.lambdaQuery();
+    //    lqw.eq(StringUtils.isNotBlank(bo.getPid()), OssFile::getPid, bo.getPid());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getXPath()), OssFile::getXPath, bo.getXPath());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getXCode()), OssFile::getXCode, bo.getXCode());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getAlias()), OssFile::getAlias, bo.getAlias());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getObjectId()), OssFile::getObjectId, bo.getObjectId());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getIco()), OssFile::getIco, bo.getIco());
+    //    lqw.like(StringUtils.isNotBlank(bo.getFName()), OssFile::getFName, bo.getFName());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getFType()), OssFile::getFType, bo.getFType());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getFExt()), OssFile::getFExt, bo.getFExt());
+    //    lqw.eq(bo.getFSize() != null, OssFile::getFSize, bo.getFSize());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getFGroup()), OssFile::getFGroup, bo.getFGroup());
+    //    lqw.eq(StringUtils.isNotBlank(bo.getFsGroup()), OssFile::getFsGroup, bo.getFsGroup());
+    //    lqw.like(StringUtils.isNotBlank(bo.getUName()), OssFile::getUName, bo.getUName());
+    //    return lqw;
+    //}
+    //
+    ///**
+    // * 新增oss
+    // */
+    //@Override
+    //public Boolean insertByBo(OssFileBo bo) {
+    //    OssFile add = BeanUtil.toBean(bo, OssFile.class);
+    //    validEntityBeforeSave(add);
+    //    boolean flag = baseMapper.insert(add) > 0;
+    //    if (flag) {
+    //        bo.setId(add.getId());
+    //    }
+    //    return flag;
+    //}
+    //
+    ///**
+    // * 修改oss
+    // */
+    //@Override
+    //public Boolean updateByBo(OssFileBo bo) {
+    //    OssFile update = BeanUtil.toBean(bo, OssFile.class);
+    //    validEntityBeforeSave(update);
+    //    return baseMapper.updateById(update) > 0;
+    //}
+    //
+    ///**
+    // * 保存前的数据校验
+    // */
+    //private void validEntityBeforeSave(OssFile entity) {
+    //    //TODO 做一些数据校验,如唯一约束
+    //}
+    //
+    ///**
+    // * 批量删除oss
+    // */
+    //@Override
+    //public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
+    //    if (isValid) {
+    //        //TODO 做一些业务上的校验,判断是否需要校验
+    //    }
+    //    return baseMapper.deleteBatchIds(ids) > 0;
+    //}
+}

+ 109 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/java/cn/xyh/oss/service/impl/OssFileShortServiceImpl.java

@@ -0,0 +1,109 @@
+package cn.xyh.oss.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.xyh.common.utils.StringUtils;
+    import cn.xyh.common.core.page.TableDataInfo;
+    import cn.xyh.common.core.domain.PageQuery;
+    import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import cn.xyh.oss.domain.bo.OssFileShortBo;
+import cn.xyh.oss.domain.vo.OssFileShortVo;
+import cn.xyh.oss.domain.OssFileShort;
+import cn.xyh.oss.mapper.OssFileShortMapper;
+import cn.xyh.oss.service.IOssFileShortService;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * oss_file_shortService业务层处理
+ *
+ * @author Yue
+ * @date 2024-01-20
+ */
+@RequiredArgsConstructor
+@Service
+public class OssFileShortServiceImpl implements IOssFileShortService {
+
+    private final OssFileShortMapper baseMapper;
+
+    /**
+     * 查询oss_file_short
+     */
+    @Override
+    public OssFileShortVo queryById(String shortUrl) {
+        return baseMapper.selectVoById(shortUrl);
+    }
+
+        /**
+         * 查询oss_file_short列表
+         */
+        @Override
+        public TableDataInfo<OssFileShortVo> queryPageList(OssFileShortBo bo, PageQuery pageQuery) {
+            LambdaQueryWrapper<OssFileShort> lqw = buildQueryWrapper(bo);
+            Page<OssFileShortVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+            return TableDataInfo.build(result);
+        }
+
+    /**
+     * 查询oss_file_short列表
+     */
+    @Override
+    public List<OssFileShortVo> queryList(OssFileShortBo bo) {
+        LambdaQueryWrapper<OssFileShort> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectVoList(lqw);
+    }
+
+    private LambdaQueryWrapper<OssFileShort> buildQueryWrapper(OssFileShortBo bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<OssFileShort> lqw = Wrappers.lambdaQuery();
+                    lqw.eq(StringUtils.isNotBlank(bo.getUrl()), OssFileShort::getUrl, bo.getUrl());
+        return lqw;
+    }
+
+    /**
+     * 新增oss_file_short
+     */
+    @Override
+    public Boolean insertByBo(OssFileShortBo bo) {
+        OssFileShort add = BeanUtil.toBean(bo, OssFileShort. class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insert(add) > 0;
+        if (flag) {
+            bo.setShortUrl(add.getShortUrl());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改oss_file_short
+     */
+    @Override
+    public Boolean updateByBo(OssFileShortBo bo) {
+        OssFileShort update = BeanUtil.toBean(bo, OssFileShort. class);
+        validEntityBeforeSave(update);
+        return baseMapper.updateById(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(OssFileShort entity) {
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    /**
+     * 批量删除oss_file_short
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
+        if (isValid) {
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deleteBatchIds(ids) > 0;
+    }
+}

+ 30 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/resources/mapper/oss/OssFileMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.xyh.oss.mapper.OssFileMapper">
+
+    <resultMap type="cn.xyh.oss.domain.OssFile" id="OssFileResult">
+        <result property="id" column="id"/>
+        <result property="pid" column="pid"/>
+        <result property="xPath" column="x_path"/>
+        <result property="xCode" column="x_code"/>
+        <result property="alias" column="alias"/>
+        <result property="objectId" column="object_id"/>
+        <result property="ico" column="ico"/>
+        <result property="fName" column="f_name"/>
+        <result property="fType" column="f_type"/>
+        <result property="fExt" column="f_ext"/>
+        <result property="fSize" column="f_size"/>
+        <result property="fGroup" column="f_group"/>
+        <result property="fsGroup" column="fs_group"/>
+        <result property="uName" column="u_name"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+
+</mapper>

+ 13 - 0
SERVER/YanZhongXYH/xyh-oss/src/main/resources/mapper/oss/OssFileShortMapper.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.xyh.oss.mapper.OssFileShortMapper">
+
+    <resultMap type="cn.xyh.oss.domain.OssFileShort" id="OssFileShortResult">
+        <result property="shortUrl" column="short_url"/>
+        <result property="url" column="url"/>
+    </resultMap>
+
+
+</mapper>

+ 4 - 0
SERVER/YanZhongXYH/xyh-system/pom.xml

@@ -21,6 +21,10 @@
             <artifactId>xyh-common</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.xyh</groupId>
+            <artifactId>xyh-oss</artifactId>
+        </dependency>
 
     </dependencies>
 

+ 8 - 9
SERVER/YanZhongXYH/xyh-system/src/main/java/cn/xyh/amActivity/domain/AmActivity.java

@@ -1,16 +1,12 @@
 package cn.xyh.amActivity.domain;
 
-import com.baomidou.mybatisplus.annotation.*;
+import cn.xyh.common.core.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
-import java.io.Serializable;
-import java.util.Date;
-import java.math.BigDecimal;
-
 import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import cn.xyh.common.core.domain.BaseEntity;
 
 /**
  * 活动信息对象 am_activity
@@ -23,12 +19,12 @@ import cn.xyh.common.core.domain.BaseEntity;
 @TableName("am_activity")
 public class AmActivity extends BaseEntity {
 
-private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
     /**
      * 活动id
      */
-        @TableId(value = "activity_id")
+    @TableId(value = "activity_id")
     private String activityId;
     /**
      * 活动标题
@@ -95,4 +91,7 @@ private static final long serialVersionUID = 1L;
      */
     private String remark;
 
+    private String images;
+
+
 }

+ 1 - 0
SERVER/YanZhongXYH/xyh-system/src/main/java/cn/xyh/amActivity/domain/bo/AmActivityBo.java

@@ -93,4 +93,5 @@ public class AmActivityBo extends BaseEntity {
      */
     private String isSys;
 
+
 }

+ 1 - 0
SERVER/YanZhongXYH/xyh-system/src/main/java/cn/xyh/amActivity/domain/vo/AmActivityVo.java

@@ -140,5 +140,6 @@ public class AmActivityVo implements Serializable {
     @ExcelProperty(value = "备注")
     private String remark;
 
+    private String images;
 
 }

+ 36 - 2
SERVER/YanZhongXYH/xyh-system/src/main/java/cn/xyh/amActivity/service/impl/AmActivityServiceImpl.java

@@ -12,12 +12,15 @@ import cn.xyh.amActivity.mapper.AmAttachMapper;
 import cn.xyh.amActivity.service.IAmActivityService;
 import cn.xyh.common.config.VberConfig;
 import cn.xyh.common.core.domain.PageQuery;
+import cn.xyh.common.core.domain.R;
 import cn.xyh.common.core.page.TableDataInfo;
 import cn.xyh.common.exception.file.InvalidExtensionException;
 import cn.xyh.common.utils.StreamUtils;
 import cn.xyh.common.utils.StringUtils;
 import cn.xyh.common.utils.file.FileUploadUtils;
 import cn.xyh.common.utils.file.MimeTypeUtils;
+import cn.xyh.oss.core.file.vo.UploadFileVo;
+import cn.xyh.oss.service.IOssFileService;
 import cn.xyh.system.utils.AuditStatusEnum;
 import cn.xyh.system.utils.GuidUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -50,6 +53,7 @@ public class AmActivityServiceImpl implements IAmActivityService {
     private final AmActivityMapper baseMapper;
     private final AmActivityApplyMapper baseApplyMapper;
     private final AmAttachMapper attachMapper;
+    private final IOssFileService ossFileService;
 
     /**
      * 查询活动信息
@@ -65,6 +69,20 @@ public class AmActivityServiceImpl implements IAmActivityService {
     @Override
     public TableDataInfo<AmActivityVo> queryPageList(AmActivityBo bo, PageQuery pageQuery) {
         LambdaQueryWrapper<AmActivity> lqw = buildQueryWrapper(bo);
+        lqw.select(
+                AmActivity::getActivityId,
+                AmActivity::getTitle,
+                AmActivity::getCategory,
+                AmActivity::getCost,
+                AmActivity::getArea,
+                AmActivity::getAddress,
+                AmActivity::getIsHead,
+                AmActivity::getAuditStatus,
+                AmActivity::getPeopleMax,
+                AmActivity::getIsHot,
+                AmActivity::getIsSys,
+                AmActivity::getActivityDate,
+                AmActivity::getExpiryDate);
         Page<AmActivityVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         return TableDataInfo.build(result);
     }
@@ -108,7 +126,8 @@ public class AmActivityServiceImpl implements IAmActivityService {
         AmActivity add = BeanUtil.toBean(bo, AmActivity.class);
         add.setActivityId(getActivityId());
         validEntityBeforeSave(add);
-        saveActivityImages(files, add.getActivityId());
+        saveActivityImages(files, add);
+        //saveActivityImages(files, add.getActivityId());
         boolean flag = baseMapper.insert(add) > 0;
         if (flag) {
             bo.setActivityId(add.getActivityId());
@@ -127,10 +146,25 @@ public class AmActivityServiceImpl implements IAmActivityService {
     public Boolean updateByBo(MultipartFile[] files, AmActivityBo bo) {
         AmActivity update = BeanUtil.toBean(bo, AmActivity.class);
         validEntityBeforeSave(update);
-        saveActivityImages(files, update.getActivityId());
+        saveActivityImages(files, update);
+
+        //saveActivityImages(files, update.getActivityId());
         return baseMapper.updateById(update) > 0;
     }
 
+
+    private void saveActivityImages(MultipartFile[] files, AmActivity activity) {
+        R<List<UploadFileVo>> res = ossFileService.upload(files, "activity");
+        if (res.getCode() == R.SUCCESS) {
+            List<UploadFileVo> fileVos = res.getData();
+            String urls = "";
+            for (UploadFileVo fileVo : fileVos) {
+                urls += (StringUtils.isNotEmpty(urls) ? "" : ",") + fileVo.getUrl();
+            }
+            activity.setImages(urls);
+        }
+    }
+
     private void saveActivityImages(MultipartFile[] files, String activityId) {
         if (files != null && files.length > 0) {
             List<AmAttach> attaches = new ArrayList<>();

+ 1 - 0
SERVER/YanZhongXYH/xyh-system/src/main/resources/mapper/amActivity/AmActivityMapper.xml

@@ -21,6 +21,7 @@
         <result property="isHead" column="is_head"/>
         <result property="isHot" column="is_hot"/>
         <result property="isSys" column="is_sys"/>
+        <result property="images" column="images"/>
         <result property="createBy" column="create_by"/>
         <result property="createTime" column="create_time"/>
         <result property="updateBy" column="update_by"/>

+ 3 - 0
UI/XYH.VUE/src/views/amActivity/activity/index.vue

@@ -580,6 +580,9 @@ onMounted(init)
 						</dl>
 					</el-col>
 				</el-row>
+				<el-row :gutter="20" v-if="detailData.images">
+					<VbImagePreview :src="detailData.images" :prefixSrc="'/oss/preview/'"></VbImagePreview>
+				</el-row>
 				<div v-if="detailType == 'A'" class="d-flex justify-content-center">
 					<vb-select
 						v-model="auditStatus"

+ 5 - 0
UI/XYH.VUE/vite.config.ts

@@ -120,6 +120,11 @@ export default defineConfig(({ mode, command }) => {
 					target: "http://127.0.0.1:5051",
 					changeOrigin: true,
 					rewrite: (p) => p.replace(/^\/dev-api/, "")
+				},
+				"/oss/preview": {
+					target: "http://127.0.0.1:5051",
+					changeOrigin: true,
+					rewrite: (p) => p.replace(/^\/oss\/preview/, "/oss/preview")
 				}
 				// "/dev-api": {
 				// 	target: "http://192.168.0.82:6060",