学员安全登出

This commit is contained in:
none
2023-03-21 14:57:00 +08:00
parent ee248b483d
commit ad02bcad59
11 changed files with 114 additions and 49 deletions

View File

@@ -1,32 +0,0 @@
package xyz.playedu.api.caches;
import org.springframework.stereotype.Component;
import xyz.playedu.api.exception.LimitException;
import xyz.playedu.api.util.RedisUtil;
/**
* @Author 杭州白书科技有限公司
* @create 2023/3/10 14:13
*/
@Component
public class UserLoginCache {
private final static String keyTemplate = "user-login:%s";
private final static int expire = 10;//10s
public void check(String email) throws LimitException {
if (RedisUtil.exists(key(email))) {
throw new LimitException();
}
}
public void put(String email) {
RedisUtil.set(key(email), "1", expire);
}
private String key(String email) {
return String.format(keyTemplate, email);
}
}