Browse Source

资源上传:对象存储切换到minio OS存储

wangqi49 3 months ago
parent
commit
249fa14c64
100 changed files with 363 additions and 6 deletions
  1. 11 0
      resources/nacos-yaml/webchat-admin-service-dev.yaml
  2. 11 0
      resources/nacos-yaml/webchat-client-chat-service-dev.yaml
  3. 7 0
      webchat-admin/pom.xml
  4. 2 0
      webchat-admin/src/main/java/com/webchat/admin/WebchatAdminApplication.java
  5. 46 0
      webchat-admin/src/main/java/com/webchat/admin/controller/FileController.java
  6. 0 1
      webchat-admin/src/main/resources/application.properties
  7. 1 0
      webchat-admin/src/main/resources/application.yml
  8. 1 1
      webchat-admin/src/main/resources/bootstrap.yml
  9. 6 0
      webchat-client-chat/pom.xml
  10. 44 0
      webchat-client-chat/src/main/java/com/webchat/client/FileController.java
  11. 2 0
      webchat-client-chat/src/main/java/com/webchat/client/WebchatClientApplication.java
  12. 0 1
      webchat-client-chat/src/main/resources/application.properties
  13. 1 0
      webchat-client-chat/src/main/resources/application.yml
  14. 1 1
      webchat-client-chat/src/main/resources/bootstrap.yml
  15. 5 0
      webchat-common/pom.xml
  16. 23 0
      webchat-common/src/main/java/com/webchat/common/config/configuration/MinioConfig.java
  17. 19 0
      webchat-common/src/main/java/com/webchat/common/config/properties/MinioProperties.java
  18. 183 0
      webchat-common/src/main/java/com/webchat/common/service/MinioService.java
  19. BIN
      webchat-common/target/classes/com/webchat/common/bean/APIPageResponseBean.class
  20. BIN
      webchat-common/target/classes/com/webchat/common/bean/APIResponseBean.class
  21. BIN
      webchat-common/target/classes/com/webchat/common/bean/APIResponseBeanUtil.class
  22. BIN
      webchat-common/target/classes/com/webchat/common/config/annotation/SafeClick.class
  23. BIN
      webchat-common/target/classes/com/webchat/common/config/annotation/SafeClickInterceptor.class
  24. BIN
      webchat-common/target/classes/com/webchat/common/config/annotation/ValidateLogin.class
  25. BIN
      webchat-common/target/classes/com/webchat/common/config/annotation/ValidateLoginInterceptor.class
  26. BIN
      webchat-common/target/classes/com/webchat/common/config/annotation/ValidatePermission.class
  27. BIN
      webchat-common/target/classes/com/webchat/common/config/annotation/ValidatePermissionInterceptor.class
  28. BIN
      webchat-common/target/classes/com/webchat/common/config/configuration/WebChatWebMvcConfigurer.class
  29. BIN
      webchat-common/target/classes/com/webchat/common/constants/CookieConstants.class
  30. BIN
      webchat-common/target/classes/com/webchat/common/constants/HttpContentType.class
  31. BIN
      webchat-common/target/classes/com/webchat/common/constants/LotteryConstants$LotteryActivityStatus.class
  32. BIN
      webchat-common/target/classes/com/webchat/common/constants/LotteryConstants$LotteryItemType.class
  33. BIN
      webchat-common/target/classes/com/webchat/common/constants/LotteryConstants$LotteryOrderStatus.class
  34. BIN
      webchat-common/target/classes/com/webchat/common/constants/LotteryConstants.class
  35. BIN
      webchat-common/target/classes/com/webchat/common/constants/MessageConstants$CategoryEnum.class
  36. BIN
      webchat-common/target/classes/com/webchat/common/constants/MessageConstants$TypeEnum.class
  37. BIN
      webchat-common/target/classes/com/webchat/common/constants/MessageConstants.class
  38. BIN
      webchat-common/target/classes/com/webchat/common/constants/WebConstant.class
  39. BIN
      webchat-common/target/classes/com/webchat/common/enums/APIErrorCommonEnum.class
  40. BIN
      webchat-common/target/classes/com/webchat/common/enums/AiFunctionEnum.class
  41. BIN
      webchat-common/target/classes/com/webchat/common/enums/ArticleStatusEnum.class
  42. BIN
      webchat-common/target/classes/com/webchat/common/enums/ChatMessageTypeEnum.class
  43. BIN
      webchat-common/target/classes/com/webchat/common/enums/ClickEvent.class
  44. BIN
      webchat-common/target/classes/com/webchat/common/enums/CommonStatusEnum.class
  45. BIN
      webchat-common/target/classes/com/webchat/common/enums/ContentConfigEnum.class
  46. BIN
      webchat-common/target/classes/com/webchat/common/enums/ESMessageTypeEum.class
  47. BIN
      webchat-common/target/classes/com/webchat/common/enums/FileTypeEnum.class
  48. BIN
      webchat-common/target/classes/com/webchat/common/enums/FriendStatusEnum.class
  49. BIN
      webchat-common/target/classes/com/webchat/common/enums/LlmModelEnum.class
  50. BIN
      webchat-common/target/classes/com/webchat/common/enums/LocalCacheKey.class
  51. BIN
      webchat-common/target/classes/com/webchat/common/enums/MessageTypeEnum.class
  52. BIN
      webchat-common/target/classes/com/webchat/common/enums/PromptTemplateEnum.class
  53. BIN
      webchat-common/target/classes/com/webchat/common/enums/RedPacketStatusEnum.class
  54. BIN
      webchat-common/target/classes/com/webchat/common/enums/RedPacketTypeEnum.class
  55. BIN
      webchat-common/target/classes/com/webchat/common/enums/RedisKeyEnum.class
  56. BIN
      webchat-common/target/classes/com/webchat/common/enums/RedisMessageChannelTopicEnum.class
  57. BIN
      webchat-common/target/classes/com/webchat/common/enums/ResourceBehaviorTypeEnum.class
  58. BIN
      webchat-common/target/classes/com/webchat/common/enums/ResourceTypeEnum.class
  59. BIN
      webchat-common/target/classes/com/webchat/common/enums/RoleCodeEnum.class
  60. BIN
      webchat-common/target/classes/com/webchat/common/enums/SseEmitterBizEnum.class
  61. BIN
      webchat-common/target/classes/com/webchat/common/enums/UserStatusEnum.class
  62. BIN
      webchat-common/target/classes/com/webchat/common/enums/WalletTransEventEnum.class
  63. BIN
      webchat-common/target/classes/com/webchat/common/enums/WalletTransTypeEnum.class
  64. BIN
      webchat-common/target/classes/com/webchat/common/exception/AsyncException.class
  65. BIN
      webchat-common/target/classes/com/webchat/common/exception/AuthException.class
  66. BIN
      webchat-common/target/classes/com/webchat/common/exception/BusinessException.class
  67. BIN
      webchat-common/target/classes/com/webchat/common/exception/NotFoundException.class
  68. BIN
      webchat-common/target/classes/com/webchat/common/exception/ParamException.class
  69. BIN
      webchat-common/target/classes/com/webchat/common/helper/SessionHelper.class
  70. BIN
      webchat-common/target/classes/com/webchat/common/helper/SseEmitterHelper.class
  71. BIN
      webchat-common/target/classes/com/webchat/common/service/RedisMessageSender.class
  72. BIN
      webchat-common/target/classes/com/webchat/common/service/RedisService.class
  73. BIN
      webchat-common/target/classes/com/webchat/common/util/ArticleUtil.class
  74. BIN
      webchat-common/target/classes/com/webchat/common/util/AvatarUtil.class
  75. BIN
      webchat-common/target/classes/com/webchat/common/util/CommonUtils.class
  76. BIN
      webchat-common/target/classes/com/webchat/common/util/DateUtils.class
  77. BIN
      webchat-common/target/classes/com/webchat/common/util/FileConvertUtil.class
  78. BIN
      webchat-common/target/classes/com/webchat/common/util/FileUtil.class
  79. BIN
      webchat-common/target/classes/com/webchat/common/util/HtmlUtil.class
  80. BIN
      webchat-common/target/classes/com/webchat/common/util/HttpClientUtil.class
  81. BIN
      webchat-common/target/classes/com/webchat/common/util/HttpsSSLRequestFactory$1.class
  82. BIN
      webchat-common/target/classes/com/webchat/common/util/HttpsSSLRequestFactory$MyCustomSSLSocketFactory.class
  83. BIN
      webchat-common/target/classes/com/webchat/common/util/HttpsSSLRequestFactory.class
  84. BIN
      webchat-common/target/classes/com/webchat/common/util/IDGenerateUtil.class
  85. BIN
      webchat-common/target/classes/com/webchat/common/util/JsonExtractorFromMarkdown.class
  86. BIN
      webchat-common/target/classes/com/webchat/common/util/JsonUtil.class
  87. BIN
      webchat-common/target/classes/com/webchat/common/util/ListUtil.class
  88. BIN
      webchat-common/target/classes/com/webchat/common/util/MD5Utils.class
  89. BIN
      webchat-common/target/classes/com/webchat/common/util/PicValidCodeUtil.class
  90. BIN
      webchat-common/target/classes/com/webchat/common/util/QRCodeUtils.class
  91. BIN
      webchat-common/target/classes/com/webchat/common/util/RemoteIpUtil.class
  92. BIN
      webchat-common/target/classes/com/webchat/common/util/SpringContextUtil.class
  93. BIN
      webchat-common/target/classes/com/webchat/common/util/StringUtil.class
  94. BIN
      webchat-common/target/classes/com/webchat/common/util/ThreadPoolExecutorUtil.class
  95. BIN
      webchat-common/target/classes/com/webchat/common/util/TransactionSyncManagerUtil$1.class
  96. BIN
      webchat-common/target/classes/com/webchat/common/util/TransactionSyncManagerUtil.class
  97. BIN
      webchat-common/target/classes/com/webchat/common/util/llm/DeepSeekAIClient.class
  98. BIN
      webchat-common/target/classes/com/webchat/common/util/llm/MoonShotAIClient.class
  99. BIN
      webchat-common/target/classes/com/webchat/common/util/obj/PicValidCodeResult.class
  100. 0 2
      webchat-connect/target/classes/application.yml

+ 11 - 0
resources/nacos-yaml/webchat-admin-service-dev.yaml

@@ -0,0 +1,11 @@
+spring:
+  servlet:
+    multipart:
+      max-file-size: 10MB
+      max-request-size: 10MB
+
+minio:
+  endpoint: http://127.0.0.1:9000
+  accessKey: BArEoI6PE8uGh13jHRuN
+  secretKey: eHRL9vpXUH6vGOGkL5Vth2ZQRpzh7AvdKzNlASko
+  bucketName: webchat

+ 11 - 0
resources/nacos-yaml/webchat-client-chat-service-dev.yaml

@@ -0,0 +1,11 @@
+spring:
+  servlet:
+    multipart:
+      max-file-size: 10MB
+      max-request-size: 10MB
+
+minio:
+  endpoint: http://127.0.0.1:9000
+  accessKey: BArEoI6PE8uGh13jHRuN
+  secretKey: eHRL9vpXUH6vGOGkL5Vth2ZQRpzh7AvdKzNlASko
+  bucketName: webchat

+ 7 - 0
webchat-admin/pom.xml

@@ -20,6 +20,13 @@
         <java.version>17</java.version>
         <java.version>17</java.version>
     </properties>
     </properties>
     <dependencies>
     <dependencies>
+
+        <dependency>
+            <groupId>com.webchat</groupId>
+            <artifactId>webchat-remote</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
         <dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter</artifactId>
             <artifactId>spring-boot-starter</artifactId>

+ 2 - 0
webchat-admin/src/main/java/com/webchat/admin/WebchatAdminApplication.java

@@ -2,8 +2,10 @@ package com.webchat.admin;
 
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
 
 
 @SpringBootApplication
 @SpringBootApplication
+@ComponentScan("com.webchat")
 public class WebchatAdminApplication {
 public class WebchatAdminApplication {
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {

+ 46 - 0
webchat-admin/src/main/java/com/webchat/admin/controller/FileController.java

@@ -0,0 +1,46 @@
+package com.webchat.admin.controller;
+
+import com.webchat.common.bean.APIResponseBean;
+import com.webchat.common.bean.APIResponseBeanUtil;
+import com.webchat.common.service.MinioService;
+import com.webchat.common.util.DateUtils;
+import com.webchat.domain.dto.UploadResultDTO;
+import com.webchat.domain.vo.response.UploadResultVO;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+
+@RestController
+@RequestMapping("/admin-service/file")
+public class FileController {
+
+    @Autowired
+    private MinioService minioService;
+    @Autowired
+    private HttpServletRequest request;
+
+    @PostMapping("/upload")
+    public APIResponseBean<UploadResultVO> upload(MultipartFile file) {
+        String path = request.getHeader("upload-path");
+        Assert.isTrue(StringUtils.isNotBlank(path), "上传路径不能为空");
+        String timePackage = DateUtils.getDate2String(DateUtils.YYYYMMDD, new Date());
+        UploadResultVO uploadResultDTO = minioService.upload(path + "/" + timePackage, file, true);
+        return APIResponseBeanUtil.success(uploadResultDTO);
+    }
+
+    @GetMapping("/download")
+    public void download(@RequestParam String filename, HttpServletResponse response) {
+        minioService.download(filename, response);
+    }
+}

+ 0 - 1
webchat-admin/src/main/resources/application.properties

@@ -1 +0,0 @@
-spring.application.name=webchat-admin

+ 1 - 0
webchat-admin/src/main/resources/application.yml

@@ -0,0 +1 @@
+server:
  port: 8081

+ 1 - 1
webchat-pgc/target/classes/bootstrap.yml → webchat-admin/src/main/resources/bootstrap.yml

@@ -1,6 +1,6 @@
 spring:
 spring:
   application:
   application:
-    name: webchat-pgc-service
+    name: webchat-admin-service
   profiles:
   profiles:
     active: dev
     active: dev
   cloud:
   cloud:

+ 6 - 0
webchat-client-chat/pom.xml

@@ -20,6 +20,12 @@
         <java.version>17</java.version>
         <java.version>17</java.version>
     </properties>
     </properties>
     <dependencies>
     <dependencies>
+
+        <dependency>
+            <groupId>com.webchat</groupId>
+            <artifactId>webchat-remote</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
         <dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter</artifactId>
             <artifactId>spring-boot-starter</artifactId>

+ 44 - 0
webchat-client-chat/src/main/java/com/webchat/client/FileController.java

@@ -0,0 +1,44 @@
+package com.webchat.client;
+
+import com.webchat.common.bean.APIResponseBean;
+import com.webchat.common.bean.APIResponseBeanUtil;
+import com.webchat.common.service.MinioService;
+import com.webchat.common.util.DateUtils;
+import com.webchat.domain.vo.response.UploadResultVO;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+
+@RestController
+@RequestMapping("/client-service/chat/file")
+public class FileController {
+
+    @Autowired
+    private MinioService minioService;
+    @Autowired
+    private HttpServletRequest request;
+
+    @PostMapping("/upload")
+    public APIResponseBean<UploadResultVO> upload(MultipartFile file) {
+        String path = request.getHeader("upload-path");
+        Assert.isTrue(StringUtils.isNotBlank(path), "上传路径不能为空");
+        String timePackage = DateUtils.getDate2String(DateUtils.YYYYMMDD, new Date());
+        UploadResultVO uploadResultDTO = minioService.upload(path + "/" + timePackage, file, true);
+        return APIResponseBeanUtil.success(uploadResultDTO);
+    }
+
+    @GetMapping("/download")
+    public void download(@RequestParam String filename, HttpServletResponse response) {
+        minioService.download(filename, response);
+    }
+}

+ 2 - 0
webchat-client-chat/src/main/java/com/webchat/client/WebchatClientApplication.java

@@ -2,8 +2,10 @@ package com.webchat.client;
 
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
 
 
 @SpringBootApplication
 @SpringBootApplication
+@ComponentScan("com.webchat")
 public class WebchatClientApplication {
 public class WebchatClientApplication {
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {

+ 0 - 1
webchat-client-chat/src/main/resources/application.properties

@@ -1 +0,0 @@
-spring.application.name=webchat-client

+ 1 - 0
webchat-client-chat/src/main/resources/application.yml

@@ -0,0 +1 @@
+server:
  port: 8082

+ 1 - 1
webchat-connect/target/classes/bootstrap.yml → webchat-client-chat/src/main/resources/bootstrap.yml

@@ -1,6 +1,6 @@
 spring:
 spring:
   application:
   application:
-    name: webchat-connect-service
+    name: webchat-client-chat-service
   profiles:
   profiles:
     active: dev
     active: dev
   cloud:
   cloud:

+ 5 - 0
webchat-common/pom.xml

@@ -22,6 +22,11 @@
 
 
     <dependencies>
     <dependencies>
         <dependency>
         <dependency>
+            <groupId>io.minio</groupId>
+            <artifactId>minio</artifactId>
+            <version>8.4.2</version>
+        </dependency>
+        <dependency>
             <groupId>com.webchat</groupId>
             <groupId>com.webchat</groupId>
             <artifactId>webchat-domain</artifactId>
             <artifactId>webchat-domain</artifactId>
             <version>1.0-SNAPSHOT</version>
             <version>1.0-SNAPSHOT</version>

+ 23 - 0
webchat-common/src/main/java/com/webchat/common/config/configuration/MinioConfig.java

@@ -0,0 +1,23 @@
+package com.webchat.common.config.configuration;
+
+
+import com.webchat.common.config.properties.MinioProperties;
+import io.minio.MinioClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MinioConfig {
+
+    @Autowired
+    private MinioProperties properties;
+
+    @Bean
+    public MinioClient minioClient() {
+        return MinioClient.builder()
+                .endpoint(properties.getEndpoint())
+                .credentials(properties.getAccessKey(), properties.getSecretKey())
+                .build();
+    }
+}

+ 19 - 0
webchat-common/src/main/java/com/webchat/common/config/properties/MinioProperties.java

@@ -0,0 +1,19 @@
+package com.webchat.common.config.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "minio")
+public class MinioProperties {
+
+    private String endpoint = "http://localhost:9000";
+
+    private String accessKey = "BArEoI6PE8uGh13jHRuN";
+
+    private String secretKey = "eHRL9vpXUH6vGOGkL5Vth2ZQRpzh7AvdKzNlASko";;
+
+    private String bucketName = "webchat";
+}

+ 183 - 0
webchat-common/src/main/java/com/webchat/common/service/MinioService.java

@@ -0,0 +1,183 @@
+package com.webchat.common.service;
+
+import com.webchat.common.config.properties.MinioProperties;
+import com.webchat.common.enums.FileTypeEnum;
+import com.webchat.domain.dto.UploadResultDTO;
+import com.webchat.domain.vo.response.UploadResultVO;
+import io.minio.GetObjectArgs;
+import io.minio.MinioClient;
+import io.minio.PutObjectArgs;
+import io.minio.UploadObjectArgs;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.util.Arrays;
+import java.util.List;
+
+@Service
+public class MinioService {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(MinioService.class);
+
+    @Autowired
+    private MinioClient minioClient;
+
+    @Autowired
+    private MinioProperties properties;
+
+    /**
+     * 定义图片和视频的MIME类型列表
+     */
+    private static final List<String> IMAGE_MIME_TYPES = Arrays.asList("image/jpeg", "image/png", "image/gif", "image/bmp");
+    private static final List<String> VIDEO_MIME_TYPES = Arrays.asList("video/mp4", "video/quicktime", "video/x-msvideo", "video/3gpp", "video/3gpp2", "video/webm", "video/ogg");
+
+    /**
+     * 上传文件到Minio服务器
+     *
+     * @param file
+     * @return
+     */
+    public boolean upload(File file) {
+        String filename = file.getName();
+        try {
+            minioClient.uploadObject(UploadObjectArgs.builder()
+                    .bucket(properties.getBucketName())
+                    .object(filename)
+                    .filename(file.getAbsolutePath())
+                    .build());
+            return true;
+        } catch (Exception e) {
+            LOGGER.error("file upload minio exception, file name: {}", filename, e);
+            return false;
+        }
+    }
+
+    /**
+     * 前端的文件上传
+     *
+     * @param file
+     * @return
+     */
+    public boolean upload(MultipartFile file) {
+        String filename = file.getOriginalFilename();
+        try {
+            InputStream inputStream = file.getInputStream();
+            minioClient.putObject(PutObjectArgs.builder()
+                    .bucket(properties.getBucketName())
+                    .object(filename)
+                    .stream(inputStream, inputStream.available(), -1)
+                    .contentType(file.getContentType())
+                    .build());
+            return true;
+        } catch (Exception e) {
+            LOGGER.error("file upload minio exception, file name: {}", filename, e);
+            return false;
+        }
+    }
+
+    /**
+     * 上传到Minio指定路径
+     *
+     * @param path
+     * @param file
+     * @return
+     */
+    public boolean upload(String path, MultipartFile file) {
+        String filename = file.getOriginalFilename();
+        try {
+            filename = path + filename;
+            InputStream inputStream = file.getInputStream();
+            minioClient.putObject(PutObjectArgs.builder()
+                    .bucket(properties.getBucketName())
+                    .object(filename)
+                    .stream(inputStream, inputStream.available(), -1)
+                    .contentType(file.getContentType())
+                    .build());
+            return true;
+        } catch (Exception e) {
+            LOGGER.error("file upload minio exception, file name: {}", filename, e);
+            return false;
+        }
+    }
+
+    /**
+     * 上传到Minio指定目录,可选择自定义随机文件名
+     *
+     * @param path
+     * @param file
+     * @param isRandom
+     * @return
+     */
+    public UploadResultVO upload(String path, MultipartFile file, Boolean isRandom) {
+        String filename = file.getOriginalFilename();
+        if (Boolean.TRUE.equals(isRandom)) {
+            long millis = System.currentTimeMillis();
+            String extension = filename.substring(filename.lastIndexOf(".") + 1);
+            filename = millis + "." + extension;
+        }
+        try {
+            filename = path + "/" + filename;
+            InputStream inputStream = file.getInputStream();
+            minioClient.putObject(PutObjectArgs.builder()
+                    .bucket(properties.getBucketName())
+                    .object(filename)
+                    .stream(inputStream, inputStream.available(), -1)
+                    .contentType(file.getContentType())
+                    .build());
+            String resourceUrl = properties.getEndpoint() + "/" + properties.getBucketName() + "/" + filename;
+            return UploadResultVO.of(resourceUrl, fileType(file), filename);
+        } catch (Exception e) {
+            LOGGER.error("file upload minio exception, file name: {}, source file name: {}", filename, file.getOriginalFilename(), e);
+            return null;
+        }
+    }
+
+    private String fileType(MultipartFile file) {
+        // 获取文件的MIME类型
+        String mimeType = file.getContentType();
+        // 发布动态上传文件仅支持图片和视频
+        if (IMAGE_MIME_TYPES.contains(mimeType)) {
+            return FileTypeEnum.IMAGE.name();
+        }
+        if (VIDEO_MIME_TYPES.contains(mimeType)) {
+            return FileTypeEnum.VIDEO.name();
+        }
+        return FileTypeEnum.OTHER.name();
+    }
+
+    /**
+     * 文件下载
+     *
+     * @param filename
+     * @param response
+     */
+    public void download(String filename, HttpServletResponse response) {
+        response.reset();
+        try(InputStream inputStream = minioClient.getObject(GetObjectArgs.builder()
+                .bucket(properties.getBucketName())
+                .object(filename)
+                .build())) {
+            filename = filename.substring(filename.lastIndexOf("/") + 1);
+            ServletOutputStream outputStream = response.getOutputStream();
+            response.setContentType("application/octet-stream");
+            response.setCharacterEncoding("utf-8");
+            response.addHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));
+            byte[] bytes = new byte[1024];
+            int len;
+            while ((len = inputStream.read(bytes)) > 0) {
+                outputStream.write(bytes, 0, len);
+            }
+            outputStream.close();
+        } catch (Exception e) {
+            LOGGER.error("file download from minio exception, file name: {}", filename,  e);
+        }
+    }
+}

BIN
webchat-common/target/classes/com/webchat/common/bean/APIPageResponseBean.class


BIN
webchat-common/target/classes/com/webchat/common/bean/APIResponseBean.class


BIN
webchat-common/target/classes/com/webchat/common/bean/APIResponseBeanUtil.class


BIN
webchat-common/target/classes/com/webchat/common/config/annotation/SafeClick.class


BIN
webchat-common/target/classes/com/webchat/common/config/annotation/SafeClickInterceptor.class


BIN
webchat-common/target/classes/com/webchat/common/config/annotation/ValidateLogin.class


BIN
webchat-common/target/classes/com/webchat/common/config/annotation/ValidateLoginInterceptor.class


BIN
webchat-common/target/classes/com/webchat/common/config/annotation/ValidatePermission.class


BIN
webchat-common/target/classes/com/webchat/common/config/annotation/ValidatePermissionInterceptor.class


BIN
webchat-common/target/classes/com/webchat/common/config/configuration/WebChatWebMvcConfigurer.class


BIN
webchat-common/target/classes/com/webchat/common/constants/CookieConstants.class


BIN
webchat-common/target/classes/com/webchat/common/constants/HttpContentType.class


BIN
webchat-common/target/classes/com/webchat/common/constants/LotteryConstants$LotteryActivityStatus.class


BIN
webchat-common/target/classes/com/webchat/common/constants/LotteryConstants$LotteryItemType.class


BIN
webchat-common/target/classes/com/webchat/common/constants/LotteryConstants$LotteryOrderStatus.class


BIN
webchat-common/target/classes/com/webchat/common/constants/LotteryConstants.class


BIN
webchat-common/target/classes/com/webchat/common/constants/MessageConstants$CategoryEnum.class


BIN
webchat-common/target/classes/com/webchat/common/constants/MessageConstants$TypeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/constants/MessageConstants.class


BIN
webchat-common/target/classes/com/webchat/common/constants/WebConstant.class


BIN
webchat-common/target/classes/com/webchat/common/enums/APIErrorCommonEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/AiFunctionEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/ArticleStatusEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/ChatMessageTypeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/ClickEvent.class


BIN
webchat-common/target/classes/com/webchat/common/enums/CommonStatusEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/ContentConfigEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/ESMessageTypeEum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/FileTypeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/FriendStatusEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/LlmModelEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/LocalCacheKey.class


BIN
webchat-common/target/classes/com/webchat/common/enums/MessageTypeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/PromptTemplateEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/RedPacketStatusEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/RedPacketTypeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/RedisKeyEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/RedisMessageChannelTopicEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/ResourceBehaviorTypeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/ResourceTypeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/RoleCodeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/SseEmitterBizEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/UserStatusEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/WalletTransEventEnum.class


BIN
webchat-common/target/classes/com/webchat/common/enums/WalletTransTypeEnum.class


BIN
webchat-common/target/classes/com/webchat/common/exception/AsyncException.class


BIN
webchat-common/target/classes/com/webchat/common/exception/AuthException.class


BIN
webchat-common/target/classes/com/webchat/common/exception/BusinessException.class


BIN
webchat-common/target/classes/com/webchat/common/exception/NotFoundException.class


BIN
webchat-common/target/classes/com/webchat/common/exception/ParamException.class


BIN
webchat-common/target/classes/com/webchat/common/helper/SessionHelper.class


BIN
webchat-common/target/classes/com/webchat/common/helper/SseEmitterHelper.class


BIN
webchat-common/target/classes/com/webchat/common/service/RedisMessageSender.class


BIN
webchat-common/target/classes/com/webchat/common/service/RedisService.class


BIN
webchat-common/target/classes/com/webchat/common/util/ArticleUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/AvatarUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/CommonUtils.class


BIN
webchat-common/target/classes/com/webchat/common/util/DateUtils.class


BIN
webchat-common/target/classes/com/webchat/common/util/FileConvertUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/FileUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/HtmlUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/HttpClientUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/HttpsSSLRequestFactory$1.class


BIN
webchat-common/target/classes/com/webchat/common/util/HttpsSSLRequestFactory$MyCustomSSLSocketFactory.class


BIN
webchat-common/target/classes/com/webchat/common/util/HttpsSSLRequestFactory.class


BIN
webchat-common/target/classes/com/webchat/common/util/IDGenerateUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/JsonExtractorFromMarkdown.class


BIN
webchat-common/target/classes/com/webchat/common/util/JsonUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/ListUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/MD5Utils.class


BIN
webchat-common/target/classes/com/webchat/common/util/PicValidCodeUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/QRCodeUtils.class


BIN
webchat-common/target/classes/com/webchat/common/util/RemoteIpUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/SpringContextUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/StringUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/ThreadPoolExecutorUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/TransactionSyncManagerUtil$1.class


BIN
webchat-common/target/classes/com/webchat/common/util/TransactionSyncManagerUtil.class


BIN
webchat-common/target/classes/com/webchat/common/util/llm/DeepSeekAIClient.class


BIN
webchat-common/target/classes/com/webchat/common/util/llm/MoonShotAIClient.class


BIN
webchat-common/target/classes/com/webchat/common/util/obj/PicValidCodeResult.class


+ 0 - 2
webchat-connect/target/classes/application.yml

@@ -1,2 +0,0 @@
-server:
-  port: 8088

Some files were not shown because too many files changed in this diff