Compare commits
No commits in common. "b41fbf27e16f397c8a0569513ca01438969ae240" and "7f08af15b36a7dd3682f5b60672e96c6f2ea7975" have entirely different histories.
b41fbf27e1
...
7f08af15b3
|
@ -31,10 +31,8 @@
|
||||||
<module name="service-product-client" options="-parameters" />
|
<module name="service-product-client" options="-parameters" />
|
||||||
<module name="service-user" options="-parameters" />
|
<module name="service-user" options="-parameters" />
|
||||||
<module name="service-user-client" options="-parameters" />
|
<module name="service-user-client" options="-parameters" />
|
||||||
<module name="spzx-common" options="" />
|
|
||||||
<module name="spzx-manager" options="-parameters" />
|
<module name="spzx-manager" options="-parameters" />
|
||||||
<module name="spzx-model" options="-parameters" />
|
<module name="spzx-model" options="-parameters" />
|
||||||
<module name="spzx-parent-v2" options="" />
|
|
||||||
<module name="spzx-server-gateway" options="-parameters" />
|
<module name="spzx-server-gateway" options="-parameters" />
|
||||||
<module name="spzx-service" options="" />
|
<module name="spzx-service" options="" />
|
||||||
<module name="spzx-service-client" options="" />
|
<module name="spzx-service-client" options="" />
|
||||||
|
|
|
@ -39,25 +39,5 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpclient</artifactId>
|
|
||||||
<version>4.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpcore</artifactId>
|
|
||||||
<version>4.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-lang</groupId>
|
|
||||||
<artifactId>commons-lang</artifactId>
|
|
||||||
<version>2.6</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
|
||||||
<artifactId>jetty-util</artifactId>
|
|
||||||
<version>9.3.7.v20160115</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -9,6 +9,12 @@ import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class Knife4jConfig {
|
public class Knife4jConfig {
|
||||||
|
@Bean
|
||||||
|
public GroupedOpenApi adminApi() {
|
||||||
|
// 分组名称
|
||||||
|
return GroupedOpenApi.builder().group("admin请求接口").pathsToMatch("/admin/**").build();// 接口请求路径规则
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OpenAPI customOpenAPI() {
|
public OpenAPI customOpenAPI() {
|
||||||
// 设定作者
|
// 设定作者
|
||||||
|
@ -17,17 +23,9 @@ public class Knife4jConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public GroupedOpenApi adminApi() {
|
public GroupedOpenApi webApi() { // 创建了一个api接口的分组
|
||||||
return GroupedOpenApi.builder().group("admin请求接口").pathsToMatch("/admin/**").build();// 接口请求路径规则
|
return GroupedOpenApi.builder()
|
||||||
}
|
.group("web-api") // 分组名称
|
||||||
|
.pathsToMatch("/api/**").build(); // 接口请求路径规则
|
||||||
@Bean
|
|
||||||
public GroupedOpenApi productApi() {
|
|
||||||
return GroupedOpenApi.builder().group("商品管理接口").pathsToMatch("/api/product/**").build(); // 接口请求路径规则
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public GroupedOpenApi userApi() {
|
|
||||||
return GroupedOpenApi.builder().group("用户接口").pathsToMatch("/api/user/**").build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -59,11 +59,13 @@ public class RedisConfiguration {
|
||||||
log.info("RedisConfiguration===>解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题");
|
log.info("RedisConfiguration===>解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题");
|
||||||
|
|
||||||
StringRedisSerializer redisSerializer = new StringRedisSerializer();
|
StringRedisSerializer redisSerializer = new StringRedisSerializer();
|
||||||
|
// json序列化
|
||||||
|
Jackson2JsonRedisSerializer<Object> serializer = jsonRedisSerializer();
|
||||||
// 配置序列化
|
// 配置序列化
|
||||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
||||||
RedisCacheConfiguration redisCacheConfiguration = config
|
RedisCacheConfiguration redisCacheConfiguration = config
|
||||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
|
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
|
||||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer()));
|
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(serializer));
|
||||||
|
|
||||||
RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
|
RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
|
||||||
.cacheDefaults(redisCacheConfiguration).build();
|
.cacheDefaults(redisCacheConfiguration).build();
|
||||||
|
|
|
@ -1,238 +0,0 @@
|
||||||
package com.atguigu.utils;
|
|
||||||
|
|
||||||
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 javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
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 {
|
|
||||||
public static HttpResponse doGet(String host, String path, String method,
|
|
||||||
Map<String, String> headers,
|
|
||||||
Map<String, String> querys)
|
|
||||||
throws Exception {
|
|
||||||
HttpClient httpClient = wrapClient(host);
|
|
||||||
|
|
||||||
HttpGet request = new HttpGet(buildUrl(host, path, querys));
|
|
||||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
|
||||||
request.addHeader(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return httpClient.execute(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HttpResponse doPost(String host, String path, String method,
|
|
||||||
Map<String, String> headers,
|
|
||||||
Map<String, String> querys,
|
|
||||||
Map<String, String> bodys)
|
|
||||||
throws Exception {
|
|
||||||
HttpClient httpClient = wrapClient(host);
|
|
||||||
|
|
||||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
|
||||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
|
||||||
request.addHeader(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bodys != null) {
|
|
||||||
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static HttpResponse doPost(String host, String path, String method,
|
|
||||||
Map<String, String> headers,
|
|
||||||
Map<String, String> querys,
|
|
||||||
String body)
|
|
||||||
throws Exception {
|
|
||||||
HttpClient httpClient = wrapClient(host);
|
|
||||||
|
|
||||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
|
||||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
|
||||||
request.addHeader(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(body)) {
|
|
||||||
request.setEntity(new StringEntity(body, "utf-8"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return httpClient.execute(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static HttpResponse doPost(String host, String path, String method,
|
|
||||||
Map<String, String> headers,
|
|
||||||
Map<String, String> querys,
|
|
||||||
byte[] body)
|
|
||||||
throws Exception {
|
|
||||||
HttpClient httpClient = wrapClient(host);
|
|
||||||
|
|
||||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
|
||||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
|
||||||
request.addHeader(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body != null) {
|
|
||||||
request.setEntity(new ByteArrayEntity(body));
|
|
||||||
}
|
|
||||||
|
|
||||||
return httpClient.execute(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static HttpResponse doPut(String host, String path, String method,
|
|
||||||
Map<String, String> headers,
|
|
||||||
Map<String, String> querys,
|
|
||||||
String body)
|
|
||||||
throws Exception {
|
|
||||||
HttpClient httpClient = wrapClient(host);
|
|
||||||
|
|
||||||
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
|
||||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
|
||||||
request.addHeader(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(body)) {
|
|
||||||
request.setEntity(new StringEntity(body, "utf-8"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return httpClient.execute(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static HttpResponse doPut(String host, String path, String method,
|
|
||||||
Map<String, String> headers,
|
|
||||||
Map<String, String> querys,
|
|
||||||
byte[] body)
|
|
||||||
throws Exception {
|
|
||||||
HttpClient httpClient = wrapClient(host);
|
|
||||||
|
|
||||||
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
|
||||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
|
||||||
request.addHeader(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body != null) {
|
|
||||||
request.setEntity(new ByteArrayEntity(body));
|
|
||||||
}
|
|
||||||
|
|
||||||
return httpClient.execute(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static HttpResponse doDelete(String host, String path, String method,
|
|
||||||
Map<String, String> headers,
|
|
||||||
Map<String, String> querys)
|
|
||||||
throws Exception {
|
|
||||||
HttpClient httpClient = wrapClient(host);
|
|
||||||
|
|
||||||
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
|
|
||||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
|
||||||
request.addHeader(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return httpClient.execute(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String buildUrl(String host, String path, Map<String, String> 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<String, String> 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(), StandardCharsets.UTF_8));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sbQuery.isEmpty()) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
WORKDIR /home/bunny
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
# 复制jar包
|
# 复制jar包
|
||||||
COPY target/*.jar /home/bunny/app.jar
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
#启动容器时的进程
|
#启动容器时的进程
|
||||||
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
|
@ -65,24 +65,4 @@
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>${java.version}</source>
|
|
||||||
<target>${java.version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skipTests>true</skipTests> <!--默认关掉单元测试 -->
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -11,7 +11,7 @@ RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
WORKDIR /home/bunny
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
# 复制jar包
|
# 复制jar包
|
||||||
COPY target/*.jar /home/bunny/app.jar
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
#启动容器时的进程
|
#启动容器时的进程
|
||||||
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
|
@ -4,7 +4,7 @@ spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
application:
|
application:
|
||||||
name: service-gateway
|
name: server-gateway
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
|
@ -12,9 +12,6 @@ spring:
|
||||||
namespace: ${bunny.nacos.discovery.namespace}
|
namespace: ${bunny.nacos.discovery.namespace}
|
||||||
server-addr: ${bunny.nacos.server-addr}
|
server-addr: ${bunny.nacos.server-addr}
|
||||||
log-name: logs/${spring.application.name}
|
log-name: logs/${spring.application.name}
|
||||||
sentinel:
|
|
||||||
log:
|
|
||||||
dir: logs/${spring.application.name}/sentinel
|
|
||||||
gateway:
|
gateway:
|
||||||
discovery:
|
discovery:
|
||||||
locator:
|
locator:
|
||||||
|
@ -36,14 +33,6 @@ spring:
|
||||||
uri: lb://service-product
|
uri: lb://service-product
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/*/product/**
|
- Path=/*/product/**
|
||||||
- id: service-user
|
|
||||||
uri: lb://service-user
|
|
||||||
predicates:
|
|
||||||
- Path=/*/user/**
|
|
||||||
- id: service-order
|
|
||||||
uri: lb://service-order
|
|
||||||
predicates:
|
|
||||||
- Path=/*/order/**
|
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<contextName>logback</contextName>
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
<!-- 日志的输出目录 -->
|
<!-- 日志的输出目录 -->
|
||||||
<property name="log.path" value="logs//service-gateway//logs"/>
|
<property name="log.path" value="logs//spzx-manager//logs"/>
|
||||||
|
|
||||||
<!--控制台日志格式:彩色日志-->
|
<!--控制台日志格式:彩色日志-->
|
||||||
<!-- magenta:洋红 -->
|
<!-- magenta:洋红 -->
|
||||||
|
|
|
@ -27,11 +27,6 @@
|
||||||
<artifactId>common-service</artifactId>
|
<artifactId>common-service</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- redis的起步依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- mybatis的起步依赖 -->
|
<!-- mybatis的起步依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -11,7 +11,7 @@ RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
WORKDIR /home/bunny
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
# 复制jar包
|
# 复制jar包
|
||||||
COPY target/*.jar /home/bunny/app.jar
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
#启动容器时的进程
|
#启动容器时的进程
|
||||||
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
server:
|
server:
|
||||||
port: 8510
|
port: 8511
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
application:
|
application:
|
||||||
name: service-order
|
name: service-product
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
|
@ -17,20 +17,6 @@ spring:
|
||||||
username: ${bunny.datasource.username}
|
username: ${bunny.datasource.username}
|
||||||
password: "${bunny.datasource.password}"
|
password: "${bunny.datasource.password}"
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.atguigu.spzx.order.mapper: debug
|
|
||||||
com.atguigu.spzx.order.controller: info
|
|
||||||
com.atguigu.spzx.order.service: info
|
|
||||||
pattern:
|
|
||||||
dateformat: HH:mm:ss:SSS
|
|
||||||
file:
|
|
||||||
path: "logs/${spring.application.name}"
|
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
type-aliases-package: com.atguigu.spzx.model
|
config-location: classpath:mybatis-config.xml
|
||||||
mapper-locations: classpath:/mapper/*/*.xml
|
mapper-locations: classpath:/mapper/*/*.xml
|
||||||
configuration:
|
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
|
||||||
map-underscore-to-camel-case: true
|
|
||||||
auto-mapping-behavior: full
|
|
|
@ -4,7 +4,7 @@
|
||||||
<contextName>logback</contextName>
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
<!-- 日志的输出目录 -->
|
<!-- 日志的输出目录 -->
|
||||||
<property name="log.path" value="logs//service-order//logs"/>
|
<property name="log.path" value="logs//spzx-manager//logs"/>
|
||||||
|
|
||||||
<!--控制台日志格式:彩色日志-->
|
<!--控制台日志格式:彩色日志-->
|
||||||
<!-- magenta:洋红 -->
|
<!-- magenta:洋红 -->
|
||||||
|
|
|
@ -11,7 +11,7 @@ RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
WORKDIR /home/bunny
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
# 复制jar包
|
# 复制jar包
|
||||||
COPY target/*.jar /home/bunny/app.jar
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
#启动容器时的进程
|
#启动容器时的进程
|
||||||
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- redis的起步依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<contextName>logback</contextName>
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
<!-- 日志的输出目录 -->
|
<!-- 日志的输出目录 -->
|
||||||
<property name="log.path" value="logs//service-product//logs"/>
|
<property name="log.path" value="logs//spzx-manager//logs"/>
|
||||||
|
|
||||||
<!--控制台日志格式:彩色日志-->
|
<!--控制台日志格式:彩色日志-->
|
||||||
<!-- magenta:洋红 -->
|
<!-- magenta:洋红 -->
|
||||||
|
|
|
@ -11,7 +11,7 @@ RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
WORKDIR /home/bunny
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
# 复制jar包
|
# 复制jar包
|
||||||
COPY target/*.jar /home/bunny/app.jar
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
#启动容器时的进程
|
#启动容器时的进程
|
||||||
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
|
@ -3,10 +3,8 @@ package com.atguigu.user;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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.atguigu")
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class UserApplication {
|
public class UserApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.atguigu.user.controller;
|
|
||||||
|
|
||||||
import com.atguigu.spzx.model.vo.result.Result;
|
|
||||||
import com.atguigu.user.service.SmsService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@Tag(name = "用户相关接口")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/user/sms")
|
|
||||||
public class SmsController {
|
|
||||||
@Autowired
|
|
||||||
private SmsService smsService;
|
|
||||||
|
|
||||||
@Operation(summary = "发送短信", description = "发送短信")
|
|
||||||
@GetMapping(value = "/sendCode/{phone}")
|
|
||||||
public Result<String> sendValidateCode(@PathVariable String phone) throws Exception {
|
|
||||||
smsService.sendValidateCode(phone);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.atguigu.user.service;
|
|
||||||
|
|
||||||
public interface SmsService {
|
|
||||||
/**
|
|
||||||
* 发送短信
|
|
||||||
*
|
|
||||||
* @param phone 手机号
|
|
||||||
*/
|
|
||||||
void sendValidateCode(String phone) throws Exception;
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package com.atguigu.user.service.impl;
|
|
||||||
|
|
||||||
import com.atguigu.user.service.SmsService;
|
|
||||||
import com.atguigu.user.service.module.SmsServiceModule;
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class SmsServiceImpl implements SmsService {
|
|
||||||
@Autowired
|
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送短信
|
|
||||||
*
|
|
||||||
* @param phone 手机号
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void sendValidateCode(String phone) throws Exception {
|
|
||||||
Object isExist = redisTemplate.opsForValue().get(phone);
|
|
||||||
// 1. 生成验证码
|
|
||||||
String code = RandomStringUtils.randomNumeric(4);
|
|
||||||
// 2. 生成的验证码放到Redis中,设置过期时间
|
|
||||||
redisTemplate.opsForValue().set(phone, code, 5, TimeUnit.MINUTES);
|
|
||||||
// 3. 向手机发送短信
|
|
||||||
if (isExist == null) {
|
|
||||||
SmsServiceModule.sendMessage(phone, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.atguigu.user.service.module;
|
|
||||||
|
|
||||||
import com.atguigu.exception.BunnyException;
|
|
||||||
import com.atguigu.utils.HttpUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class SmsServiceModule {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送短信
|
|
||||||
*
|
|
||||||
* @param phone 手机号
|
|
||||||
* @param code 验证码
|
|
||||||
*/
|
|
||||||
public static void sendMessage(String phone, String code) throws Exception {
|
|
||||||
String host = "https://gyytz.market.alicloudapi.com";
|
|
||||||
String path = "/sms/smsSend";
|
|
||||||
String method = "POST";
|
|
||||||
String appcode = "5a4cb12374904a7fa2975ec5a1a9d50f";
|
|
||||||
Map<String, String> headers = new HashMap<>();
|
|
||||||
headers.put("Authorization", "APPCODE " + appcode);
|
|
||||||
Map<String, String> querys = new HashMap<>();
|
|
||||||
querys.put("mobile", phone);
|
|
||||||
querys.put("param", "**code**:" + code + ",**minute**:5");
|
|
||||||
querys.put("smsSignId", "2e65b1bb3d054466b82f0c9d125465e2");
|
|
||||||
querys.put("templateId", "908e94ccf08b4476ba6c876d13f084ad");
|
|
||||||
Map<String, String> bodys = new HashMap<>();
|
|
||||||
|
|
||||||
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
|
||||||
log.info("请求完成响应:{}", response);
|
|
||||||
|
|
||||||
if (response.getStatusLine().getStatusCode() > 300) {
|
|
||||||
throw new BunnyException("短信接码未授权");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,14 +4,4 @@ bunny:
|
||||||
port: 3305
|
port: 3305
|
||||||
sqlData: db_spzx
|
sqlData: db_spzx
|
||||||
username: root
|
username: root
|
||||||
password: "02120212"
|
password: "02120212"
|
||||||
|
|
||||||
redis:
|
|
||||||
host: 106.15.251.123
|
|
||||||
port: 6379
|
|
||||||
database: 2
|
|
||||||
|
|
||||||
nacos:
|
|
||||||
server-addr: z-bunny.cn:8848
|
|
||||||
discovery:
|
|
||||||
namespace: spzx
|
|
|
@ -1,16 +1,14 @@
|
||||||
server:
|
server:
|
||||||
port: 8512
|
port: 8511
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
application:
|
application:
|
||||||
name: service-user
|
name: service-product
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
server-addr: 192.168.1.5:8848
|
||||||
namespace: ${bunny.nacos.discovery.namespace}
|
|
||||||
server-addr: ${bunny.nacos.server-addr}
|
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
@ -19,26 +17,6 @@ spring:
|
||||||
username: ${bunny.datasource.username}
|
username: ${bunny.datasource.username}
|
||||||
password: "${bunny.datasource.password}"
|
password: "${bunny.datasource.password}"
|
||||||
|
|
||||||
data:
|
|
||||||
redis:
|
|
||||||
host: ${bunny.redis.host}
|
|
||||||
port: ${bunny.redis.port}
|
|
||||||
database: ${bunny.redis.database}
|
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.atguigu.spzx.user.mapper: debug
|
|
||||||
com.atguigu.spzx.user.controller: info
|
|
||||||
com.atguigu.spzx.user.service: info
|
|
||||||
pattern:
|
|
||||||
dateformat: HH:mm:ss:SSS
|
|
||||||
file:
|
|
||||||
path: "logs/${spring.application.name}"
|
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
type-aliases-package: com.atguigu.spzx.model
|
config-location: classpath:mybatis-config.xml
|
||||||
mapper-locations: classpath:/mapper/*/*.xml
|
mapper-locations: classpath:/mapper/*/*.xml
|
||||||
configuration:
|
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
|
||||||
map-underscore-to-camel-case: true
|
|
||||||
auto-mapping-behavior: full
|
|
|
@ -1,16 +0,0 @@
|
||||||
-----------------▄██-█▄---------
|
|
||||||
-----------------███▄██▄--------
|
|
||||||
-----------------███████--------
|
|
||||||
-----------------▀███████-------
|
|
||||||
-------------------██████▄▄-----
|
|
||||||
-------------------█████████▄---
|
|
||||||
-------------------██████▄████--
|
|
||||||
-------▄███████████████████████-
|
|
||||||
-----▄███████████████████████▀--
|
|
||||||
---▄██████████████████████------
|
|
||||||
---███████████████████████------
|
|
||||||
---███████████████████████------
|
|
||||||
-▄▄██████████████████████▀------
|
|
||||||
-█████████████████▀█████--------
|
|
||||||
-▀██████████████▀▀-▀█████▄------
|
|
||||||
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------
|
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
|
@ -4,7 +4,7 @@
|
||||||
<contextName>logback</contextName>
|
<contextName>logback</contextName>
|
||||||
|
|
||||||
<!-- 日志的输出目录 -->
|
<!-- 日志的输出目录 -->
|
||||||
<property name="log.path" value="logs//service-user//logs"/>
|
<property name="log.path" value="logs//spzx-manager//logs"/>
|
||||||
|
|
||||||
<!--控制台日志格式:彩色日志-->
|
<!--控制台日志格式:彩色日志-->
|
||||||
<!-- magenta:洋红 -->
|
<!-- magenta:洋红 -->
|
||||||
|
|
Loading…
Reference in New Issue