commit 772d61ef4c7516a8a1f2df8b069df1d0bd0985fb
Author: YuanYh <2972788632@qq.com>
Date: Thu Apr 18 22:20:06 2024 +0800
网关
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3e403e3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,35 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..35410ca
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..63574ec
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..e2044d1
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..37614f4
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,299 @@
+
+
+ 4.0.0
+
+ com.yyh
+ GatewayLoadCenter
+ 1.0-SNAPSHOT
+ jar
+
+
+ 17
+ 17
+ UTF-8
+ 2.7.13
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+ com.alibaba.fastjson2
+ fastjson2
+ 2.0.47
+
+
+
+
+
+
+
+ com.aliyun
+ ecs20140526
+ 3.1.2
+
+
+ com.aliyun
+ tea-openapi
+ 0.3.2
+
+
+ com.aliyun
+ tea-util
+ 0.2.21
+
+
+ com.aliyun
+ darabonba-number
+ 0.0.3
+
+
+ com.aliyun
+ tea-console
+ 0.0.1
+
+
+ com.aliyun
+ darabonba-env
+ 0.1.1
+
+
+ com.aliyun
+ tea
+ 1.1.14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.aliyun
+ darabonba-string
+ 0.0.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.3
+ true
+
+ sonatype-nexus-staging
+ https://s01.oss.sonatype.org/
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.1.1
+
+ UTF-8
+ none
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.1
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 2.4.1
+
+
+ jar-with-dependencies
+
+
+
+ true
+ com.aliyun.sample.Sample
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/yyh/GatewayLoadCenter.java b/src/main/java/com/yyh/GatewayLoadCenter.java
new file mode 100644
index 0000000..e36d2d3
--- /dev/null
+++ b/src/main/java/com/yyh/GatewayLoadCenter.java
@@ -0,0 +1,17 @@
+package com.yyh;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @ClassName GatewayLoadCenter
+ * @Description TODO
+ * @Author YuanYongH
+ * @Date 2024/4/18 15:34
+ */
+@SpringBootApplication
+public class GatewayLoadCenter {
+ public static void main(String[] args) {
+ SpringApplication.run(GatewayLoadCenter.class, args);
+ }
+}
diff --git a/src/main/java/com/yyh/common/domain/Result.java b/src/main/java/com/yyh/common/domain/Result.java
new file mode 100644
index 0000000..7357f76
--- /dev/null
+++ b/src/main/java/com/yyh/common/domain/Result.java
@@ -0,0 +1,110 @@
+package com.yyh.common.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 响应信息主体
+ *
+ * @author zhilian
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class Result implements Serializable {
+ /**
+ * 成功
+ */
+ public static final int SUCCESS = 200;
+ /**
+ * 失败
+ */
+ public static final int FAIL = 500;
+ /**
+ * 警告
+ */
+ public static final int WARN = 501;
+
+ private static final long serialVersionUID = 1L;
+ private int code;
+
+ private String msg;
+
+ private T data;
+
+ public static Result success () {
+ return restResult(null, SUCCESS, null);
+ }
+
+ public static Result success (T data) {
+ return restResult(data, SUCCESS, null);
+ }
+
+ public static Result success (T data, String msg) {
+ return restResult(data, SUCCESS, msg);
+ }
+
+ public static Result error () {
+ return restResult(null, FAIL, null);
+ }
+
+ public static Result error (String msg) {
+ return restResult(null, FAIL, msg);
+ }
+
+ public static Result error (T data) {
+ return restResult(data, FAIL, null);
+ }
+
+ public static Result error (T data, String msg) {
+ return restResult(data, FAIL, msg);
+ }
+
+ public static Result error (int code, String msg) {
+ return restResult(null, code, msg);
+ }
+
+
+
+ public static Result warn () {
+ return restResult(null, WARN, null);
+ }
+
+ public static Result warn (String msg) {
+ return restResult(null, WARN, msg);
+ }
+
+ public static Result warn (T data) {
+ return restResult(data, WARN, null);
+ }
+
+ public static Result warn (T data, String msg) {
+ return restResult(data, WARN, msg);
+ }
+
+ public static Result warn (int code, String msg) {
+ return restResult(null, code, msg);
+ }
+
+ private static Result restResult (T data, int code, String msg) {
+ return Result.builder()
+ .code(code)
+ .data(data)
+ .msg(msg)
+ .build();
+ }
+
+ public static Boolean isError (Result ret) {
+ return !isSuccess(ret);
+ }
+
+ public static Boolean isSuccess (Result ret) {
+ return Result.SUCCESS == ret.getCode();
+ }
+
+}
diff --git a/src/main/java/com/yyh/common/redis/configure/FastJson2JsonRedisSerializer.java b/src/main/java/com/yyh/common/redis/configure/FastJson2JsonRedisSerializer.java
new file mode 100644
index 0000000..f3cf49b
--- /dev/null
+++ b/src/main/java/com/yyh/common/redis/configure/FastJson2JsonRedisSerializer.java
@@ -0,0 +1,51 @@
+package com.yyh.common.redis.configure;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONReader;
+import com.alibaba.fastjson2.JSONWriter;
+import com.alibaba.fastjson2.filter.Filter;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+
+import java.nio.charset.Charset;
+
+/**
+ * Redis使用FastJson序列化
+ *
+ * @author couplet
+ */
+public class FastJson2JsonRedisSerializer implements RedisSerializer {
+ public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+
+ /**
+ * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
+ */
+ public static final String[] JSON_WHITELIST_STR = {"org.springframework", "com.couplet"};
+
+ static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(JSON_WHITELIST_STR);
+
+ private Class clazz;
+
+ public FastJson2JsonRedisSerializer (Class clazz) {
+ super();
+ this.clazz = clazz;
+ }
+
+ @Override
+ public byte[] serialize (T t) throws SerializationException {
+ if (t == null) {
+ return new byte[0];
+ }
+ return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
+ }
+
+ @Override
+ public T deserialize (byte[] bytes) throws SerializationException {
+ if (bytes == null || bytes.length <= 0) {
+ return null;
+ }
+ String str = new String(bytes, DEFAULT_CHARSET);
+
+ return JSON.parseObject(str, clazz, AUTO_TYPE_FILTER);
+ }
+}
diff --git a/src/main/java/com/yyh/common/redis/configure/RedisConfig.java b/src/main/java/com/yyh/common/redis/configure/RedisConfig.java
new file mode 100644
index 0000000..67e98f6
--- /dev/null
+++ b/src/main/java/com/yyh/common/redis/configure/RedisConfig.java
@@ -0,0 +1,43 @@
+package com.yyh.common.redis.configure;
+
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * @ClassName RedisConfig
+ * @Description TODO
+ * @Author YuanYongH
+ * @Date 2024/4/18 15:36
+ */
+@Configuration
+@EnableCaching
+@AutoConfigureBefore(RedisAutoConfiguration.class)
+public class RedisConfig extends CachingConfigurerSupport {
+
+ @Bean
+ @SuppressWarnings(value = {"unchecked", "rawtypes" })
+ public RedisTemplate