fix:修复记录用户书签修改时间bug

This commit is contained in:
fanxb 2020-01-27 23:50:48 +08:00
parent cf22fd2997
commit d95441d860
2 changed files with 6 additions and 3 deletions

View File

@ -48,7 +48,7 @@ public class BookmarkService {
@Autowired @Autowired
private BookmarkDao bookmarkDao; private BookmarkDao bookmarkDao;
@Autowired
private StringRedisTemplate redisTemplate; private StringRedisTemplate redisTemplate;
@Autowired @Autowired

View File

@ -1,6 +1,7 @@
package com.fanxb.bookmark.business.user.schedule; package com.fanxb.bookmark.business.user.schedule;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.fanxb.bookmark.business.user.dao.UserDao;
import com.fanxb.bookmark.common.constant.RedisConstant; import com.fanxb.bookmark.common.constant.RedisConstant;
import com.fanxb.bookmark.common.entity.redis.UserBookmarkUpdate; import com.fanxb.bookmark.common.entity.redis.UserBookmarkUpdate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -23,13 +24,15 @@ public class UserInfoUpdate {
@Autowired @Autowired
private StringRedisTemplate redisTemplate; private StringRedisTemplate redisTemplate;
@Autowired
private UserDao userDao;
@Scheduled(fixedDelay = 5000) @Scheduled(fixedDelay = 100000)
public void userBookmarkUpdateTime() { public void userBookmarkUpdateTime() {
String value; String value;
while ((value = redisTemplate.opsForList().rightPop(RedisConstant.BOOKMARK_UPDATE_TIME, BLOCK_TIME, TimeUnit.SECONDS)) != null) { while ((value = redisTemplate.opsForList().rightPop(RedisConstant.BOOKMARK_UPDATE_TIME, BLOCK_TIME, TimeUnit.SECONDS)) != null) {
UserBookmarkUpdate item = JSON.parseObject(value, UserBookmarkUpdate.class); UserBookmarkUpdate item = JSON.parseObject(value, UserBookmarkUpdate.class);
userDao.updateLastBookmarkUpdateTime(item);
} }
} }
} }