-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
wine/src/main/java/com/wine/game/wine/config/MyRedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.wine.game.wine.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.PropertyAccessor; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
import redis.clients.jedis.JedisPool; | ||
import redis.clients.jedis.JedisPoolConfig; | ||
|
||
/** | ||
* @description: # ┏┓ ┏┓+ + | ||
* # ┏┛┻━━━┛┻┓ + + | ||
* # ┃ ┃ | ||
* # ┃ ━ ┃ ++ + + + | ||
* # ████━████ ┃+ | ||
* # ┃ ┃ + | ||
* # ┃ ┻ ┃ | ||
* # ┃ ┃ + + | ||
* # ┗━┓ ┏━┛ | ||
* # ┃ ┃ | ||
* # ┃ ┃ + + + + | ||
* # ┃ ┃ Codes are far away from bugs with the animal protecting | ||
* # ┃ ┃ + 神兽保佑,代码无bug | ||
* # ┃ ┃ | ||
* # ┃ ┃ + | ||
* # ┃ ┗━━━┓ + + | ||
* # ┃ ┣┓ | ||
* # ┃ ┏┛ | ||
* # ┗┓┓┏━┳┓┏┛ + + + + | ||
* # ┃┫┫ ┃┫┫ | ||
* # ┗┻┛ ┗┻┛+ + + + | ||
* # | ||
* @author: zeno fung | ||
* @create: 2022-03-14 14:51 | ||
*/ | ||
|
||
@Configuration | ||
public class MyRedisConfig { | ||
|
||
@Bean | ||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { | ||
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(redisConnectionFactory); | ||
|
||
// 使用Jackson2JsonRedisSerialize 替换默认序列化 | ||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); | ||
|
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | ||
// objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); | ||
|
||
jackson2JsonRedisSerializer.setObjectMapper(objectMapper); | ||
|
||
// 设置value的序列化规则和 key的序列化规则 | ||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); | ||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.afterPropertiesSet(); | ||
return redisTemplate; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
|
||
## \u516C\u4F17\u53F7\u914D\u7F6E(\u5FC5\u586B) | ||
#wx.miniapp.appid = wx1665a2834d959989 | ||
#wx.miniapp.secret = 3ac50cbfd17e19046d352ea560c6bd14 | ||
#wx.miniapp.token = @token | ||
#wx.miniapp.aesKey = @aesKey | ||
## \u6D88\u606F\u683C\u5F0F\uFF0CXML\u6216\u8005JSON. | ||
#wx.miniapp.msgDataFormat = XML | ||
## \u5B58\u50A8\u914D\u7F6Eredis(\u53EF\u9009) | ||
## \u6CE8\u610F: \u6307\u5B9Aredis.host\u503C\u540E\u4E0D\u4F1A\u4F7F\u7528\u5BB9\u5668\u6CE8\u5165\u7684redis\u8FDE\u63A5(JedisPool) | ||
## \u914D\u7F6E\u7C7B\u578B: Memory(\u9ED8\u8BA4), Jedis, RedisTemplate | ||
#wx.miniapp.config-storage.type = redistemplate | ||
# # \u76F8\u5173redis\u524D\u7F00\u914D\u7F6E: wa(\u9ED8\u8BA4) | ||
#wx.miniapp.config-storage.key-prefix = wa | ||
#wx.miniapp.config-storage.redis.host = 120.26.163.91 | ||
#wx.miniapp.config-storage.redis.password=123456 | ||
#wx.miniapp.config-storage.redis.port = 6379 | ||
# | ||
## http\u5BA2\u6237\u7AEF\u914D\u7F6E # http\u5BA2\u6237\u7AEF\u7C7B\u578B: HttpClient(\u9ED8\u8BA4), OkHttp, JoddHttp | ||
#wx.miniapp.config-storage.http-client-type=HttpClient | ||
#wx.miniapp.config-storage.http-proxy-host= | ||
#wx.miniapp.config-storage.http-proxy-port= | ||
#wx.miniapp.config-storage.http-proxy-username= | ||
#wx.miniapp.config-storage.http-proxy-password= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
wine/src/test/java/com/wine/game/wine/WineApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,36 @@ | ||
package com.wine.game.wine; | ||
|
||
import cn.binarywang.wx.miniapp.api.WxMaSchemeService; | ||
import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; | ||
import cn.binarywang.wx.miniapp.api.WxMaService; | ||
import me.chanjar.weixin.common.bean.WxAccessToken; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
|
||
@SpringBootTest | ||
class WineApplicationTests { | ||
|
||
@Autowired | ||
private RedisTemplate redisTemplate; | ||
|
||
@Autowired | ||
private WxMaService wxMaService; | ||
|
||
@Test | ||
void contextLoads() { | ||
// redisTemplate.opsForValue().set("1","3"); | ||
try { | ||
// String accessToken = wxMaService.getAccessToken(); | ||
boolean aa = wxMaService.getSecCheckService().checkMessage("特3456书yuuo莞6543李zxcz蒜7782法fgnv级"); | ||
boolean bb = wxMaService.getSecCheckService().checkMessage("草拟吗"); | ||
System.out.println("aa---->"+aa+"bb---->"+bb); | ||
} catch (WxErrorException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
} |