From a1dd9eec015457da1caf9684468198923bc288a0 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Fri, 7 Mar 2025 14:57:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/SpringConfiguration.java | 6 +-- .../test/core/base/BaseUnitTest.java | 4 +- .../visor/launch/LaunchApplication.java | 6 ++- .../orion-visor-module-asset-service/pom.xml | 4 ++ .../module/asset/service/HostService.java | 7 --- .../asset/service/impl/HostServiceImpl.java | 50 +++++++------------ 6 files changed, 34 insertions(+), 43 deletions(-) rename orion-visor-launch/src/main/java/org/dromara/visor/launch/configuration/LaunchApplicationConfiguration.java => orion-visor-common/src/main/java/org/dromara/visor/common/configuration/SpringConfiguration.java (91%) diff --git a/orion-visor-launch/src/main/java/org/dromara/visor/launch/configuration/LaunchApplicationConfiguration.java b/orion-visor-common/src/main/java/org/dromara/visor/common/configuration/SpringConfiguration.java similarity index 91% rename from orion-visor-launch/src/main/java/org/dromara/visor/launch/configuration/LaunchApplicationConfiguration.java rename to orion-visor-common/src/main/java/org/dromara/visor/common/configuration/SpringConfiguration.java index 31148f0f..a7ce3d52 100644 --- a/orion-visor-launch/src/main/java/org/dromara/visor/launch/configuration/LaunchApplicationConfiguration.java +++ b/orion-visor-common/src/main/java/org/dromara/visor/common/configuration/SpringConfiguration.java @@ -20,21 +20,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.dromara.visor.launch.configuration; +package org.dromara.visor.common.configuration; import cn.orionsec.kit.spring.SpringHolder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** - * 应用配置类 + * spring 配置类 * * @author Jiahang Li * @version 1.0.0 * @since 2023/6/20 10:34 */ @Configuration -public class LaunchApplicationConfiguration { +public class SpringConfiguration { /** * @return spring 容器工具类 diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-test/src/main/java/org/dromara/visor/framework/test/core/base/BaseUnitTest.java b/orion-visor-framework/orion-visor-spring-boot-starter-test/src/main/java/org/dromara/visor/framework/test/core/base/BaseUnitTest.java index 1f07ce5a..2a943537 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-test/src/main/java/org/dromara/visor/framework/test/core/base/BaseUnitTest.java +++ b/orion-visor-framework/orion-visor-spring-boot-starter-test/src/main/java/org/dromara/visor/framework/test/core/base/BaseUnitTest.java @@ -24,6 +24,7 @@ package org.dromara.visor.framework.test.core.base; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; +import org.dromara.visor.common.configuration.SpringConfiguration; import org.dromara.visor.framework.datasource.configuration.OrionDataSourceAutoConfiguration; import org.dromara.visor.framework.mybatis.configuration.OrionMybatisAutoConfiguration; import org.dromara.visor.framework.redis.configuration.OrionRedisAutoConfiguration; @@ -57,6 +58,8 @@ import org.springframework.transaction.annotation.Transactional; public class BaseUnitTest { @Import({ + // spring + SpringConfiguration.class, // mock OrionMockBeanTestConfiguration.class, OrionMockRedisTestConfiguration.class, @@ -74,7 +77,6 @@ public class BaseUnitTest { RedisAutoConfiguration.class, RedissonAutoConfiguration.class, }) - // TODO public static class Application { } diff --git a/orion-visor-launch/src/main/java/org/dromara/visor/launch/LaunchApplication.java b/orion-visor-launch/src/main/java/org/dromara/visor/launch/LaunchApplication.java index 5d893310..fae60a26 100644 --- a/orion-visor-launch/src/main/java/org/dromara/visor/launch/LaunchApplication.java +++ b/orion-visor-launch/src/main/java/org/dromara/visor/launch/LaunchApplication.java @@ -42,7 +42,11 @@ import java.util.Optional; * @version 1.0.0 * @since 2023/6/19 16:55 */ -@SpringBootApplication(scanBasePackages = {"org.dromara.visor.launch", "org.dromara.visor.module"}) +@SpringBootApplication(scanBasePackages = { + "org.dromara.visor.launch", + "org.dromara.visor.common", + "org.dromara.visor.module" +}) public class LaunchApplication { public static void main(String[] args) { diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/pom.xml b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/pom.xml index d3c6ff2d..77d4baba 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/pom.xml +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/pom.xml @@ -82,6 +82,10 @@ org.dromara.visor orion-visor-spring-boot-starter-job + + org.dromara.visor + orion-visor-spring-boot-starter-test + \ No newline at end of file diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/service/HostService.java b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/service/HostService.java index 1d6d17ba..8dfc2ccb 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/service/HostService.java +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/service/HostService.java @@ -135,13 +135,6 @@ public interface HostService { */ void deleteHostRelByIdListAsync(List idList); - /** - * 获取当前更新配置的 hostId - * - * @return hostId - */ - Long getCurrentUpdateConfigHostId(); - /** * 清除缓存 */ diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/service/impl/HostServiceImpl.java b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/service/impl/HostServiceImpl.java index d21992db..8d9b0c45 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/service/impl/HostServiceImpl.java +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/service/impl/HostServiceImpl.java @@ -83,8 +83,6 @@ import java.util.stream.Collectors; @Service public class HostServiceImpl implements HostService { - private static final ThreadLocal CURRENT_UPDATE_CONFIG_ID = new ThreadLocal<>(); - @Resource private HostDAO hostDAO; @@ -185,30 +183,25 @@ public class HostServiceImpl implements HostService { OperatorLogs.add(ExtraFieldConst.CONFIG, param); log.info("HostService-updateHostConfig request: {}", param); Long id = request.getId(); - try { - CURRENT_UPDATE_CONFIG_ID.set(id); - // 查询主机信息 - HostDO host = hostDAO.selectById(id); - Valid.notNull(host, ErrorMessage.HOST_ABSENT); - HostTypeEnum type = Valid.valid(HostTypeEnum::of, host.getType()); - GenericsDataModel beforeConfig = type.parse(host.getConfig()); - GenericsDataModel newConfig = type.parse(request.getConfig()); - // 添加日志参数 - OperatorLogs.add(OperatorLogs.ID, id); - OperatorLogs.add(OperatorLogs.NAME, host.getName()); - // 更新前校验 - type.doValid(beforeConfig, newConfig); - // 修改配置 - HostDO updateHost = HostDO.builder() - .id(id) - .config(newConfig.serial()) - .build(); - int effect = hostDAO.updateById(updateHost); - log.info("HostService-updateHostConfig effect: {}", effect); - return effect; - } finally { - CURRENT_UPDATE_CONFIG_ID.remove(); - } + // 查询主机信息 + HostDO host = hostDAO.selectById(id); + Valid.notNull(host, ErrorMessage.HOST_ABSENT); + HostTypeEnum type = Valid.valid(HostTypeEnum::of, host.getType()); + GenericsDataModel beforeConfig = type.parse(host.getConfig()); + GenericsDataModel newConfig = type.parse(request.getConfig()); + // 添加日志参数 + OperatorLogs.add(OperatorLogs.ID, id); + OperatorLogs.add(OperatorLogs.NAME, host.getName()); + // 更新前校验 + type.doValid(beforeConfig, newConfig); + // 修改配置 + HostDO updateHost = HostDO.builder() + .id(id) + .config(newConfig.serial()) + .build(); + int effect = hostDAO.updateById(updateHost); + log.info("HostService-updateHostConfig effect: {}", effect); + return effect; } @Override @@ -348,11 +341,6 @@ public class HostServiceImpl implements HostService { dataExtraApi.deleteByRelIdList(DataExtraTypeEnum.HOST, idList); } - @Override - public Long getCurrentUpdateConfigHostId() { - return CURRENT_UPDATE_CONFIG_ID.get(); - } - @Override public void clearCache() { RedisMaps.scanKeysDelete(HostCacheKeyDefine.HOST_INFO.format("*")); From 05bc6c1fbb43cce015c32a2e95797be2e404a781 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Fri, 7 Mar 2025 15:50:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:zap:=20=E4=BF=AE=E6=94=B9=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E8=A7=84=E5=88=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/orion-vue-router.ts.vm | 2 +- .../src/router/routes/modules/asset-audit.ts | 6 +++--- .../src/router/routes/modules/asset.ts | 8 ++++---- orion-visor-ui/src/router/routes/modules/exec.ts | 16 ++++++++-------- .../src/router/routes/modules/system.ts | 6 +++--- orion-visor-ui/src/router/routes/modules/user.ts | 8 ++++---- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-router.ts.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-router.ts.vm index 22c2d775..28bb74e8 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-router.ts.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-router.ts.vm @@ -8,7 +8,7 @@ const $vue.moduleConst: AppRouteRecordRaw = { children: [ { name: '$vue.featureEntityFirstLower', - path: '/$vue.feature', + path: '/$vue.module/$vue.feature', component: () => import('@/views/$vue.module/$vue.feature/index.vue'), }, ], diff --git a/orion-visor-ui/src/router/routes/modules/asset-audit.ts b/orion-visor-ui/src/router/routes/modules/asset-audit.ts index 28851a10..5f1554e8 100644 --- a/orion-visor-ui/src/router/routes/modules/asset-audit.ts +++ b/orion-visor-ui/src/router/routes/modules/asset-audit.ts @@ -8,17 +8,17 @@ const ASSET_AUDIT: AppRouteRecordRaw = { children: [ { name: 'connectLog', - path: '/connect-log', + path: '/audit/connect-log', component: () => import('@/views/asset-audit/connect-log/index.vue'), }, { name: 'connectSession', - path: '/connect-session', + path: '/audit/connect-session', component: () => import('@/views/asset-audit/connect-session/index.vue'), }, { name: 'sftpLog', - path: '/sftp-log', + path: '/audit/sftp-log', component: () => import('@/views/asset-audit/sftp-log/index.vue'), }, ], diff --git a/orion-visor-ui/src/router/routes/modules/asset.ts b/orion-visor-ui/src/router/routes/modules/asset.ts index 87255138..5ca19011 100644 --- a/orion-visor-ui/src/router/routes/modules/asset.ts +++ b/orion-visor-ui/src/router/routes/modules/asset.ts @@ -8,19 +8,19 @@ const ASSET: AppRouteRecordRaw = { children: [ { name: 'hostList', - path: '/host-list', + path: '/asset/host', component: () => import('@/views/asset/host-list/index.vue'), }, { name: 'hostKey', - path: '/host-key', + path: '/asset/host-key', component: () => import('@/views/asset/host-key/index.vue'), }, { name: 'hostIdentity', - path: '/host-identity', + path: '/asset/host-identity', component: () => import('@/views/asset/host-identity/index.vue'), }, { name: 'assetGrant', - path: '/asset-grant', + path: '/asset/grant', component: () => import('@/views/asset/grant/index.vue'), }, ], diff --git a/orion-visor-ui/src/router/routes/modules/exec.ts b/orion-visor-ui/src/router/routes/modules/exec.ts index 507b546e..ec68a96e 100644 --- a/orion-visor-ui/src/router/routes/modules/exec.ts +++ b/orion-visor-ui/src/router/routes/modules/exec.ts @@ -9,37 +9,37 @@ const EXEC: Array = [ children: [ { name: 'execCommand', - path: '/exec-command', + path: '/exec/command', component: () => import('@/views/exec/exec-command/index.vue'), }, { name: 'execCommandLog', - path: '/exec-log', + path: '/exec/command-log', component: () => import('@/views/exec/exec-command-log/index.vue'), }, { name: 'execJob', - path: '/exec-job', + path: '/exec/job', component: () => import('@/views/exec/exec-job/index.vue'), }, { name: 'execJobLog', - path: '/exec-job-log', + path: '/exec/job-log', component: () => import('@/views/exec/exec-job-log/index.vue'), }, { name: 'batchUpload', - path: '/batch-upload', + path: '/exec/upload', component: () => import('@/views/exec/batch-upload/index.vue'), }, { name: 'uploadTask', - path: '/upload-task', + path: '/exec/upload-task', component: () => import('@/views/exec/upload-task/index.vue'), }, { name: 'execTemplate', - path: '/exec-template', + path: '/exec/template', component: () => import('@/views/exec/exec-template/index.vue'), }, ], @@ -50,7 +50,7 @@ const EXEC: Array = [ children: [ { name: 'execJobLogView', - path: '/job-log-view', + path: '/exec/job-log/view', component: () => import('@/views/exec/exec-job-log-view/index.vue'), }, ], diff --git a/orion-visor-ui/src/router/routes/modules/system.ts b/orion-visor-ui/src/router/routes/modules/system.ts index 22903439..831d3a56 100644 --- a/orion-visor-ui/src/router/routes/modules/system.ts +++ b/orion-visor-ui/src/router/routes/modules/system.ts @@ -8,17 +8,17 @@ const SYSTEM: AppRouteRecordRaw = { children: [ { name: 'systemMenu', - path: '/menu', + path: '/system/menu', component: () => import('@/views/system/menu/index.vue'), }, { name: 'dictKey', - path: '/dict-key', + path: '/system/dict-key', component: () => import('@/views/system/dict-key/index.vue'), }, { name: 'dictValue', - path: '/dict-value', + path: '/system/dict-value', component: () => import('@/views/system/dict-value/index.vue'), }, { diff --git a/orion-visor-ui/src/router/routes/modules/user.ts b/orion-visor-ui/src/router/routes/modules/user.ts index 575f9217..ee068384 100644 --- a/orion-visor-ui/src/router/routes/modules/user.ts +++ b/orion-visor-ui/src/router/routes/modules/user.ts @@ -8,22 +8,22 @@ const USER: AppRouteRecordRaw = { children: [ { name: 'role', - path: '/role', + path: '/user/role', component: () => import('@/views/user/role/index.vue'), }, { name: 'user', - path: '/user', + path: '/user/list', component: () => import('@/views/user/user/index.vue'), }, { name: 'userInfo', - path: '/user-info', + path: '/user/info', component: () => import('@/views/user/info/index.vue'), }, { name: 'operatorLog', - path: '/operator-log', + path: '/user/operator-log', component: () => import('@/views/user/operator-log/index.vue'), }, ],