From 585dd4290db78587e1491431645beb7418d7ef5f Mon Sep 17 00:00:00 2001
From: bunny <1319900154@qq.com>
Date: Sun, 6 Jul 2025 23:15:28 +0800
Subject: [PATCH] =?UTF-8?q?:tada:=20=E5=88=9D=E5=A7=8B=E5=8C=96=E7=AC=AC?=
=?UTF-8?q?=E4=B8=89=E6=96=B9=E6=8F=92=E4=BB=B6=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
mall-common/pom.xml | 24 +-
mall-gateway/pom.xml | 4 -
.../mall/gateway/MallGatewayApplication.java | 2 +
.../main/resources/application-routes.yaml | 9 +-
.../src/main/resources/application.yaml | 8 +-
mall-product/pom.xml | 11 +
.../src/main/resources/application.yaml | 7 +-
mall-third-party/pom.xml | 69 +++++
.../src/main/java/com/mall/App.java | 13 -
.../thirdParty/MallThirdPartyApplication.java | 15 +
.../mall/thirdParty/client/AliOssClient.java | 66 +++++
.../mall/thirdParty/config/Knife4jConfig.java | 54 ++++
.../controller/AliOssController.java | 29 ++
.../thirdParty/service/AliOssService.java | 12 +
.../service/ext/AliOssServiceImplExt.java | 61 ++++
.../service/impl/AliOssServiceImpl.java | 84 ++++++
.../src/main/resources/application-dev.yml | 22 ++
.../src/main/resources/application.yaml | 27 ++
.../src/main/resources/banner.txt | 13 +
.../src/main/resources/logback.xml | 72 +++++
.../src/main/resources/static/error/400.html | 69 +++++
.../src/main/resources/static/error/403.html | 69 +++++
.../src/main/resources/static/error/404.html | 78 +++++
.../src/main/resources/static/error/500.html | 64 +++++
.../src/main/resources/static/error/501.html | 66 +++++
.../src/main/resources/static/error/502.html | 80 ++++++
.../src/main/resources/static/error/503.html | 69 +++++
.../src/main/resources/static/error/504.html | 81 ++++++
.../src/main/resources/static/error/505.html | 72 +++++
.../src/main/resources/static/error/506.html | 66 +++++
.../src/main/resources/static/error/507.html | 66 +++++
.../src/main/resources/static/error/509.html | 66 +++++
.../src/main/resources/static/error/510.html | 66 +++++
.../src/main/resources/static/favicon.ico | Bin 0 -> 17014 bytes
.../static/images/architecture-diagram.jpg | Bin 0 -> 355597 bytes
.../src/main/resources/templates/index.html | 266 ++++++++++++++++++
mall-third-party/src/test/java/Demo.java | 82 ++++++
.../thirdParty/config/AliOssClientTest.java | 54 ++++
pom.xml | 4 +-
39 files changed, 1878 insertions(+), 42 deletions(-)
delete mode 100644 mall-third-party/src/main/java/com/mall/App.java
create mode 100644 mall-third-party/src/main/java/com/mall/thirdParty/MallThirdPartyApplication.java
create mode 100644 mall-third-party/src/main/java/com/mall/thirdParty/client/AliOssClient.java
create mode 100644 mall-third-party/src/main/java/com/mall/thirdParty/config/Knife4jConfig.java
create mode 100644 mall-third-party/src/main/java/com/mall/thirdParty/controller/AliOssController.java
create mode 100644 mall-third-party/src/main/java/com/mall/thirdParty/service/AliOssService.java
create mode 100644 mall-third-party/src/main/java/com/mall/thirdParty/service/ext/AliOssServiceImplExt.java
create mode 100644 mall-third-party/src/main/java/com/mall/thirdParty/service/impl/AliOssServiceImpl.java
create mode 100644 mall-third-party/src/main/resources/application-dev.yml
create mode 100644 mall-third-party/src/main/resources/application.yaml
create mode 100644 mall-third-party/src/main/resources/banner.txt
create mode 100644 mall-third-party/src/main/resources/logback.xml
create mode 100644 mall-third-party/src/main/resources/static/error/400.html
create mode 100644 mall-third-party/src/main/resources/static/error/403.html
create mode 100644 mall-third-party/src/main/resources/static/error/404.html
create mode 100644 mall-third-party/src/main/resources/static/error/500.html
create mode 100644 mall-third-party/src/main/resources/static/error/501.html
create mode 100644 mall-third-party/src/main/resources/static/error/502.html
create mode 100644 mall-third-party/src/main/resources/static/error/503.html
create mode 100644 mall-third-party/src/main/resources/static/error/504.html
create mode 100644 mall-third-party/src/main/resources/static/error/505.html
create mode 100644 mall-third-party/src/main/resources/static/error/506.html
create mode 100644 mall-third-party/src/main/resources/static/error/507.html
create mode 100644 mall-third-party/src/main/resources/static/error/509.html
create mode 100644 mall-third-party/src/main/resources/static/error/510.html
create mode 100644 mall-third-party/src/main/resources/static/favicon.ico
create mode 100644 mall-third-party/src/main/resources/static/images/architecture-diagram.jpg
create mode 100644 mall-third-party/src/main/resources/templates/index.html
create mode 100644 mall-third-party/src/test/java/Demo.java
create mode 100644 mall-third-party/src/test/java/com/mall/thirdParty/config/AliOssClientTest.java
diff --git a/mall-common/pom.xml b/mall-common/pom.xml
index 1e6424b..ba550d8 100644
--- a/mall-common/pom.xml
+++ b/mall-common/pom.xml
@@ -24,23 +24,15 @@
lombok
+
+ com.github.ben-manes.caffeine
+ caffeine
+
org.springframework.boot
spring-boot-starter-thymeleaf
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- junit
- junit
- test
-
-
com.alibaba.cloud
@@ -54,10 +46,10 @@
-
-
-
-
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
diff --git a/mall-gateway/pom.xml b/mall-gateway/pom.xml
index 51075b7..17fd885 100644
--- a/mall-gateway/pom.xml
+++ b/mall-gateway/pom.xml
@@ -36,9 +36,5 @@
org.springframework.cloud
spring-cloud-starter-gateway
-
-
-
-
diff --git a/mall-gateway/src/main/java/com/mall/gateway/MallGatewayApplication.java b/mall-gateway/src/main/java/com/mall/gateway/MallGatewayApplication.java
index 7220dfe..10e06c0 100644
--- a/mall-gateway/src/main/java/com/mall/gateway/MallGatewayApplication.java
+++ b/mall-gateway/src/main/java/com/mall/gateway/MallGatewayApplication.java
@@ -3,8 +3,10 @@ package com.mall.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
+@EnableDiscoveryClient
public class MallGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(MallGatewayApplication.class, args);
diff --git a/mall-gateway/src/main/resources/application-routes.yaml b/mall-gateway/src/main/resources/application-routes.yaml
index da5ca6d..6b79c5c 100644
--- a/mall-gateway/src/main/resources/application-routes.yaml
+++ b/mall-gateway/src/main/resources/application-routes.yaml
@@ -11,9 +11,8 @@ spring:
- "*"
allowed-methods:
- "*"
- allowed-origins:
- - "*"
allow-credentials: true
+
routes:
- id: route-product
uri: lb://service-product
@@ -32,4 +31,8 @@ spring:
- id: route-coupon
uri: lb://service-coupon
predicates:
- - Path=/api/coupon/**
\ No newline at end of file
+ - Path=/api/coupon/**
+ - id: route-third-party
+ uri: lb://service-third-party
+ predicates:
+ - Path=/api/third-party/**
\ No newline at end of file
diff --git a/mall-gateway/src/main/resources/application.yaml b/mall-gateway/src/main/resources/application.yaml
index b950296..02d80ab 100644
--- a/mall-gateway/src/main/resources/application.yaml
+++ b/mall-gateway/src/main/resources/application.yaml
@@ -7,12 +7,16 @@ spring:
- routes
application:
name: service-gateway
+ devtools:
+ livereload:
+ port: 0
cloud:
nacos:
server-addr: bunny-web.site:8848
- username: admin
- password: admin123
+ config:
+ import-check:
+ enabled: false
jackson:
date-format: yyyy-MM-dd HH:mm:ss
diff --git a/mall-product/pom.xml b/mall-product/pom.xml
index cd770ee..86c8b8e 100644
--- a/mall-product/pom.xml
+++ b/mall-product/pom.xml
@@ -31,6 +31,17 @@
runtime
true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ junit
+ junit
+ test
+
org.springframework.boot
diff --git a/mall-product/src/main/resources/application.yaml b/mall-product/src/main/resources/application.yaml
index a5a84b0..3721ea7 100644
--- a/mall-product/src/main/resources/application.yaml
+++ b/mall-product/src/main/resources/application.yaml
@@ -17,6 +17,9 @@ spring:
maximum-pool-size: 20
connection-timeout: 30000
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+
mybatis-plus:
mapper-locations: classpath:/mapper/*.xml
global-config:
@@ -25,5 +28,5 @@ mybatis-plus:
logic-delete-value: 1
logic-not-delete-value: 0
- jackson:
- date-format: yyyy-MM-dd HH:mm:ss
\ No newline at end of file
+# LTAI5tMynexvsUvznfXXL6x4
+# 8H3EwbyvCKQ9FiTpnRzOojmHg1NKpg
\ No newline at end of file
diff --git a/mall-third-party/pom.xml b/mall-third-party/pom.xml
index c8a4486..6aae891 100644
--- a/mall-third-party/pom.xml
+++ b/mall-third-party/pom.xml
@@ -18,6 +18,75 @@
+
+ com.mall
+ mall-common
+ 1.0-SNAPSHOT
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+
+
+ com.mysql
+ mysql-connector-j
+
+
+ com.zaxxer
+ HikariCP
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ junit
+ junit
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+ 3.18.2
+
+
+ com.aliyun
+ alibabacloud-secretsmanager-client
+ 1.3.7
+
+
+ com.aliyun
+ aliyun-java-sdk-core
+ 4.7.0
+
+
+ com.aliyun
+ sts20150401
+ 1.1.6
+
diff --git a/mall-third-party/src/main/java/com/mall/App.java b/mall-third-party/src/main/java/com/mall/App.java
deleted file mode 100644
index 38d1876..0000000
--- a/mall-third-party/src/main/java/com/mall/App.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.mall;
-
-/**
- * Hello world!
- *
- */
-public class App
-{
- public static void main( String[] args )
- {
- System.out.println( "Hello World!" );
- }
-}
diff --git a/mall-third-party/src/main/java/com/mall/thirdParty/MallThirdPartyApplication.java b/mall-third-party/src/main/java/com/mall/thirdParty/MallThirdPartyApplication.java
new file mode 100644
index 0000000..5f08255
--- /dev/null
+++ b/mall-third-party/src/main/java/com/mall/thirdParty/MallThirdPartyApplication.java
@@ -0,0 +1,15 @@
+package com.mall.thirdParty;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+
+@EnableDiscoveryClient
+@RefreshScope
+@SpringBootApplication()
+public class MallThirdPartyApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(MallThirdPartyApplication.class, args);
+ }
+}
diff --git a/mall-third-party/src/main/java/com/mall/thirdParty/client/AliOssClient.java b/mall-third-party/src/main/java/com/mall/thirdParty/client/AliOssClient.java
new file mode 100644
index 0000000..fba39cb
--- /dev/null
+++ b/mall-third-party/src/main/java/com/mall/thirdParty/client/AliOssClient.java
@@ -0,0 +1,66 @@
+package com.mall.thirdParty.client;
+
+import com.aliyun.oss.ClientBuilderConfiguration;
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.common.auth.Credentials;
+import com.aliyun.oss.common.auth.CredentialsProvider;
+import com.aliyun.oss.common.auth.DefaultCredentials;
+import com.aliyun.oss.common.comm.SignVersion;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ConfigurationProperties(prefix = "aliyun.oss")
+@Data
+@Slf4j
+public class AliOssClient {
+
+ @Value("${aliyun.oss.endpoint}")
+ String endpoint;
+
+ @Value("${aliyun.oss.accessKeyId}")
+ String accessKeyId;
+
+ @Value("${aliyun.oss.accessKeySecrect}")
+ String accessKeySecrect;
+
+ @Value("${aliyun.oss.bucketName}")
+ String bucketName;
+
+ @Value("${aliyun.oss.region}")
+ String region;
+
+ @Bean("AliOssClient")
+ public OSS aliOssClient() {
+ CredentialsProvider credentialsProvider = new CredentialsProvider() {
+ @Override
+ public Credentials getCredentials() {
+ return new DefaultCredentials(accessKeyId, accessKeySecrect);
+ }
+
+ @Override
+ public void setCredentials(Credentials credentials) {
+ }
+ };
+
+ try {
+ ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
+ clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
+ return OSSClientBuilder.create()
+ .endpoint(endpoint)
+ .credentialsProvider(credentialsProvider)
+ .clientConfiguration(clientBuilderConfiguration)
+ .region(region)
+ .build();
+ } catch (Exception exception) {
+ log.error(exception.getMessage(), exception);
+ }
+
+ return null;
+ }
+}
diff --git a/mall-third-party/src/main/java/com/mall/thirdParty/config/Knife4jConfig.java b/mall-third-party/src/main/java/com/mall/thirdParty/config/Knife4jConfig.java
new file mode 100644
index 0000000..c65719a
--- /dev/null
+++ b/mall-third-party/src/main/java/com/mall/thirdParty/config/Knife4jConfig.java
@@ -0,0 +1,54 @@
+package com.mall.thirdParty.config;
+
+import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
+import io.swagger.v3.oas.models.ExternalDocumentation;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
+import lombok.extern.slf4j.Slf4j;
+import org.springdoc.core.models.GroupedOpenApi;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableKnife4j
+@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.ANY)
+@Slf4j
+public class Knife4jConfig {
+
+ @Value("${server.port}")
+ private String port;
+
+ @Bean
+ public OpenAPI openAPI() {
+ String url = "http://localhost:" + port;
+
+ // 作者等信息
+ Contact contact = new Contact().name("Bunny").email("1319900154@qq.com").url(url);
+ // 使用协议
+ License license = new License().name("MIT").url("https://mit-license.org");
+ // 相关信息
+ Info info = new Info().title("Bunny-Admin")
+ .contact(contact).license(license)
+ .description("BunnyMall商城")
+ .summary("Bunny商城")
+ .termsOfService(url)
+ .version("v0.0.1");
+
+ return new OpenAPI().info(info).externalDocs(new ExternalDocumentation());
+ }
+
+ @Bean
+ public GroupedOpenApi all() {
+ return GroupedOpenApi.builder().group("全部请求接口").pathsToMatch("/api/**").build();
+ }
+
+ @Bean
+ public GroupedOpenApi product() {
+ return GroupedOpenApi.builder().group("第三方请求接口").pathsToMatch("/api/third-party/**").build();
+ }
+
+}
diff --git a/mall-third-party/src/main/java/com/mall/thirdParty/controller/AliOssController.java b/mall-third-party/src/main/java/com/mall/thirdParty/controller/AliOssController.java
new file mode 100644
index 0000000..eed48c9
--- /dev/null
+++ b/mall-third-party/src/main/java/com/mall/thirdParty/controller/AliOssController.java
@@ -0,0 +1,29 @@
+package com.mall.thirdParty.controller;
+
+import com.mall.common.domain.vo.result.Result;
+import com.mall.thirdParty.service.AliOssService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+@Tag(name = "阿里云上传文件", description = "阿里云上传文件相关接口")
+@RestController
+@RequestMapping("/api/third-party")
+@RequiredArgsConstructor
+public class AliOssController {
+
+ private final AliOssService aliOssService;
+
+ @GetMapping("/oss/policy")
+ @Operation(summary = "oss请求Token", description = "oss请求Token")
+ public Result