From f1ced1daaf344300d5112662b4fd28526d36e44e Mon Sep 17 00:00:00 2001 From: sikadi <13315935+sikadi_love@user.noreply.gitee.com> Date: Thu, 5 Oct 2023 14:26:54 +0800 Subject: [PATCH] =?UTF-8?q?api=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 38 +++ .idea/.gitignore | 8 + .idea/aws.xml | 11 + .idea/encodings.xml | 11 + .idea/inspectionProfiles/Project_Default.xml | 14 + .idea/misc.xml | 14 + .idea/vcs.xml | 6 + holiday02-common/.gitignore | 38 +++ holiday02-common/pom.xml | 127 +++++++ .../sikadi/common/constants/Constants.java | 21 ++ .../sikadi/common/constants/JwtConstants.java | 30 ++ .../common/constants/TokenConstants.java | 27 ++ .../com/sikadi/common/result/PageResult.java | 37 +++ .../java/com/sikadi/common/result/Result.java | 56 ++++ .../com/sikadi/common/utils/HttpUtils.java | 310 ++++++++++++++++++ .../com/sikadi/common/utils/JwtUtils.java | 106 ++++++ .../java/com/sikadi/common/utils/MsgUtil.java | 41 +++ .../java/com/sikadi/common/utils/OssUtil.java | 153 +++++++++ .../com/sikadi/common/utils/StringUtils.java | 71 ++++ .../com/sikadi/common/utils/TelSmsUtils.java | 87 +++++ holiday02-store/.gitignore | 38 +++ holiday02-store/pom.xml | 165 ++++++++++ .../store/controller/StoreController.java | 20 ++ .../store/service/impl/StoreServiceImpl.java | 50 +++ .../com/sikadi/store/util/FileDuoJiYun.java | 117 +++++++ .../src/main/resources/bootstrap.yml | 30 ++ pom.xml | 62 ++++ 27 files changed, 1688 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/aws.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 holiday02-common/.gitignore create mode 100644 holiday02-common/pom.xml create mode 100644 holiday02-common/src/main/java/com/sikadi/common/constants/Constants.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/constants/JwtConstants.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/constants/TokenConstants.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/result/PageResult.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/result/Result.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/utils/HttpUtils.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/utils/JwtUtils.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/utils/MsgUtil.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/utils/OssUtil.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/utils/StringUtils.java create mode 100644 holiday02-common/src/main/java/com/sikadi/common/utils/TelSmsUtils.java create mode 100644 holiday02-store/.gitignore create mode 100644 holiday02-store/pom.xml create mode 100644 holiday02-store/src/main/java/com/sikadi/store/controller/StoreController.java create mode 100644 holiday02-store/src/main/java/com/sikadi/store/service/impl/StoreServiceImpl.java create mode 100644 holiday02-store/src/main/java/com/sikadi/store/util/FileDuoJiYun.java create mode 100644 holiday02-store/src/main/resources/bootstrap.yml 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..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/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..52f008a --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..ee2c34b --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..132404b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ 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/holiday02-common/.gitignore b/holiday02-common/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/holiday02-common/.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/holiday02-common/pom.xml b/holiday02-common/pom.xml new file mode 100644 index 0000000..eaa08d7 --- /dev/null +++ b/holiday02-common/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + + com.sikadi + holiday02 + 1.0-SNAPSHOT + + + holiday02-common + + + 8 + 8 + 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.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.9.10 + + + + com.aliyun.oss + aliyun-sdk-oss + 3.10.2 + + + + com.github.tobato + fastdfs-client + 1.26.5 + + + org.elasticsearch.client + elasticsearch-rest-high-level-client + + + com.aliyun.oss + aliyun-sdk-oss + 3.11.0 + + + + diff --git a/holiday02-common/src/main/java/com/sikadi/common/constants/Constants.java b/holiday02-common/src/main/java/com/sikadi/common/constants/Constants.java new file mode 100644 index 0000000..690e184 --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/constants/Constants.java @@ -0,0 +1,21 @@ +package com.sikadi.common.constants; + +/** + * @ClassName Constants + * @Description 系统常量 + * @Author ChenLong + * @Date 2023/2/23 16:04 + * @Version 1.0 + */ +public class Constants { + /** + * 成功标记 + */ + public static final Integer SUCCESS = 200; + public static final String SUCCESS_MSG = "操作成功"; + /** + * 失败标记 + */ + public static final Integer ERROR = 500; + public static final String ERROR_MSG = "操作异常"; +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/constants/JwtConstants.java b/holiday02-common/src/main/java/com/sikadi/common/constants/JwtConstants.java new file mode 100644 index 0000000..38df798 --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/constants/JwtConstants.java @@ -0,0 +1,30 @@ +package com.sikadi.common.constants; + +/** + * @ClassName JwtConstants + * @Description Jwt常量 + * @Author ChenLong + * @Date 2023/2/23 16:07 + * @Version 1.0 + */ +public class JwtConstants { + /** + * 用户ID字段 + */ + public static final String DETAILS_USER_ID = "user_id"; + + /** + * 用户名字段 + */ + public static final String DETAILS_USERNAME = "username"; + + /** + * 用户标识 + */ + public static final String USER_KEY = "user_key"; + + /** + * 令牌秘钥 + */ + public final static String SECRET = "abcdefghijklmnopqrstuvwxyz"; +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/constants/TokenConstants.java b/holiday02-common/src/main/java/com/sikadi/common/constants/TokenConstants.java new file mode 100644 index 0000000..8b6b631 --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/constants/TokenConstants.java @@ -0,0 +1,27 @@ +package com.sikadi.common.constants; + +/** + * @ClassName TokenConstants + * @Description 令牌常量 + * @Author ChenLong + * @Date 2023/2/23 16:08 + * @Version 1.0 + */ +public class TokenConstants { + /** + * 缓存有效期,默认720(分钟) + */ + public final static long EXPIRATION = 720; + /** + * 缓存刷新时间,默认120(分钟) + */ + public final static long REFRESH_TIME = 120; + /** + * 权限缓存前缀 + */ + public final static String LOGIN_TOKEN_KEY = "login_tokens:"; + /** + * token标识 + */ + public static final String TOKEN = "token"; +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/result/PageResult.java b/holiday02-common/src/main/java/com/sikadi/common/result/PageResult.java new file mode 100644 index 0000000..cb59eef --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/result/PageResult.java @@ -0,0 +1,37 @@ +package com.sikadi.common.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @ClassName PageResult + * @Description 列表返回结果集 + * @Author ChenLong + * @Date 2023/2/23 16:09 + * @Version 1.0 + */ +@Data +public class PageResult implements Serializable { + /** + * 总条数 + */ + private long total; + /** + * 结果集合 + */ + private List list; + public PageResult() { + } + public PageResult(long total, List list) { + this.total = total; + this.list = list; + } + public static PageResult toPageResult(long total, List list){ + return new PageResult(total , list); + } + public static Result> toResult(long total, List list){ + return Result.success(PageResult.toPageResult(total,list)); + } +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/result/Result.java b/holiday02-common/src/main/java/com/sikadi/common/result/Result.java new file mode 100644 index 0000000..42bae11 --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/result/Result.java @@ -0,0 +1,56 @@ +package com.sikadi.common.result; + +import com.sikadi.common.constants.Constants; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName Result + * @Description 响应信息主体 + * @Author ChenLong + * @Date 2023/2/23 16:08 + * @Version 1.0 + */ +@Data +public class Result implements Serializable { + private static final long serialVersionUID = 1L; + /** 成功 */ + public static final int SUCCESS = Constants.SUCCESS; + /** 失败 */ + public static final int FAIL = Constants.ERROR; + private int code; + private String msg; + private T data; + public static Result success() { + return restResult(null, SUCCESS, Constants.SUCCESS_MSG); + } + public static Result success(T data) { + return restResult(data, SUCCESS, Constants.SUCCESS_MSG); + } + public static Result success(T data, String msg) { + return restResult(data, SUCCESS, msg); + } + public static Result error() { + return restResult(null, FAIL, Constants.ERROR_MSG); + } + public static Result error(String msg) { + return restResult(null, FAIL, msg); + } + public static Result error(T data) { + return restResult(data, FAIL, Constants.ERROR_MSG); + } + 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); + } + private static Result restResult(T data, int code, String msg) { + Result apiResult = new Result<>(); + apiResult.setCode(code); + apiResult.setData(data); + apiResult.setMsg(msg); + return apiResult; + } +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/utils/HttpUtils.java b/holiday02-common/src/main/java/com/sikadi/common/utils/HttpUtils.java new file mode 100644 index 0000000..6f7cbe2 --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/utils/HttpUtils.java @@ -0,0 +1,310 @@ +package com.sikadi.common.utils; + +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.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 HttpResponse doGet(String host, String path, String method, + Map headers, + Map querys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpGet request = new HttpGet(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + return httpClient.execute(request); + } + + /** + * 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/holiday02-common/src/main/java/com/sikadi/common/utils/JwtUtils.java b/holiday02-common/src/main/java/com/sikadi/common/utils/JwtUtils.java new file mode 100644 index 0000000..f36485c --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/utils/JwtUtils.java @@ -0,0 +1,106 @@ +package com.sikadi.common.utils; + +import com.sikadi.common.constants.JwtConstants; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import java.util.Map; + +/** + * @ClassName JwtUtils + * @Description Jwt工具类 + * @Author ChenLong + * @Date 2023/2/23 16:10 + * @Version 1.0 + */ +public class JwtUtils { + public static String secret = JwtConstants.SECRET; + /** + * 从数据声明生成令牌 + * + * @param claims 数据声明 + * @return 令牌 + */ + public static String createToken(Map claims){ + String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact(); + return token; + } + /** + * 从令牌中获取数据声明 + * + * @param token 令牌 + * @return 数据声明 + */ + public static Claims parseToken(String token){ + return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody(); + } + /** + * 根据令牌获取用户标识 + * + * @param token 令牌 + * @return 用户ID + */ + public static String getUserKey(String token){ + Claims claims = parseToken(token); + return getValue(claims, JwtConstants.USER_KEY); + } + /** + * 根据令牌获取用户标识 + * + * @param claims 身份信息 + * @return 用户ID + */ + public static String getUserKey(Claims claims){ + return getValue(claims, JwtConstants.USER_KEY); + } + /** + * 根据令牌获取用户ID + * + * @param token 令牌 + * @return 用户ID + */ + public static String getUserId(String token){ + Claims claims = parseToken(token); + return getValue(claims, JwtConstants.DETAILS_USER_ID); + } + /** + * 根据身份信息获取用户ID + * + * @param claims 身份信息 + * @return 用户ID + */ + public static String getUserId(Claims claims){ + return getValue(claims, JwtConstants.DETAILS_USER_ID); + } + /** + * 根据令牌获取用户名 + * + * @param token 令牌 + * @return 用户名 + */ + public static String getUserName(String token){ + Claims claims = parseToken(token); + return getValue(claims, JwtConstants.DETAILS_USERNAME); + } + /** + * 根据身份信息获取用户名 + * + * @param claims 身份信息 + * @return 用户名 + */ + public static String getUserName(Claims claims){ + return getValue(claims, JwtConstants.DETAILS_USERNAME); + } + /** + * 根据身份信息获取键值 + * + * @param claims 身份信息 + * @param key 键 + * @return 值 + */ + public static String getValue(Claims claims, String key){ + Object obj = claims.get(key); + return obj == null ? "" : obj.toString(); + } +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/utils/MsgUtil.java b/holiday02-common/src/main/java/com/sikadi/common/utils/MsgUtil.java new file mode 100644 index 0000000..5e874a1 --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/utils/MsgUtil.java @@ -0,0 +1,41 @@ +package com.sikadi.common.utils; + + +import org.apache.http.HttpResponse; + +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 + */ +public class MsgUtil { + + + public static void sendMsg(String phone,String code){ + String host = "http://dingxin.market.alicloudapi.com"; + String path = "/dx/sendSms"; + String method = "POST"; + //String appcode = "0d534f614a8647ca94d697eec974aa63"; + String appcode = "dcb3dabebd3843a7a138901659ed112a"; + Map headers = new HashMap(); + headers.put("Authorization", "APPCODE " + appcode); + Map querys = new HashMap(); + querys.put("mobile", phone); + querys.put("param", "code:"+code); + querys.put("tpl_id", "TP1711063"); + Map bodys = new HashMap(); + + try { + + HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys); + System.out.println(response.toString()); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/utils/OssUtil.java b/holiday02-common/src/main/java/com/sikadi/common/utils/OssUtil.java new file mode 100644 index 0000000..6d71c3b --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/utils/OssUtil.java @@ -0,0 +1,153 @@ +package com.sikadi.common.utils; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.GetObjectRequest; +import com.aliyun.oss.model.PutObjectRequest; +import lombok.extern.log4j.Log4j2; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.time.LocalDateTime; +import java.util.UUID; + +/** + * Oss服务调用 + */ +@Log4j2 +public class OssUtil { + + /** + * Endpoint 存储对象概述 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 访问路径前缀 存储对象概述 + */ + private static String endPoint = "oss-cn-shanghai.aliyuncs.com"; + private static String accessKeyId = "LTAI5tPHcqEdn49yrDCNpLhb"; + private static String accessKeySecret = "C29u7EmS0TFlgMBzVszvuPFUxsKJuW"; + private static String accessPre = "https://liushiqian.oss-cn-shanghai.aliyuncs.com/"; + + /** + * bucket名称 + * @return + */ + private static String bucketName = "liushiqian"; + + private static OSS ossClient ; + + static { + ossClient = new OSSClientBuilder().build( + endPoint, + accessKeyId, + accessKeySecret); + log.info("oss服务连接成功!"); + } + + /** + * 默认路径上传本地文件 + * @param filePath + */ + public static String uploadFile(String filePath){ + return uploadFileForBucket(bucketName,getOssFilePath(filePath) ,filePath); + } + + /** + * 默认路径上传multipartFile文件 + * @param multipartFile + */ + public static String uploadMultipartFile(MultipartFile multipartFile) { + return uploadMultipartFile(bucketName,getOssFilePath(multipartFile.getOriginalFilename()),multipartFile); + } + /** + * 上传 multipartFile 类型文件 + * @param bucketName + * @param ossPath + * @param multipartFile + */ + public static String uploadMultipartFile(String bucketName , String ossPath , MultipartFile multipartFile){ + InputStream inputStream = null; + try { + inputStream = multipartFile.getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + } + uploadFileInputStreamForBucket(bucketName, ossPath, inputStream); + return accessPre+ossPath; + } + + /** + * 使用File上传PutObject上传文件 ** 程序默认使用次方法上传 + * @param bucketName 实例名称 + * @param ossPath oss存储路径 + * @param filePath 本地文件路径 + */ + public static String uploadFileForBucket(String bucketName , String ossPath , String filePath) { + // 创建PutObjectRequest对象。 + PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath)); + + // 上传 + ossClient.putObject(putObjectRequest); + return accessPre+ossPath; + } + + /** + * 使用文件流上传到指定的bucket实例 + * @param bucketName 实例名称 + * @param ossPath oss存储路径 + * @param filePath 本地文件路径 + */ + public static String uploadFileInputStreamForBucket(String bucketName , String ossPath , String filePath){ + + // 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。 + InputStream inputStream = null; + try { + inputStream = new FileInputStream(filePath); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + // 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。 + uploadFileInputStreamForBucket(bucketName, ossPath, inputStream); + return accessPre+ossPath; + } + + public static void uploadFileInputStreamForBucket(String bucketName , String ossPath , InputStream inputStream ){ + ossClient.putObject(bucketName, ossPath, inputStream); + } + + /** + * 下载 + * @param ossFilePath + * @param filePath + */ + public static void downloadFile(String ossFilePath , String filePath ){ + downloadFileForBucket(bucketName , ossFilePath , filePath); + } + /** + * 下载 + * @param bucketName 实例名称 + * @param ossFilePath oss存储路径 + * @param filePath 本地文件路径 + */ + public static void downloadFileForBucket(String bucketName , String ossFilePath , String filePath ){ + ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath)); + } + + /** + * + * @return + */ + public static String getOssDefaultPath(){ + LocalDateTime now = LocalDateTime.now(); + String url = + now.getYear()+"/"+ + now.getMonth()+"/"+ + now.getDayOfMonth()+"/"+ + now.getHour()+"/"+ + now.getMinute()+"/"; + return url; + } + + public static String getOssFilePath(String filePath){ + String fileSuf = filePath.substring(filePath.indexOf(".") + 1); + return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf; + } + +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/utils/StringUtils.java b/holiday02-common/src/main/java/com/sikadi/common/utils/StringUtils.java new file mode 100644 index 0000000..d84fa1d --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/utils/StringUtils.java @@ -0,0 +1,71 @@ +package com.sikadi.common.utils; + +import org.springframework.util.AntPathMatcher; + +import java.util.Collection; +import java.util.List; + +/** + * @ClassName StringUtils + * @Description 字符串处理工具类 + * @Author ChenLong + * @Date 2023/2/23 16:11 + * @Version 1.0 + */ +public class StringUtils extends org.apache.commons.lang3.StringUtils { + + /** + * * 判断一个对象是否为空 + * + * @param object Object + * @return true:为空 false:非空 + */ + public static boolean isNull(Object object) { + return object == null; + } + + /** + * * 判断一个Collection是否为空, 包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Collection coll) { + return isNull(coll) || coll.isEmpty(); + } + + /** + * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串 + * + * @param str 指定字符串 + * @param strs 需要检查的字符串数组 + * @return 是否匹配 + */ + public static boolean matches(String str, List strs) { + if (isEmpty(str) || isEmpty(strs)) { + return false; + } + for (String pattern : strs) { + if (isMatch(pattern, str)) + { + return true; + } + } + return false; + } + + /** + * 判断url是否与规则配置: + * ? 表示单个字符; + * * 表示一层路径内的任意字符串,不可跨层级; + * ** 表示任意层路径; + * + * @param pattern 匹配规则 + * @param url 需要匹配的url + * @return + */ + public static boolean isMatch(String pattern, String url) { + AntPathMatcher matcher = new AntPathMatcher(); + return matcher.match(pattern, url); + } +} diff --git a/holiday02-common/src/main/java/com/sikadi/common/utils/TelSmsUtils.java b/holiday02-common/src/main/java/com/sikadi/common/utils/TelSmsUtils.java new file mode 100644 index 0000000..6f44ae2 --- /dev/null +++ b/holiday02-common/src/main/java/com/sikadi/common/utils/TelSmsUtils.java @@ -0,0 +1,87 @@ +package com.sikadi.common.utils; + +import com.alibaba.fastjson.JSONObject; +import com.aliyun.dysmsapi20170525.Client; +import com.aliyun.dysmsapi20170525.models.SendSmsRequest; +import com.aliyun.dysmsapi20170525.models.SendSmsResponse; +import com.aliyun.teaopenapi.models.Config; +import lombok.extern.log4j.Log4j2; + +import java.util.Map; + +/** + * 短信工具类 + */ +@Log4j2 +public class TelSmsUtils { + + /** + * 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 + */ + private static String accessKeyId = "LTAIEVXszCmcd1T5"; + private static String accessKeySecret = "2zHwciQXln8wExSEnkIYtRTSwLeRNd"; + + /** + * 短信访问域名 + */ + private static String endpoint = "dysmsapi.aliyuncs.com"; + /** + * 短信签名 + */ + private static String signName = "登录验证"; + + /** + * 实例化短信对象 + */ + private static Client client; + + static { + log.info("初始化短信服务开始"); + long startTime = System.currentTimeMillis(); + try { + client = initClient(); + log.info("初始化短信成功:{}",signName); + } catch (Exception e) { + e.printStackTrace(); + } + log.info("初始化短信服务结束:耗时:{}MS",(System.currentTimeMillis()-startTime)); + } + /** + * 初始化短信对象 + * @return + * @throws Exception + */ + private static Client initClient() throws Exception{ + Config config = new Config() + // 您的AccessKey ID + .setAccessKeyId(accessKeyId) + // 您的AccessKey Secret + .setAccessKeySecret(accessKeySecret); + // 访问的域名 + config.endpoint = endpoint; + return new Client(config); + } + + /** + * 发送单条短信 + * @param tel + * @param templateCode SMS_153991546 + * @param sendDataMap + */ + public static String sendSms(String tel , String templateCode , Map sendDataMap){ + SendSmsRequest sendSmsRequest = new SendSmsRequest() + .setPhoneNumbers(tel) + .setSignName(signName) + .setTemplateCode(templateCode) + .setTemplateParam(JSONObject.toJSONString(sendDataMap)); + SendSmsResponse sendSmsResponse = null; + try { + log.info("发送短信验证码:消息内容是:【{}】", JSONObject.toJSONString(sendDataMap)); + sendSmsResponse = client.sendSms(sendSmsRequest); + } catch (Exception e) { + log.error("短信发送异常,手机号:【{}】,短信内容:【{}】,异常信息:【{}】", tel, sendDataMap, e); + } + return JSONObject.toJSONString(sendSmsResponse.getBody()); + } + +} diff --git a/holiday02-store/.gitignore b/holiday02-store/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/holiday02-store/.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/holiday02-store/pom.xml b/holiday02-store/pom.xml new file mode 100644 index 0000000..6500b5d --- /dev/null +++ b/holiday02-store/pom.xml @@ -0,0 +1,165 @@ + + + 4.0.0 + + com.sikadi + holiday02 + 1.0-SNAPSHOT + + + holiday02-store + + + 8 + 8 + UTF-8 + + + + + com.sikadi + holiday02-common + 1.0-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-web + + + + com.alibaba + druid-spring-boot-starter + 1.2.8 + + + + mysql + mysql-connector-java + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.2.2 + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.4.1 + + + + software.amazon.awssdk + s3 + 2.18.30 + + + org.slf4j + slf4j-simple + 2.0.5 + + + software.amazon.awssdk + s3-transfer-manager + 2.18.30-PREVIEW + + + org.json + json + 20090211 + + + org.junit.jupiter + junit-jupiter-api + 5.10.0-M1 + + + + org.springframework.boot + spring-boot-configuration-processor + true + 2.7.8 + + + cn.hutool + hutool-all + 5.8.18 + + + org.springframework.boot + spring-boot-starter-web + 2.7.8 + + + com.alibaba + fastjson + 1.2.67 + + + org.java-websocket + Java-WebSocket + 1.3.8 + + + + com.squareup.okhttp3 + okhttp + 4.9.3 + + + + org.projectlombok + lombok + 1.18.24 + + + org.slf4j + slf4j-log4j12 + 1.7.30 + + + mysql + mysql-connector-java + 5.1.32 + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.3.1 + + + org.springframework.boot + spring-boot-starter-aop + 2.7.2 + + + org.json + json + 20210307 + + + commons-codec + commons-codec + 1.15 + + + com.amazonaws + aws-java-sdk-s3 + 1.12.68 + + + + com.amazonaws + aws-java-sdk-core + 1.12.68 + + + + + + + diff --git a/holiday02-store/src/main/java/com/sikadi/store/controller/StoreController.java b/holiday02-store/src/main/java/com/sikadi/store/controller/StoreController.java new file mode 100644 index 0000000..254cacd --- /dev/null +++ b/holiday02-store/src/main/java/com/sikadi/store/controller/StoreController.java @@ -0,0 +1,20 @@ +package com.sikadi.store.controller; + + +import org.json.JSONObject; + +import static com.sikadi.store.util.FileDuoJiYun.*; + +public class StoreController { + + //用来调用多吉云API获取秘钥 + public static JSONObject getCredentials() { + JSONObject body = new JSONObject(); + body.put("channel", "OSS_FULL"); + body.append("scopes", "*"); // 要操作的存储空间名称,注意不是 s3Bucket 值,也可以设置为 * + + JSONObject data = dogeAPIGet("/auth/tmp_token.json", body); + JSONObject credentials = data.getJSONObject("Credentials"); + return credentials; + } +} diff --git a/holiday02-store/src/main/java/com/sikadi/store/service/impl/StoreServiceImpl.java b/holiday02-store/src/main/java/com/sikadi/store/service/impl/StoreServiceImpl.java new file mode 100644 index 0000000..ae708e2 --- /dev/null +++ b/holiday02-store/src/main/java/com/sikadi/store/service/impl/StoreServiceImpl.java @@ -0,0 +1,50 @@ +package com.sikadi.store.service.impl; + +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicSessionCredentials; +import com.amazonaws.client.builder.AwsClientBuilder; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import com.amazonaws.services.s3.model.PutObjectResult; +import com.amazonaws.services.s3.model.S3Object; +import com.sikadi.store.controller.StoreController; +import com.sikadi.store.util.FileDuoJiYun; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; + +import static com.sikadi.store.util.FileDuoJiYun.dogeAPIGet; + +public class StoreServiceImpl { + + public static AmazonS3 initS3(JSONObject credentials){ + BasicSessionCredentials awsCredentials = new BasicSessionCredentials(credentials.getString("accessKeyId"), credentials.getString("secretAccessKey"), credentials.getString("sessionToken")); + AmazonS3 s3 = AmazonS3ClientBuilder.standard() + .withCredentials(new AWSStaticCredentialsProvider(awsCredentials)) + .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( + "https://cos.ap-chengdu.myqcloud.com", // 修改为多吉云控制台存储空间 SDK 参数中的 s3Endpoint + "automatic")) + .build(); + return s3; + } + + public static void main(String[] args) throws Exception { + JSONObject data = dogeAPIGet("/oss/bucket/list.json"); + JSONArray buckets = data.getJSONArray("buckets"); + for (int i = 0 ; i < buckets.length(); i++) { + System.out.println(buckets.getJSONObject(i).toString()); + } + + JSONObject credentials = StoreController.getCredentials(); + AmazonS3 s3 = initS3(credentials); + PutObjectResult putObjectResult = s3.putObject("s-cd-7677-wsm-sj-1258813047", "7e2u.png", new File("\"D:\\只爱蒂蒂\\Pictures\\兔兔.jpg\"")); + String string = putObjectResult.toString(); + System.out.println(string); + + } + +} diff --git a/holiday02-store/src/main/java/com/sikadi/store/util/FileDuoJiYun.java b/holiday02-store/src/main/java/com/sikadi/store/util/FileDuoJiYun.java new file mode 100644 index 0000000..fe47b60 --- /dev/null +++ b/holiday02-store/src/main/java/com/sikadi/store/util/FileDuoJiYun.java @@ -0,0 +1,117 @@ +package com.sikadi.store.util; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Map; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +import org.json.JSONException; +import org.json.JSONObject; +import org.apache.commons.codec.binary.Hex; + +public class FileDuoJiYun { + + // 普通 API 请使用这个方法 + public static JSONObject dogeAPIGet(String apiPath, Map params) { + StringBuilder sb = new StringBuilder(); + for(Map.Entry hm : params.entrySet()){ + try { + sb.append(URLEncoder.encode(hm.getKey(), String.valueOf(StandardCharsets.UTF_8))).append('=').append(URLEncoder.encode(hm.getValue(), String.valueOf(StandardCharsets.UTF_8))).append("&"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + String bodyText = sb.toString().replace("&$", ""); + try { + return dogeAPIGet(apiPath, bodyText, false); + } catch (IOException | JSONException e) { + e.printStackTrace(); + throw new RuntimeException(e.getMessage()); + } + } + + // 要求请求内容 Body 是一个 JSON 的 API,请使用这个方法 + public static JSONObject dogeAPIGet(String apiPath, JSONObject params) throws JSONException { + String bodyText = params.toString(); + try { + return dogeAPIGet(apiPath, bodyText, true); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e.getMessage()); + } + } + + // 无参数 API + public static JSONObject dogeAPIGet(String apiPath) throws JSONException { + try { + return dogeAPIGet(apiPath, "", true); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e.getMessage()); + } + } + + public static JSONObject dogeAPIGet(String apiPath, String paramsText, Boolean jsonMode) throws IOException, JSONException { + // 这里返回值类型是 JSONObject,你也可以根据你的具体情况使用不同的 JSON 库并修改最下方 JSON 处理代码 + + // 这里替换为你的多吉云永久 AccessKey 和 SecretKey,可在用户中心 - 密钥管理中查看 + // 请勿在客户端暴露 AccessKey 和 SecretKey,那样恶意用户将获得账号完全控制权 + String accessKey = "kjd189189u981kj"; + String secretKey = "ada91871ns1jc9711jkn981d"; + + String signStr = apiPath + "\n" + paramsText; + String sign = ""; + try { + Mac mac = Mac.getInstance("HmacSHA1"); + mac.init(new SecretKeySpec(secretKey.getBytes(), "HmacSHA1")); + sign = new String(new Hex().encode(mac.doFinal(signStr.getBytes())), StandardCharsets.UTF_8); // 这里 Hex 来自 org.apache.commons.codec.binary.Hex + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + throw new RuntimeException(e.getMessage()); + } catch (InvalidKeyException e) { + e.printStackTrace(); + throw new RuntimeException(e.getMessage()); + } + String authorization = "TOKEN " + accessKey + ':' + sign; + + URL u = new URL("https://api.dogecloud.com" + apiPath); + HttpURLConnection conn = (HttpURLConnection) u.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty( "Content-Type", jsonMode ? "application/json" : "application/x-www-form-urlencoded"); + conn.setRequestProperty( "Authorization", authorization); + conn.setRequestProperty( "Content-Length", String.valueOf(paramsText.length())); + OutputStream os = conn.getOutputStream(); + os.write(paramsText.getBytes()); + os.flush(); + os.close(); + StringBuilder retJSON = new StringBuilder(); + if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){ + String readLine = ""; + try (BufferedReader responseReader=new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) { + while((readLine=responseReader.readLine())!=null){ + retJSON.append(readLine).append("\n"); + } + responseReader.close(); + } + JSONObject ret = new JSONObject(retJSON.toString()); + if (ret.getInt("code") != 200) { + System.err.println("{\"error\":\"API 返回错误:" + ret.getString("msg") + "\"}"); + } else { + JSONObject output = new JSONObject(); + JSONObject data = ret.getJSONObject("data"); + return data; + } + } else { + System.err.println("{\"error\":\"网络错误:" + conn.getResponseCode() + "\"}"); + } + return null; + } +} diff --git a/holiday02-store/src/main/resources/bootstrap.yml b/holiday02-store/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..3f0ddbc --- /dev/null +++ b/holiday02-store/src/main/resources/bootstrap.yml @@ -0,0 +1,30 @@ +# Tomcat +server: + port: 9001 +# Spring +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: sikadi-user + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 182.254.222.21:8848 + config: + # 配置中心地址 + server-addr: 182.254.222.21:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + namespace: Sikadi diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..be57626 --- /dev/null +++ b/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + com.sikadi + holiday02 + 1.0-SNAPSHOT + pom + + holiday02-common + holiday02-store + + + + 8 + 8 + UTF-8 + + + + + spring-boot-starter-parent + org.springframework.boot + 2.6.2 + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + 2021.0.0 + pom + import + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + 2021.1 + pom + import + + + + com.alibaba.nacos + nacos-client + 2.0.4 + + + com.sikadi + holiday02-common + 1.0-SNAPSHOT + + + + +