优化插件更新配置
This commit is contained in:
@@ -188,9 +188,9 @@ public class CoolPluginService {
|
|||||||
pluginInfo.setConfig(one.getConfig());
|
pluginInfo.setConfig(one.getConfig());
|
||||||
pluginInfo.getPluginJson().setConfig(one.getConfig());
|
pluginInfo.getPluginJson().setConfig(one.getConfig());
|
||||||
CopyOptions options = CopyOptions.create().setIgnoreNullValue(true);
|
CopyOptions options = CopyOptions.create().setIgnoreNullValue(true);
|
||||||
BeanUtil.copyProperties(pluginInfo, one, options);
|
// 忽略无变更,无需更新的字段
|
||||||
// 忽略为更新的字段
|
|
||||||
ignoreNoChange(pluginInfo, one);
|
ignoreNoChange(pluginInfo, one);
|
||||||
|
BeanUtil.copyProperties(pluginInfo, one, options);
|
||||||
one.updateById();
|
one.updateById();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,16 +209,16 @@ public class CoolPluginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 忽略为更新的字段
|
* 忽略无变更,无需更新的字段
|
||||||
*/
|
*/
|
||||||
private static void ignoreNoChange(PluginInfoEntity pluginInfo, PluginInfoEntity one) {
|
private static void ignoreNoChange(PluginInfoEntity pluginInfo, PluginInfoEntity one) {
|
||||||
if (ObjUtil.equals(pluginInfo.getLogo(), one.getLogo())) {
|
if (ObjUtil.equals(pluginInfo.getLogo(), one.getLogo())) {
|
||||||
// 头像没变,不更新
|
// 头像没变,无需更新
|
||||||
one.setLogo(null);
|
pluginInfo.setLogo(null);
|
||||||
}
|
}
|
||||||
if (ObjUtil.equals(pluginInfo.getReadme(), one.getReadme())) {
|
if (ObjUtil.equals(pluginInfo.getReadme(), one.getReadme())) {
|
||||||
// readme没变,不更新
|
// readme没变,无需更新
|
||||||
one.setReadme(null);
|
pluginInfo.setReadme(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,11 +257,11 @@ public class CoolPluginService {
|
|||||||
}
|
}
|
||||||
if (!ObjUtil.equals(entity.getStatus(), dbPluginInfoEntity.getStatus())) {
|
if (!ObjUtil.equals(entity.getStatus(), dbPluginInfoEntity.getStatus())) {
|
||||||
// 更新状态
|
// 更新状态
|
||||||
updateConfig = updateStatus(entity, dbPluginInfoEntity, updateConfig);
|
updateStatus(entity, dbPluginInfoEntity);
|
||||||
}
|
}
|
||||||
if (updateConfig) {
|
if (updateConfig) {
|
||||||
// 更新配置
|
// 更新配置
|
||||||
CoolPluginInvokers.setPluginJson(getKeyById(entity.getId()), entity);
|
CoolPluginInvokers.setPluginJson(dbPluginInfoEntity.getKey(), entity);
|
||||||
}
|
}
|
||||||
pluginInfoService.update(entity);
|
pluginInfoService.update(entity);
|
||||||
}
|
}
|
||||||
@@ -269,8 +269,7 @@ public class CoolPluginService {
|
|||||||
/**
|
/**
|
||||||
* 更新插件状态
|
* 更新插件状态
|
||||||
*/
|
*/
|
||||||
private boolean updateStatus(PluginInfoEntity entity, PluginInfoEntity dbPluginInfoEntity,
|
private void updateStatus(PluginInfoEntity entity, PluginInfoEntity dbPluginInfoEntity) {
|
||||||
boolean updateConfig) {
|
|
||||||
// 更新状态
|
// 更新状态
|
||||||
Integer status = entity.getStatus();
|
Integer status = entity.getStatus();
|
||||||
if (ObjUtil.equals(status, 1)) {
|
if (ObjUtil.equals(status, 1)) {
|
||||||
@@ -287,14 +286,12 @@ public class CoolPluginService {
|
|||||||
hookPlugin.getName());
|
hookPlugin.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 充关闭置为开启,触发重新加载jar
|
// 从关闭置为开启,触发重新加载jar
|
||||||
initInstall(dbPluginInfoEntity);
|
initInstall(dbPluginInfoEntity);
|
||||||
updateConfig = false;
|
|
||||||
} else if (ObjUtil.equals(status, 0)) {
|
} else if (ObjUtil.equals(status, 0)) {
|
||||||
// 插件关闭 卸载jar
|
// 插件关闭 卸载jar
|
||||||
dynamicJarLoaderService.uninstall(dbPluginInfoEntity.getKey());
|
dynamicJarLoaderService.uninstall(dbPluginInfoEntity.getKey());
|
||||||
}
|
}
|
||||||
return updateConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -304,17 +301,6 @@ public class CoolPluginService {
|
|||||||
return pluginInfoService.getPluginInfoEntityByHookNoJarFile(hook);
|
return pluginInfoService.getPluginInfoEntityByHookNoJarFile(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过id 获取key
|
|
||||||
*/
|
|
||||||
private String getKeyById(Long id) {
|
|
||||||
PluginInfoEntity one = pluginInfoService.getPluginInfoEntityByIdNoJarFile(id);
|
|
||||||
if (ObjUtil.isNotEmpty(one)) {
|
|
||||||
return one.getKey();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取插件实例对象
|
* 获取插件实例对象
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjUtil;
|
|||||||
import com.mybatisflex.annotation.Table;
|
import com.mybatisflex.annotation.Table;
|
||||||
import com.mybatisflex.core.query.QueryColumn;
|
import com.mybatisflex.core.query.QueryColumn;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -72,8 +73,9 @@ public class EntityUtils {
|
|||||||
|
|
||||||
public static List<QueryColumn> getFieldNamesListWithSuperClass(QueryColumn[] queryColumns,
|
public static List<QueryColumn> getFieldNamesListWithSuperClass(QueryColumn[] queryColumns,
|
||||||
String... excludeNames) {
|
String... excludeNames) {
|
||||||
|
ArrayList<String> excludeList = new ArrayList<>(List.of(excludeNames));
|
||||||
return Arrays.stream(queryColumns).toList().stream()
|
return Arrays.stream(queryColumns).toList().stream()
|
||||||
.filter(o -> ObjUtil.equals(o.getName(), excludeNames)).toList();
|
.filter(o -> !excludeList.contains(o.getName())).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user