Skip to content

Commit

Permalink
Merge pull request #3222 from KouShenhai/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
KouShenhai authored Dec 29, 2024
2 parents 53b9b37 + 7f6524b commit baaa30a
Show file tree
Hide file tree
Showing 27 changed files with 301 additions and 120 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ https://kcloud.blog.csdn.net[博客:https://kcloud.blog.csdn.net]

https://mail.qq.com[邮箱:[email protected]]

http://wpa.qq.com/msgrd?v=3&uin=2413176044&Site=gitee&Menu=yes[QQ:243176044]
http://wpa.qq.com/msgrd?v=3&uin=2413176044&Site=gitee&Menu=yes[QQ:2413176044]

image::https://img.shields.io/badge/Q群-465450496-blue.svg[QQ群,link=https://jq.qq.com/?_wv=1027&k=Ec8T76dR]

Expand Down
48 changes: 24 additions & 24 deletions doc/db/kcloud_platform_nacos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,9 @@ jasypt:
spring:
# mail
mail:
host: smtp.qq.com
username: 2413176044@qq.com
password: ENC(A7pfP5nvz3Mmc/6Nc3ewvkcNv7AQyZz8qWri7Kn8GqW4vwPFmZt+Vaq0gjS8SS1767v2h0exWJbJpA2zsTtmVA==)
host: smtp.163.com
username: koushenhai@163.com
password: ENC(f9S1dcXET/YKM04p66g9WLHu38+02CDn+Wf+6CBfaAFq93R7ukbNfj9nMstp32rvxF9uDDMd20/FtxmpETnecQ==)
default-encoding: UTF-8', '3e16e7d481fcc41559736dc5f7258251', '2024-05-25 18:12:47.354', '2024-07-16 21:51:27.174', 'nacos', '127.0.0.1', 'laokou-mail', '0dac1a68-2f01-40df-bd26-bf0cb199057a', 'mail配置', '', '', 'yaml', '', '');
INSERT INTO "public"."config_info" VALUES (39, 'application-report.yaml', 'LAOKOU_GROUP', 'server:
port: 8088', '89f7b26715cf760d099a258200381fe0', '2024-05-25 18:13:10.644', '2024-05-25 18:13:10.644', NULL, '127.0.0.1', 'laokou-report', '8140e92b-fb43-48f5-b63b-7506185206a5', '', NULL, NULL, 'yaml', NULL, '');
Expand All @@ -740,9 +740,9 @@ jasypt:
spring:
# mail
mail:
host: smtp.qq.com
username: 2413176044@qq.com
password: ENC(A7pfP5nvz3Mmc/6Nc3ewvkcNv7AQyZz8qWri7Kn8GqW4vwPFmZt+Vaq0gjS8SS1767v2h0exWJbJpA2zsTtmVA==)
host: smtp.163.com
username: koushenhai@163.com
password: ENC(f9S1dcXET/YKM04p66g9WLHu38+02CDn+Wf+6CBfaAFq93R7ukbNfj9nMstp32rvxF9uDDMd20/FtxmpETnecQ==)
default-encoding: UTF-8', '3e16e7d481fcc41559736dc5f7258251', '2023-02-13 20:00:32', '2024-07-16 21:52:10.149', 'nacos', '127.0.0.1', 'laokou-mail', 'a61abd4c-ef96-42a5-99a1-616adee531f3', 'mail配置', '', '', 'yaml', '', '');
INSERT INTO "public"."config_info" VALUES (90, 'application-report.yaml', 'LAOKOU_GROUP', 'server:
port: 8088', '89f7b26715cf760d099a258200381fe0', '2023-10-01 04:56:06', '2024-05-01 00:45:57', 'nacos', '0:0:0:0:0:0:0:1', 'laokou-report', 'a61abd4c-ef96-42a5-99a1-616adee531f3', '', '', '', 'yaml', '', '');
Expand Down Expand Up @@ -895,8 +895,8 @@ jasypt:
encryptor:
password: 5201314wumeihua
sms:
type: gyy
gyy:
enabled: true
template-id: ENC(YpExkbRJjCJUNB9QWmqzSmJl9XJ2BMnw2KmxxQ5JPXbhB66Z9ARRPJ3o4cuZNcxDgaLsLB0Qnplvvagdn0XJN7iZOPSL7P8pg3iFIoS8RKE=)
sign-id: ENC(anORfPoXwjam7f2azlNZAJbPfgmYUd6p8OVOyyNnTNgHNZPesJhYXE9mvqvpgHFSit3aNeIyBuJS6j1PSsFs6m0aJdL0NjvKNwPd2aGTLog=)
appcode: ENC(Mlk2DvR7RwOjEj0EajZ+9cjHqHK9Qzkmti7U1r8/iVDj2bFOwoO1ZdwbaYon/1QivDL1hu4vvxFVNv56mVdqCQiPQrhPW3oIJRDd9sQBfWA=)', '3adcbf9b68966d16ac2136f236f2f919', '2024-05-25 18:13:10.588', '2024-07-16 21:50:44.322', 'nacos', '127.0.0.1', 'laokou-sms', '8140e92b-fb43-48f5-b63b-7506185206a5', 'sms配置', '', '', 'yaml', '', '');
Expand All @@ -907,9 +907,9 @@ jasypt:
spring:
# mail
mail:
host: smtp.qq.com
username: 2413176044@qq.com
password: ENC(A7pfP5nvz3Mmc/6Nc3ewvkcNv7AQyZz8qWri7Kn8GqW4vwPFmZt+Vaq0gjS8SS1767v2h0exWJbJpA2zsTtmVA==)
host: smtp.163.com
username: koushenhai@163.com
password: ENC(f9S1dcXET/YKM04p66g9WLHu38+02CDn+Wf+6CBfaAFq93R7ukbNfj9nMstp32rvxF9uDDMd20/FtxmpETnecQ==)
default-encoding: UTF-8', '3e16e7d481fcc41559736dc5f7258251', '2024-05-25 18:13:10.594', '2024-07-16 21:52:24.67', 'nacos', '127.0.0.1', 'laokou-mail', '8140e92b-fb43-48f5-b63b-7506185206a5', 'mail配置', '', '', 'yaml', '', '');
INSERT INTO "public"."config_info" VALUES (61, 'application-report.yaml', 'LAOKOU_GROUP', 'server:
port: 8088', '89f7b26715cf760d099a258200381fe0', '2024-05-25 18:13:33.406', '2024-05-25 18:13:33.406', NULL, '127.0.0.1', 'laokou-report', '0dac1a68-2f01-40df-bd26-bf0cb199057a', '', NULL, NULL, 'yaml', NULL, '');
Expand Down Expand Up @@ -1802,8 +1802,8 @@ jasypt:
encryptor:
password: 5201314wumeihua
sms:
type: gyy
gyy:
enabled: true
template-id: ENC(YpExkbRJjCJUNB9QWmqzSmJl9XJ2BMnw2KmxxQ5JPXbhB66Z9ARRPJ3o4cuZNcxDgaLsLB0Qnplvvagdn0XJN7iZOPSL7P8pg3iFIoS8RKE=)
sign-id: ENC(anORfPoXwjam7f2azlNZAJbPfgmYUd6p8OVOyyNnTNgHNZPesJhYXE9mvqvpgHFSit3aNeIyBuJS6j1PSsFs6m0aJdL0NjvKNwPd2aGTLog=)
appcode: ENC(Mlk2DvR7RwOjEj0EajZ+9cjHqHK9Qzkmti7U1r8/iVDj2bFOwoO1ZdwbaYon/1QivDL1hu4vvxFVNv56mVdqCQiPQrhPW3oIJRDd9sQBfWA=)', '3adcbf9b68966d16ac2136f236f2f919', '2024-05-25 18:12:47.349', '2024-07-16 21:51:04.709', 'nacos', '127.0.0.1', 'laokou-sms', '0dac1a68-2f01-40df-bd26-bf0cb199057a', 'sms配置', '', '', 'yaml', '', '');
Expand Down Expand Up @@ -1840,7 +1840,7 @@ spring:
admin:
notify:
mail:
from: 2413176044@qq.com
from: koushenhai@163.com
to: [email protected]
template: META-INF/spring-boot-admin-server/mail/status-changed.html
# security
Expand All @@ -1852,9 +1852,9 @@ spring:
password: ENC(mHjKcITM5U60bq7M4fxh4yUQ9L3PPWPskvnWRE0PVxIqQ34Ztx7zOESwWCdjeWPW)
# mail
mail:
host: smtp.qq.com
username: 2413176044@qq.com
password: ENC(A7pfP5nvz3Mmc/6Nc3ewvkcNv7AQyZz8qWri7Kn8GqW4vwPFmZt+Vaq0gjS8SS1767v2h0exWJbJpA2zsTtmVA==)
host: smtp.163.com
username: koushenhai@163.com
password: ENC(f9S1dcXET/YKM04p66g9WLHu38+02CDn+Wf+6CBfaAFq93R7ukbNfj9nMstp32rvxF9uDDMd20/FtxmpETnecQ==)
default-encoding: UTF-8
logging:
Expand Down Expand Up @@ -1902,7 +1902,7 @@ spring:
admin:
notify:
mail:
from: 2413176044@qq.com
from: koushenhai@163.com
to: [email protected]
template: META-INF/spring-boot-admin-server/mail/status-changed.html
# security
Expand All @@ -1914,9 +1914,9 @@ spring:
password: ENC(mHjKcITM5U60bq7M4fxh4yUQ9L3PPWPskvnWRE0PVxIqQ34Ztx7zOESwWCdjeWPW)
# mail
mail:
host: smtp.qq.com
username: 2413176044@qq.com
password: ENC(A7pfP5nvz3Mmc/6Nc3ewvkcNv7AQyZz8qWri7Kn8GqW4vwPFmZt+Vaq0gjS8SS1767v2h0exWJbJpA2zsTtmVA==)
host: smtp.163.com
username: koushenhai@163.com
password: ENC(f9S1dcXET/YKM04p66g9WLHu38+02CDn+Wf+6CBfaAFq93R7ukbNfj9nMstp32rvxF9uDDMd20/FtxmpETnecQ==)
default-encoding: UTF-8
logging:
Expand Down Expand Up @@ -2233,7 +2233,7 @@ spring:
admin:
notify:
mail:
from: 2413176044@qq.com
from: koushenhai@163.com
to: [email protected]
template: META-INF/spring-boot-admin-server/mail/status-changed.html
# security
Expand All @@ -2245,9 +2245,9 @@ spring:
password: ENC(mHjKcITM5U60bq7M4fxh4yUQ9L3PPWPskvnWRE0PVxIqQ34Ztx7zOESwWCdjeWPW)
# mail
mail:
host: smtp.qq.com
username: 2413176044@qq.com
password: ENC(A7pfP5nvz3Mmc/6Nc3ewvkcNv7AQyZz8qWri7Kn8GqW4vwPFmZt+Vaq0gjS8SS1767v2h0exWJbJpA2zsTtmVA==)
host: smtp.163.com
username: koushenhai@163.com
password: ENC(f9S1dcXET/YKM04p66g9WLHu38+02CDn+Wf+6CBfaAFq93R7ukbNfj9nMstp32rvxF9uDDMd20/FtxmpETnecQ==)
default-encoding: UTF-8
logging:
Expand Down Expand Up @@ -5719,8 +5719,8 @@ jasypt:
encryptor:
password: 5201314wumeihua
sms:
type: gyy
gyy:
enabled: true
template-id: ENC(YpExkbRJjCJUNB9QWmqzSmJl9XJ2BMnw2KmxxQ5JPXbhB66Z9ARRPJ3o4cuZNcxDgaLsLB0Qnplvvagdn0XJN7iZOPSL7P8pg3iFIoS8RKE=)
sign-id: ENC(anORfPoXwjam7f2azlNZAJbPfgmYUd6p8OVOyyNnTNgHNZPesJhYXE9mvqvpgHFSit3aNeIyBuJS6j1PSsFs6m0aJdL0NjvKNwPd2aGTLog=)
appcode: ENC(Mlk2DvR7RwOjEj0EajZ+9cjHqHK9Qzkmti7U1r8/iVDj2bFOwoO1ZdwbaYon/1QivDL1hu4vvxFVNv56mVdqCQiPQrhPW3oIJRDd9sQBfWA=)', '3adcbf9b68966d16ac2136f236f2f919', '2023-02-13 19:59:35', '2024-07-16 21:50:25.922', 'nacos', '127.0.0.1', 'laokou-sms', 'a61abd4c-ef96-42a5-99a1-616adee531f3', 'sms配置', '', '', 'yaml', '', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ snail-job:
auth: true
connectionTimeout: 0
enabled: true
from: 2413176044@qq.com
host: smtp.qq.com
pass: ENC(A7pfP5nvz3Mmc/6Nc3ewvkcNv7AQyZz8qWri7Kn8GqW4vwPFmZt+Vaq0gjS8SS1767v2h0exWJbJpA2zsTtmVA==)
from: koushenhai@163.com
host: smtp.163.com
pass: ENC(f9S1dcXET/YKM04p66g9WLHu38+02CDn+Wf+6CBfaAFq93R7ukbNfj9nMstp32rvxF9uDDMd20/FtxmpETnecQ==)
port: 465
sslEnable: false
starttlsEnable: false
timeout: 0
user: 2413176044@qq.com
user: koushenhai@163.com
retry-pull-page-size: 1000 # 拉取重试数据的每批次的大小
job-pull-page-size: 1000 # 拉取重试数据的每批次的大小
netty-port: 1788 # 服务端netty端口
Expand Down
9 changes: 9 additions & 0 deletions laokou-common/laokou-common-crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -51,6 +55,11 @@
<artifactId>jasypt-spring-boot-starter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.laokou</groupId>
<artifactId>laokou-common-log4j2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void testJasypt2() {
String plainText = "laokou";
String encryptWithMD5AndDESStr = encryptWithMD5AndDES(plainText, factor);
String decryptWithMD5AndDESStr = decryptWithMD5AndDES(encryptWithMD5AndDESStr, factor);
log.info("采用PBEWithMD5AndDES加密前原文密文:{}", encryptWithMD5AndDESStr);
log.info("采用PBEWithMD5AndDES解密后密文原文:{}", decryptWithMD5AndDESStr);
log.info("采用PBEWithMD5AndDES加密后:{}", encryptWithMD5AndDESStr);
log.info("采用PBEWithMD5AndDES解密后:{}", decryptWithMD5AndDESStr);
Assertions.assertEquals(decryptWithMD5AndDESStr, plainText);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void testJasypt3() {
String plainText = "laokou";
String encryptWithMD5ANDAES256Str = encryptWithHMACSHA512ANDAES256(plainText, factor);
String decryptWithMD5ANDAES256Str = decryptWithHMACSHA512ANDAES256(encryptWithMD5ANDAES256Str, factor);
log.info("采用PBEWITHHMACSHA512ANDAES_256加密前原文密文:{}", encryptWithMD5ANDAES256Str);
log.info("采用PBEWITHHMACSHA512ANDAES_256解密后密文原文:{}", decryptWithMD5ANDAES256Str);
log.info("采用PBEWITHHMACSHA512ANDAES_256加密后:{}", encryptWithMD5ANDAES256Str);
log.info("采用PBEWITHHMACSHA512ANDAES_256解密后:{}", decryptWithMD5ANDAES256Str);
Assertions.assertEquals(decryptWithMD5ANDAES256Str, plainText);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.laokou.common.mail.config;

import org.laokou.common.mail.service.MailService;
import org.laokou.common.mail.service.impl.QQMailServiceImpl;
import org.laokou.common.mail.service.impl.MailServiceImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -33,7 +33,7 @@ public class MailAutoConfig {

@Bean
public MailService mailService(MailProperties mailProperties) {
return new QQMailServiceImpl(mailProperties);
return new MailServiceImpl(mailProperties);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,32 @@
* @author laokou
*/
@Slf4j
public class QQMailServiceImpl extends AbstractMailServiceImpl {
public class MailServiceImpl extends AbstractMailServiceImpl {

private static final String CAPTCHA_TEMPLATE = "验证码:${captcha},${minute}分钟内容有效,您正在登录,若非本人操作,请勿泄露。";

public QQMailServiceImpl(MailProperties mailProperties) {
public MailServiceImpl(MailProperties mailProperties) {
super(mailProperties);
}

@Override
public MailResult send(String mail) {
String subject = "验证码";
String name = "QQ邮箱" + subject;
String name = "邮箱" + subject;
String captcha = RandomStringUtil.randomNumeric(6);
// 默认5分钟有效
Map<String, Object> param = Map.of("captcha", captcha, "minute", 5);
String content = TemplateUtil.getContent(CAPTCHA_TEMPLATE, param);
// 敏感信息过滤
String params = JacksonUtil.toJsonStr(Map.of("mail", SensitiveUtil.formatMail(mail), "content", content));
String paramString = JacksonUtil.toJsonStr(Map.of("mail", SensitiveUtil.formatMail(mail), "content", content));
try {
// 发送邮件
sendMail(subject, content, mail);
return new MailResult(name, SendStatus.OK.getCode(), EMPTY, params, captcha);
return new MailResult(name, SendStatus.OK.getCode(), EMPTY, paramString, captcha);
}
catch (Exception e) {
log.error("错误信息:{}", e.getMessage());
return new MailResult(name, SendStatus.FAIL.getCode(), e.getMessage(), params, captcha);
return new MailResult(name, SendStatus.FAIL.getCode(), e.getMessage(), paramString, captcha);
}
}

Expand Down
4 changes: 4 additions & 0 deletions laokou-common/laokou-common-sms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.laokou</groupId>
<artifactId>laokou-common-sensitive</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* @author laokou
*/
@AutoConfiguration
@ConditionalOnProperty(havingValue = "true", matchIfMissing = true, prefix = "sms.gyy", name = "enabled")
public class SmsAutoConfig {

@Bean("smsService")
@ConditionalOnProperty(prefix = "sms", matchIfMissing = true, name = "type", havingValue = "GYY")
public SmsService gyySmsServiceImpl(SmsProperties smsProperties) {
return new GYYSmsServiceImpl(smsProperties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.laokou.common.sms.config;

import lombok.Data;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

Expand All @@ -29,13 +30,29 @@
@ConfigurationProperties(prefix = "sms")
public class SmsProperties {

private final GYY gyy = new GYY();
private GYY gyy = new GYY();

private Type type = Type.GYY;

@Getter
public enum Type {

GYY("gyy", "国阳云");

private final String code;

private final String desc;

Type(String code, String desc) {
this.code = code;
this.desc = desc;
}

}

@Data
public static class GYY {

private boolean enabled = true;

private String templateId;

private String signId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2022-2024 KCloud-Platform-IoT Author or Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.laokou.common.sms.dto;

import lombok.Getter;

@Getter
public enum SendStatus {

OK(0, "发送成功"), FAIL(1, "发送失败");

private final int code;

private final String desc;

SendStatus(int code, String desc) {
this.code = code;
this.desc = desc;
}

}
Loading

0 comments on commit baaa30a

Please sign in to comment.