1、mybatis-flex.ext 版本升级

2、系统日志参数写入大小控制
3、覆盖插件时,删除原因插件包
This commit is contained in:
ruying408
2024-07-24 22:21:34 +08:00
parent ba400993dc
commit b4c8d0cdd1
5 changed files with 22 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
package com.cool.core.base;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
@@ -20,17 +21,18 @@ import lombok.Setter;
public abstract class BaseEntity<T extends Model<T>> extends Model<T> implements Serializable {
@Id(keyType = KeyType.Auto, comment = "ID")
private Long id;
protected Long id;
@Column(onInsertValue = "now()")
@ColumnDefine(comment = "创建时间")
private Date createTime;
protected Date createTime;
@Column(onInsertValue = "now()", onUpdateValue = "now()")
@ColumnDefine(comment = "更新时间")
private Date updateTime;
protected Date updateTime;
@Ignore
@Column(ignore = true)
@JsonIgnore
private QueryWrapper queryWrapper;
}

View File

@@ -184,6 +184,7 @@ public class CoolPluginService {
// 通过key 找到id
PluginInfoEntity one = pluginInfoService.getByKeyNoJarFile(pluginJson.getKey());
if (ObjUtil.isNotEmpty(one)) {
String oldJarPath = one.getPluginJson().getJarPath();
// 重新加载配置不更新
pluginInfo.setConfig(one.getConfig());
pluginInfo.getPluginJson().setConfig(one.getConfig());
@@ -191,7 +192,10 @@ public class CoolPluginService {
// 忽略无变更,无需更新的字段
ignoreNoChange(pluginInfo, one);
BeanUtil.copyProperties(pluginInfo, one, options);
one.updateById();
if (one.updateById()) {
// 覆盖时删除旧版本插件
FileUtil.del(oldJarPath);
}
}
}

View File

@@ -19,6 +19,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Date;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -36,6 +37,9 @@ public class BaseSysLogServiceImpl extends BaseServiceImpl<BaseSysLogMapper, Bas
private final IPUtils ipUtils;
@Value("${cool.log.maxJsonLength:1024}")
private int maxJsonLength;
@Override
public Object page(
JSONObject requestParams, Page<BaseSysLogEntity> page, QueryWrapper queryWrapper) {
@@ -76,7 +80,10 @@ public class BaseSysLogServiceImpl extends BaseServiceImpl<BaseSysLogMapper, Bas
newJSONObject.remove("tokenInfo");
newJSONObject.remove("refreshToken");
newJSONObject.remove("body");
if (newJSONObject.toString().getBytes().length > maxJsonLength) {
// 超过指定
newJSONObject.clear();
}
recordAsync(requestURI, ipAddr, userId, newJSONObject);
}

View File

@@ -127,7 +127,9 @@ cool:
local:
# 文件访问地址
base-url: http://127.0.0.1:${server.port}/upload
# 系统日志请求参数超过1024字节 就不记录,避免日志过大
log:
maxJsonLength: 1024
# AutoTable配置根据实体类自动生成表
auto-table:
show-banner: false