Commit f3d301ae authored by liwei's avatar liwei

修改了用户点赞redis名称

parent 852e0aaf
...@@ -9,7 +9,7 @@ package org.rcisoft.business.memInfo.bean; ...@@ -9,7 +9,7 @@ package org.rcisoft.business.memInfo.bean;
*/ */
public class MemberInfoRedisBean { public class MemberInfoRedisBean {
//总共的点赞key //总共的点赞key
public static final String MEMBERINFO_USERLIKEALL = "memberInfo:userLikeAll:"; public static final String USER_LIKE_USERLIKEALL = "user:like:userLikeAll:";
//对每个人点赞的key //对每个人点赞的key
public static final String MEMBERINFO_USERLIKE = "memberInfo:userLike:"; public static final String USER_LIKE_USERLIKE = "user:like:userLike:";
} }
...@@ -375,7 +375,7 @@ public class MemInfo extends CyIdIncreEntity<MemInfo> { ...@@ -375,7 +375,7 @@ public class MemInfo extends CyIdIncreEntity<MemInfo> {
* @column mem_liked_count * @column mem_liked_count
* @default * @default
*/ */
private String memLikedCount; private Integer memLikedCount;
/** /**
* 开始时间 * 开始时间
......
package org.rcisoft.business.memInfo.entity;
import lombok.Data;
@Data
public class UserLeaveMessageDTO {
//目标id
private Integer targetId;
//用户id
private Integer userId;
//留言内容
private String content;
//删除类型 0未删除,1本人已删除,2对方已删除,3双方都删除了
private String delStatus;
}
...@@ -585,14 +585,14 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -585,14 +585,14 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
//一天最多给某个人点赞的总次数 //一天最多给某个人点赞的总次数
Integer dicCountToPersonal = Integer.valueOf(userLikeConfig.get(1).getDictValue()); Integer dicCountToPersonal = Integer.valueOf(userLikeConfig.get(1).getDictValue());
//redis中 该用户对所有用户的点赞次数 //redis中 该用户对所有用户的点赞次数
Object redisCountToAll = cyRedisServiceImpl.get(MemberInfoRedisBean.MEMBERINFO_USERLIKEALL + userId); Object redisCountToAll = cyRedisServiceImpl.get(MemberInfoRedisBean.USER_LIKE_USERLIKEALL + userId);
//redis中 该用户对目标用户的点赞次数 //redis中 该用户对目标用户的点赞次数
Object redisCountToPersonal = cyRedisServiceImpl.hget(MemberInfoRedisBean.MEMBERINFO_USERLIKE + userId, String.valueOf(likeDTO.getTargetId())); Object redisCountToPersonal = cyRedisServiceImpl.hget(MemberInfoRedisBean.USER_LIKE_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()));
if (redisCountToAll == null && redisCountToPersonal == null){ if (redisCountToAll == null && redisCountToPersonal == null){
//用户第一次进行点赞 设置redis缓存 24小时 //用户第一次进行点赞 设置redis缓存 24小时
//对所有用户的点赞次数存储 //对所有用户的点赞次数存储
cyRedisServiceImpl.set(MemberInfoRedisBean.MEMBERINFO_USERLIKEALL + userId,1,86400L); cyRedisServiceImpl.set(MemberInfoRedisBean.USER_LIKE_USERLIKEALL + userId,1);
cyRedisServiceImpl.hset(MemberInfoRedisBean.MEMBERINFO_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()),1,86400L); cyRedisServiceImpl.hset(MemberInfoRedisBean.USER_LIKE_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()),1);
likeDTO.setUserId(userId); likeDTO.setUserId(userId);
int line = baseMapper.addLike(likeDTO); int line = baseMapper.addLike(likeDTO);
return new CyPersistModel(line); return new CyPersistModel(line);
...@@ -601,8 +601,8 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -601,8 +601,8 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
//判断点赞总数限制 //判断点赞总数限制
if (((int)redisCountToAll < dicCountToAll)){ if (((int)redisCountToAll < dicCountToAll)){
//条件限制都满足 点赞次数都+1 //条件限制都满足 点赞次数都+1
cyRedisServiceImpl.incr(MemberInfoRedisBean.MEMBERINFO_USERLIKEALL + userId, 1L); cyRedisServiceImpl.incr(MemberInfoRedisBean.USER_LIKE_USERLIKEALL + userId, 1L);
cyRedisServiceImpl.hincr(MemberInfoRedisBean.MEMBERINFO_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()), (double) 1L); cyRedisServiceImpl.hincr(MemberInfoRedisBean.USER_LIKE_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()), (double) 1L);
likeDTO.setUserId(userId); likeDTO.setUserId(userId);
int line = baseMapper.addLike(likeDTO); int line = baseMapper.addLike(likeDTO);
return new CyPersistModel(line); return new CyPersistModel(line);
...@@ -615,8 +615,8 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -615,8 +615,8 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
//判断个人点赞次数限制 //判断个人点赞次数限制
if ((int)redisCountToPersonal < dicCountToPersonal){ if ((int)redisCountToPersonal < dicCountToPersonal){
//条件限制都满足 点赞次数都+1 //条件限制都满足 点赞次数都+1
cyRedisServiceImpl.incr(MemberInfoRedisBean.MEMBERINFO_USERLIKEALL + userId, 1L); cyRedisServiceImpl.incr(MemberInfoRedisBean.USER_LIKE_USERLIKEALL + userId, 1L);
cyRedisServiceImpl.hincr(MemberInfoRedisBean.MEMBERINFO_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()), (double) 1L); cyRedisServiceImpl.hincr(MemberInfoRedisBean.USER_LIKE_USERLIKE + userId, String.valueOf(likeDTO.getTargetId()), (double) 1L);
} else { } else {
throw new CyServiceException("点赞失败,今日对该用户的点赞次数已达上限"); throw new CyServiceException("点赞失败,今日对该用户的点赞次数已达上限");
} }
...@@ -643,7 +643,7 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -643,7 +643,7 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
*/ */
public void userLikeSchedule() { public void userLikeSchedule() {
//将redis中存储的点赞数同步到opm_user_like表中 //将redis中存储的点赞数同步到opm_user_like表中
Set<String> keys = redisTemplate.keys(MemberInfoRedisBean.MEMBERINFO_USERLIKE + "*"); Set<String> keys = redisTemplate.keys(MemberInfoRedisBean.USER_LIKE_USERLIKE + "*");
if (keys != null && !keys.isEmpty()) { if (keys != null && !keys.isEmpty()) {
for (String key : keys) { for (String key : keys) {
//截取key最后一个:后的值,为userId //截取key最后一个:后的值,为userId
......
...@@ -34,7 +34,7 @@ public class ScheduleTasks { ...@@ -34,7 +34,7 @@ public class ScheduleTasks {
* 用户点赞数据定时任务 将点赞数据同步到对应的表中 * 用户点赞数据定时任务 将点赞数据同步到对应的表中
* 会员表 点赞表 * 会员表 点赞表
*/ */
@Scheduled(cron = "0 0 13 * * ?") @Scheduled(cron = "0 0 10 * * ?")
public void userLikeSchedule() { public void userLikeSchedule() {
memInfoService.userLikeSchedule(); memInfoService.userLikeSchedule();
} }
......
...@@ -567,6 +567,7 @@ ...@@ -567,6 +567,7 @@
LEFT JOIN mem_info mi ON mi.user_id = su.business_id LEFT JOIN mem_info mi ON mi.user_id = su.business_id
WHERE 1=1 WHERE 1=1
and ouf.user_id = #{entity.loginUserId} and ouf.user_id = #{entity.loginUserId}
and su.del_flag = '0'
</select> </select>
<select id="queryFollowMePaged" resultType="org.rcisoft.business.memInfo.entity.MemInfo"> <select id="queryFollowMePaged" resultType="org.rcisoft.business.memInfo.entity.MemInfo">
SELECT mi.* SELECT mi.*
...@@ -575,6 +576,7 @@ ...@@ -575,6 +576,7 @@
LEFT JOIN mem_info mi ON mi.user_id = su.business_id LEFT JOIN mem_info mi ON mi.user_id = su.business_id
WHERE 1=1 WHERE 1=1
and ouf.target_id = #{entity.loginUserId} and ouf.target_id = #{entity.loginUserId}
and su.del_flag = '0'
</select> </select>
<select id="queryEachFollowPaged" resultType="org.rcisoft.business.memInfo.entity.MemInfo"> <select id="queryEachFollowPaged" resultType="org.rcisoft.business.memInfo.entity.MemInfo">
SELECT mi.* SELECT mi.*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment