feat:记录用户上次修改书签的时间
This commit is contained in:
parent
05aba42335
commit
cf22fd2997
@ -1,6 +1,7 @@
|
||||
package com.fanxb.bookmark.business.user.dao;
|
||||
|
||||
import com.fanxb.bookmark.common.entity.User;
|
||||
import com.fanxb.bookmark.common.entity.redis.UserBookmarkUpdate;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -100,7 +101,8 @@ public interface UserDao {
|
||||
|
||||
/**
|
||||
* 更新用户新邮箱
|
||||
* @param userId userId
|
||||
*
|
||||
* @param userId userId
|
||||
* @param newPassword userId
|
||||
*/
|
||||
@Update("update user set newEmail=#{newPassword} where userId= #{userId}")
|
||||
@ -108,8 +110,19 @@ public interface UserDao {
|
||||
|
||||
/**
|
||||
* 新邮箱校验成功,更新邮箱
|
||||
*
|
||||
* @param userId userId
|
||||
*/
|
||||
@Update("update user set email=newEmail,newEmail='' where userId=#{userId}")
|
||||
void updateEmailByUserId(int userId);
|
||||
|
||||
/**
|
||||
* 功能描述: 更新用户上次更新书签时间
|
||||
*
|
||||
* @param item item
|
||||
* @author fanxb
|
||||
* @date 2020/1/26 下午3:47
|
||||
*/
|
||||
@Update("update user set bookmarkChangeTime=#{updateTime} where userId=#{userId}")
|
||||
void updateLastBookmarkUpdateTime(UserBookmarkUpdate item);
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.fanxb.bookmark.business.user.schedule;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fanxb.bookmark.common.constant.RedisConstant;
|
||||
import com.fanxb.bookmark.common.entity.redis.UserBookmarkUpdate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author fanxb
|
||||
* @date 2020/1/26 上午11:54
|
||||
*/
|
||||
@Component
|
||||
public class UserInfoUpdate {
|
||||
/**
|
||||
* 阻塞时间
|
||||
*/
|
||||
private static final int BLOCK_TIME = 15;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void userBookmarkUpdateTime() {
|
||||
String value;
|
||||
while ((value = redisTemplate.opsForList().rightPop(RedisConstant.BOOKMARK_UPDATE_TIME, BLOCK_TIME, TimeUnit.SECONDS)) != null) {
|
||||
UserBookmarkUpdate item = JSON.parseObject(value, UserBookmarkUpdate.class);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -100,9 +100,4 @@ public class BaseInfoService {
|
||||
}
|
||||
userDao.updateEmailByUserId(userId);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void updateBookmarkUpdateTime(){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.fanxb.bookmark.common.configuration;
|
||||
|
||||
import com.fanxb.bookmark.common.factory.CustomThreadFactory;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2020/1/26
|
||||
*/
|
||||
public class ScheduleConfig implements SchedulingConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
|
||||
|
||||
ScheduledExecutorService service = new ScheduledThreadPoolExecutor(5, new CustomThreadFactory("schedule"));
|
||||
scheduledTaskRegistrar.setScheduler(service);
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ package com.fanxb.bookmark.web;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
@ -16,6 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@SpringBootApplication(scanBasePackages = {"com.fanxb.bookmark"})
|
||||
@MapperScan(basePackages = "com.fanxb.bookmark.**.dao")
|
||||
@EnableTransactionManagement
|
||||
@EnableScheduling
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
|
@ -25,7 +25,7 @@ spring:
|
||||
database: 0
|
||||
host: localhost
|
||||
password:
|
||||
timeout: 500ms
|
||||
timeout: 20000ms
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 20
|
||||
|
@ -1,2 +1,2 @@
|
||||
ALTER TABLE `psn`.`user`
|
||||
ALTER TABLE `user`
|
||||
ADD COLUMN `bookmarkChangeTime` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `lastLoginTime`;
|
||||
|
Loading…
x
Reference in New Issue
Block a user