From 09d3bf0e1d80a54528cf8fa8c0f9a7e1ec345820 Mon Sep 17 00:00:00 2001
From: jia <2744404105@qq.com>
Date: Tue, 12 Mar 2024 13:25:10 +0800
Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E8=80=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 38 +++
.idea/.gitignore | 8 +
.idea/encodings.xml | 17 +
.idea/misc.xml | 19 ++
bwie-auth/pom.xml | 58 ++++
.../src/main/java/com/bwie/auth/AuthApp.java | 16 +
.../bwie/auth/controller/AuthController.java | 40 +++
.../java/com/bwie/auth/feign/AuthFeign.java | 14 +
.../com/bwie/auth/service/AuthService.java | 13 +
.../auth/service/impl/AuthServiceImpl.java | 72 ++++
.../java/com/bwie/auth/util/HttpUtils.java | 319 ++++++++++++++++++
.../main/java/com/bwie/auth/util/MsgUtil.java | 80 +++++
bwie-auth/src/main/resources/bootstrap.yml | 31 ++
bwie-common/pom.xml | 114 +++++++
.../config/FastJson2JsonRedisSerializer.java | 48 +++
.../bwie/common/config/MybatisPlusConfig.java | 30 ++
.../com/bwie/common/config/RedisConfig.java | 65 ++++
.../com/bwie/common/constant/Constants.java | 18 +
.../bwie/common/constant/JwtConstants.java | 27 ++
.../common/constant/ServerNameConstants.java | 6 +
.../bwie/common/constant/TokenConstants.java | 24 ++
.../main/java/com/bwie/common/domain/Car.java | 24 ++
.../java/com/bwie/common/domain/Goods.java | 51 +++
.../java/com/bwie/common/domain/User.java | 34 ++
.../bwie/common/domain/request/BuyReq.java | 9 +
.../bwie/common/domain/request/GoodsReq.java | 14 +
.../bwie/common/domain/request/LoginReq.java | 9 +
.../bwie/common/domain/response/CarRes.java | 18 +
.../bwie/common/domain/response/JwtRes.java | 11 +
.../common/handler/GlobalExceptionHandle.java | 56 +++
.../com/bwie/common/redis/RedisCache.java | 260 ++++++++++++++
.../com/bwie/common/result/PageResult.java | 34 ++
.../java/com/bwie/common/result/Result.java | 63 ++++
.../java/com/bwie/common/utils/IdUtils.java | 19 ++
.../java/com/bwie/common/utils/JwtUtils.java | 105 ++++++
.../com/bwie/common/utils/SecurityUtils.java | 54 +++
.../com/bwie/common/utils/StringUtils.java | 68 ++++
.../main/resources/META-INF/spring.factories | 5 +
bwie-gateway/pom.xml | 42 +++
.../java/com/bwie/gateway/GatewayApp.java | 15 +
.../gateway/config/GatewaySentinelConfig.java | 71 ++++
.../gateway/config/IgnoreWhiteConfig.java | 32 ++
.../com/bwie/gateway/filters/AuthFilter.java | 62 ++++
.../com/bwie/gateway/utils/GatewayUtils.java | 67 ++++
bwie-gateway/src/main/resources/bootstrap.yml | 29 ++
bwie-modules/bwie-car/pom.xml | 62 ++++
.../src/main/java/com/bwie/car/CarApp.java | 15 +
.../bwie/car/controller/CarController.java | 34 ++
.../java/com/bwie/car/mapper/CarMapper.java | 11 +
.../java/com/bwie/car/service/CarService.java | 10 +
.../com/bwie/car/service/CarServiceImpl.java | 71 ++++
.../bwie-car/src/main/resources/bootstrap.yml | 30 ++
.../src/main/resources/mapper/CarMapper.xml | 13 +
bwie-modules/bwie-goods/pom.xml | 66 ++++
.../main/java/com/bwie/goods/GoodsApp.java | 29 ++
.../java/com/bwie/goods/config/InitEsRes.java | 25 ++
.../goods/controller/GoodsController.java | 30 ++
.../com/bwie/goods/mapper/GoodsMapper.java | 7 +
.../com/bwie/goods/service/GoodsService.java | 14 +
.../bwie/goods/service/GoodsServiceImpl.java | 141 ++++++++
.../src/main/resources/bootstrap.yml | 35 ++
.../src/main/resources/mapper/GoodsMapper.xml | 5 +
bwie-modules/bwie-ord/pom.xml | 62 ++++
.../bwie/ord/controller/OrdController.java | 4 +
.../java/com/bwie/ord/mapper/OrdMapper.java | 4 +
.../java/com/bwie/ord/service/OrdService.java | 7 +
.../com/bwie/ord/service/OrdServiceImpl.java | 4 +
.../bwie-ord/src/main/resources/bootstrap.yml | 30 ++
.../src/main/resources/mapper/OrdMapper.xml | 5 +
bwie-modules/bwie-user/pom.xml | 62 ++++
.../src/main/java/com/bwie/user/UserApp.java | 15 +
.../bwie/user/controller/UserController.java | 41 +++
.../java/com/bwie/user/mapper/UserMapper.java | 12 +
.../com/bwie/user/service/UserService.java | 11 +
.../bwie/user/service/UserServiceImpl.java | 44 +++
.../src/main/resources/bootstrap.yml | 30 ++
.../src/main/resources/mapper/UserMapper.xml | 12 +
bwie-modules/pom.xml | 27 ++
pom.xml | 66 ++++
79 files changed, 3243 insertions(+)
create mode 100644 .gitignore
create mode 100644 .idea/.gitignore
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/misc.xml
create mode 100644 bwie-auth/pom.xml
create mode 100644 bwie-auth/src/main/java/com/bwie/auth/AuthApp.java
create mode 100644 bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java
create mode 100644 bwie-auth/src/main/java/com/bwie/auth/feign/AuthFeign.java
create mode 100644 bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java
create mode 100644 bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java
create mode 100644 bwie-auth/src/main/java/com/bwie/auth/util/HttpUtils.java
create mode 100644 bwie-auth/src/main/java/com/bwie/auth/util/MsgUtil.java
create mode 100644 bwie-auth/src/main/resources/bootstrap.yml
create mode 100644 bwie-common/pom.xml
create mode 100644 bwie-common/src/main/java/com/bwie/common/config/FastJson2JsonRedisSerializer.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/config/MybatisPlusConfig.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/constant/Constants.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/constant/JwtConstants.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/constant/ServerNameConstants.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/constant/TokenConstants.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/Car.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/Goods.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/User.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/request/BuyReq.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/request/GoodsReq.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/request/LoginReq.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/response/CarRes.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/response/JwtRes.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/handler/GlobalExceptionHandle.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/redis/RedisCache.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/result/PageResult.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/result/Result.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/utils/IdUtils.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/utils/SecurityUtils.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java
create mode 100644 bwie-common/src/main/resources/META-INF/spring.factories
create mode 100644 bwie-gateway/pom.xml
create mode 100644 bwie-gateway/src/main/java/com/bwie/gateway/GatewayApp.java
create mode 100644 bwie-gateway/src/main/java/com/bwie/gateway/config/GatewaySentinelConfig.java
create mode 100644 bwie-gateway/src/main/java/com/bwie/gateway/config/IgnoreWhiteConfig.java
create mode 100644 bwie-gateway/src/main/java/com/bwie/gateway/filters/AuthFilter.java
create mode 100644 bwie-gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java
create mode 100644 bwie-gateway/src/main/resources/bootstrap.yml
create mode 100644 bwie-modules/bwie-car/pom.xml
create mode 100644 bwie-modules/bwie-car/src/main/java/com/bwie/car/CarApp.java
create mode 100644 bwie-modules/bwie-car/src/main/java/com/bwie/car/controller/CarController.java
create mode 100644 bwie-modules/bwie-car/src/main/java/com/bwie/car/mapper/CarMapper.java
create mode 100644 bwie-modules/bwie-car/src/main/java/com/bwie/car/service/CarService.java
create mode 100644 bwie-modules/bwie-car/src/main/java/com/bwie/car/service/CarServiceImpl.java
create mode 100644 bwie-modules/bwie-car/src/main/resources/bootstrap.yml
create mode 100644 bwie-modules/bwie-car/src/main/resources/mapper/CarMapper.xml
create mode 100644 bwie-modules/bwie-goods/pom.xml
create mode 100644 bwie-modules/bwie-goods/src/main/java/com/bwie/goods/GoodsApp.java
create mode 100644 bwie-modules/bwie-goods/src/main/java/com/bwie/goods/config/InitEsRes.java
create mode 100644 bwie-modules/bwie-goods/src/main/java/com/bwie/goods/controller/GoodsController.java
create mode 100644 bwie-modules/bwie-goods/src/main/java/com/bwie/goods/mapper/GoodsMapper.java
create mode 100644 bwie-modules/bwie-goods/src/main/java/com/bwie/goods/service/GoodsService.java
create mode 100644 bwie-modules/bwie-goods/src/main/java/com/bwie/goods/service/GoodsServiceImpl.java
create mode 100644 bwie-modules/bwie-goods/src/main/resources/bootstrap.yml
create mode 100644 bwie-modules/bwie-goods/src/main/resources/mapper/GoodsMapper.xml
create mode 100644 bwie-modules/bwie-ord/pom.xml
create mode 100644 bwie-modules/bwie-ord/src/main/java/com/bwie/ord/controller/OrdController.java
create mode 100644 bwie-modules/bwie-ord/src/main/java/com/bwie/ord/mapper/OrdMapper.java
create mode 100644 bwie-modules/bwie-ord/src/main/java/com/bwie/ord/service/OrdService.java
create mode 100644 bwie-modules/bwie-ord/src/main/java/com/bwie/ord/service/OrdServiceImpl.java
create mode 100644 bwie-modules/bwie-ord/src/main/resources/bootstrap.yml
create mode 100644 bwie-modules/bwie-ord/src/main/resources/mapper/OrdMapper.xml
create mode 100644 bwie-modules/bwie-user/pom.xml
create mode 100644 bwie-modules/bwie-user/src/main/java/com/bwie/user/UserApp.java
create mode 100644 bwie-modules/bwie-user/src/main/java/com/bwie/user/controller/UserController.java
create mode 100644 bwie-modules/bwie-user/src/main/java/com/bwie/user/mapper/UserMapper.java
create mode 100644 bwie-modules/bwie-user/src/main/java/com/bwie/user/service/UserService.java
create mode 100644 bwie-modules/bwie-user/src/main/java/com/bwie/user/service/UserServiceImpl.java
create mode 100644 bwie-modules/bwie-user/src/main/resources/bootstrap.yml
create mode 100644 bwie-modules/bwie-user/src/main/resources/mapper/UserMapper.xml
create mode 100644 bwie-modules/pom.xml
create mode 100644 pom.xml
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.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
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/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..119866f
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..9a89e4c
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bwie-auth/pom.xml b/bwie-auth/pom.xml
new file mode 100644
index 0000000..344ebcd
--- /dev/null
+++ b/bwie-auth/pom.xml
@@ -0,0 +1,58 @@
+
+
+ 4.0.0
+
+ com.bwie
+ test_week3
+ 1.0.0
+
+
+ bwie-auth
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ com.bwie
+ bwie-common
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.15
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.3
+
+
+ org.apache.httpcomponents
+ httpcore
+ 4.4.15
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+ org.eclipse.jetty
+ jetty-util
+ 9.3.7.v20160115
+
+
+
diff --git a/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java b/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java
new file mode 100644
index 0000000..b32381f
--- /dev/null
+++ b/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java
@@ -0,0 +1,16 @@
+package com.bwie.auth;
+
+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;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
+@EnableDiscoveryClient
+@EnableFeignClients(basePackages = "com.bwie.**")
+public class AuthApp {
+ public static void main(String[] args) {
+ SpringApplication.run(AuthApp.class);
+ }
+}
diff --git a/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java b/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java
new file mode 100644
index 0000000..cea9c1e
--- /dev/null
+++ b/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java
@@ -0,0 +1,40 @@
+package com.bwie.auth.controller;
+
+import com.bwie.auth.service.AuthService;
+import com.bwie.common.domain.User;
+import com.bwie.common.domain.request.LoginReq;
+import com.bwie.common.domain.response.JwtRes;
+import com.bwie.common.result.Result;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+public class AuthController {
+ private final AuthService authService;
+
+
+ public AuthController(AuthService authService) {
+ this.authService = authService;
+ }
+
+ @PostMapping("sendcode")
+ public Result sendcode(@RequestParam String userTel){
+ String sendcode = authService.sendcode(userTel);
+ return Result.success(sendcode);
+ }
+
+@PostMapping("login")
+ public Result login(@RequestBody LoginReq loginReq){
+ JwtRes login = authService.login(loginReq);
+ return Result.success(login);
+ }
+
+ @GetMapping("info")
+ public Result info(){
+ User info = authService.info();
+ return Result.success(info);
+ }
+
+
+
+
+}
diff --git a/bwie-auth/src/main/java/com/bwie/auth/feign/AuthFeign.java b/bwie-auth/src/main/java/com/bwie/auth/feign/AuthFeign.java
new file mode 100644
index 0000000..3e6883d
--- /dev/null
+++ b/bwie-auth/src/main/java/com/bwie/auth/feign/AuthFeign.java
@@ -0,0 +1,14 @@
+package com.bwie.auth.feign;
+
+import com.bwie.common.domain.User;
+import com.bwie.common.result.Result;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@FeignClient("bwie-system")
+public interface AuthFeign {
+
+ @PostMapping("findtel")
+ public Result findtel(@RequestParam String userTel);
+}
diff --git a/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java b/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java
new file mode 100644
index 0000000..d4b5c00
--- /dev/null
+++ b/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java
@@ -0,0 +1,13 @@
+package com.bwie.auth.service;
+
+import com.bwie.common.domain.User;
+import com.bwie.common.domain.request.LoginReq;
+import com.bwie.common.domain.response.JwtRes;
+
+public interface AuthService {
+ String sendcode(String userTel);
+ JwtRes login(LoginReq loginReq);
+ User info();
+
+
+}
diff --git a/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java b/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java
new file mode 100644
index 0000000..2135f2b
--- /dev/null
+++ b/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java
@@ -0,0 +1,72 @@
+package com.bwie.auth.service.impl;
+
+import com.bwie.auth.feign.AuthFeign;
+import com.bwie.auth.service.AuthService;
+import com.bwie.auth.util.MsgUtil;
+import com.bwie.common.constant.JwtConstants;
+import com.bwie.common.constant.TokenConstants;
+import com.bwie.common.domain.User;
+import com.bwie.common.domain.request.LoginReq;
+import com.bwie.common.domain.response.JwtRes;
+import com.bwie.common.redis.RedisCache;
+import com.bwie.common.result.Result;
+import com.bwie.common.utils.IdUtils;
+import com.bwie.common.utils.JwtUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
+
+@Service
+public class AuthServiceImpl implements AuthService {
+ private final MsgUtil msgUtil;
+ private final AuthFeign authFeign;
+ private final RedisCache redisCache;
+ private final HttpServletRequest request;
+
+ public AuthServiceImpl(MsgUtil msgUtil, AuthFeign authFeign, RedisCache redisCache, HttpServletRequest request) {
+ this.msgUtil = msgUtil;
+ this.authFeign = authFeign;
+ this.redisCache = redisCache;
+ this.request = request;
+ }
+
+ @Override
+ public String sendcode(String userTel) {
+ msgUtil.sendMsg(userTel,"1111");
+ redisCache.setCacheObject("tel_"+userTel,"1111");
+ return "1111";
+ }
+
+ @Override
+ public JwtRes login(LoginReq loginReq) {
+ Result findtel = authFeign.findtel(loginReq.getUserTel());
+ Assert.isTrue(findtel.isSuccess(),"登陆失败");
+ User data = findtel.getData();
+ Assert.notNull(data,"电话不存在");
+ Assert.isTrue(redisCache.hasKey("tel_" + loginReq.getUserTel()),"验证码过期");
+ String cacheObject = redisCache.getCacheObject("tel_" + loginReq.getUserTel());
+ Assert.isTrue(loginReq.getUserCode().equals(cacheObject),"验证码错误");
+ HashMap map = new HashMap<>();
+ String s = IdUtils.genId();
+ map.put(JwtConstants.USER_KEY,s);
+ String token = JwtUtils.createToken(map);
+ redisCache.setCacheObject(TokenConstants.LOGIN_TOKEN_KEY+s,data,TokenConstants.EXPIRATION, TimeUnit.SECONDS);
+
+ return JwtRes.builder()
+ .expireTime(TokenConstants.EXPIRATION)
+ .token(token)
+ .build();
+ }
+
+ @Override
+ public User info() {
+ String header = request.getHeader(TokenConstants.TOKEN);
+ String userKey = JwtUtils.getUserKey(header);
+ User cacheObject = redisCache.getCacheObject(TokenConstants.LOGIN_TOKEN_KEY + userKey);
+
+ return cacheObject;
+ }
+}
diff --git a/bwie-auth/src/main/java/com/bwie/auth/util/HttpUtils.java b/bwie-auth/src/main/java/com/bwie/auth/util/HttpUtils.java
new file mode 100644
index 0000000..8257735
--- /dev/null
+++ b/bwie-auth/src/main/java/com/bwie/auth/util/HttpUtils.java
@@ -0,0 +1,319 @@
+package com.bwie.auth.util;
+
+import com.alibaba.fastjson.JSON;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpUtils {
+
+ /**
+ * get
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @return
+ * @throws Exception
+ */
+ public static List doGet(String host, String path, String method,
+ Map headers,
+ Map querys
+ ,Class clazz)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpGet request = new HttpGet(buildUrl(host, path, querys));
+ if(headers!=null){
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ }
+ HttpResponse execute = httpClient.execute(request);
+ String s = EntityUtils.toString(execute.getEntity(),"UTF-8");
+ List ts = JSON.parseArray(s, clazz);
+ return ts;
+ }
+
+ /**
+ * post form
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param bodys
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPost(String host, String path, String method,
+ Map headers,
+ Map querys,
+ Map bodys)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (bodys != null) {
+ List nameValuePairList = new ArrayList();
+
+ for (String key : bodys.keySet()) {
+ nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
+ }
+ UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
+ formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
+ request.setEntity(formEntity);
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Post String
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param body
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPost(String host, String path, String method,
+ Map headers,
+ Map querys,
+ String body)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (StringUtils.isNotBlank(body)) {
+ request.setEntity(new StringEntity(body, "utf-8"));
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Post stream
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param body
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPost(String host, String path, String method,
+ Map headers,
+ Map querys,
+ byte[] body)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (body != null) {
+ request.setEntity(new ByteArrayEntity(body));
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Put String
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param body
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPut(String host, String path, String method,
+ Map headers,
+ Map querys,
+ String body)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPut request = new HttpPut(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (StringUtils.isNotBlank(body)) {
+ request.setEntity(new StringEntity(body, "utf-8"));
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Put stream
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @param body
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doPut(String host, String path, String method,
+ Map headers,
+ Map querys,
+ byte[] body)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPut request = new HttpPut(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (body != null) {
+ request.setEntity(new ByteArrayEntity(body));
+ }
+
+ return httpClient.execute(request);
+ }
+
+ /**
+ * Delete
+ *
+ * @param host
+ * @param path
+ * @param method
+ * @param headers
+ * @param querys
+ * @return
+ * @throws Exception
+ */
+ public static HttpResponse doDelete(String host, String path, String method,
+ Map headers,
+ Map querys)
+ throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ return httpClient.execute(request);
+ }
+
+ private static String buildUrl(String host, String path, Map querys) throws UnsupportedEncodingException {
+ StringBuilder sbUrl = new StringBuilder();
+ sbUrl.append(host);
+ if (!StringUtils.isBlank(path)) {
+ sbUrl.append(path);
+ }
+ if (null != querys) {
+ StringBuilder sbQuery = new StringBuilder();
+ for (Map.Entry query : querys.entrySet()) {
+ if (0 < sbQuery.length()) {
+ sbQuery.append("&");
+ }
+ if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
+ sbQuery.append(query.getValue());
+ }
+ if (!StringUtils.isBlank(query.getKey())) {
+ sbQuery.append(query.getKey());
+ if (!StringUtils.isBlank(query.getValue())) {
+ sbQuery.append("=");
+ sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
+ }
+ }
+ }
+ if (0 < sbQuery.length()) {
+ sbUrl.append("?").append(sbQuery);
+ }
+ }
+
+ return sbUrl.toString();
+ }
+
+ private static HttpClient wrapClient(String host) {
+ HttpClient httpClient = new DefaultHttpClient();
+ if (host.startsWith("https://")) {
+ sslClient(httpClient);
+ }
+
+ return httpClient;
+ }
+
+ private static void sslClient(HttpClient httpClient) {
+ try {
+ SSLContext ctx = SSLContext.getInstance("TLS");
+ X509TrustManager tm = new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ public void checkClientTrusted(X509Certificate[] xcs, String str) {
+
+ }
+ public void checkServerTrusted(X509Certificate[] xcs, String str) {
+
+ }
+ };
+ ctx.init(null, new TrustManager[] { tm }, null);
+ SSLSocketFactory ssf = new SSLSocketFactory(ctx);
+ ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ ClientConnectionManager ccm = httpClient.getConnectionManager();
+ SchemeRegistry registry = ccm.getSchemeRegistry();
+ registry.register(new Scheme("https", 443, ssf));
+ } catch (KeyManagementException ex) {
+ throw new RuntimeException(ex);
+ } catch (NoSuchAlgorithmException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/bwie-auth/src/main/java/com/bwie/auth/util/MsgUtil.java b/bwie-auth/src/main/java/com/bwie/auth/util/MsgUtil.java
new file mode 100644
index 0000000..3d2d75e
--- /dev/null
+++ b/bwie-auth/src/main/java/com/bwie/auth/util/MsgUtil.java
@@ -0,0 +1,80 @@
+package com.bwie.auth.util;
+
+
+import org.apache.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author
+ * @version 1.0.0
+ * @ClassName MsgUtil.java
+ * @Description TODO
+ * @createTime 2022年05月26日 15:49:00
+ */
+@Component
+public class MsgUtil {
+
+
+// //列表添加
+// //@CacheConfig(cacheNames = "aaa")
+// //列表
+// //@Cacheable
+// //实时更新
+// //@CacheEvict(allEntries = true)
+//
+// @Cacheable(key = "#phone",value = "bbb")
+// public String getCacheCode(String phone){
+//
+// return null;
+// }
+//
+// @CachePut(key = "#codeEntity.phone",value = "bbb")
+// public String saveCacheCode(CodeEntity codeEntity){
+//
+// return codeEntity.getCode();
+// }
+
+// 858f87d76b7f4e618a5f7e1557f1d529
+
+ public void sendMsg(String phone,String code){
+ String host = "https://gyytz.market.alicloudapi.com";
+ String path = "/sms/smsSend";
+ String method = "POST";
+ String appcode = "13a8b5b781bc4c458ce2de65ed79be80";
+ Map headers = new HashMap();
+ //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
+ headers.put("Authorization", "APPCODE " + appcode);
+ Map querys = new HashMap();
+ querys.put("mobile", phone);
+ querys.put("param", "**code**:"+code+",**minute**:5");
+
+//smsSignId(短信前缀)和templateId(短信模板),可登录国阳云控制台自助申请。参考文档:http://help.guoyangyun.com/Problem/Qm.html
+
+ querys.put("smsSignId", "2e65b1bb3d054466b82f0c9d125465e2");
+ querys.put("templateId", "908e94ccf08b4476ba6c876d13f084ad");
+ Map bodys = new HashMap();
+
+
+ try {
+ /**
+ * 重要提示如下:
+ * HttpUtils请从\r\n\t \t* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java\r\n\t \t* 下载
+ *
+ * 相应的依赖请参照
+ * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
+ */
+ HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
+ System.out.println(response.toString());
+ //获取response的body
+ System.out.println(EntityUtils.toString(response.getEntity()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/bwie-auth/src/main/resources/bootstrap.yml b/bwie-auth/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..770cce2
--- /dev/null
+++ b/bwie-auth/src/main/resources/bootstrap.yml
@@ -0,0 +1,31 @@
+# Tomcat
+server:
+ port: 9001
+# Spring
+spring:
+ main:
+ allow-circular-references: true
+ allow-bean-definition-overriding: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: bwie-auth
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.221.177.197:8848
+ config:
+ # 配置中心地址
+ server-addr: 124.221.177.197:8848
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+
diff --git a/bwie-common/pom.xml b/bwie-common/pom.xml
new file mode 100644
index 0000000..2e78959
--- /dev/null
+++ b/bwie-common/pom.xml
@@ -0,0 +1,114 @@
+
+
+ 4.0.0
+
+ com.bwie
+ test_week3
+ 1.0.0
+
+
+ bwie-common
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+ io.jsonwebtoken
+ jjwt
+ 0.9.1
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.80
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+ cn.hutool
+ hutool-all
+ 5.8.3
+
+
+
+ com.aliyun
+ dysmsapi20170525
+ 2.0.1
+
+
+
+ org.springframework.boot
+ spring-boot-starter-amqp
+
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.5.4.1
+
+
+
+
+ com.alibaba.fastjson2
+ fastjson2
+ 2.0.42
+
+
+
diff --git a/bwie-common/src/main/java/com/bwie/common/config/FastJson2JsonRedisSerializer.java b/bwie-common/src/main/java/com/bwie/common/config/FastJson2JsonRedisSerializer.java
new file mode 100644
index 0000000..584566b
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/config/FastJson2JsonRedisSerializer.java
@@ -0,0 +1,48 @@
+package com.bwie.common.config;
+
+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;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * Redis使用FastJson序列化
+ *
+ * @author ruoyi
+ */
+public class FastJson2JsonRedisSerializer implements RedisSerializer {
+ public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
+
+ static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(
+ "org.springframework", "com");
+
+ 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/bwie-common/src/main/java/com/bwie/common/config/MybatisPlusConfig.java b/bwie-common/src/main/java/com/bwie/common/config/MybatisPlusConfig.java
new file mode 100644
index 0000000..1983b7e
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/config/MybatisPlusConfig.java
@@ -0,0 +1,30 @@
+package com.bwie.common.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author DongZl
+ * @description: Mybatis-Plus配置
+ * @Date 2024-1-10 下午 05:12
+ */
+@Configuration
+public class MybatisPlusConfig {
+
+ public MybatisPlusConfig () {
+ System.out.println("初始化-----------");
+ }
+
+ /**
+ * 添加分页插件
+ */
+ @Bean
+ public MybatisPlusInterceptor mybatisPlusInterceptor() {
+ MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+ interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+ return interceptor;
+ }
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java b/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java
new file mode 100644
index 0000000..5d3ecc0
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java
@@ -0,0 +1,65 @@
+package com.bwie.common.config;
+
+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.core.script.DefaultRedisScript;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * redis配置
+ *
+ * @author ruoyi
+ */
+@Configuration
+@EnableCaching
+public class RedisConfig extends CachingConfigurerSupport {
+ @Bean
+ @SuppressWarnings(value = {"unchecked", "rawtypes"})
+ public RedisTemplate