Skip to content

Commit

Permalink
优化日志输入,解决一些warning提示
Browse files Browse the repository at this point in the history
  • Loading branch information
wenwst committed Sep 22, 2024
1 parent aaa6118 commit e19894f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@


> **本项目,基于Spring Boot3构建,实现微信小程序注册、登陆功能。**
>
> 当前项目只可用于学习哦。^_^

## 模块说明
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
<version>${httpcomponents.version}</version>
</dependency>

<!-- Jcode2Session 解密依赖 -->
<!-- jcode2Session 解密依赖 -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
Expand Down Expand Up @@ -307,9 +307,9 @@
<!-- Maven 仓库配置 -->
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<id>aliMaven</id>
<name>aliYun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import cn.binarywang.wx.miniapp.message.WxMaMessageHandler;
import cn.binarywang.wx.miniapp.message.WxMaMessageRouter;
import cn.tradewar.core.consts.LogConst;
import com.google.common.collect.Lists;
import lombok.extern.log4j.Log4j2;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
Expand Down Expand Up @@ -81,7 +82,7 @@ public WxMaMessageRouter wxMaMessageRouter(WxMaService wxMaService) {
};

private final WxMaMessageHandler logHandler = (wxMessage, context, service, sessionManager) -> {
log.info("收到消息:" + wxMessage.toString());
log.info("收到消息:{}", wxMessage.toString());
service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("收到信息为:" + wxMessage.toJson())
.toUser(wxMessage.getFromUser()).build());
return null;
Expand All @@ -105,7 +106,7 @@ public WxMaMessageRouter wxMaMessageRouter(WxMaService wxMaService) {
.toUser(wxMessage.getFromUser())
.build());
} catch (WxErrorException e) {
e.printStackTrace();
log.error(LogConst.EXCEPTION_FORMAT,"picHandler", e);
}

return null;
Expand All @@ -122,7 +123,7 @@ public WxMaMessageRouter wxMaMessageRouter(WxMaService wxMaService) {
.toUser(wxMessage.getFromUser())
.build());
} catch (WxErrorException e) {
e.printStackTrace();
log.error(LogConst.EXCEPTION_FORMAT,"qrcodeHandler", e);
}

return null;
Expand Down
11 changes: 10 additions & 1 deletion wst-core/src/main/java/cn/tradewar/core/utils/RedisUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public RedisUtil(RedisTemplate<String, Object> redisTemplate) {
* @param key 要查询的键
* @return 符合条件的key的集合
*/
@SuppressWarnings("unused")
public Set<String> keys(String key){
return redisTemplate.keys(key);
}
Expand All @@ -41,6 +42,7 @@ public Set<String> keys(String key){
* @param key 要查询的键
* @return 对应的值
*/
@SuppressWarnings("unused")
public Object get(String key){
return redisTemplate.opsForValue().get(key);
}
Expand All @@ -50,6 +52,7 @@ public Object get(String key){
* @param key 键
* @param value 值
*/
@SuppressWarnings("unused")
public void set(String key, String value){
set(key, value, expirationMilliSeconds);
}
Expand All @@ -68,6 +71,7 @@ public void set(String key, String value, long expire){
* 删除指定的key
* @param key 要删除的键
*/
@SuppressWarnings("unused")
public void delete(String key){
redisTemplate.opsForValue().getOperations().delete(key);
}
Expand All @@ -78,6 +82,7 @@ public void delete(String key){
* @param filed 哈希字段
* @param domain 要存储的对象
*/
@SuppressWarnings("unused")
public void hset(String key, String filed, Object domain){
hset(key, filed, domain, expirationMilliSeconds);
}
Expand All @@ -91,7 +96,7 @@ public void hset(String key, String filed, Object domain){
*/
public void hset(String key, String filed, Object domain, long expire){
redisTemplate.opsForHash().put(key, filed, domain);
setKeyExpire(key, expirationMilliSeconds);
setKeyExpire(key, expire);
}

/**
Expand All @@ -110,6 +115,7 @@ public void hset(String key, HashMap<String, Object> hm){
* @param filed 哈希字段
* @param domain 要存储的对象
*/
@SuppressWarnings("unused")
public void hsetAbsent(String key, String filed, Object domain){
redisTemplate.opsForHash().putIfAbsent(key, filed, domain);
}
Expand All @@ -120,6 +126,7 @@ public void hsetAbsent(String key, String filed, Object domain){
* @param field 哈希字段
* @return 对应的值
*/
@SuppressWarnings("unused")
public Object hget(String key, String field) {
return redisTemplate.opsForHash().get(key, field);
}
Expand Down Expand Up @@ -157,6 +164,7 @@ public void sset(String key, Set<?> set, long expire){
* @param key 键
* @param set 要存储的Set集合
*/
@SuppressWarnings("unused")
public void sset(String key, Set<?> set){
sset(key, set, expirationMilliSeconds);
}
Expand All @@ -167,6 +175,7 @@ public void sset(String key, Set<?> set){
* @param field 哈希字段
* @return 是否存在
*/
@SuppressWarnings("unused")
public Boolean hasKey(String key, String field) {
return redisTemplate.opsForHash().hasKey(key, field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public GenericResponse wxLogin(String code) {
return GenericResponse.response(ServiceError.WX_CODE_ERR);
}

String sessionKey = sessionInfo.getSessionKey();
// String sessionKey = sessionInfo.getSessionKey();
String openId = sessionInfo.getOpenid();


Expand Down
6 changes: 4 additions & 2 deletions wst-wx-api/wx-requests.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ POST http://localhost:8030/wx/auth/wxLogin?code=11111
Content-Type: application/json


> {% client.global.set("auth_token", response.body.content); %}
> {%
client.global.set("auth_token", response.body.content);
%}


###
Expand All @@ -16,7 +18,7 @@ Content-Type: application/json
{
"code": "111111",
"encryptedData": "encryptedData",
"iv": "iviviviviv",
"iv": "ivContent",
"phone": "18699999999"
}

Expand Down

0 comments on commit e19894f

Please sign in to comment.