fix 迁移系统参数表中的 sync_trigger_token 数据重复问题

This commit is contained in:
bwcx_jzy 2023-01-09 17:58:50 +08:00
parent f0c994b1ea
commit 71a802b845
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
3 changed files with 13 additions and 23 deletions

View File

@ -8,6 +8,7 @@
2. 【server】优化 解析文件数据采用分片形式,避免大文件造成浏览器奔溃
3. 【server】优化 插件端在线升级管理页面错误信息提示由弹窗改到对应节点
4. 【server】修复 迁移数据出现监控报警记录表字段不全问题 (感谢@loyal
5. 【server】修复 迁移系统参数表中的 sync_trigger_token 数据重复问题
### ❌ 不兼容功能
@ -46,8 +47,8 @@
1. 插件端需要同步升级,否则节点分发项目无法显示项目名称
2. 插件端需要同步升级,否则会出现部分接口 404 或者参数不正确的情况
3. 建议升级验证上传项目文件无问题后,将插件端上传文件大小限制配置属性大改小
1. spring.servlet.multipart.max-file-size=5MB
2. spring.servlet.multipart.max-request-size=20MB
1. spring.servlet.multipart.max-file-size=5MB
2. spring.servlet.multipart.max-request-size=20MB
**如果需要使用 mysql 存储,则需要修改配置**

View File

@ -23,7 +23,10 @@
package io.jpom.model.data;
import io.jpom.model.BaseStrikeDbModel;
import io.jpom.service.user.TriggerTokenLogServer;
import io.jpom.util.StringUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import top.jpom.h2db.TableName;
/**
@ -32,7 +35,9 @@ import top.jpom.h2db.TableName;
* @author bwcx_jzy
* @since 2021/12/2
*/
@TableName(value = "SYSTEM_PARAMETERS", name = "系统参数")
@EqualsAndHashCode(callSuper = true)
@TableName(value = "SYSTEM_PARAMETERS", name = "系统参数", migrateIgnoreId = TriggerTokenLogServer.NAME)
@Data
public class SystemParametersModel extends BaseStrikeDbModel {
/**
@ -44,22 +49,6 @@ public class SystemParametersModel extends BaseStrikeDbModel {
*/
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public <T> T jsonToBean(Class<T> cls) {
return StringUtil.jsonConvert(this.getValue(), cls);
}

View File

@ -57,6 +57,7 @@ public class TriggerTokenLogServer extends BaseDbService<TriggerTokenLogBean> im
* 填充的长度
*/
private static final int BUILD_INFO_TRIGGER_TOKEN_FILL_LEN = 3;
public static final String NAME = "sync_trigger_token";
private final SystemParametersServer parametersServer;
private final UserService userService;
@ -145,15 +146,14 @@ public class TriggerTokenLogServer extends BaseDbService<TriggerTokenLogBean> im
@Override
public int statusRecover() {
String name = "sync_trigger_token";
String triggerToken = parametersServer.getConfig(name, String.class);
String triggerToken = parametersServer.getConfig(NAME, String.class);
if (StrUtil.isNotEmpty(triggerToken)) {
// 已经同步过啦
return 0;
}
List<UserModel> list = userService.list();
if (CollUtil.isEmpty(list)) {
log.warn("TriggerToken status recover,user list empty");
log.debug("TriggerToken status recover,user list empty");
return -1;
}
List<String> userIds = list.stream().map(BaseIdModel::getId).collect(Collectors.toList());
@ -179,7 +179,7 @@ public class TriggerTokenLogServer extends BaseDbService<TriggerTokenLogBean> im
//
return CollUtil.size(triggerTokenLogBeans);
}).sum();
parametersServer.upsert(name, count, name);
parametersServer.upsert(NAME, count, NAME);
log.info("trigger token sync count:{}", count);
return count;
}