feat: 修改第三方登录逻辑/更新数据库

This commit is contained in:
landaiqing
2024-06-19 22:17:13 +08:00
parent ae1fe09101
commit 962b82dd01
40 changed files with 96 additions and 1362 deletions

View File

@@ -5,6 +5,7 @@ import com.schisandra.wechat.handler.WeChatMsgHandler;
import com.schisandra.wechat.utils.MessageUtil;
import com.schisandra.wechat.utils.SHA1;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@@ -27,7 +28,8 @@ public class CallBackController {
@Resource
private WeChatMsgFactory weChatMsgFactory;
private static final String token = "LDQ20020618xxx";
@Value("${wechat.token}")
private String token;
@RequestMapping("/test")
public String test() {

View File

@@ -36,10 +36,10 @@ public class ReceiveTextMsgHandler implements WeChatMsgHandler {
String toUserName = messageMap.get("ToUserName");
Random random = new Random();
int num = random.nextInt(1000);
int num = random.nextInt(9000)+1000;
String numKey = redisUtil.buildKey(LOGIN_PREFIX, String.valueOf(num));
redisUtil.setNx(numKey, fromUserName, 5L, TimeUnit.MINUTES);
String numContent = "您当前的验证码是:【" + num + " 5分钟内有效";
redisUtil.setNx(numKey, fromUserName, 1L, TimeUnit.MINUTES);
String numContent = "您当前的验证码是:【" + num + " 1分钟内有效";
String replyContent = "<xml>\n" +
" <ToUserName><![CDATA[" + fromUserName + "]]></ToUserName>\n" +
" <FromUserName><![CDATA[" + toUserName + "]]></FromUserName>\n" +

View File

@@ -19,7 +19,7 @@ public class SubscribeMsgHandler implements WeChatMsgHandler {
log.info("触发用户关注事件!");
String fromUserName = messageMap.get("FromUserName");
String toUserName = messageMap.get("ToUserName");
String subscribeContent = "感谢您的关注,我是清语博客";
String subscribeContent = "感谢您的关注!";
String content = "<xml>\n" +
" <ToUserName><![CDATA[" + fromUserName + "]]></ToUserName>\n" +
" <FromUserName><![CDATA[" + toUserName + "]]></FromUserName>\n" +

View File

@@ -23,3 +23,5 @@ spring:
max-idle: 10
# 连接池中的最小空闲连接
min-idle: 0
wechat:
token: LDQ20020618xxx

View File

@@ -0,0 +1,18 @@
,---,
,--.' | ,--, ,---,
| | : ,--.'| ,---, ,---.'| __ ,-.
.--.--. : : : | |, .--.--. ,-+-. / | | | :,' ,'/ /|
/ / ' ,---. : | |,--.`--'_ / / ' ,--.--. ,--.'|' | | | |' | |' | ,--.--.
| : /`./ / \ | : ' |,' ,'| | : /`./ / \ | | ,"' | ,--.__| || | ,'/ \
| : ;_ / / ' | | /' :' | | | : ;_ .--. .-. | | | / | | / ,' |' : / .--. .-. |
\ \ `. . ' / ' : | | || | : \ \ `. \__\/: . . | | | | |. ' / || | ' \__\/: . .
`----. \' ; :__ | | ' | :' : |__ `----. \ ," .--.; | | | | |/ ' ; |: |; : | ," .--.; |
/ /`--' /' | '.'|| : :_:,'| | '.'| / /`--' // / ,. | | | |--' | | '/ '| , ; / / ,. |
'--'. / | : :| | ,' ; : ;'--'. /; : .' \| |/ | : :| ---' ; : .' \
`--'---' \ \ / `--'' | , / `--'---' | , .-./'---' \ \ / | , .-./
`----' ---`-' `--`---' `----' `--`---'
Spring Boot: ${spring-boot.formatted-version}
五味子云存储