幻雨堂
2024-02-29 760fea77a7fcfaf59ceebffc3c4355e9cfa133ea
配置
3个文件已修改
105 ■■■■■ 已修改文件
dujy-admin/src/main/resources/application-dev.yml 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dujy-admin/src/main/resources/application.yml 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dujy-modules/dujy-demo/src/main/java/org/dromara/demo/util/MinioUtil.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dujy-admin/src/main/resources/application-dev.yml
@@ -36,23 +36,23 @@
      hibernate:
        format_sql: true
  graphql:
    path: /graphql
    graphiql:
      enabled: true
      path: /graphiql
    cors:
      allow-credentials: true
      allowed-headers: '*'
      allowed-methods: '*'
    schema:
      locations:
        - classpath*:graphql/
      file-extensions:
        - .graphql
        - .gqls
      printer:
        enabled: true
#  graphql:
#    path: /graphql
#    graphiql:
#      enabled: true
#      path: /graphiql
#    cors:
#      allow-credentials: true
#      allowed-headers: '*'
#      allowed-methods: '*'
#    schema:
#      locations:
#        - classpath*:graphql/
#      file-extensions:
#        - .graphql
#        - .gqls
#      printer:
#        enabled: true
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    # 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
@@ -123,16 +123,16 @@
spring.data:
  redis:
    # 地址
    host: 162.14.79.111
    host: 42.193.1.25
    # 端口,默认为6379
    port: 6379
    password: 234#Wersdf!
    password: ycl2018
    # 数据库索引
    database: 0
    # 密码(如没有密码请注释掉)
    # password:
    # 连接超时时间
    timeout: 10s
    timeout: 20s
    # 是否开启ssl
    ssl.enabled: false
@@ -277,3 +277,8 @@
      client-id: 10**********6
      client-secret: 1f7d08**********5b7**********29e
      redirect-uri: ${justauth.address}/social-callback?source=gitlab
minio:
  endpoint: http://127.0.0.1:9000
  accessKey: UqCoWBRAVf7DI1gcznSg
  secretKey: UL4hmEIcgFpTmSaJEpYTiQDIWHEG4RavPxTyMjgX
  bucketName: dujyimage
dujy-admin/src/main/resources/application.yml
@@ -125,19 +125,19 @@
    - /actuator/**
# 多租户配置
tenant:
  # 是否开启
  enable: true
  # 排除表
  excludes:
    - sys_menu
    - sys_tenant
    - sys_tenant_package
    - sys_role_dept
    - sys_role_menu
    - sys_user_post
    - sys_user_role
    - sys_client
#tenant:
#  # 是否开启
#  enable: true
#  # 排除表
#  excludes:
#    - sys_menu
#    - sys_tenant
#    - sys_tenant_package
#    - sys_role_dept
#    - sys_role_menu
#    - sys_user_post
#    - sys_user_role
#    - sys_client
# MyBatisPlus配置
# https://baomidou.com/config/
dujy-modules/dujy-demo/src/main/java/org/dromara/demo/util/MinioUtil.java
@@ -5,7 +5,10 @@
import io.minio.messages.DeleteError;
import io.minio.messages.DeleteObject;
import io.minio.messages.Item;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.compress.utils.IOUtils;
import org.dromara.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
@@ -20,6 +23,7 @@
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -215,10 +219,34 @@
    }
    /**
     * 查看文件对象
     * @param bucketName 存储bucket名称
     * @return 存储bucket内文件对象信息
     * 下载文件
     *
     * @param originalName 文件路径
     */
    public InputStream downloadFile(String originalName, HttpServletResponse response) {
        try {
            InputStream file = minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(originalName).build());
            String filename = new String(originalName.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
            if (StringUtils.isNotBlank(originalName)) {
                filename = originalName;
            }
            response.setHeader("Content-Disposition", "attachment;filename=" + filename);
            ServletOutputStream servletOutputStream = response.getOutputStream();
            int len;
            byte[] buffer = new byte[1024];
            while ((len = file.read(buffer)) > 0) {
                servletOutputStream.write(buffer, 0, len);
            }
            servletOutputStream.flush();
            file.close();
            servletOutputStream.close();
            return file;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**