记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
0018358e
Commit
0018358e
authored
Jan 08, 2025
by
wangyifan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
缓存改造- sweet:user:applet:unionid 增加缓存过期时间
parent
d6016455
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
RedisKeyExpireConst.java
.../liquidnet/service/base/constant/RedisKeyExpireConst.java
+6
-0
WechatUsersRedisUtils.java
.../liquidnet/service/sweet/utils/WechatUsersRedisUtils.java
+26
-2
No files found.
liquidnet-bus-common/liquidnet-common-service-base/src/main/java/com/liquidnet/service/base/constant/RedisKeyExpireConst.java
View file @
0018358e
...
...
@@ -25,4 +25,10 @@ public class RedisKeyExpireConst {
// adam:identity:mobile 过期时间为30天
public
static
final
long
ADAM_IDENTITY_MOBILE_EXPIRE
=
30
*
24
*
60
*
60
;
// sweet:user:applet:unionid 过期时间30天
public
static
final
long
SWEET_USER_APPLET_UNIONID_EXPIRE
=
30
*
24
*
60
*
60
;
// sweet:user:applet:mobile 过期时间30天
public
static
final
long
SWEET_USER_APPLET_MOBILE_EXPIRE
=
30
*
24
*
60
*
60
;
}
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/sweet/utils/WechatUsersRedisUtils.java
View file @
0018358e
package
com
.
liquidnet
.
service
.
sweet
.
utils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.service.base.constant.RedisKeyExpireConst
;
import
com.liquidnet.service.sweet.constant.SweetConstant
;
import
com.liquidnet.service.sweet.entity.SweetAppletUsers
;
import
com.liquidnet.service.sweet.mapper.SweetAppletUsersMapper
;
import
com.liquidnet.service.sweet.vo.SweetAppletUsersVo
;
import
com.liquidnet.service.sweet.vo.SweetMaoDengVo
;
import
com.liquidnet.service.sweet.vo.SweetWechatUsersVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
@Component
@Slf4j
...
...
@@ -15,6 +24,8 @@ public class WechatUsersRedisUtils {
@Autowired
private
RedisUtil
redisUtil
;
@Autowired
private
SweetAppletUsersMapper
sweetAppletUsersMapper
;
public
SweetWechatUsersVo
getSweetWechatUsersOfUnionId
(
String
unionId
,
Integer
type
)
{
String
redisKey
=
SweetConstant
.
REDIS_KEY_SWEET_WECHAT_USERS_UNIONID
.
concat
(
unionId
)
...
...
@@ -75,7 +86,20 @@ public class WechatUsersRedisUtils {
String
redisKey
=
SweetConstant
.
REDIS_KEY_SWEET_APPLET_USERS_UNIONID
.
concat
(
unionId
);
Object
obj
=
redisUtil
.
get
(
redisKey
);
if
(
null
==
obj
)
{
return
null
;
// 从MySQL数据库查询
LambdaQueryWrapper
<
SweetAppletUsers
>
lambda
=
new
QueryWrapper
<
SweetAppletUsers
>()
.
lambda
()
.
eq
(
SweetAppletUsers:
:
getUnionId
,
unionId
)
.
orderByDesc
(
SweetAppletUsers:
:
getUpdatedAt
);
List
<
SweetAppletUsers
>
sweetAppletUsers
=
sweetAppletUsersMapper
.
selectList
(
lambda
);
if
(!
CollectionUtils
.
isEmpty
(
sweetAppletUsers
))
{
SweetAppletUsersVo
usersVo
=
SweetAppletUsersVo
.
getNew
();
BeanUtils
.
copyProperties
(
sweetAppletUsers
.
get
(
0
),
usersVo
);
setSweetAppletUsers
(
usersVo
);
return
usersVo
;
}
else
{
return
null
;
}
}
else
{
SweetAppletUsersVo
sweetAppletUsersVo
=
(
SweetAppletUsersVo
)
obj
;
return
sweetAppletUsersVo
;
...
...
@@ -87,7 +111,7 @@ public class WechatUsersRedisUtils {
redisUtil
.
set
(
redisKey
,
sweetAppletUsersVo
);
String
redisKeyU
=
SweetConstant
.
REDIS_KEY_SWEET_APPLET_USERS_UNIONID
.
concat
(
sweetAppletUsersVo
.
getUnionId
());
redisUtil
.
set
(
redisKeyU
,
sweetAppletUsersVo
);
redisUtil
.
set
(
redisKeyU
,
sweetAppletUsersVo
,
RedisKeyExpireConst
.
SWEET_USER_APPLET_UNIONID_EXPIRE
);
}
public
void
setStrawberryPosterClick
(
String
openId
,
long
time
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment