update Scheduled task
This commit is contained in:
parent
c9bad95f43
commit
42327ffde0
|
@ -16,5 +16,5 @@ features:
|
||||||
details: 判题使用 cgroup 隔离用户程序,网站权限控制完善
|
details: 判题使用 cgroup 隔离用户程序,网站权限控制完善
|
||||||
- title: 多样化
|
- title: 多样化
|
||||||
details: 独有自身判题服务,同时支持其它知名OJ题目的提交判题
|
details: 独有自身判题服务,同时支持其它知名OJ题目的提交判题
|
||||||
footer: MIT Licensed | Copyright © 2021.12.12 @Author Himit_ZH QQ Group:598587305
|
footer: MIT Licensed | Copyright © 2021.12.14 @Author Himit_ZH QQ Group:598587305
|
||||||
---
|
---
|
|
@ -28,6 +28,9 @@
|
||||||
> 注意:各服务ip最好不改动,保持处于172.20.0.0/16网段的docker network
|
> 注意:各服务ip最好不改动,保持处于172.20.0.0/16网段的docker network
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
|
# hoj全部数据存储的文件夹位置(默认当前路径生成hoj文件夹)
|
||||||
|
HOJ_DATA_DIRECTORY=./hoj
|
||||||
|
|
||||||
# redis的配置
|
# redis的配置
|
||||||
REDIS_HOST=172.20.0.2
|
REDIS_HOST=172.20.0.2
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
@ -35,7 +38,8 @@
|
||||||
|
|
||||||
# mysql的配置
|
# mysql的配置
|
||||||
MYSQL_HOST=172.20.0.3
|
MYSQL_HOST=172.20.0.3
|
||||||
MYSQL_PUBLIC_HOST=172.20.0.3 # 如果判题服务是分布式,请提供当前mysql所在服务器的公网ip
|
# 如果判题服务是分布式,请提供当前mysql所在服务器的公网ip
|
||||||
|
MYSQL_PUBLIC_HOST=172.20.0.3
|
||||||
MYSQL_PORT=3306
|
MYSQL_PORT=3306
|
||||||
MYSQL_ROOT_PASSWORD=hoj123456
|
MYSQL_ROOT_PASSWORD=hoj123456
|
||||||
|
|
||||||
|
@ -48,13 +52,18 @@
|
||||||
# backend后端服务的配置
|
# backend后端服务的配置
|
||||||
BACKEND_HOST=172.20.0.5
|
BACKEND_HOST=172.20.0.5
|
||||||
BACKEND_PORT=6688
|
BACKEND_PORT=6688
|
||||||
JWT_TOKEN_SECRET=default # token加密秘钥 默认则生成32位随机密钥
|
# token加密秘钥 默认则生成32位随机密钥
|
||||||
JWT_TOKEN_EXPIRE=86400 # token过期时间默认为24小时 86400s
|
JWT_TOKEN_SECRET=default
|
||||||
JWT_TOKEN_FRESH_EXPIRE=43200 # token默认12小时可自动刷新
|
# token过期时间默认为24小时 86400s
|
||||||
JUDGE_TOKEN=default # 调用判题服务器的token 默认则生成32位随机密钥
|
JWT_TOKEN_EXPIRE=86400
|
||||||
EMAIL_SERVER_HOST=smtp.qq.com # 请使用邮件服务的域名或ip
|
# token默认12小时可自动刷新
|
||||||
|
JWT_TOKEN_FRESH_EXPIRE=43200
|
||||||
|
# 调用判题服务器的token 默认则生成32位随机密钥
|
||||||
|
JUDGE_TOKEN=default
|
||||||
|
# 请使用邮件服务的域名或ip
|
||||||
|
EMAIL_SERVER_HOST=smtp.qq.com
|
||||||
EMAIL_SERVER_PORT=465
|
EMAIL_SERVER_PORT=465
|
||||||
EMAIL_USERNMAE=your_email_username
|
EMAIL_USERNAME=your_email_username
|
||||||
EMAIL_PASSWORD=your_email_password
|
EMAIL_PASSWORD=your_email_password
|
||||||
# 开启虚拟判题请提供对应oj的账号密码 格式为
|
# 开启虚拟判题请提供对应oj的账号密码 格式为
|
||||||
# username1,username2,...
|
# username1,username2,...
|
||||||
|
@ -65,50 +74,50 @@
|
||||||
CF_ACCOUNT_PASSWORD_LIST=
|
CF_ACCOUNT_PASSWORD_LIST=
|
||||||
POJ_ACCOUNT_USERNAME_LIST=
|
POJ_ACCOUNT_USERNAME_LIST=
|
||||||
POJ_ACCOUNT_PASSWORD_LIST=
|
POJ_ACCOUNT_PASSWORD_LIST=
|
||||||
|
|
||||||
# judgeserver的配置
|
# judgeserver的配置
|
||||||
JUDGE_SERVER_IP=172.20.0.7
|
JUDGE_SERVER_IP=172.20.0.7
|
||||||
JUDGE_SERVER_PORT=8088
|
JUDGE_SERVER_PORT=8088
|
||||||
JUDGE_SERVER_NAME=judger-alone
|
JUDGE_SERVER_NAME=judger-alone
|
||||||
|
|
||||||
# docker network的配置
|
# docker network的配置
|
||||||
SUBNET=172.20.0.0/16
|
SUBNET=172.20.0.0/16
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
> 提示:如果服务器的内存在4G或4G以上,请去掉JVM限制才能大大提高并发量,操作如下:
|
||||||
> 提示:如果服务器的内存在4G或4G以上,请去掉JVM限制才能大大提高并发量,操作如下:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
vim docker-compose.yml
|
vim docker-compose.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
**注释或去掉图中选中的行**
|
**注释或去掉图中选中的行**
|
||||||
|
|
||||||
① hoj-backend模块
|
① hoj-backend模块
|
||||||
|
|
||||||
|
![在这里插入图片描述](https://img-blog.csdnimg.cn/4dfdcb2461c742f1b3717a8a27c3598a.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBASGltaXRfWkg=,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
|
||||||
|
|
||||||
![在这里插入图片描述](https://img-blog.csdnimg.cn/4dfdcb2461c742f1b3717a8a27c3598a.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBASGltaXRfWkg=,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
② hoj-judgeserver模块
|
② hoj-judgeserver模块
|
||||||
|
|
||||||
![在这里插入图片描述](https://img-blog.csdnimg.cn/9a936ad86ff2439a9e1188c286cfd751.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBASGltaXRfWkg=,size_20,color_FFFFFF,t_70,g_se,x_16)
|
![在这里插入图片描述](https://img-blog.csdnimg.cn/9a936ad86ff2439a9e1188c286cfd751.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBASGltaXRfWkg=,size_20,color_FFFFFF,t_70,g_se,x_16)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
如果不改动,则以默认参数启动
|
|
||||||
|
如果不改动,则以默认参数启动
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
**根据网速情况,大约十到二十分钟拉取镜像,全程无需人工干预,拉取完毕后,自动启动容器服务,大概需要一至两分钟的初始化。**
|
**根据网速情况,大约十到二十分钟拉取镜像,全程无需人工干预,拉取完毕后,自动启动容器服务,大概需要一至两分钟的初始化。**
|
||||||
|
|
||||||
等待命令执行完毕后,查看容器状态
|
等待命令执行完毕后,查看容器状态
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker ps -a
|
docker ps -a
|
||||||
```
|
```
|
||||||
|
|
||||||
当看到所有的容器的状态status都为`UP`或`healthy`就代表 OJ 已经启动成功。
|
当看到所有的容器的状态status都为`UP`或`healthy`就代表 OJ 已经启动成功。
|
||||||
|
@ -188,6 +197,9 @@ Password: 开启SMTP服务后生成的随机授权码
|
||||||
> 注意:各服务ip最好不改动,保持处于172.20.0.0/16网段的docker network
|
> 注意:各服务ip最好不改动,保持处于172.20.0.0/16网段的docker network
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
|
# hoj全部数据存储的文件夹位置(默认当前路径生成hoj文件夹)
|
||||||
|
HOJ_DATA_DIRECTORY=./hoj
|
||||||
|
|
||||||
# redis的配置
|
# redis的配置
|
||||||
REDIS_HOST=172.20.0.2
|
REDIS_HOST=172.20.0.2
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
@ -195,7 +207,8 @@ Password: 开启SMTP服务后生成的随机授权码
|
||||||
|
|
||||||
# mysql的配置
|
# mysql的配置
|
||||||
MYSQL_HOST=172.20.0.3
|
MYSQL_HOST=172.20.0.3
|
||||||
MYSQL_PUBLIC_HOST=172.20.0.3 # 请提供当前mysql所在服务器的公网ip
|
# 请提供当前mysql所在服务器的公网ip
|
||||||
|
MYSQL_PUBLIC_HOST=172.20.0.3
|
||||||
MYSQL_PORT=3306
|
MYSQL_PORT=3306
|
||||||
MYSQL_ROOT_PASSWORD=hoj123456
|
MYSQL_ROOT_PASSWORD=hoj123456
|
||||||
|
|
||||||
|
@ -208,13 +221,18 @@ Password: 开启SMTP服务后生成的随机授权码
|
||||||
# backend后端服务的配置
|
# backend后端服务的配置
|
||||||
BACKEND_HOST=172.20.0.5
|
BACKEND_HOST=172.20.0.5
|
||||||
BACKEND_PORT=6688
|
BACKEND_PORT=6688
|
||||||
JWT_TOKEN_SECRET=default # token加密秘钥 默认则生成32位随机密钥
|
# token加密秘钥 默认则生成32位随机密钥
|
||||||
JWT_TOKEN_EXPIRE=86400 # token过期时间默认为24小时 86400s
|
JWT_TOKEN_SECRET=default
|
||||||
JWT_TOKEN_FRESH_EXPIRE=43200 # token默认12小时可自动刷新
|
# token过期时间默认为24小时 86400s
|
||||||
JUDGE_TOKEN=default # 调用判题服务器的token 默认则生成32位随机密钥
|
JWT_TOKEN_EXPIRE=86400
|
||||||
EMAIL_SERVER_HOST=smtp.qq.com # 请使用邮件服务的域名或ip
|
# token默认12小时可自动刷新
|
||||||
|
JWT_TOKEN_FRESH_EXPIRE=43200
|
||||||
|
# 调用判题服务器的token 默认则生成32位随机密钥
|
||||||
|
JUDGE_TOKEN=default
|
||||||
|
# 请使用邮件服务的域名或ip
|
||||||
|
EMAIL_SERVER_HOST=smtp.qq.com
|
||||||
EMAIL_SERVER_PORT=465
|
EMAIL_SERVER_PORT=465
|
||||||
EMAIL_USERNMAE=your_email_username
|
EMAIL_USERNAME=your_email_username
|
||||||
EMAIL_PASSWORD=your_email_password
|
EMAIL_PASSWORD=your_email_password
|
||||||
# 开启虚拟判题请提供对应oj的账号密码 格式为
|
# 开启虚拟判题请提供对应oj的账号密码 格式为
|
||||||
# username1,username2,...
|
# username1,username2,...
|
||||||
|
@ -227,7 +245,8 @@ Password: 开启SMTP服务后生成的随机授权码
|
||||||
POJ_ACCOUNT_PASSWORD_LIST=
|
POJ_ACCOUNT_PASSWORD_LIST=
|
||||||
|
|
||||||
# 评测数据同步的配置
|
# 评测数据同步的配置
|
||||||
RSYNC_PASSWORD=hoj123456 # 请修改数据同步密码
|
# 请修改数据同步密码
|
||||||
|
RSYNC_PASSWORD=hoj123456
|
||||||
|
|
||||||
# docker network的配置
|
# docker network的配置
|
||||||
SUBNET=172.20.0.0/16
|
SUBNET=172.20.0.0/16
|
||||||
|
@ -254,23 +273,36 @@ Password: 开启SMTP服务后生成的随机授权码
|
||||||
4. 接着,在另一台服务器上,依旧git clone该文件夹下来,然后进入`judgeserver`文件夹,修改`.env`的配置
|
4. 接着,在另一台服务器上,依旧git clone该文件夹下来,然后进入`judgeserver`文件夹,修改`.env`的配置
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
|
# hoj全部数据存储的文件夹位置(默认当前路径生成judge文件夹)
|
||||||
|
HOJ_JUDGESERVER_DATA_DIRECTORY=./judge
|
||||||
|
|
||||||
# nacos的配置
|
# nacos的配置
|
||||||
NACOS_HOST=NACOS_HOST # 修改为nacos所在服务的ip,即主服务器的公网ip
|
# 修改为nacos所在服务的ip
|
||||||
NACOS_PORT=8848 # 修改为nacos启动端口号,默认为8848
|
NACOS_HOST=NACOS_HOST
|
||||||
NACOS_USERNAME=root # 修改为nacos的管理员账号
|
# 修改为nacos启动端口号,默认为8848
|
||||||
NACOS_PASSWORD=hoj123456 # 修改为nacos的管理员密码
|
NACOS_PORT=8848
|
||||||
|
# 修改为nacos的管理员账号
|
||||||
|
NACOS_USERNAME=root
|
||||||
|
# 修改为nacos的管理员密码
|
||||||
|
NACOS_PASSWORD=hoj123456
|
||||||
|
|
||||||
# judgeserver的配置
|
# judgeserver的配置
|
||||||
JUDGE_SERVER_IP=172.20.0.7 # 修改为当前的服务器公网ip
|
#修改服务器公网ip
|
||||||
JUDGE_SERVER_PORT=8088 # judgeserver启动端口号
|
JUDGE_SERVER_IP=172.20.0.7
|
||||||
|
JUDGE_SERVER_PORT=8088
|
||||||
JUDGE_SERVER_NAME=judger-1
|
JUDGE_SERVER_NAME=judger-1
|
||||||
MAX_TASK_NUM=-1 # -1表示最大并行任务数为cpu核心数+1
|
# -1表示最大并行任务数为cpu核心数+1
|
||||||
REMOTE_JUDGE_OPEN=true # 当前判题服务器是否开启远程虚拟判题功能
|
MAX_TASK_NUM=-1
|
||||||
REMOTE_JUDGE_MAX_TASK_NUM=-1 # -1表示最大并行任务数为cpu核心数*2+1
|
# 当前判题服务器是否开启远程虚拟判题功能
|
||||||
|
REMOTE_JUDGE_OPEN=true
|
||||||
|
# -1表示最大并行任务数为cpu核心数*2+1
|
||||||
|
REMOTE_JUDGE_MAX_TASK_NUM=-1
|
||||||
|
|
||||||
# rsync评测数据同步的配置
|
# rsync评测数据同步的配置
|
||||||
RSYNC_MASTER_ADDR=127.0.0.1 # 写入主服务器ip
|
# 写入主服务器ip
|
||||||
RSYNC_PASSWORD=hoj123456 # 与主服务器的rsync密码一致
|
RSYNC_MASTER_ADDR=127.0.0.1
|
||||||
|
# 与主服务器的rsync密码一致
|
||||||
|
RSYNC_PASSWORD=hoj123456
|
||||||
```
|
```
|
||||||
|
|
||||||
配置修改保存后,当前路径下启动该服务
|
配置修改保存后,当前路径下启动该服务
|
||||||
|
|
|
@ -82,7 +82,7 @@ docker-compose up -d
|
||||||
|
|
||||||
> 附加:如何自定义前端请看这里 => [自定义前端文档](/use/update-fe.html)
|
> 附加:如何自定义前端请看这里 => [自定义前端文档](/use/update-fe.html)
|
||||||
|
|
||||||
(1)首先到`./hoj/hoj-vue`文件夹中,拉取[hoj-vue](https://gitee.com/himitzh0730/hoj/tree/master/hoj-vue)仓库最新的代码,可能会覆盖本地的修改,请注意合并分支。
|
(1)首先到`./hoj/hoj-vue`文件夹中,拉取[hoj-vue](https://gitee.com/himitzh0730/hoj/tree/master/hoj-vue)仓库最新的代码,请注意解决出现的冲突。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git pull
|
git pull
|
||||||
|
@ -90,6 +90,16 @@ git pull
|
||||||
|
|
||||||
或者重新直接download成zip包,然后重新自定义修改前端
|
或者重新直接download成zip包,然后重新自定义修改前端
|
||||||
|
|
||||||
|
当然,如果想查看对比主仓库更新的内容,可以用以下命令一步步合并
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git remote -v # 查看主仓库的远程仓库
|
||||||
|
git fetch origin master:temp # 将最新的主仓库代码拉到本地一个temp的分支
|
||||||
|
git diff temp # 比较现在本地代码与最新temp分支的区别
|
||||||
|
git merge temp # 合并temp分支到本地的master分支
|
||||||
|
git branch -d temp # 删除temp这个临时分支
|
||||||
|
```
|
||||||
|
|
||||||
(2)接着,重新用npm打包,在`./hoj/hoj-vue/dist`文件夹会生成静态的前端文件,放到原来指定的位置即可
|
(2)接着,重新用npm打包,在`./hoj/hoj-vue/dist`文件夹会生成静态的前端文件,放到原来指定的位置即可
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.hcode</groupId>
|
<groupId>top.hcode</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
|
|
|
@ -3,7 +3,6 @@ package top.hcode.hoj;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
|
||||||
import org.springframework.retry.annotation.EnableRetry;
|
import org.springframework.retry.annotation.EnableRetry;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
|
@ -8,4 +8,5 @@ import top.hcode.hoj.pojo.entity.user.Session;
|
||||||
@Mapper
|
@Mapper
|
||||||
@Repository
|
@Repository
|
||||||
public interface SessionMapper extends BaseMapper<Session> {
|
public interface SessionMapper extends BaseMapper<Session> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="top.hcode.hoj.dao.SessionMapper">
|
<mapper namespace="top.hcode.hoj.dao.SessionMapper">
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -9,6 +9,7 @@ import cn.hutool.json.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.time.DateFormatUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
|
@ -32,6 +33,7 @@ import top.hcode.hoj.utils.RedisUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,13 +260,18 @@ public class ScheduleServiceImpl implements ScheduleService {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("爬虫爬取Codeforces Rating分数异常----------------------->{}", e.getMessage());
|
log.error("爬虫爬取Codeforces Rating分数异常----------------------->{}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(2);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log.info("获取Codeforces Rating成功!");
|
log.info("获取Codeforces Rating成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Retryable(value = Exception.class,
|
@Retryable(value = Exception.class,
|
||||||
maxAttempts = 5,
|
maxAttempts = 5,
|
||||||
backoff = @Backoff(delay = 500, multiplier = 1.4))
|
backoff = @Backoff(delay = 1000, multiplier = 1.4))
|
||||||
public JSONObject getCFUserInfo(String url) throws Exception {
|
public JSONObject getCFUserInfo(String url) throws Exception {
|
||||||
return JsoupUtils.getJsonFromConnection(JsoupUtils.getConnectionFromUrl(url, null, null));
|
return JsoupUtils.getJsonFromConnection(JsoupUtils.getConnectionFromUrl(url, null, null));
|
||||||
}
|
}
|
||||||
|
@ -278,19 +285,21 @@ public class ScheduleServiceImpl implements ScheduleService {
|
||||||
* @Since 2021/9/6
|
* @Since 2021/9/6
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 3 * * *")
|
@Scheduled(cron = "0 0 3 * * *")
|
||||||
|
// @Scheduled(cron = "0/5 * * * * *")
|
||||||
@Override
|
@Override
|
||||||
public void deleteUserSession() {
|
public void deleteUserSession() {
|
||||||
QueryWrapper<Session> sessionQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<Session> sessionQueryWrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
DateTime dateTime = DateUtil.offsetMonth(new Date(), -6);
|
DateTime dateTime = DateUtil.offsetMonth(new Date(), -6);
|
||||||
|
String strTime = DateFormatUtils.format(dateTime, "yyyy-MM-dd HH:mm:ss");
|
||||||
sessionQueryWrapper.select("distinct uid");
|
sessionQueryWrapper.select("distinct uid");
|
||||||
sessionQueryWrapper.ge("gmt_create", dateTime.toJdkDate());
|
sessionQueryWrapper.apply("UNIX_TIMESTAMP(gmt_create) >= UNIX_TIMESTAMP('" + strTime + "')");
|
||||||
List<Session> sessionList = sessionService.list(sessionQueryWrapper);
|
List<Session> sessionList = sessionService.list(sessionQueryWrapper);
|
||||||
if (sessionList.size() > 0) {
|
if (sessionList.size() > 0) {
|
||||||
List<String> uidList = sessionList.stream().map(Session::getUid).collect(Collectors.toList());
|
List<String> uidList = sessionList.stream().map(Session::getUid).collect(Collectors.toList());
|
||||||
UpdateWrapper<Session> sessionUpdateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<Session> sessionUpdateWrapper = new UpdateWrapper<>();
|
||||||
sessionQueryWrapper.in("uid", uidList)
|
sessionQueryWrapper.in("uid", uidList)
|
||||||
.lt("gmt_create", dateTime.toJdkDate());
|
.apply("UNIX_TIMESTAMP('" + strTime + "') > UNIX_TIMESTAMP(gmt_create)");
|
||||||
boolean isSuccess = sessionService.remove(sessionUpdateWrapper);
|
boolean isSuccess = sessionService.remove(sessionUpdateWrapper);
|
||||||
if (!isSuccess) {
|
if (!isSuccess) {
|
||||||
log.error("=============数据库session表定时删除用户6个月前的记录失败===============");
|
log.error("=============数据库session表定时删除用户6个月前的记录失败===============");
|
||||||
|
|
|
@ -36,10 +36,6 @@
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>2.9.2</version>
|
<version>2.9.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
<artifactId>hoj-springboot</artifactId>
|
<artifactId>hoj-springboot</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>DataBackup</module>
|
|
||||||
<module>api</module>
|
<module>api</module>
|
||||||
|
<module>DataBackup</module>
|
||||||
<module>JudgeServer</module>
|
<module>JudgeServer</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
|
@ -437,7 +437,7 @@ export default {
|
||||||
keyword: '',
|
keyword: '',
|
||||||
cid: '',
|
cid: '',
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
limit: 8,
|
limit: 10,
|
||||||
pid: '',
|
pid: '',
|
||||||
onlyMine: false,
|
onlyMine: false,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue