style: 应用 Spotless 代码格式化
- 对所有 Java 源文件应用统一的代码格式化 - 统一缩进为 4 个空格 - 清理尾随空白字符和文件末尾换行 - 优化导入语句组织 - 总计格式化 654 个 Java 文件 有问题可以回滚或者找我聊
This commit is contained in:
@@ -6,7 +6,6 @@ import com.starry.common.constant.CacheConstants;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
import com.starry.common.utils.SpringUtils;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,7 +17,8 @@ public class DictUtils {
|
||||
/**
|
||||
* 获取 cache key
|
||||
*
|
||||
* @param key 参数键
|
||||
* @param key
|
||||
* 参数键
|
||||
* @return 缓存键key
|
||||
*/
|
||||
public static String getCacheKey(String key) {
|
||||
@@ -28,7 +28,8 @@ public class DictUtils {
|
||||
/**
|
||||
* 获取字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @param key
|
||||
* 参数键
|
||||
* @return dictDatas 字典数据列表
|
||||
*/
|
||||
public static List<SysDictDataEntity> getDictCache(String key) {
|
||||
@@ -42,8 +43,10 @@ public class DictUtils {
|
||||
/**
|
||||
* 设置字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @param dataList 字典数据列表
|
||||
* @param key
|
||||
* 参数键
|
||||
* @param dataList
|
||||
* 字典数据列表
|
||||
*/
|
||||
public static void setDictCache(String key, List<SysDictDataEntity> dataList) {
|
||||
SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dataList);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.starry.admin.utils;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
@@ -16,7 +15,8 @@ public class ExcelUtils {
|
||||
return EasyExcel.read(is).head(pojoClass).sheet().doReadSync();
|
||||
}
|
||||
|
||||
public static void exportEasyExcel(HttpServletResponse response, Class<?> pojoClass, List<?> list, String sheetName) {
|
||||
public static void exportEasyExcel(HttpServletResponse response, Class<?> pojoClass, List<?> list,
|
||||
String sheetName) {
|
||||
try {
|
||||
EasyExcel.write(response.getOutputStream(), pojoClass).sheet(sheetName).doWrite(list);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
package com.starry.admin.utils;
|
||||
|
||||
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;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
@@ -18,18 +29,6 @@ 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 {
|
||||
|
||||
/**
|
||||
@@ -43,10 +42,8 @@ public class HttpUtils {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doGet(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys)
|
||||
throws Exception {
|
||||
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));
|
||||
@@ -69,11 +66,8 @@ public class HttpUtils {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
Map<String, String> bodys)
|
||||
throws Exception {
|
||||
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));
|
||||
@@ -107,11 +101,8 @@ public class HttpUtils {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
String body)
|
||||
throws Exception {
|
||||
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));
|
||||
@@ -138,11 +129,8 @@ public class HttpUtils {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
byte[] body)
|
||||
throws Exception {
|
||||
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));
|
||||
@@ -169,11 +157,8 @@ public class HttpUtils {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPut(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
String body)
|
||||
throws Exception {
|
||||
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));
|
||||
@@ -200,11 +185,8 @@ public class HttpUtils {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPut(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
byte[] body)
|
||||
throws Exception {
|
||||
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));
|
||||
@@ -230,10 +212,8 @@ public class HttpUtils {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doDelete(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys)
|
||||
throws Exception {
|
||||
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));
|
||||
@@ -244,7 +224,8 @@ public class HttpUtils {
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
|
||||
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)) {
|
||||
@@ -312,4 +293,4 @@ public class HttpUtils {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,27 +8,26 @@ package com.starry.admin.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
/**
|
||||
* List<Integer> ==> string
|
||||
* List<Integer> ==> string
|
||||
*
|
||||
* @Date 2022-10-08
|
||||
*/
|
||||
public class ListToStringHandle extends BaseTypeHandler<List> {
|
||||
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement preparedStatement, int i, List list, JdbcType jdbcType) throws SQLException {
|
||||
public void setNonNullParameter(PreparedStatement preparedStatement, int i, List list, JdbcType jdbcType)
|
||||
throws SQLException {
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
preparedStatement.setString(i, JSON.toJSONString(list));
|
||||
} else {
|
||||
@@ -55,4 +54,3 @@ public class ListToStringHandle extends BaseTypeHandler<List> {
|
||||
return result == null ? new ArrayList<>() : JSONArray.parseArray(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.starry.admin.utils;
|
||||
|
||||
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
|
||||
/**
|
||||
* 金额辅助类
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class MoneyUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 校验金钱值是否正常
|
||||
*
|
||||
* @param money 金钱值
|
||||
* @param money
|
||||
* 金钱值
|
||||
*/
|
||||
public static void verificationTypeIsNormal(String money) {
|
||||
if (money == null || money.isEmpty()) {
|
||||
@@ -33,5 +33,4 @@ public class MoneyUtils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.starry.admin.utils;
|
||||
|
||||
|
||||
import com.starry.admin.common.domain.LoginUser;
|
||||
import com.starry.admin.common.security.entity.JwtUser;
|
||||
import com.starry.admin.modules.system.module.entity.SysUserEntity;
|
||||
@@ -80,7 +79,8 @@ public class SecurityUtils {
|
||||
/**
|
||||
* 生成BCryptPasswordEncoder密码
|
||||
*
|
||||
* @param password 密码
|
||||
* @param password
|
||||
* 密码
|
||||
* @return 加密字符串
|
||||
*/
|
||||
public static String encryptPassword(String password) {
|
||||
@@ -91,8 +91,10 @@ public class SecurityUtils {
|
||||
/**
|
||||
* 判断密码是否相同
|
||||
*
|
||||
* @param rawPassword 真实密码
|
||||
* @param encodedPassword 加密后字符
|
||||
* @param rawPassword
|
||||
* 真实密码
|
||||
* @param encodedPassword
|
||||
* 加密后字符
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean matchesPassword(String rawPassword, String encodedPassword) {
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.starry.admin.utils;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: huchuansai
|
||||
* @Date: 2024/7/29 5:41 PM
|
||||
@@ -33,17 +32,17 @@ public class SmsUtils {
|
||||
|
||||
// 校验短信验证码是否正确
|
||||
public void checkSmsCode(String phone, String code) {
|
||||
//if(StringUtils.isEmpty(code)){
|
||||
// throw new RuntimeException("短信验证码必填");
|
||||
//}
|
||||
//String key = "sms:phone:" + phone;
|
||||
//Object data = redisCache.getCacheObject(key);
|
||||
//if (Objects.isNull(data)) {
|
||||
// throw new RuntimeException("短信验证码无效或已过期");
|
||||
//}
|
||||
//if (!code.equals(data.toString())) {
|
||||
// throw new RuntimeException("短信验证码错误");
|
||||
//}
|
||||
// if(StringUtils.isEmpty(code)){
|
||||
// throw new RuntimeException("短信验证码必填");
|
||||
// }
|
||||
// String key = "sms:phone:" + phone;
|
||||
// Object data = redisCache.getCacheObject(key);
|
||||
// if (Objects.isNull(data)) {
|
||||
// throw new RuntimeException("短信验证码无效或已过期");
|
||||
// }
|
||||
// if (!code.equals(data.toString())) {
|
||||
// throw new RuntimeException("短信验证码错误");
|
||||
// }
|
||||
}
|
||||
|
||||
private static void sendSms(String phone, String code, String templateId) {
|
||||
@@ -57,7 +56,7 @@ public class SmsUtils {
|
||||
Map<String, String> querys = new HashMap<>();
|
||||
Map<String, String> bodys = new HashMap<>();
|
||||
bodys.put("content", "code:" + code);
|
||||
bodys.put("template_id", templateId); //注意,模板CST_11253 仅作调试使用,下发短信不稳定,请联系客服报备自己的专属签名模板,以保障业务稳定使用
|
||||
bodys.put("template_id", templateId); // 注意,模板CST_11253 仅作调试使用,下发短信不稳定,请联系客服报备自己的专属签名模板,以保障业务稳定使用
|
||||
bodys.put("phone_number", phone);
|
||||
try {
|
||||
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
||||
|
||||
Reference in New Issue
Block a user