Skip to content

Commit

Permalink
Merge pull request #3398 from KouShenhai/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
KouShenhai authored Jan 22, 2025
2 parents b1f9519 + 9eb0982 commit 33622a7
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 57 deletions.
9 changes: 9 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ image:https://img.shields.io/badge/Q群-465450496-blue.svg[KCloud-Platform开源
image:doc/image/img_1.png[COLA架构图,400,400,align=center]
image:doc/image/img.png[COLA架构图,400,400,align=center]

=== 🌿 服务器配置

[width=100%]
|===
|环境 |配置 |备注
|开发 | 32G【内存】  512G【磁盘】 |无
|生产 | 16G【内存】  40G【磁盘】 |请搭建集群
|===

=== 🔗 在线体验

[width=100%]
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ KCloud-Platform-IoT(阻塞式)(老寇IoT云平台)是一个企业级微
<img src="doc/image/img_1.png" width=400 height=400 alt="COLA架构图"/>
<img src="doc/image/img.png" width=400 height=400 alt="COLA架构图"/>

### 🌿 服务器配置

| 环境 | 配置 | 备注 |
|:--:|:---------------------------:|:-----:|
| 开发 | 32G【内存】&nbsp;&nbsp;512G【磁盘】 ||
| 生产 | 16G【内存】&nbsp;&nbsp;40G【磁盘】 | 请搭建集群 |

### 🔗 在线体验

| 序号 | 账号 | 密码 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class MybatisPlusAutoConfig {
}

@Bean
public ConfigurationCustomizer slowSqlConfigurationCustomizer(MybatisPlusExtProperties mybatisPlusExtProperties) {
public ConfigurationCustomizer configurationCustomizer(MybatisPlusExtProperties mybatisPlusExtProperties) {
return configuration -> {
// 异步查询count
configuration.addInterceptor(new AsyncCountInterceptor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,35 @@ public Object intercept(Invocation invocation) throws Throwable {
if (sqlMonitor.isEnabled()
&& costTime >= sqlMonitor.getInterval()
&& target instanceof StatementHandler statementHandler) {
// 替换空格、制表符、换页符
String sql = getSql(statementHandler).replaceAll("\\s+", SPACE);
String sql = getSql(statementHandler);
log.info("Consume Time:{} ms,Execute SQL:{}", costTime, sql);
}
return obj;
}

private String getSql(StatementHandler statementHandler) throws JsonProcessingException {
BoundSql boundSql = statementHandler.getBoundSql();
String sql = boundSql.getSql();
if (sql.indexOf("?") > 0) {
// 替换空格、制表符、换页符
String sql = boundSql.getSql().replaceAll("\\s+", SPACE);
if (sql.indexOf('?') > 0) {
String parameter = JacksonUtil.toJsonStr(boundSql.getParameterObject());
JsonNode jsonNode = JacksonUtil.readTree(parameter);
String json = jsonNode.get("ew").get("paramNameValuePairs").toString();
Map<String, String> map = JacksonUtil.toMap(json, String.class, String.class);
List<String> list = map.entrySet().stream().sorted(Map.Entry.comparingByKey()).map(Map.Entry::getValue).toList();
for (String str : list) {
sql = sql.replaceFirst("\\?", "'" + str + "'");
Map<String, Object> map = JacksonUtil.toMap(json, String.class, Object.class);
List<Object> list = map.entrySet().stream().sorted(Map.Entry.comparingByKey()).map(Map.Entry::getValue).toList();
for (Object obj : list) {
sql = sql.replaceFirst("\\?", getPrettyValue(obj));
}
}
return sql;
}

private String getPrettyValue(Object obj) {
if (obj instanceof String str) {
return "'".concat(str).concat("'");
} else {
return obj.toString();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,47 +37,32 @@ class AuthParamValidatorTest {
@Test
void testUsernamePasswordAuthParamValidator() {
AuthParamValidatorExtPt authParamValidator = new UsernamePasswordAuthParamValidator();
Assertions.assertNotNull(authParamValidator);

AuthA auth = DomainFactory.getUsernamePasswordAuth(1L, "admin", "123", "laokou", "1", "1234");
Assertions.assertNotNull(auth);

// 校验用户名密码登录
authParamValidator.validate(auth);
}

@Test
void testAuthorizationCodeAuthParamValidator() {
AuthParamValidatorExtPt authParamValidator = new AuthorizationCodeAuthParamValidator();
Assertions.assertNotNull(authParamValidator);

AuthA auth = DomainFactory.getAuthorizationCodeAuth(1L, "admin", "123", "laokou");
Assertions.assertNotNull(auth);

// 校验授权码登录
authParamValidator.validate(auth);
}

@Test
void testMailAuthParamValidator() {
AuthParamValidatorExtPt authParamValidator = new MailAuthParamValidator();
Assertions.assertNotNull(authParamValidator);

AuthA auth = DomainFactory.getMailAuth(1L, "[email protected]", "123456", "laokou");
Assertions.assertNotNull(auth);

// 校验邮箱登录
authParamValidator.validate(auth);
}

@Test
void testMobileAuthParamValidator() {
AuthParamValidatorExtPt authParamValidator = new MobileAuthParamValidator();
Assertions.assertNotNull(authParamValidator);

AuthA auth = DomainFactory.getMobileAuth(1L, "18888888888", "123456", "laokou");
Assertions.assertNotNull(auth);

// 校验手机号登录
authParamValidator.validate(auth);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.laokou.auth;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.laokou.auth.factory.DomainFactory;
import org.laokou.auth.model.CaptchaE;
Expand All @@ -35,11 +34,7 @@ class CaptchaParamValidatorTest {
@Test
void testMailCaptchaParamValidator() {
CaptchaParamValidatorExtPt captchaParamValidator = new MailCaptchaParamValidator();
Assertions.assertNotNull(captchaParamValidator);

CaptchaE captcha = DomainFactory.getCaptcha();
Assertions.assertNotNull(captcha);

// 校验邮箱验证码
captcha.setUuid("[email protected]");
captcha.setTenantCode("laokou");
Expand All @@ -49,11 +44,7 @@ void testMailCaptchaParamValidator() {
@Test
void testMobileCaptchaParamValidator() {
CaptchaParamValidatorExtPt captchaParamValidator = new MobileCaptchaParamValidator();
Assertions.assertNotNull(captchaParamValidator);

CaptchaE captcha = DomainFactory.getCaptcha();
Assertions.assertNotNull(captcha);

// 校验手机号验证码
captcha.setUuid("18888888888");
captcha.setTenantCode("laokou");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,9 @@ class ExtensionExecutorTest {
void testUsernamePasswordAuthParamValidateExecutor() {
// 校验参数
validate();

AuthA auth = DomainFactory.getUsernamePasswordAuth(1L, "admin", "123", "laokou", "1", "1234");
Assertions.assertNotNull(auth);

// 注册【用户名密码登录】校验器
doRegistration(new UsernamePasswordAuthParamValidator());

// 执行参数校验【用户名密码登录】
execute(auth);
}
Expand All @@ -75,13 +71,9 @@ void testUsernamePasswordAuthParamValidateExecutor() {
void testMailAuthParamValidateExecutor() {
// 校验参数
validate();

AuthA auth = DomainFactory.getMailAuth(1L, "[email protected]", "123456", "laokou");
Assertions.assertNotNull(auth);

// 注册【邮箱登录】校验器
doRegistration(new MailAuthParamValidator());

// 执行参数校验【邮箱登录】
execute(auth);
}
Expand All @@ -90,13 +82,9 @@ void testMailAuthParamValidateExecutor() {
void testMobileAuthParamValidateExecutor() {
// 校验参数
validate();

AuthA auth = DomainFactory.getMobileAuth(1L, "18888888888", "123456", "laokou");
Assertions.assertNotNull(auth);

// 注册【手机号登录】校验器
doRegistration(new MobileAuthParamValidator());

// 执行参数校验【手机号登录】
execute(auth);
}
Expand All @@ -105,13 +93,9 @@ void testMobileAuthParamValidateExecutor() {
void testAuthorizationCodeAuthParamValidateExecutor() {
// 校验参数
validate();

AuthA auth = DomainFactory.getAuthorizationCodeAuth(1L, "admin", "123", "laokou");
Assertions.assertNotNull(auth);

// 注册【授权码登录】校验器
doRegistration(new AuthorizationCodeAuthParamValidator());

// 执行参数校验【授权码登录】
execute(auth);
}
Expand All @@ -120,13 +104,9 @@ void testAuthorizationCodeAuthParamValidateExecutor() {
void testMailCaptchaParamValidateExecutor() {
// 校验参数
validate();

CaptchaE captcha = DomainFactory.getCaptcha();
Assertions.assertNotNull(captcha);

// 注册【邮箱验证码】校验器
doRegistration(new MailCaptchaParamValidator());

// 执行参数校验【邮箱验证码】
captcha.setTag(MAIL_TAG);
captcha.setUuid("[email protected]");
Expand All @@ -138,13 +118,9 @@ void testMailCaptchaParamValidateExecutor() {
void testCaptchaParamValidateExecutor() {
// 校验参数
validate();

CaptchaE captcha = DomainFactory.getCaptcha();
Assertions.assertNotNull(captcha);

// 注册【手机号验证码】校验器
doRegistration(new MobileCaptchaParamValidator());

// 执行参数校验【手机号验证码】
captcha.setTag(MOBILE_TAG);
captcha.setUuid("18888888888");
Expand Down

0 comments on commit 33622a7

Please sign in to comment.