diff --git a/README.md b/README.md index 3f7710586..9a50c4241 100644 --- a/README.md +++ b/README.md @@ -66,16 +66,16 @@ git clone https://github.com/lijiahangmax/orion-visor cd orion-visor # 启动 docker compose up -d +# 等待后端服务启动后 (2min±) 访问 http://localhost:1081/ ``` ## 项目文档 -* [文档地址](https://lijiahangmax.github.io/orion-visor/#/) -* [docker安装](https://lijiahangmax.github.io/orion-visor/#/quickstart/docker-install) -* [普通安装](https://lijiahangmax.github.io/orion-visor/#/quickstart/install) -* [更新日志](https://lijiahangmax.github.io/orion-visor/#/about/change-log) -* [操作手册](https://lijiahangmax.github.io/orion-visor/#/operator/asset) -* [常见问题](https://lijiahangmax.github.io/orion-visor/#/quickstart/faq) +* [文档地址](https://lijiahangmax.github.io/open-orion/orion-visor/) +* [安装文档](https://lijiahangmax.github.io/open-orion/orion-visor/quickstart/docker.html) +* [更新日志](https://lijiahangmax.github.io/open-orion/orion-visor/update/change-log.html) +* [操作手册](https://lijiahangmax.github.io/open-orion/orion-visor/operator/asset.html) +* [常见问题](https://lijiahangmax.github.io/open-orion/orion-visor/support/faq.html) ## 技术栈 diff --git a/docker-compose.yml b/docker-compose.yml index a091af2a0..c970bedbe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.3' services: orion-visor-service: - image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.3 + image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.4 ports: - 1081:80 environment: @@ -20,7 +20,7 @@ services: - orion-visor-mysql - orion-visor-redis orion-visor-mysql: - image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.3 + image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.4 privileged: true ports: - 3307:3306 @@ -34,7 +34,7 @@ services: - /data/orion-visor-space/docker-volumes/orion-visor-mysql/var-lib-mysql-files:/var/lib/mysql-files - /data/orion-visor-space/docker-volumes/orion-visor-mysql/etc-mysql:/etc/mysql orion-visor-redis: - image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.3 + image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.4 privileged: true ports: - 6380:6379 diff --git a/docker/orion-visor-mysql/build.sh b/docker/orion-visor-mysql/build.sh index e4ddf2660..94d658d7d 100644 --- a/docker/orion-visor-mysql/build.sh +++ b/docker/orion-visor-mysql/build.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.0.3 +version=2.0.4 cp -r ../../sql ./sql docker build -t orion-visor-mysql:${version} . rm -rf ./sql diff --git a/docker/orion-visor-redis/build.sh b/docker/orion-visor-redis/build.sh index a7009fe6e..8351213f1 100644 --- a/docker/orion-visor-redis/build.sh +++ b/docker/orion-visor-redis/build.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.0.3 +version=2.0.4 docker build -t orion-visor-redis:${version} . docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version} docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version} diff --git a/docker/orion-visor-service/build.sh b/docker/orion-visor-service/build.sh index 012e10de8..01c636903 100644 --- a/docker/orion-visor-service/build.sh +++ b/docker/orion-visor-service/build.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.0.3 +version=2.0.4 mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar mv ../../orion-visor-ui/dist ./dist docker build -t orion-visor-service:${version} . diff --git a/docs/README.md b/docs/README.md index 04f8d385b..584eb34c3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -40,6 +40,12 @@ ------------------------------ +

⛔⛔此页面已不再维护, 请跳转至 +这里 +查看最新文档 ❗

+ +------------------------------ + **`orion-visor`** 提供一站式服务器运维解决方案。 * **资产管理**:支持对资产进行分组,实现对主机、密钥和身份的统一管理和授权。 @@ -70,9 +76,8 @@ docker compose up -d ## 项目文档 -* [文档地址](https://lijiahangmax.github.io/orion-visor/#/) -* [docker安装](/quickstart/docker-install) -* [普通安装](/quickstart/install) +* [文档地址](/) +* [安装文档](/quickstart/docker-install) * [更新日志](/about/change-log) * [操作手册](/operator/asset) * [常见问题](/quickstart/faq) diff --git a/docs/_coverpage.md b/docs/_coverpage.md index f6f036953..5862710d6 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,4 +1,4 @@ -# orion-visor 2.0.3 +# orion-visor > 一款高颜值、现代化的智能运维&轻量堡垒机平台。 diff --git a/orion-visor-dependencies/pom.xml b/orion-visor-dependencies/pom.xml index c6f5a0552..4e10be9df 100644 --- a/orion-visor-dependencies/pom.xml +++ b/orion-visor-dependencies/pom.xml @@ -14,11 +14,11 @@ https://github.com/lijiahangmax/orion-visor - 2.0.3 + 2.0.4 2.7.17 2.7.15 1.5.0 - 1.0.7 + 1.0.7 1.9.7 1.18.26 1.6.15 @@ -50,7 +50,7 @@ io.github.lijiahangmax orion-all - ${orion.kit.revision} + ${orion.kit.version} orion-log diff --git a/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/AppConst.java b/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/AppConst.java index 792d5092b..421bfaf49 100644 --- a/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/AppConst.java +++ b/orion-visor-framework/orion-visor-framework-common/src/main/java/com/orion/visor/framework/common/constant/AppConst.java @@ -14,7 +14,7 @@ public interface AppConst extends OrionConst { /** * 同 ${orion.version} 迭代时候需要手动更改 */ - String VERSION = "2.0.3"; + String VERSION = "2.0.4"; String ORION_VISOR = "orion-visor"; diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/core/CustomFileFilter.java b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/core/CustomFileFilter.java index 3ce3b9c6a..78e650563 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/core/CustomFileFilter.java +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/core/CustomFileFilter.java @@ -62,10 +62,6 @@ public List doFilter() { if (!table.isEnableCache()) { files.removeIf(file -> isServerCacheFile(file.getTemplatePath())); } - // 不生成导出文件 - if (!table.isEnableExport()) { - files.removeIf(file -> isExportFile(file.getTemplatePath())); - } // 不生成操作日志文件 if (!table.isEnableOperatorLog()) { files.removeIf(file -> isOperatorLogFile(file.getTemplatePath())); diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/ServerTemplate.java b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/ServerTemplate.java index c1b74336d..3d664ced6 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/ServerTemplate.java +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/ServerTemplate.java @@ -73,16 +73,6 @@ public ServerTemplate enableProviderApi() { return this; } - // /** - // * 生成导出 - // * - // * @return this - // */ - // public ServerTemplate enableExport() { - // table.enableExport = true; - // return this; - // } - /** * 不生成单元测试 * diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/Table.java b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/Table.java index 1d659c7b2..7538a5ce1 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/Table.java +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/Table.java @@ -43,11 +43,6 @@ public class Table { */ protected boolean enableUnitTest; - /** - * 是否生成导出 - */ - protected boolean enableExport; - /** * 是否可缓存 */ diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/VueTemplate.java b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/VueTemplate.java index 76cbd45fa..18a8611e2 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/VueTemplate.java +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/java/com/orion/visor/framework/mybatis/core/generator/template/VueTemplate.java @@ -17,6 +17,7 @@ public VueTemplate(Table table) { public VueTemplate(Table table, String module, String feature) { super(table); table.enableVue = true; + table.enableRowSelection = true; table.module = module; table.feature = feature; } @@ -54,12 +55,12 @@ public VueTemplate enableDrawerForm() { } /** - * 列表可多选 + * 关闭列表可多选 * * @return this */ - public VueTemplate enableRowSelection() { - table.enableRowSelection = true; + public VueTemplate disableRowSelection() { + table.enableRowSelection = false; return this; } diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-controller.http.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-controller.http.vm index 644013433..11dfd87b4 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-controller.http.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-controller.http.vm @@ -68,19 +68,5 @@ Authorization: {{token}} ${httpComment} ${apiComment.batchDelete} DELETE {{baseUrl}}/${package.ModuleName}/${typeHyphen}/batch-delete?idList=1,2,3 Authorization: {{token}} -#if($meta.enableExport) - - -${httpComment} ${apiComment.export} -POST {{baseUrl}}/${package.ModuleName}/${typeHyphen}/export -Content-Type: application/json -Authorization: {{token}} - -{ - #foreach($field in ${table.fields}) - "${field.propertyName}": ""#if($foreach.hasNext),#end - #end -} -#end ${httpComment} diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-controller.java.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-controller.java.vm index e24ac874a..3f8e69580 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-controller.java.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-controller.java.vm @@ -141,19 +141,6 @@ public class ${table.controllerName} { public Integer batchDelete${type}(@RequestParam("idList") List idList) { return ${typeLower}Service.delete${type}ByIdList(idList); } - #if($meta.enableExport) - - #if($meta.enableOperatorLog) - @OperatorLog(${type}OperatorType.EXPORT) - #end - @PostMapping("/export") - @Operation(summary = "${apiComment.export}") - @PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:export')") - public void export${type}(@Validated @RequestBody ${type}QueryRequest request, - HttpServletResponse response) throws IOException { - ${typeLower}Service.export${type}(request, response); - } - #end } diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-convert.java.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-convert.java.vm index f4fb8c3a0..e08ef6abe 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-convert.java.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-convert.java.vm @@ -28,10 +28,6 @@ public interface ${type}Convert { ${type}DO to(${type}QueryRequest request); ${type}VO to(${type}DO domain); - #if($meta.enableExport) - - ${type}Export toExport(${type}DO domain); - #end List<${type}VO> to(List<${type}DO> list); diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-operator-key-define.java.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-operator-key-define.java.vm index be7d053a7..0283219bb 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-operator-key-define.java.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-operator-key-define.java.vm @@ -21,10 +21,6 @@ public class ${type}OperatorType extends InitializingOperatorTypes { public static final String UPDATE = "${typeHyphen}:update"; public static final String DELETE = "${typeHyphen}:delete"; - #if($meta.enableExport) - - public static final String EXPORT = "${typeHyphen}:export"; - #end @Override public OperatorType[] types() { @@ -32,9 +28,6 @@ public class ${type}OperatorType extends InitializingOperatorTypes { new OperatorType(L, CREATE, "创建$!{table.comment}"), new OperatorType(M, UPDATE, "更新$!{table.comment}"), new OperatorType(H, DELETE, "删除$!{table.comment}"), - #if($meta.enableExport) - new OperatorType(M, EXPORT, "导出$!{table.comment}"), - #end }; } diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-service-impl.java.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-service-impl.java.vm index ba4580488..bf096cb06 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-service-impl.java.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-service-impl.java.vm @@ -5,13 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.orion.lang.define.wrapper.DataGrid; import com.orion.lang.utils.Strings; import com.orion.lang.utils.collect.Lists; -#if($meta.enableExport) -import com.orion.office.excel.writer.exporting.ExcelExport; -#end import com.orion.visor.framework.common.constant.ErrorMessage; -#if($meta.enableExport) -import com.orion.visor.framework.common.utils.FileNames; -#end import com.orion.visor.framework.common.utils.Valid; #if($meta.enableCache) import com.orion.visor.framework.redis.core.utils.RedisMaps; @@ -23,18 +17,11 @@ import ${pkg}.*; import ${package.Entity}.${entity}; import ${package.Mapper}.${table.mapperName}; import ${package.Service}.${table.serviceName}; -#if($meta.enableExport) -import com.orion.web.servlet.web.Servlets; -#end import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -#if($meta.enableExport) -import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -#end import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -54,6 +41,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} { private ${type}DAO ${typeLower}DAO; @Override + @Transactional(rollbackFor = Exception.class) public Long create${type}(${type}CreateRequest request) { log.info("${type}Service-create${type} request: {}", JSON.toJSONString(request)); // 转换 @@ -72,6 +60,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} { } @Override + @Transactional(rollbackFor = Exception.class) public Integer update${type}ById(${type}UpdateRequest request) { Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING); log.info("${type}Service-update${type}ById id: {}, request: {}", id, JSON.toJSONString(request)); @@ -93,6 +82,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} { } @Override + @Transactional(rollbackFor = Exception.class) public Integer update${type}(${type}QueryRequest query, ${type}UpdateRequest update) { log.info("${type}Service.update${type} query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update)); // 条件 @@ -179,6 +169,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} { } @Override + @Transactional(rollbackFor = Exception.class) public Integer delete${type}ById(Long id) { log.info("${type}Service-delete${type}ById id: {}", id); // 检查数据是否存在 @@ -195,6 +186,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} { } @Override + @Transactional(rollbackFor = Exception.class) public Integer delete${type}ByIdList(List idList) { log.info("${type}Service-delete${type}ByIdList idList: {}", idList); int effect = ${typeLower}DAO.deleteBatchIds(idList); @@ -207,6 +199,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} { } @Override + @Transactional(rollbackFor = Exception.class) public Integer delete${type}(${type}QueryRequest request) { log.info("${type}Service.delete${type} request: {}", JSON.toJSONString(request)); // 条件 @@ -220,26 +213,6 @@ public class ${table.serviceImplName} implements ${table.serviceName} { #end return effect; } - #if($meta.enableExport) - - @Override - public void export${type}(${type}QueryRequest request, HttpServletResponse response) throws IOException { - log.info("${type}Service.export${type} request: {}", JSON.toJSONString(request)); - // 条件 - LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request); - // 查询 - List<${type}Export> rows = ${typeLower}DAO.of(wrapper).list(${type}Convert.MAPPER::toExport); - log.info("${type}Service.export${type} size: {}", rows.size()); - // 导出 - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ExcelExport.create(${type}Export.class) - .addRows(rows) - .write(out) - .close(); - // 传输 - Servlets.transfer(response, out.toByteArray(), FileNames.exportName(${type}Export.TITLE)); - } - #end /** * 检查对象是否存在 diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-service.java.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-service.java.vm index 09325bf24..d5293f74f 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-service.java.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-server-module-service.java.vm @@ -115,16 +115,5 @@ public interface ${table.serviceName} { * @return effect */ Integer delete${type}(${type}QueryRequest request); - #if($meta.enableExport) - - /** - * ${apiComment.export} - * - * @param request request - * @param response response - * @throws IOException IOException - */ - void export${type}(${type}QueryRequest request, HttpServletResponse response) throws IOException; - #end } diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-sql-dict.sql.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-sql-dict.sql.vm index d9c5ae936..a6779d462 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-sql-dict.sql.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-sql-dict.sql.vm @@ -14,12 +14,7 @@ VALUES (@MODULE_KEY_ID, 'operatorLogModule', '${package.ModuleName}:${typeHyphen}', '$!{table.comment}', '{}', @MODULE_KEY_MAX_SORT + 10, now(), now(), '1', '1', 0), (@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:create', '创建$!{table.comment}', '{}', 10, now(), now(), '1', '1', 0), (@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:update', '更新$!{table.comment}', '{}', 20, now(), now(), '1', '1', 0), - #if($meta.enableExport) - (@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:delete', '删除$!{table.comment}', '{}', 30, now(), now(), '1', '1', 0), - (@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:export', '导出$!{table.comment}', '{}', 40, now(), now(), '1', '1', 0); - #else (@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:delete', '删除$!{table.comment}', '{}', 30, now(), now(), '1', '1', 0); - #end #end #if($dictMap.entrySet().size() > 0) diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-api.ts.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-api.ts.vm index e3b199a4c..5d815a250 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-api.ts.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-api.ts.vm @@ -133,12 +133,4 @@ export function batchDelete${vue.featureEntity}(idList: Array) { } }); } -#if($meta.enableExport) -/** - * $apiComment.export - */ -export function export${vue.featureEntity}(request: ${vue.featureEntity}QueryRequest) { - return axios.post('/${package.ModuleName}/${typeHyphen}/export', request); -} -#end diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-views-components-table.vue.vm b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-views-components-table.vue.vm index 6426aa764..d89b76f85 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-views-components-table.vue.vm +++ b/orion-visor-framework/orion-visor-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-views-components-table.vue.vm @@ -79,12 +79,16 @@ + #if($vue.enableRowSelection) + userIdList); + +} diff --git a/orion-visor-module-asset/orion-visor-module-asset-provider/src/main/java/com/orion/visor/module/infra/api/PathBookmarkApi.java b/orion-visor-module-asset/orion-visor-module-asset-provider/src/main/java/com/orion/visor/module/infra/api/PathBookmarkApi.java new file mode 100644 index 000000000..f0649f7fb --- /dev/null +++ b/orion-visor-module-asset/orion-visor-module-asset-provider/src/main/java/com/orion/visor/module/infra/api/PathBookmarkApi.java @@ -0,0 +1,22 @@ +package com.orion.visor.module.infra.api; + +import java.util.List; + +/** + * 路径标签 对外服务类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2024/6/3 11:07 + */ +public interface PathBookmarkApi { + + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + Integer deleteByUserIdList(List userIdList); + +} diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/api/impl/CommandSnippetApiImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/api/impl/CommandSnippetApiImpl.java new file mode 100644 index 000000000..316c9a0e1 --- /dev/null +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/api/impl/CommandSnippetApiImpl.java @@ -0,0 +1,30 @@ +package com.orion.visor.module.asset.api.impl; + +import com.orion.visor.module.asset.service.CommandSnippetService; +import com.orion.visor.module.infra.api.CommandSnippetApi; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 命令片段 对外服务实现类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2024/6/3 11:11 + */ +@Slf4j +@Service +public class CommandSnippetApiImpl implements CommandSnippetApi { + + @Resource + private CommandSnippetService commandSnippetService; + + @Override + public Integer deleteByUserIdList(List userIdList) { + return commandSnippetService.deleteByUserIdList(userIdList); + } + +} diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/api/impl/PathBookmarkApiImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/api/impl/PathBookmarkApiImpl.java new file mode 100644 index 000000000..d11a2b337 --- /dev/null +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/api/impl/PathBookmarkApiImpl.java @@ -0,0 +1,30 @@ +package com.orion.visor.module.asset.api.impl; + +import com.orion.visor.module.asset.service.PathBookmarkService; +import com.orion.visor.module.infra.api.PathBookmarkApi; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 路径标签 对外服务实现类 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2024/6/3 11:11 + */ +@Slf4j +@Service +public class PathBookmarkApiImpl implements PathBookmarkApi { + + @Resource + private PathBookmarkService pathBookmarkService; + + @Override + public Integer deleteByUserIdList(List userIdList) { + return pathBookmarkService.deleteByUserIdList(userIdList); + } + +} diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/ExecJobController.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/ExecJobController.java index 6e4717e21..c95e784e1 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/ExecJobController.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/ExecJobController.java @@ -98,6 +98,15 @@ public Integer deleteExecJob(@RequestParam("id") Long id) { return execJobService.deleteExecJobById(id); } + @OperatorLog(ExecJobOperatorType.DELETE) + @DeleteMapping("/batch-delete") + @Operation(summary = "批量删除计划任务") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:exec-job:delete')") + public Integer batchDeleteExecJob(@RequestParam("idList") List idList) { + return execJobService.deleteExecJobByIdList(idList); + } + @OperatorLog(ExecJobOperatorType.TRIGGER) @PostMapping("/trigger") @Operation(summary = "手动触发计划任务") diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/ExecTemplateController.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/ExecTemplateController.java index 5915aaac0..f0842f6ed 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/ExecTemplateController.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/ExecTemplateController.java @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.List; /** * 执行模板 api @@ -92,5 +93,14 @@ public Integer deleteExecTemplate(@RequestParam("id") Long id) { return execTemplateService.deleteExecTemplateById(id); } + @OperatorLog(ExecTemplateOperatorType.DELETE) + @DeleteMapping("/batch-delete") + @Operation(summary = "批量删除执行模板") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:exec-template:delete')") + public Integer batchDeleteExecTemplate(@RequestParam("idList") List idList) { + return execTemplateService.deleteExecTemplateByIdList(idList); + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostController.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostController.java index f89e1bf17..dcfe79167 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostController.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostController.java @@ -96,5 +96,15 @@ public Integer deleteHost(@RequestParam("id") Long id) { return hostService.deleteHostById(id); } + @DemoDisableApi + @OperatorLog(HostOperatorType.DELETE) + @DeleteMapping("/batch-delete") + @Operation(summary = "批量删除主机") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:host:delete')") + public Integer batchDeleteHost(@RequestParam("idList") List idList) { + return hostService.deleteHostByIdList(idList); + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostIdentityController.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostIdentityController.java index 68d8a0d67..977f26c43 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostIdentityController.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostIdentityController.java @@ -97,5 +97,15 @@ public Integer deleteHostIdentity(@RequestParam("id") Long id) { return hostIdentityService.deleteHostIdentityById(id); } + @DemoDisableApi + @OperatorLog(HostIdentityOperatorType.DELETE) + @DeleteMapping("/batch-delete") + @Operation(summary = "批量删除主机身份") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-identity:delete')") + public Integer batchDeleteHostIdentity(@RequestParam("idList") List idList) { + return hostIdentityService.deleteHostIdentityByIdList(idList); + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostKeyController.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostKeyController.java index 1341d487e..905767eff 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostKeyController.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/controller/HostKeyController.java @@ -96,5 +96,15 @@ public Integer deleteHostKey(@RequestParam("id") Long id) { return hostKeyService.deleteHostKeyById(id); } + @DemoDisableApi + @OperatorLog(HostKeyOperatorType.DELETE) + @DeleteMapping("/batch-delete") + @Operation(summary = "批量删除主机密钥") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('asset:host-key:delete')") + public Integer batchDeleteHostKey(@RequestParam("idList") List idList) { + return hostKeyService.deleteHostKeyByIdList(idList); + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/CommandSnippetDAO.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/CommandSnippetDAO.java index 1ad015da7..66b221239 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/CommandSnippetDAO.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/CommandSnippetDAO.java @@ -7,6 +7,8 @@ import com.orion.visor.module.asset.entity.domain.CommandSnippetDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 命令片段 Mapper 接口 * @@ -42,4 +44,16 @@ default int deleteByGroupId(Long groupId) { return this.delete(wrapper); } + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + default int deleteByUserIdList(List userIdList) { + LambdaQueryWrapper wrapper = this.lambda() + .in(CommandSnippetDO::getUserId, userIdList); + return this.delete(wrapper); + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/ExecJobHostDAO.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/ExecJobHostDAO.java index 5db909626..3dfe18ac3 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/ExecJobHostDAO.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/ExecJobHostDAO.java @@ -44,6 +44,18 @@ default Integer deleteByJobId(Long jobId) { return this.delete(wrapper); } + /** + * 通过 jobId 删除 + * + * @param jobIdList jobIdList + * @return effect + */ + default Integer deleteByJobIdList(List jobIdList) { + LambdaQueryWrapper wrapper = this.wrapper() + .in(ExecJobHostDO::getJobId, jobIdList); + return this.delete(wrapper); + } + /** * 通过 hostId 删除 * @@ -56,4 +68,16 @@ default Integer deleteByHostId(Long hostId) { return this.delete(wrapper); } + /** + * 通过 hostId 删除 + * + * @param hostIdList hostIdList + * @return effect + */ + default Integer deleteByHostIdList(List hostIdList) { + LambdaQueryWrapper wrapper = this.wrapper() + .in(ExecJobHostDO::getHostId, hostIdList); + return this.delete(wrapper); + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/HostConfigDAO.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/HostConfigDAO.java index 2f4d6b128..d1094da32 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/HostConfigDAO.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/HostConfigDAO.java @@ -95,17 +95,17 @@ default Integer deleteByHostIdList(List hostIdList) { /** * 设置 keyId 为 NULL * - * @param keyId keyId + * @param keyIdList keyIdList * @return effect */ - int setKeyIdWithNull(@Param("keyId") Long keyId); + int setKeyIdWithNull(@Param("keyIdList") List keyIdList); /** * 设置 identityId 为 NULL * - * @param identityId identityId + * @param identityIdList identityIdList * @return effect */ - int setIdentityIdWithNull(@Param("identityId") Long identityId); + int setIdentityIdWithNull(@Param("identityIdList") List identityIdList); } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/HostIdentityDAO.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/HostIdentityDAO.java index ba9d9617a..c2e131fbb 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/HostIdentityDAO.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/HostIdentityDAO.java @@ -5,7 +5,8 @@ import com.orion.visor.framework.mybatis.core.mapper.IMapper; import com.orion.visor.module.asset.entity.domain.HostIdentityDO; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 主机身份 Mapper 接口 @@ -20,13 +21,13 @@ public interface HostIdentityDAO extends IMapper { /** * 设置 keyId 为 null * - * @param keyId keyId + * @param keyIdList keyIdList * @return effect */ - default int setKeyWithNull(@Param("keyId") Long keyId) { + default int setKeyWithNull(List keyIdList) { LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate() .set(HostIdentityDO::getKeyId, null) - .eq(HostIdentityDO::getKeyId, keyId); + .in(HostIdentityDO::getKeyId, keyIdList); return this.update(null, updateWrapper); } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/PathBookmarkDAO.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/PathBookmarkDAO.java index 17eeb699e..870b31760 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/PathBookmarkDAO.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/dao/PathBookmarkDAO.java @@ -7,6 +7,8 @@ import com.orion.visor.module.asset.entity.domain.PathBookmarkDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 路径标签 Mapper 接口 * @@ -42,4 +44,16 @@ default int deleteByGroupId(Long groupId) { return this.delete(wrapper); } + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + default int deleteByUserIdList(List userIdList) { + LambdaQueryWrapper wrapper = this.lambda() + .in(PathBookmarkDO::getUserId, userIdList); + return this.delete(wrapper); + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/CommandSnippetService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/CommandSnippetService.java index b445b57cf..1caaead8a 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/CommandSnippetService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/CommandSnippetService.java @@ -46,6 +46,15 @@ public interface CommandSnippetService { */ List getCommandSnippetList(); + /** + * 设置分组为 null + * + * @param userId userId + * @param groupId groupId + * @return effect + */ + Integer setGroupNull(Long userId, Long groupId); + /** * 删除命令片段 * @@ -55,21 +64,20 @@ public interface CommandSnippetService { Integer deleteCommandSnippetById(Long id); /** - * 设置分组为 null + * 通过 groupId 删除 * * @param userId userId * @param groupId groupId * @return effect */ - Integer setGroupNull(Long userId, Long groupId); + Integer deleteByGroupId(Long userId, Long groupId); /** - * 通过 groupId 删除 + * 通过 userId 删除 * - * @param userId userId - * @param groupId groupId + * @param userIdList userIdList * @return effect */ - Integer deleteByGroupId(Long userId, Long groupId); + Integer deleteByUserIdList(List userIdList); } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecJobHostService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecJobHostService.java index 18d22c764..4e4b5f176 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecJobHostService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecJobHostService.java @@ -35,6 +35,14 @@ public interface ExecJobHostService { */ Integer deleteByJobId(Long jobId); + /** + * 通过 jobId 删除 + * + * @param jobIdList jobIdList + * @return effect + */ + Integer deleteByJobIdList(List jobIdList); + /** * 通过 hostId 删除 * @@ -43,4 +51,12 @@ public interface ExecJobHostService { */ Integer deleteByHostId(Long hostId); + /** + * 通过 hostId 删除 + * + * @param hostIdList hostIdList + * @return effect + */ + Integer deleteByHostIdList(List hostIdList); + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecJobService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecJobService.java index a380192fd..8b854c8f8 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecJobService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecJobService.java @@ -78,6 +78,14 @@ public interface ExecJobService { */ Integer deleteExecJobById(Long id); + /** + * 批量删除计划任务 + * + * @param idList idList + * @return effect + */ + Integer deleteExecJobByIdList(List idList); + /** * 手动触发任务 * diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecTemplateHostService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecTemplateHostService.java index e6f569a31..e4b3a7324 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecTemplateHostService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecTemplateHostService.java @@ -45,6 +45,14 @@ public interface ExecTemplateHostService { */ Integer deleteByTemplateId(Long templateId); + /** + * 通过 templateId 删除 + * + * @param templateIdList templateIdList + * @return effect + */ + Integer deleteByTemplateIdList(List templateIdList); + /** * 通过 hostId 删除 * @@ -53,4 +61,12 @@ public interface ExecTemplateHostService { */ Integer deleteByHostId(Long hostId); + /** + * 通过 hostId 删除 + * + * @param hostIdList hostIdList + * @return effect + */ + Integer deleteByHostIdList(List hostIdList); + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecTemplateService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecTemplateService.java index 3a1781995..5796df126 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecTemplateService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/ExecTemplateService.java @@ -6,6 +6,8 @@ import com.orion.visor.module.asset.entity.request.exec.ExecTemplateUpdateRequest; import com.orion.visor.module.asset.entity.vo.ExecTemplateVO; +import java.util.List; + /** * 执行模板 服务类 * @@ -63,4 +65,12 @@ public interface ExecTemplateService { */ Integer deleteExecTemplateById(Long id); + /** + * 批量删除执行模板 + * + * @param idList idList + * @return effect + */ + Integer deleteExecTemplateByIdList(List idList); + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostIdentityService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostIdentityService.java index ccfc21736..0a7aaf17f 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostIdentityService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostIdentityService.java @@ -64,4 +64,12 @@ public interface HostIdentityService { */ Integer deleteHostIdentityById(Long id); + /** + * 通过 id 批量删除主机身份 + * + * @param idList idList + * @return effect + */ + Integer deleteHostIdentityByIdList(List idList); + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostKeyService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostKeyService.java index bebb60142..3d9d339bb 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostKeyService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostKeyService.java @@ -66,11 +66,19 @@ public interface HostKeyService { DataGrid getHostKeyPage(HostKeyQueryRequest request); /** - * 通过 id 删除主机密钥 + * 通过 id 批量删除主机密钥 * * @param id id * @return effect */ Integer deleteHostKeyById(Long id); + /** + * 通过 id 删除主机密钥 + * + * @param idList idList + * @return effect + */ + Integer deleteHostKeyByIdList(List idList); + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostService.java index 10d4ed338..e94e05a6f 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/HostService.java @@ -64,11 +64,19 @@ public interface HostService { */ Integer deleteHostById(Long id); + /** + * 通过 id 批量删除主机 + * + * @param idList idList + * @return effect + */ + Integer deleteHostByIdList(List idList); + /** * 通过 id 删除主机引用 * - * @param id id + * @param idList idList */ - void deleteHostRelByIdAsync(Long id); + void deleteHostRelByIdListAsync(List idList); } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/PathBookmarkService.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/PathBookmarkService.java index 4f6e46895..079048470 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/PathBookmarkService.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/PathBookmarkService.java @@ -46,6 +46,15 @@ public interface PathBookmarkService { */ List getPathBookmarkList(); + /** + * 设置分组为 null + * + * @param userId userId + * @param groupId groupId + * @return effect + */ + Integer setGroupNull(Long userId, Long groupId); + /** * 删除路径标签 * @@ -55,21 +64,20 @@ public interface PathBookmarkService { Integer deletePathBookmarkById(Long id); /** - * 设置分组为 null + * 通过 groupId 删除 * * @param userId userId * @param groupId groupId * @return effect */ - Integer setGroupNull(Long userId, Long groupId); + Integer deleteByGroupId(Long userId, Long groupId); /** - * 通过 groupId 删除 + * 通过 userId 删除 * - * @param userId userId - * @param groupId groupId + * @param userIdList userIdList * @return effect */ - Integer deleteByGroupId(Long userId, Long groupId); + Integer deleteByUserIdList(List userIdList); } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/CommandSnippetServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/CommandSnippetServiceImpl.java index da2a3070f..cda262cac 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/CommandSnippetServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/CommandSnippetServiceImpl.java @@ -23,7 +23,6 @@ import com.orion.visor.module.asset.service.CommandSnippetService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Comparator; @@ -52,7 +51,7 @@ public class CommandSnippetServiceImpl implements CommandSnippetService { @Override public Long createCommandSnippet(CommandSnippetCreateRequest request) { Long userId = SecurityUtils.getLoginUserId(); - log.info("CommandSnippetService-createCommandSnippet request: {}", JSON.toJSONString(request)); + log.info("CommandSnippetService-createCommandSnippet request: {}" , JSON.toJSONString(request)); // 转换 CommandSnippetDO record = CommandSnippetConvert.MAPPER.to(request); record.setUserId(userId); @@ -61,7 +60,7 @@ public Long createCommandSnippet(CommandSnippetCreateRequest request) { // 插入 int effect = commandSnippetDAO.insert(record); Long id = record.getId(); - log.info("CommandSnippetService-createCommandSnippet id: {}, effect: {}", id, effect); + log.info("CommandSnippetService-createCommandSnippet id: {}, effect: {}" , id, effect); // 删除缓存 RedisMaps.delete(CommandSnippetCacheKeyDefine.SNIPPET.format(userId)); return id; @@ -71,7 +70,7 @@ public Long createCommandSnippet(CommandSnippetCreateRequest request) { public Integer updateCommandSnippetById(CommandSnippetUpdateRequest request) { Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING); Long userId = SecurityUtils.getLoginUserId(); - log.info("CommandSnippetService-updateCommandSnippetById id: {}, request: {}", id, JSON.toJSONString(request)); + log.info("CommandSnippetService-updateCommandSnippetById id: {}, request: {}" , id, JSON.toJSONString(request)); // 查询 CommandSnippetDO record = commandSnippetDAO.selectById(id); Valid.notNull(record, ErrorMessage.DATA_ABSENT); @@ -86,7 +85,7 @@ public Integer updateCommandSnippetById(CommandSnippetUpdateRequest request) { .eq(CommandSnippetDO::getId, id) .eq(CommandSnippetDO::getUserId, userId); int effect = commandSnippetDAO.update(null, update); - log.info("CommandSnippetService-updateCommandSnippetById effect: {}", effect); + log.info("CommandSnippetService-updateCommandSnippetById effect: {}" , effect); // 删除缓存 RedisMaps.delete(CommandSnippetCacheKeyDefine.SNIPPET.format(userId)); return effect; @@ -145,35 +144,39 @@ public List getCommandSnippetList() { } @Override - @Transactional(rollbackFor = Exception.class) + public Integer setGroupNull(Long userId, Long groupId) { + int effect = commandSnippetDAO.setGroupIdWithNull(groupId); + // 删除缓存 + RedisMaps.delete(CommandSnippetCacheKeyDefine.SNIPPET.format(userId)); + return effect; + } + + @Override public Integer deleteCommandSnippetById(Long id) { Long userId = SecurityUtils.getLoginUserId(); - log.info("CommandSnippetService-deleteCommandSnippetById id: {}", id); + log.info("CommandSnippetService-deleteCommandSnippetById id: {}" , id); // 检查数据是否存在 CommandSnippetDO record = commandSnippetDAO.selectById(id); Valid.notNull(record, ErrorMessage.DATA_ABSENT); // 删除 int effect = commandSnippetDAO.deleteById(id); - log.info("CommandSnippetService-deleteCommandSnippetById id: {}, effect: {}", id, effect); + log.info("CommandSnippetService-deleteCommandSnippetById id: {}, effect: {}" , id, effect); // 删除缓存 RedisMaps.delete(CommandSnippetCacheKeyDefine.SNIPPET.format(userId), id); return effect; } @Override - public Integer setGroupNull(Long userId, Long groupId) { - int effect = commandSnippetDAO.setGroupIdWithNull(groupId); + public Integer deleteByGroupId(Long userId, Long groupId) { + int effect = commandSnippetDAO.deleteByGroupId(groupId); // 删除缓存 RedisMaps.delete(CommandSnippetCacheKeyDefine.SNIPPET.format(userId)); return effect; } @Override - public Integer deleteByGroupId(Long userId, Long groupId) { - int effect = commandSnippetDAO.deleteByGroupId(groupId); - // 删除缓存 - RedisMaps.delete(CommandSnippetCacheKeyDefine.SNIPPET.format(userId)); - return effect; + public Integer deleteByUserIdList(List userIdList) { + return commandSnippetDAO.deleteByUserIdList(userIdList); } /** diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecJobHostServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecJobHostServiceImpl.java index fb19d183f..f99c6a796 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecJobHostServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecJobHostServiceImpl.java @@ -49,9 +49,19 @@ public Integer deleteByJobId(Long jobId) { return execJobHostDAO.deleteByJobId(jobId); } + @Override + public Integer deleteByJobIdList(List jobIdList) { + return execJobHostDAO.deleteByJobIdList(jobIdList); + } + @Override public Integer deleteByHostId(Long hostId) { return execJobHostDAO.deleteByHostId(hostId); } + @Override + public Integer deleteByHostIdList(List hostIdList) { + return execJobHostDAO.deleteByHostIdList(hostIdList); + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecJobServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecJobServiceImpl.java index 7486b0faf..21c902c8d 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecJobServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecJobServiceImpl.java @@ -8,6 +8,7 @@ import com.orion.lang.utils.collect.Lists; import com.orion.lang.utils.time.cron.Cron; import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs; +import com.orion.visor.framework.common.constant.Const; import com.orion.visor.framework.common.constant.ErrorMessage; import com.orion.visor.framework.common.utils.Valid; import com.orion.visor.framework.job.core.utils.QuartzUtils; @@ -235,19 +236,30 @@ public Integer getNextExecSeq(Long id) { @Override @Transactional(rollbackFor = Exception.class) public Integer deleteExecJobById(Long id) { - log.info("ExecJobService-deleteExecJobById id: {}", id); + return this.deleteExecJobByIdList(Lists.singleton(id)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Integer deleteExecJobByIdList(List idList) { + log.info("ExecJobService-deleteExecJobByIdList idList: {}", idList); // 检查数据是否存在 - ExecJobDO record = execJobDAO.selectById(id); - Valid.notNull(record, ErrorMessage.DATA_ABSENT); + List jobList = execJobDAO.selectBatchIds(idList); + Valid.notEmpty(jobList, ErrorMessage.DATA_ABSENT); // 删除任务 - int effect = execJobDAO.deleteById(id); + int effect = execJobDAO.deleteBatchIds(idList); // 删除任务主机 - effect += execJobHostService.deleteByJobId(id); + effect += execJobHostService.deleteByJobIdList(idList); // 设置日志参数 - OperatorLogs.add(OperatorLogs.NAME, record.getName()); + String name = jobList.stream() + .map(ExecJobDO::getName) + .collect(Collectors.joining(Const.COMMA)); + OperatorLogs.add(OperatorLogs.NAME, name); // 设置 quartz 状态 - this.setQuartzJobStatus(record, true, false); - log.info("ExecJobService-deleteExecJobById id: {}, effect: {}", id, effect); + for (ExecJobDO job : jobList) { + this.setQuartzJobStatus(job, true, false); + } + log.info("ExecJobService-deleteExecJobByIdList idList: {}, effect: {}", idList, effect); return effect; } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecTemplateHostServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecTemplateHostServiceImpl.java index d5b79962b..44bbfc7b3 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecTemplateHostServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecTemplateHostServiceImpl.java @@ -97,20 +97,40 @@ public void setTemplateHost(Long templateId, List hostList) { public Integer deleteByTemplateId(Long templateId) { LambdaQueryWrapper wrapper = execTemplateHostDAO.lambda() .eq(ExecTemplateHostDO::getTemplateId, templateId); - log.info("ExecTemplateHostService-deleteByTemplateId idList: {}", templateId); + log.info("ExecTemplateHostService-deleteByTemplateId id: {}", templateId); int effect = execTemplateHostDAO.delete(wrapper); log.info("ExecTemplateHostService-deleteByTemplateId effect: {}", effect); return effect; } + @Override + public Integer deleteByTemplateIdList(List templateIdList) { + LambdaQueryWrapper wrapper = execTemplateHostDAO.lambda() + .in(ExecTemplateHostDO::getTemplateId, templateIdList); + log.info("ExecTemplateHostService-deleteByTemplateIdList idList: {}", templateIdList); + int effect = execTemplateHostDAO.delete(wrapper); + log.info("ExecTemplateHostService-deleteByTemplateIdList effect: {}", effect); + return effect; + } + @Override public Integer deleteByHostId(Long hostId) { LambdaQueryWrapper wrapper = execTemplateHostDAO.lambda() .eq(ExecTemplateHostDO::getHostId, hostId); - log.info("ExecTemplateHostService-deleteByHostId idList: {}", hostId); + log.info("ExecTemplateHostService-deleteByHostId id: {}", hostId); int effect = execTemplateHostDAO.delete(wrapper); log.info("ExecTemplateHostService-deleteByHostId effect: {}", effect); return effect; } + @Override + public Integer deleteByHostIdList(List hostIdList) { + LambdaQueryWrapper wrapper = execTemplateHostDAO.lambda() + .in(ExecTemplateHostDO::getHostId, hostIdList); + log.info("ExecTemplateHostService-deleteByHostIdList id: {}", hostIdList); + int effect = execTemplateHostDAO.delete(wrapper); + log.info("ExecTemplateHostService-deleteByHostIdList effect: {}", effect); + return effect; + } + } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecTemplateServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecTemplateServiceImpl.java index b21cdf9f2..b3a696a1c 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecTemplateServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/ExecTemplateServiceImpl.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.orion.lang.define.wrapper.DataGrid; import com.orion.lang.utils.collect.Lists; +import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs; +import com.orion.visor.framework.common.constant.Const; import com.orion.visor.framework.common.constant.ErrorMessage; import com.orion.visor.framework.common.utils.Valid; import com.orion.visor.framework.security.core.utils.SecurityUtils; @@ -21,10 +23,12 @@ import com.orion.visor.module.asset.service.ExecTemplateService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; /** * 执行模板 服务实现类 @@ -126,16 +130,28 @@ public DataGrid getExecTemplatePage(ExecTemplateQueryRequest req } @Override + @Transactional(rollbackFor = Exception.class) public Integer deleteExecTemplateById(Long id) { - log.info("ExecTemplateService-deleteExecTemplateById id: {}", id); + return this.deleteExecTemplateByIdList(Lists.singleton(id)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Integer deleteExecTemplateByIdList(List idList) { + log.info("ExecTemplateService-deleteExecTemplateByIdList idList: {}", idList); // 检查数据是否存在 - ExecTemplateDO record = execTemplateDAO.selectById(id); - Valid.notNull(record, ErrorMessage.DATA_ABSENT); + List recordList = execTemplateDAO.selectBatchIds(idList); + Valid.notEmpty(recordList, ErrorMessage.DATA_ABSENT); + // 设置日志参数 + String name = recordList.stream() + .map(ExecTemplateDO::getName) + .collect(Collectors.joining(Const.COMMA)); + OperatorLogs.add(OperatorLogs.NAME, name); // 删除模板 - int effect = execTemplateDAO.deleteById(id); - log.info("ExecTemplateService-deleteExecTemplateById id: {}, effect: {}", id, effect); + int effect = execTemplateDAO.deleteBatchIds(idList); + log.info("ExecTemplateService-deleteExecTemplateByIdList idList: {}, effect: {}", idList, effect); // 删除模板主机 - effect += execTemplateHostService.deleteByTemplateId(id); + effect += execTemplateHostService.deleteByTemplateIdList(idList); return effect; } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostIdentityServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostIdentityServiceImpl.java index 4afc6b4fc..c42b0bdfe 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostIdentityServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostIdentityServiceImpl.java @@ -6,12 +6,15 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.orion.lang.define.wrapper.DataGrid; import com.orion.lang.utils.Strings; +import com.orion.lang.utils.collect.Lists; import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs; +import com.orion.visor.framework.common.constant.Const; import com.orion.visor.framework.common.constant.ErrorMessage; import com.orion.visor.framework.common.security.PasswordModifier; import com.orion.visor.framework.common.utils.CryptoUtils; import com.orion.visor.framework.common.utils.Valid; import com.orion.visor.framework.redis.core.utils.RedisMaps; +import com.orion.visor.framework.redis.core.utils.RedisUtils; import com.orion.visor.framework.redis.core.utils.barrier.CacheBarriers; import com.orion.visor.module.asset.convert.HostIdentityConvert; import com.orion.visor.module.asset.dao.HostConfigDAO; @@ -32,6 +35,7 @@ import com.orion.visor.module.infra.enums.DataPermissionTypeEnum; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Comparator; @@ -185,24 +189,34 @@ public DataGrid getHostIdentityPage(HostIdentityQueryRequest req } @Override + @Transactional(rollbackFor = Exception.class) public Integer deleteHostIdentityById(Long id) { - log.info("HostIdentityService-deleteHostIdentityById id: {}", id); + return this.deleteHostIdentityByIdList(Lists.singleton(id)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Integer deleteHostIdentityByIdList(List idList) { + log.info("HostIdentityService-deleteHostIdentityByIdList idList: {}", idList); // 检查数据是否存在 - HostIdentityDO record = hostIdentityDAO.selectById(id); - Valid.notNull(record, ErrorMessage.DATA_ABSENT); + List list = hostIdentityDAO.selectBatchIds(idList); + Valid.notEmpty(list, ErrorMessage.DATA_ABSENT); // 添加日志参数 - OperatorLogs.add(OperatorLogs.NAME, record.getName()); + String name = list.stream() + .map(HostIdentityDO::getName) + .collect(Collectors.joining(Const.COMMA)); + OperatorLogs.add(OperatorLogs.NAME, name); // 删除数据库 - int effect = hostIdentityDAO.deleteById(id); + int effect = hostIdentityDAO.deleteBatchIds(idList); // 删除主机配置 - hostConfigDAO.setIdentityIdWithNull(id); + hostConfigDAO.setIdentityIdWithNull(idList); // 删除主机身份额外配置 - dataExtraApi.deleteHostIdentityExtra(id); + dataExtraApi.deleteHostIdentityExtra(idList); // 删除数据权限 - dataPermissionApi.deleteByRelId(DataPermissionTypeEnum.HOST_IDENTITY, id); + dataPermissionApi.deleteByRelIdList(DataPermissionTypeEnum.HOST_IDENTITY, idList); // 删除缓存 - RedisMaps.delete(HostCacheKeyDefine.HOST_IDENTITY.getKey(), record.getId()); - log.info("HostIdentityService-deleteHostIdentityById effect: {}", effect); + RedisUtils.delete(HostCacheKeyDefine.HOST_IDENTITY); + log.info("HostIdentityService-deleteHostIdentityByIdList effect: {}", effect); return effect; } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostKeyServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostKeyServiceImpl.java index 611b1e781..43cb45ca6 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostKeyServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostKeyServiceImpl.java @@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.orion.lang.define.wrapper.DataGrid; import com.orion.lang.utils.Strings; +import com.orion.lang.utils.collect.Lists; import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs; +import com.orion.visor.framework.common.constant.Const; import com.orion.visor.framework.common.constant.ErrorMessage; import com.orion.visor.framework.common.security.PasswordModifier; import com.orion.visor.framework.common.utils.CryptoUtils; import com.orion.visor.framework.common.utils.Valid; import com.orion.visor.framework.redis.core.utils.RedisMaps; +import com.orion.visor.framework.redis.core.utils.RedisUtils; import com.orion.visor.framework.redis.core.utils.barrier.CacheBarriers; import com.orion.visor.module.asset.convert.HostKeyConvert; import com.orion.visor.module.asset.dao.HostConfigDAO; @@ -170,24 +173,33 @@ public DataGrid getHostKeyPage(HostKeyQueryRequest request) { @Override @Transactional(rollbackFor = Exception.class) public Integer deleteHostKeyById(Long id) { - log.info("HostKeyService-deleteHostKeyById id: {}", id); + return this.deleteHostKeyByIdList(Lists.singleton(id)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Integer deleteHostKeyByIdList(List idList) { + log.info("HostKeyService-deleteHostKeyById idList: {}", idList); // 检查数据是否存在 - HostKeyDO record = hostKeyDAO.selectById(id); - Valid.notNull(record, ErrorMessage.DATA_ABSENT); + List list = hostKeyDAO.selectBatchIds(idList); + Valid.notEmpty(list, ErrorMessage.DATA_ABSENT); // 添加日志参数 - OperatorLogs.add(OperatorLogs.NAME, record.getName()); + String name = list.stream() + .map(HostKeyDO::getName) + .collect(Collectors.joining(Const.COMMA)); + OperatorLogs.add(OperatorLogs.NAME, name); // 删除数据库 - int effect = hostKeyDAO.deleteById(id); + int effect = hostKeyDAO.deleteBatchIds(idList); // 删除关联 - hostIdentityDAO.setKeyWithNull(id); + hostIdentityDAO.setKeyWithNull(idList); // 删除主机配置 - hostConfigDAO.setKeyIdWithNull(id); + hostConfigDAO.setKeyIdWithNull(idList); // 删除主机密钥额外配置 - dataExtraApi.deleteHostKeyExtra(id); + dataExtraApi.deleteHostKeyExtra(idList); // 删除数据权限 - dataPermissionApi.deleteByRelId(DataPermissionTypeEnum.HOST_KEY, id); + dataPermissionApi.deleteByRelIdList(DataPermissionTypeEnum.HOST_KEY, idList); // 删除缓存 - RedisMaps.delete(HostCacheKeyDefine.HOST_KEY.getKey(), record.getId()); + RedisUtils.delete(HostCacheKeyDefine.HOST_KEY); log.info("HostKeyService-deleteHostKeyById effect: {}", effect); return effect; } diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostServiceImpl.java index 22ee7a551..3470675e5 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostServiceImpl.java @@ -8,9 +8,11 @@ import com.orion.lang.utils.collect.Lists; import com.orion.spring.SpringHolder; import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs; +import com.orion.visor.framework.common.constant.Const; import com.orion.visor.framework.common.constant.ErrorMessage; import com.orion.visor.framework.common.utils.Valid; import com.orion.visor.framework.redis.core.utils.RedisMaps; +import com.orion.visor.framework.redis.core.utils.RedisUtils; import com.orion.visor.framework.redis.core.utils.barrier.CacheBarriers; import com.orion.visor.module.asset.convert.HostConvert; import com.orion.visor.module.asset.dao.HostConfigDAO; @@ -191,41 +193,49 @@ public DataGrid getHostPage(HostQueryRequest request) { @Override public Integer deleteHostById(Long id) { - log.info("HostService-deleteHostById id: {}", id); + return this.deleteHostByIdList(Lists.singleton(id)); + } + + @Override + public Integer deleteHostByIdList(List idList) { + log.info("HostService-deleteHostByIdList idList: {}", idList); // 查询 - HostDO record = hostDAO.selectById(id); - Valid.notNull(record, ErrorMessage.HOST_ABSENT); + List hosts = hostDAO.selectBatchIds(idList); + Valid.notEmpty(hosts, ErrorMessage.HOST_ABSENT); // 添加日志参数 - OperatorLogs.add(OperatorLogs.NAME, record.getName()); + String name = hosts.stream() + .map(HostDO::getName) + .collect(Collectors.joining(Const.COMMA)); + OperatorLogs.add(OperatorLogs.NAME, name); // 删除 - int effect = hostDAO.deleteById(id); - log.info("HostService-deleteHostById effect: {}", effect); + int effect = hostDAO.deleteBatchIds(hosts); + log.info("HostService-deleteHostByIdList effect: {}", effect); // 删除缓存 - RedisMaps.delete(HostCacheKeyDefine.HOST_INFO, id); + RedisUtils.delete(HostCacheKeyDefine.HOST_INFO); // 删除主机引用 SpringHolder.getBean(HostService.class) - .deleteHostRelByIdAsync(id); + .deleteHostRelByIdListAsync(idList); return effect; } @Override @Async("asyncExecutor") - public void deleteHostRelByIdAsync(Long id) { - log.info("HostService-deleteHostRelByIdAsync id: {}", id); + public void deleteHostRelByIdListAsync(List idList) { + log.info("HostService-deleteHostRelByIdListAsync idList: {}", idList); // 删除主机配置 - hostConfigDAO.deleteByHostId(id); + hostConfigDAO.deleteByHostIdList(idList); // 删除计划任务主机 - execJobHostService.deleteByHostId(id); + execJobHostService.deleteByHostIdList(idList); // 删除执行模板主机 - execTemplateHostService.deleteByHostId(id); + execTemplateHostService.deleteByHostIdList(idList); // 删除分组 - dataGroupRelApi.deleteByRelId(DataGroupTypeEnum.HOST, id); + dataGroupRelApi.deleteByRelIdList(DataGroupTypeEnum.HOST, idList); // 删除 tag 引用 - tagRelApi.deleteRelId(TagTypeEnum.HOST, id); + tagRelApi.deleteRelIdList(TagTypeEnum.HOST, idList); // 删除收藏引用 - favoriteApi.deleteByRelId(FavoriteTypeEnum.HOST, id); + favoriteApi.deleteByRelIdList(FavoriteTypeEnum.HOST, idList); // 删除额外配置 - dataExtraApi.deleteByRelId(DataExtraTypeEnum.HOST, id); + dataExtraApi.deleteByRelIdList(DataExtraTypeEnum.HOST, idList); } /** diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostTerminalServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostTerminalServiceImpl.java index bbc60bd93..813e3cf00 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostTerminalServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/HostTerminalServiceImpl.java @@ -151,11 +151,13 @@ public HostTerminalConnectDTO getTerminalConnectInfo(Long userId, HostDO host) { HostExtraSshAuthTypeEnum extraAuthType = HostExtraSshAuthTypeEnum.of(extra.getAuthType()); if (HostExtraSshAuthTypeEnum.CUSTOM_KEY.equals(extraAuthType)) { // 验证主机密钥是否有权限 + Valid.notNull(extra.getKeyId(), ErrorMessage.KEY_ABSENT); Valid.isTrue(dataPermissionApi.hasPermission(DataPermissionTypeEnum.HOST_KEY, userId, extra.getKeyId()), ErrorMessage.ANY_NO_PERMISSION, DataPermissionTypeEnum.HOST_KEY.getPermissionName()); } else if (HostExtraSshAuthTypeEnum.CUSTOM_IDENTITY.equals(extraAuthType)) { // 验证主机身份是否有权限 + Valid.notNull(extra.getIdentityId(), ErrorMessage.IDENTITY_ABSENT); Valid.isTrue(dataPermissionApi.hasPermission(DataPermissionTypeEnum.HOST_IDENTITY, userId, extra.getIdentityId()), ErrorMessage.ANY_NO_PERMISSION, DataPermissionTypeEnum.HOST_IDENTITY.getPermissionName()); @@ -270,6 +272,7 @@ private HostTerminalConnectDTO getHostConnectInfo(HostDO host, HostSshAuthTypeEnum authType = HostSshAuthTypeEnum.of(config.getAuthType()); if (HostSshAuthTypeEnum.IDENTITY.equals(authType)) { // 身份认证 + Valid.notNull(config.getIdentityId(), ErrorMessage.IDENTITY_ABSENT); HostIdentityDO identity = hostIdentityDAO.selectById(config.getIdentityId()); Valid.notNull(identity, ErrorMessage.IDENTITY_ABSENT); config.setUsername(identity.getUsername()); @@ -293,6 +296,7 @@ private HostTerminalConnectDTO getHostConnectInfo(HostDO host, } else if (HostSshAuthTypeEnum.KEY.equals(authType)) { // 密钥认证 Long keyId = config.getKeyId(); + Valid.notNull(keyId, ErrorMessage.KEY_ABSENT); HostKeyDO key = hostKeyDAO.selectById(keyId); Valid.notNull(key, ErrorMessage.KEY_ABSENT); conn.setKeyId(keyId); diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/PathBookmarkServiceImpl.java b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/PathBookmarkServiceImpl.java index 407810cec..e507fc4c6 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/PathBookmarkServiceImpl.java +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/com/orion/visor/module/asset/service/impl/PathBookmarkServiceImpl.java @@ -143,6 +143,14 @@ public List getPathBookmarkList() { .collect(Collectors.toList()); } + @Override + public Integer setGroupNull(Long userId, Long groupId) { + int effect = pathBookmarkDAO.setGroupIdWithNull(groupId); + // 删除缓存 + RedisMaps.delete(PathBookmarkCacheKeyDefine.PATH_BOOKMARK.format(userId)); + return effect; + } + @Override public Integer deletePathBookmarkById(Long id) { Long userId = SecurityUtils.getLoginUserId(); @@ -159,19 +167,16 @@ public Integer deletePathBookmarkById(Long id) { } @Override - public Integer setGroupNull(Long userId, Long groupId) { - int effect = pathBookmarkDAO.setGroupIdWithNull(groupId); + public Integer deleteByGroupId(Long userId, Long groupId) { + int effect = pathBookmarkDAO.deleteByGroupId(groupId); // 删除缓存 RedisMaps.delete(PathBookmarkCacheKeyDefine.PATH_BOOKMARK.format(userId)); return effect; } @Override - public Integer deleteByGroupId(Long userId, Long groupId) { - int effect = pathBookmarkDAO.deleteByGroupId(groupId); - // 删除缓存 - RedisMaps.delete(PathBookmarkCacheKeyDefine.PATH_BOOKMARK.format(userId)); - return effect; + public Integer deleteByUserIdList(List userIdList) { + return pathBookmarkDAO.deleteByUserIdList(userIdList); } /** diff --git a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/resources/mapper/HostConfigMapper.xml b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/resources/mapper/HostConfigMapper.xml index 23fa4103c..c55c69629 100644 --- a/orion-visor-module-asset/orion-visor-module-asset-service/src/main/resources/mapper/HostConfigMapper.xml +++ b/orion-visor-module-asset/orion-visor-module-asset-service/src/main/resources/mapper/HostConfigMapper.xml @@ -25,17 +25,21 @@ UPDATE host_config SET version = version + 1, - config = JSON_REMOVE(config, '$.keyId') + config = JSON_REMOVE(config, '$.keyId') WHERE deleted = 0 - AND JSON_CONTAINS(config, JSON_OBJECT('keyId', #{keyId})) + + JSON_CONTAINS(config, JSON_OBJECT('keyId', #{item})) + UPDATE host_config SET version = version + 1, - config = JSON_REMOVE(config, '$.identityId') + config = JSON_REMOVE(config, '$.identityId') WHERE deleted = 0 - AND JSON_CONTAINS(config, JSON_OBJECT('identityId', #{identityId})) + + JSON_CONTAINS(config, JSON_OBJECT('identityId', #{item})) + diff --git a/orion-visor-module-infra/orion-visor-module-infra-provider/src/main/java/com/orion/visor/module/infra/api/DataExtraApi.java b/orion-visor-module-infra/orion-visor-module-infra-provider/src/main/java/com/orion/visor/module/infra/api/DataExtraApi.java index d63428c47..63db0895f 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-provider/src/main/java/com/orion/visor/module/infra/api/DataExtraApi.java +++ b/orion-visor-module-infra/orion-visor-module-infra-provider/src/main/java/com/orion/visor/module/infra/api/DataExtraApi.java @@ -138,20 +138,29 @@ public interface DataExtraApi { */ Integer deleteByRelId(DataExtraTypeEnum type, Long relId); + /** + * 通过 relId 删除 + * + * @param type type + * @param relIdList relIdList + * @return effect + */ + Integer deleteByRelIdList(DataExtraTypeEnum type, List relIdList); + /** * 删除主机密钥 * - * @param keyId keyId + * @param keyIdList keyIdList * @return effect */ - int deleteHostKeyExtra(Long keyId); + int deleteHostKeyExtra(List keyIdList); /** * 删除主机身份 * - * @param identityId identityId + * @param identityIdList identityIdList * @return effect */ - int deleteHostIdentityExtra(Long identityId); + int deleteHostIdentityExtra(List identityIdList); } diff --git a/orion-visor-module-infra/orion-visor-module-infra-provider/src/main/java/com/orion/visor/module/infra/api/DataPermissionApi.java b/orion-visor-module-infra/orion-visor-module-infra-provider/src/main/java/com/orion/visor/module/infra/api/DataPermissionApi.java index 73b6f058a..e2352a935 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-provider/src/main/java/com/orion/visor/module/infra/api/DataPermissionApi.java +++ b/orion-visor-module-infra/orion-visor-module-infra-provider/src/main/java/com/orion/visor/module/infra/api/DataPermissionApi.java @@ -76,4 +76,13 @@ public interface DataPermissionApi { */ int deleteByRelId(DataPermissionTypeEnum type, Long relId); + /** + * 通过 relId 删除 + * + * @param type type + * @param relIdList relIdList + * @return effect + */ + int deleteByRelIdList(DataPermissionTypeEnum type, List relIdList); + } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/pom.xml b/orion-visor-module-infra/orion-visor-module-infra-service/pom.xml index d927017b1..82a410240 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/pom.xml +++ b/orion-visor-module-infra/orion-visor-module-infra-service/pom.xml @@ -28,6 +28,13 @@ ${revision} + + + com.orion.visor + orion-visor-module-asset-provider + ${revision} + + com.orion.visor diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/api/impl/DataExtraApiImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/api/impl/DataExtraApiImpl.java index b281593dc..24e4889b6 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/api/impl/DataExtraApiImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/api/impl/DataExtraApiImpl.java @@ -134,15 +134,20 @@ public Integer deleteByRelId(DataExtraTypeEnum type, Long relId) { } @Override - public int deleteHostKeyExtra(Long keyId) { - Valid.notNull(keyId); - return dataExtraDAO.deleteHostKey(keyId); + public Integer deleteByRelIdList(DataExtraTypeEnum type, List relIdList) { + return dataExtraService.deleteByRelIdList(type.name(), relIdList); } @Override - public int deleteHostIdentityExtra(Long identityId) { - Valid.notNull(identityId); - return dataExtraDAO.deleteHostIdentity(identityId); + public int deleteHostKeyExtra(List keyIdList) { + Valid.notEmpty(keyIdList); + return dataExtraDAO.deleteHostKey(keyIdList); + } + + @Override + public int deleteHostIdentityExtra(List identityIdList) { + Valid.notEmpty(identityIdList); + return dataExtraDAO.deleteHostIdentity(identityIdList); } } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/api/impl/DataPermissionApiImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/api/impl/DataPermissionApiImpl.java index 3e1089739..289e5acec 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/api/impl/DataPermissionApiImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/api/impl/DataPermissionApiImpl.java @@ -75,4 +75,9 @@ public int deleteByRelId(DataPermissionTypeEnum type, Long relId) { return dataPermissionService.deleteByRelId(type.name(), relId); } + @Override + public int deleteByRelIdList(DataPermissionTypeEnum type, List relIdList) { + return dataPermissionService.deleteByRelIdList(type.name(), relIdList); + } + } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/SystemUserController.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/SystemUserController.java index 733f1e956..30ed137d0 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/SystemUserController.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/controller/SystemUserController.java @@ -150,6 +150,16 @@ public Integer deleteSystemUser(@RequestParam("id") Long id) { return systemUserService.deleteSystemUserById(id); } + @DemoDisableApi + @OperatorLog(SystemUserOperatorType.DELETE) + @DeleteMapping("/batch-delete") + @Operation(summary = "批量删除用户") + @Parameter(name = "idList", description = "idList", required = true) + @PreAuthorize("@ss.hasPermission('infra:system-user:delete')") + public Integer batchDeleteSystemUser(@RequestParam("idList") List idList) { + return systemUserService.deleteSystemUserByIdList(idList); + } + @IgnoreLog(IgnoreLogMode.RET) @GetMapping("/session/list") @Operation(summary = "获取用户会话列表") diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/DataExtraDAO.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/DataExtraDAO.java index 62737ccbb..299b073ea 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/DataExtraDAO.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/DataExtraDAO.java @@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 数据拓展信息 Mapper 接口 * @@ -28,6 +30,18 @@ default int deleteByUserId(Long userId) { return this.delete(wrapper); } + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + default int deleteByUserIdList(List userIdList) { + LambdaQueryWrapper wrapper = this.lambda() + .in(DataExtraDO::getUserId, userIdList); + return this.delete(wrapper); + } + /** * 通过 relId 删除 * @@ -42,20 +56,34 @@ default int deleteByRelId(String type, Long relId) { return this.delete(wrapper); } + /** + * 通过 relId 删除 + * + * @param type type + * @param relIdList relIdList + * @return effect + */ + default int deleteByRelIdList(String type, List relIdList) { + LambdaQueryWrapper wrapper = this.lambda() + .eq(DataExtraDO::getType, type) + .in(DataExtraDO::getRelId, relIdList); + return this.delete(wrapper); + } + /** * 删除主机密钥 * - * @param keyId keyId + * @param keyIdList keyIdList * @return effect */ - int deleteHostKey(@Param("keyId") Long keyId); + int deleteHostKey(@Param("keyIdList") List keyIdList); /** * 删除主机身份 * - * @param identityId identityId + * @param identityIdList identityIdList * @return effect */ - int deleteHostIdentity(@Param("identityId") Long identityId); + int deleteHostIdentity(@Param("identityIdList") List identityIdList); } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/OperatorLogDAO.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/OperatorLogDAO.java index 3752d028b..33bb3a103 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/OperatorLogDAO.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/OperatorLogDAO.java @@ -5,6 +5,8 @@ import com.orion.visor.module.infra.entity.domain.OperatorLogDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 操作日志 Mapper 接口 * @@ -27,4 +29,16 @@ default int deleteByUserId(Long userId) { return this.delete(wrapper); } + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + default int deleteByUserIdList(List userIdList) { + LambdaQueryWrapper wrapper = this.wrapper() + .in(OperatorLogDO::getUserId, userIdList); + return this.delete(wrapper); + } + } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/PreferenceDAO.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/PreferenceDAO.java index ef24f586b..8c0abe103 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/PreferenceDAO.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/PreferenceDAO.java @@ -5,6 +5,8 @@ import com.orion.visor.module.infra.entity.domain.PreferenceDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 用户偏好 Mapper 接口 * @@ -25,4 +27,14 @@ default int deleteByUserId(Long userId) { return this.delete(Conditions.eq(PreferenceDO::getUserId, userId)); } + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + default int deleteByUserIdList(List userIdList) { + return this.delete(Conditions.in(PreferenceDO::getUserId, userIdList)); + } + } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/SystemUserRoleDAO.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/SystemUserRoleDAO.java index 685311ff3..aa3bbf408 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/SystemUserRoleDAO.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/dao/SystemUserRoleDAO.java @@ -76,6 +76,18 @@ default int deleteByUserId(Long userId) { return this.delete(wrapper); } + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + default int deleteByUserIdList(List userIdList) { + LambdaQueryWrapper wrapper = this.wrapper() + .in(SystemUserRoleDO::getUserId, userIdList); + return this.delete(wrapper); + } + /** * 通过 roleId 删除 * diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataExtraService.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataExtraService.java index 5f7242c80..4f7e83a17 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataExtraService.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataExtraService.java @@ -119,6 +119,14 @@ public interface DataExtraService { */ Integer deleteByUserId(Long userId); + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + Integer deleteByUserIdList(List userIdList); + /** * 通过 relId 删除 * @@ -128,4 +136,13 @@ public interface DataExtraService { */ Integer deleteByRelId(String type, Long relId); + /** + * 通过 relId 删除 + * + * @param type type + * @param relIdList relIdList + * @return effect + */ + Integer deleteByRelIdList(String type, List relIdList); + } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataGroupService.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataGroupService.java index 299f00c69..78746c3a2 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataGroupService.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataGroupService.java @@ -84,4 +84,12 @@ public interface DataGroupService { */ Integer deleteDataGroupByUserId(Long userId); + /** + * 通过 userId 删除数据分组 + * + * @param userIdList userIdList + * @return effect + */ + Integer deleteDataGroupByUserIdList(List userIdList); + } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataPermissionService.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataPermissionService.java index f46cbea30..3f61268ea 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataPermissionService.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/DataPermissionService.java @@ -73,6 +73,15 @@ public interface DataPermissionService { */ int deleteByRelId(String type, Long relId); + /** + * 通过 relId 删除 + * + * @param type type + * @param relIdList relIdList + * @return effect + */ + int deleteByRelIdList(String type, List relIdList); + /** * 通过 userId 删除 * @@ -81,6 +90,14 @@ public interface DataPermissionService { */ int deleteByUserId(Long userId); + /** + * 通过 userId 删除 + * + * @param userIdList userIdList + * @return effect + */ + int deleteByUserIdList(List userIdList); + /** * 通过 roleId 删除 * diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/PreferenceService.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/PreferenceService.java index 9059afc28..33175935c 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/PreferenceService.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/PreferenceService.java @@ -66,4 +66,11 @@ public interface PreferenceService { */ void deletePreferenceByUserId(Long userId); + /** + * 删除用户偏好 + * + * @param userIdList userIdList + */ + void deletePreferenceByUserIdList(List userIdList); + } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/SystemUserService.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/SystemUserService.java index 358153c85..20b6aaa4f 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/SystemUserService.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/SystemUserService.java @@ -71,12 +71,19 @@ public interface SystemUserService { Integer deleteSystemUserById(Long id); /** - * 删除 id 删除用户拓展信息 + * 通过 id 批量删除用户 * - * @param id id - * @param username username + * @param idList idList + * @return effect + */ + Integer deleteSystemUserByIdList(List idList); + + /** + * 通过 idList 删除用户拓展信息 + * + * @param idList idList */ - void deleteSystemUserRelAsync(Long id, String username); + void deleteSystemUserListRelAsync(List idList); /** * 重置密码 diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataExtraServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataExtraServiceImpl.java index 8630542f7..66e2d140c 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataExtraServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataExtraServiceImpl.java @@ -192,32 +192,56 @@ public List getExtraItems(DataExtraQueryRequest request) { @Override public Integer deleteByUserId(Long userId) { - List list = this.getCacheSelectWrapper() - .eq(DataExtraDO::getUserId, userId) - .then() - .list(); - if (list.isEmpty()) { - return Const.N_0; + if (userId == null) { + return 0; + } + // 删除 + return this.deleteByUserIdList(Lists.singleton(userId)); + } + + @Override + public Integer deleteByUserIdList(List userIdList) { + if (Lists.isEmpty(userIdList)) { + return 0; } // 删除数据 - int effect = dataExtraDAO.deleteByUserId(userId); - // 删除缓存 - this.deleteCache(list); - return effect; + return dataExtraDAO.deleteByUserIdList(userIdList); + // // 查询数据 + // List list = this.getCacheSelectWrapper() + // .in(DataExtraDO::getUserId, userIdList) + // .then() + // .list(); + // if (list.isEmpty()) { + // return Const.N_0; + // } + // // 删除缓存 让其自动过期 + // this.deleteCache(list); } @Override public Integer deleteByRelId(String type, Long relId) { + if (relId == null) { + return 0; + } + // 删除 + return this.deleteByRelIdList(type, Lists.singleton(relId)); + } + + @Override + public Integer deleteByRelIdList(String type, List relIdList) { + if (Lists.isEmpty(relIdList)) { + return 0; + } List list = this.getCacheSelectWrapper() .eq(DataExtraDO::getType, type) - .eq(DataExtraDO::getRelId, relId) + .in(DataExtraDO::getRelId, relIdList) .then() .list(); if (list.isEmpty()) { return Const.N_0; } // 删除数据 - int effect = dataExtraDAO.deleteByRelId(type, relId); + int effect = dataExtraDAO.deleteByRelIdList(type, relIdList); // 删除缓存 this.deleteCache(list); return effect; diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataGroupServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataGroupServiceImpl.java index aa027e558..e42a2b53f 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataGroupServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataGroupServiceImpl.java @@ -250,15 +250,27 @@ public Integer deleteDataGroupByIdList(String type, Long userId, List idLi @Override public Integer deleteDataGroupByUserId(Long userId) { + if (userId == null) { + return 0; + } + // 删除 + return this.deleteDataGroupByUserIdList(Lists.singleton(userId)); + } + + @Override + public Integer deleteDataGroupByUserIdList(List userIdList) { + if (Lists.isEmpty(userIdList)) { + return 0; + } // 删除分组 LambdaQueryWrapper deleteGroup = dataGroupDAO.wrapper() - .eq(DataGroupDO::getUserId, userId); + .in(DataGroupDO::getUserId, userIdList); int effect = dataGroupDAO.delete(deleteGroup); // 删除分组引用 LambdaQueryWrapper deleteRel = dataGroupRelDAO.wrapper() - .eq(DataGroupRelDO::getUserId, userId); + .in(DataGroupRelDO::getUserId, userIdList); effect += dataGroupRelDAO.delete(deleteRel); - // 不删除缓存 自动过期 + // 不删除缓存 让其自动过期 return effect; } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataPermissionServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataPermissionServiceImpl.java index f36b02091..5c8d51d31 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataPermissionServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DataPermissionServiceImpl.java @@ -182,9 +182,21 @@ public List getUserAuthorizedRelIdList(String type, Long userId) { @Override public int deleteByRelId(String type, Long relId) { + if (relId == null) { + return 0; + } + // 删除 + return this.deleteByRelIdList(type, Lists.singleton(relId)); + } + + @Override + public int deleteByRelIdList(String type, List relIdList) { + if (Lists.isEmpty(relIdList)) { + return 0; + } LambdaQueryWrapper wrapper = dataPermissionDAO.wrapper() .eq(DataPermissionDO::getType, type) - .eq(DataPermissionDO::getRelId, relId); + .in(DataPermissionDO::getRelId, relIdList); // 查询 List rows = dataPermissionDAO.selectList(wrapper); // 删除 @@ -204,12 +216,23 @@ public int deleteByRelId(String type, Long relId) { @Override public int deleteByUserId(Long userId) { - LambdaQueryWrapper wrapper = Conditions.eq(DataPermissionDO::getUserId, userId); + if (userId == null) { + return 0; + } // 删除 - int effect = dataPermissionDAO.delete(wrapper); - // 删除缓存 - this.deleteCache(null, Lists.singleton(userId), null); - return effect; + return this.deleteByUserIdList(Lists.singleton(userId)); + } + + @Override + public int deleteByUserIdList(List userIdList) { + if (Lists.isEmpty(userIdList)) { + return 0; + } + LambdaQueryWrapper wrapper = Conditions.in(DataPermissionDO::getUserId, userIdList); + // 删除 + return dataPermissionDAO.delete(wrapper); + // 删除缓存 让其自动过期 + // this.deleteCache(null, userIdList, null); } @Override diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DictKeyServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DictKeyServiceImpl.java index 8808c43b5..dd51f63f7 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DictKeyServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/DictKeyServiceImpl.java @@ -6,6 +6,7 @@ import com.orion.lang.define.wrapper.DataGrid; import com.orion.lang.utils.Objects1; import com.orion.lang.utils.Strings; +import com.orion.lang.utils.collect.Lists; import com.orion.lang.utils.collect.Maps; import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs; import com.orion.visor.framework.common.constant.Const; @@ -176,24 +177,13 @@ public void refreshCache() { } @Override + @Transactional(rollbackFor = Exception.class) public Integer deleteDictKeyById(Long id) { - log.info("DictKeyService-deleteDictKeyById id: {}", id); - // 检查数据是否存在 - DictKeyDO record = dictKeyDAO.selectById(id); - Valid.notNull(record, ErrorMessage.CONFIG_ABSENT); - OperatorLogs.add(OperatorLogs.KEY_NAME, record.getKeyName()); - // 删除配置项 - int effect = dictKeyDAO.deleteById(id); - // 删除配置值 - dictValueService.deleteDictValueByKeyId(id); - // 删除缓存 - RedisMaps.delete(DictCacheKeyDefine.DICT_KEY, id); - RedisUtils.delete(DictCacheKeyDefine.DICT_SCHEMA.format(record.getKeyName())); - log.info("DictKeyService-deleteDictKeyById id: {}, effect: {}", id, effect); - return effect; + return this.deleteDictKeyByIdList(Lists.singleton(id)); } @Override + @Transactional(rollbackFor = Exception.class) public Integer deleteDictKeyByIdList(List idList) { log.info("DictKeyService-deleteDictKeyByIdList idList: {}", idList); // 检查数据是否存在 diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/FavoriteServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/FavoriteServiceImpl.java index e6e4744af..3c668e1fa 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/FavoriteServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/FavoriteServiceImpl.java @@ -20,8 +20,6 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -118,13 +116,8 @@ public void deleteFavoriteByUserId(Long userId) { if (userId == null) { return; } - // 删除库 - favoriteDAO.deleteFavoriteByUserId(userId); - // 删除缓存 - List favoriteKeyList = Arrays.stream(FavoriteTypeEnum.values()) - .map(s -> FavoriteCacheKeyDefine.FAVORITE.format(s, userId)) - .collect(Collectors.toList()); - redisTemplate.delete(favoriteKeyList); + // 删除 + this.deleteFavoriteByUserIdList(Lists.singleton(userId)); } @Override @@ -134,14 +127,14 @@ public void deleteFavoriteByUserIdList(List userIdList) { } // 删除库 favoriteDAO.deleteFavoriteByUserIdList(userIdList); - // 删除缓存 - List favoriteKeyList = new ArrayList<>(); - for (Long userId : userIdList) { - Arrays.stream(FavoriteTypeEnum.values()) - .map(s -> FavoriteCacheKeyDefine.FAVORITE.format(s, userId)) - .forEach(favoriteKeyList::add); - } - redisTemplate.delete(favoriteKeyList); + // 缓存自动过期 + // List favoriteKeyList = new ArrayList<>(); + // for (Long userId : userIdList) { + // Arrays.stream(FavoriteTypeEnum.values()) + // .map(s -> FavoriteCacheKeyDefine.FAVORITE.format(s, userId)) + // .forEach(favoriteKeyList::add); + // } + // redisTemplate.delete(favoriteKeyList); } /** diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/PreferenceServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/PreferenceServiceImpl.java index 1440ae543..1c29785cb 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/PreferenceServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/PreferenceServiceImpl.java @@ -21,7 +21,6 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -164,14 +163,29 @@ public Future> getPreferenceAsync(Long userId, PreferenceTyp @Override public void deletePreferenceByUserId(Long userId) { + if (userId == null) { + return; + } // 删除 - int effect = preferenceDAO.deleteByUserId(userId); - log.info("PreferenceService-deletePreferenceById userId: {}, effect: {}", userId, effect); - // 删除缓存 - List deleteKeys = Arrays.stream(PreferenceTypeEnum.values()) - .map(s -> PreferenceCacheKeyDefine.PREFERENCE.format(userId, s)) - .collect(Collectors.toList()); - RedisMaps.delete(deleteKeys); + this.deletePreferenceByUserIdList(Lists.singleton(userId)); + } + + @Override + public void deletePreferenceByUserIdList(List userIdList) { + if (Lists.isEmpty(userIdList)) { + return; + } + // 删除 + int effect = preferenceDAO.deleteByUserIdList(userIdList); + log.info("PreferenceService-deletePreferenceByUserIdList userIdList: {}, effect: {}", userIdList, effect); + // 删除缓存 让他自动过期 + // List deleteKeys = new ArrayList<>(); + // for (Long userId : userIdList) { + // Arrays.stream(PreferenceTypeEnum.values()) + // .map(s -> PreferenceCacheKeyDefine.PREFERENCE.format(userId, s)) + // .forEach(deleteKeys::add); + // } + // RedisMaps.delete(deleteKeys); } /** diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/SystemUserServiceImpl.java b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/SystemUserServiceImpl.java index 91ebe9c0c..c4e952f69 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/SystemUserServiceImpl.java +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/java/com/orion/visor/module/infra/service/impl/SystemUserServiceImpl.java @@ -3,9 +3,11 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.orion.lang.define.wrapper.DataGrid; +import com.orion.lang.utils.collect.Lists; import com.orion.lang.utils.crypto.Signatures; import com.orion.spring.SpringHolder; import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs; +import com.orion.visor.framework.common.constant.Const; import com.orion.visor.framework.common.constant.ErrorCode; import com.orion.visor.framework.common.constant.ErrorMessage; import com.orion.visor.framework.common.security.LoginUser; @@ -15,6 +17,8 @@ import com.orion.visor.framework.redis.core.utils.RedisUtils; import com.orion.visor.framework.redis.core.utils.barrier.CacheBarriers; import com.orion.visor.framework.security.core.utils.SecurityUtils; +import com.orion.visor.module.infra.api.CommandSnippetApi; +import com.orion.visor.module.infra.api.PathBookmarkApi; import com.orion.visor.module.infra.convert.SystemRoleConvert; import com.orion.visor.module.infra.convert.SystemUserConvert; import com.orion.visor.module.infra.dao.OperatorLogDAO; @@ -38,7 +42,9 @@ import javax.annotation.Resource; import java.util.Comparator; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; /** @@ -82,6 +88,12 @@ public class SystemUserServiceImpl implements SystemUserService { @Resource private DataGroupService dataGroupService; + @Resource + private CommandSnippetApi commandSnippetApi; + + @Resource + private PathBookmarkApi pathBookmarkApi; + @Override public Long createSystemUser(SystemUserCreateRequest request) { // 转换 @@ -212,58 +224,58 @@ public DataGrid getSystemUserPage(SystemUserQueryRequest request) @Override public Integer deleteSystemUserById(Long id) { - if (id.equals(SecurityUtils.getLoginUserId())) { + return this.deleteSystemUserByIdList(Lists.singleton(id)); + } + + @Override + public Integer deleteSystemUserByIdList(List idList) { + if (idList.contains(SecurityUtils.getLoginUserId())) { throw ErrorCode.UNSUPPOETED.exception(); } - // 查询用户 - SystemUserDO record = systemUserDAO.selectById(id); - Valid.notNull(record, ErrorMessage.USER_ABSENT); + // 查询用户列表 + List userList = systemUserDAO.selectBatchIds(idList); + Valid.notEmpty(userList, ErrorMessage.USER_ABSENT); // 添加日志参数 - OperatorLogs.add(OperatorLogs.USERNAME, record.getUsername()); + idList = userList.stream() + .map(SystemUserDO::getId) + .collect(Collectors.toList()); + String username = userList.stream() + .map(SystemUserDO::getUsername) + .collect(Collectors.joining(Const.COMMA)); + OperatorLogs.add(OperatorLogs.USERNAME, username); // 删除用户 - int effect = systemUserDAO.deleteById(id); - log.info("SystemUserService-deleteSystemUserById id: {}, effect: {}", id, effect); - // 删除用户信息缓存 - RedisUtils.delete(UserCacheKeyDefine.USER_INFO.format(id)); - // 删除 token 缓存 - RedisUtils.scanKeysDelete( - // 登录 token - UserCacheKeyDefine.LOGIN_TOKEN.format(id, "*"), - // 刷新 token - UserCacheKeyDefine.LOGIN_REFRESH.format(id, "*") - ); + int effect = systemUserDAO.deleteBatchIds(idList); + log.info("SystemUserService-deleteSystemUserByIdList idList: {}, effect: {}", idList, effect); + // 删除缓存 其他的缓存自动过期 + this.deleteUserCacheKey(userList); // 异步删除额外信息 - SpringHolder.getBean(SystemUserService.class).deleteSystemUserRelAsync(id, record.getUsername()); + SpringHolder.getBean(SystemUserService.class) + .deleteSystemUserListRelAsync(idList); return effect; } @Override @Async("asyncExecutor") - public void deleteSystemUserRelAsync(Long id, String username) { - log.info("SystemUserService-deleteSystemUserRel id: {}", id); - // 删除用户列表缓存 - RedisMaps.delete(UserCacheKeyDefine.USER_LIST, id); - // 删除用户缓存 其他的 key 让其自动过期 - RedisUtils.delete( - // 登录失败次数 - UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(username), - // 用户提示 - TipsCacheKeyDefine.TIPS.format(id) - ); + public void deleteSystemUserListRelAsync(List idList) { + log.info("SystemUserService-deleteSystemUserListRelAsync idList: {}", idList); // 删除角色关联 - systemUserRoleDAO.deleteByUserId(id); + systemUserRoleDAO.deleteByUserIdList(idList); // 删除操作日志 - operatorLogDAO.deleteByUserId(id); + operatorLogDAO.deleteByUserIdList(idList); // 删除用户收藏 - favoriteService.deleteFavoriteByUserId(id); + favoriteService.deleteFavoriteByUserIdList(idList); // 删除用户偏好 - preferenceService.deletePreferenceByUserId(id); + preferenceService.deletePreferenceByUserIdList(idList); // 删除用户数据权限 - dataPermissionService.deleteByUserId(id); + dataPermissionService.deleteByUserIdList(idList); // 删除用户拓展数据 - dataExtraService.deleteByUserId(id); + dataExtraService.deleteByUserIdList(idList); // 删除分组数据 - dataGroupService.deleteDataGroupByUserId(id); + dataGroupService.deleteDataGroupByUserIdList(idList); + // 删除命令片段 + commandSnippetApi.deleteByUserIdList(idList); + // 删除路径标签 + pathBookmarkApi.deleteByUserIdList(idList); } @Override @@ -327,4 +339,29 @@ private void checkNicknamePresent(SystemUserDO domain) { Valid.isFalse(present, ErrorMessage.NICKNAME_PRESENT); } + /** + * 删除主要用户缓存 其他的缓存自动过期 + * + * @param userList + */ + private void deleteUserCacheKey(List userList) { + Set deleteKeys = new HashSet<>(); + // 用户列表缓存 + deleteKeys.add(UserCacheKeyDefine.USER_LIST.getKey()); + userList.forEach(s -> { + Long id = s.getId(); + // 用户提示 + deleteKeys.add(TipsCacheKeyDefine.TIPS.format(id)); + // 用户信息缓存 + deleteKeys.add(UserCacheKeyDefine.USER_INFO.format(id)); + // 登录失败次数 + deleteKeys.add(UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(s.getUsername())); + // 登录 token + deleteKeys.addAll(RedisUtils.scanKeys(UserCacheKeyDefine.LOGIN_TOKEN.format(id, "*"))); + // 刷新 token + deleteKeys.addAll(RedisUtils.scanKeys(UserCacheKeyDefine.LOGIN_REFRESH.format(id, "*"))); + }); + RedisUtils.delete(deleteKeys); + } + } diff --git a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/resources/mapper/DataExtraMapper.xml b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/resources/mapper/DataExtraMapper.xml index fa0027a8b..e8e04b6d3 100644 --- a/orion-visor-module-infra/orion-visor-module-infra-service/src/main/resources/mapper/DataExtraMapper.xml +++ b/orion-visor-module-infra/orion-visor-module-infra-service/src/main/resources/mapper/DataExtraMapper.xml @@ -26,30 +26,44 @@ UPDATE data_extra SET value = JSON_REPLACE(value, "$.keyId", NULL, - "$.authType", IF( - JSON_EXTRACT(value, "$.authType") = 'CUSTOM_KEY', - 'DEFAULT', - JSON_EXTRACT(value, "$.authType") - )) + "$.authType", + REPLACE( + IF(JSON_EXTRACT(value, "$.authType") = 'CUSTOM_KEY', + 'DEFAULT', + JSON_EXTRACT(value, "$.authType") + ), + '"', + '' + ) + ) WHERE deleted = 0 - AND type = 'HOST' - AND item = 'ssh' - AND JSON_CONTAINS(value, JSON_OBJECT('keyId', #{keyId})) + AND type = 'HOST' + AND item = 'ssh' + + JSON_CONTAINS(value, JSON_OBJECT('keyId', #{item})) + UPDATE data_extra SET value = JSON_REPLACE(value, "$.identityId", NULL, - "$.authType", IF( - JSON_EXTRACT(value, "$.authType") = 'CUSTOM_IDENTITY', - 'DEFAULT', - JSON_EXTRACT(value, "$.authType") - )) + "$.authType", + REPLACE( + IF(JSON_EXTRACT(value, "$.authType") = 'CUSTOM_IDENTITY', + 'DEFAULT', + JSON_EXTRACT(value, "$.authType") + ), + '"', + '' + ) + ) WHERE deleted = 0 - AND type = 'HOST' - AND item = 'ssh' - AND JSON_CONTAINS(value, JSON_OBJECT('identityId', #{identityId})) + AND type = 'HOST' + AND item = 'ssh' + + JSON_CONTAINS(value, JSON_OBJECT('identityId', #{item})) + diff --git a/orion-visor-ui/.env.development b/orion-visor-ui/.env.development index fdc659c10..8d55101ac 100644 --- a/orion-visor-ui/.env.development +++ b/orion-visor-ui/.env.development @@ -1,5 +1,5 @@ VITE_API_BASE_URL= 'http://127.0.0.1:9200/orion-visor/api' VITE_WS_BASE_URL= 'ws://127.0.0.1:9200/orion-visor/keep-alive' -VITE_APP_VERSION= '2.0.3' +VITE_APP_VERSION= '2.0.4' VITE_SFTP_PREVIEW_MB= 2 VITE_DEMO_MODE= false diff --git a/orion-visor-ui/.env.production b/orion-visor-ui/.env.production index f3992cab7..3bfb41fcf 100644 --- a/orion-visor-ui/.env.production +++ b/orion-visor-ui/.env.production @@ -1,5 +1,5 @@ VITE_API_BASE_URL= '/orion-visor/api' VITE_WS_BASE_URL= '/orion-visor/keep-alive' -VITE_APP_VERSION= '2.0.3' +VITE_APP_VERSION= '2.0.4' VITE_SFTP_PREVIEW_MB= 2 VITE_DEMO_MODE= false diff --git a/orion-visor-ui/package.json b/orion-visor-ui/package.json index 76a6fa4c4..78cb6a1fa 100644 --- a/orion-visor-ui/package.json +++ b/orion-visor-ui/package.json @@ -1,7 +1,7 @@ { "name": "orion-visor-ui", "description": "Orion Visor UI", - "version": "2.0.3", + "version": "2.0.4", "private": true, "author": "Jiahang Li", "license": "Apache 2.0", diff --git a/orion-visor-ui/src/api/asset/host-identity.ts b/orion-visor-ui/src/api/asset/host-identity.ts index 772765628..f721b1c62 100644 --- a/orion-visor-ui/src/api/asset/host-identity.ts +++ b/orion-visor-ui/src/api/asset/host-identity.ts @@ -1,6 +1,7 @@ import type { DataGrid, Pagination } from '@/types/global'; import type { TableData } from '@arco-design/web-vue/es/table/interface'; import axios from 'axios'; +import qs from 'query-string'; /** * 主机身份创建请求 @@ -91,3 +92,14 @@ export function deleteHostIdentity(id: number) { return axios.delete('/asset/host-identity/delete', { params: { id } }); } +/** + * 批量删除主机身份 + */ +export function batchDeleteHostIdentity(idList: Array) { + return axios.delete('/asset/host-identity/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} diff --git a/orion-visor-ui/src/api/asset/host-key.ts b/orion-visor-ui/src/api/asset/host-key.ts index baf2dd417..ae1960761 100644 --- a/orion-visor-ui/src/api/asset/host-key.ts +++ b/orion-visor-ui/src/api/asset/host-key.ts @@ -1,6 +1,7 @@ import type { DataGrid, Pagination } from '@/types/global'; import type { TableData } from '@arco-design/web-vue/es/table/interface'; import axios from 'axios'; +import qs from 'query-string'; /** * 主机密钥创建请求 @@ -85,3 +86,15 @@ export function getHostKeyPage(request: HostKeyQueryRequest) { export function deleteHostKey(id: number) { return axios.delete('/asset/host-key/delete', { params: { id } }); } + +/** + * 批量删除主机密钥 + */ +export function batchDeleteHostKey(idList: Array) { + return axios.delete('/asset/host-key/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} diff --git a/orion-visor-ui/src/api/asset/host.ts b/orion-visor-ui/src/api/asset/host.ts index 736eba6af..ef60622dd 100644 --- a/orion-visor-ui/src/api/asset/host.ts +++ b/orion-visor-ui/src/api/asset/host.ts @@ -1,6 +1,7 @@ import type { DataGrid, Pagination } from '@/types/global'; import type { TableData } from '@arco-design/web-vue/es/table/interface'; import axios from 'axios'; +import qs from 'query-string'; /** * 主机创建请求 @@ -102,3 +103,15 @@ export function getHostPage(request: HostQueryRequest) { export function deleteHost(id: number) { return axios.delete('/asset/host/delete', { params: { id } }); } + +/** + * 批量删除主机 + */ +export function batchDeleteHost(idList: Array) { + return axios.delete('/asset/host/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} diff --git a/orion-visor-ui/src/api/exec/exec-template.ts b/orion-visor-ui/src/api/exec/exec-template.ts index a2814ed93..16aea19d5 100644 --- a/orion-visor-ui/src/api/exec/exec-template.ts +++ b/orion-visor-ui/src/api/exec/exec-template.ts @@ -1,6 +1,7 @@ import type { DataGrid, Pagination } from '@/types/global'; import type { TableData } from '@arco-design/web-vue/es/table/interface'; import axios from 'axios'; +import qs from 'query-string'; /** * 执行模板创建请求 @@ -88,3 +89,15 @@ export function getExecTemplatePage(request: ExecTemplateQueryRequest) { export function deleteExecTemplate(id: number) { return axios.delete('/asset/exec-template/delete', { params: { id } }); } + +/** + * 批量删除执行模板 + */ +export function batchDeleteExecTemplate(idList: Array) { + return axios.delete('/asset/exec-template/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} diff --git a/orion-visor-ui/src/api/job/exec-job.ts b/orion-visor-ui/src/api/job/exec-job.ts index 9c130d9a7..3aef3c29a 100644 --- a/orion-visor-ui/src/api/job/exec-job.ts +++ b/orion-visor-ui/src/api/job/exec-job.ts @@ -2,6 +2,7 @@ import type { DataGrid, Pagination } from '@/types/global'; import type { TableData } from '@arco-design/web-vue/es/table/interface'; import type { HostQueryResponse } from '@/api/asset/host'; import axios from 'axios'; +import qs from 'query-string'; /** * 计划任务创建请求 @@ -112,6 +113,18 @@ export function deleteExecJob(id: number) { return axios.delete('/asset/exec-job/delete', { params: { id } }); } +/** + * 批量删除计划任务 + */ +export function batchDeleteExecJob(idList: Array) { + return axios.delete('/asset/exec-job/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} + /** * 手动触发计划任务 */ diff --git a/orion-visor-ui/src/api/user/user.ts b/orion-visor-ui/src/api/user/user.ts index 16439a3cc..819502bb2 100644 --- a/orion-visor-ui/src/api/user/user.ts +++ b/orion-visor-ui/src/api/user/user.ts @@ -2,6 +2,7 @@ import type { DataGrid, Pagination } from '@/types/global'; import type { TableData } from '@arco-design/web-vue/es/table/interface'; import type { RoleQueryResponse } from '@/api/user/role'; import axios from 'axios'; +import qs from 'query-string'; /** * 用户创建请求 @@ -162,6 +163,18 @@ export function deleteUser(id: number) { return axios.delete('/infra/system-user/delete', { params: { id } }); } +/** + * 批量删除用户 + */ +export function batchDeleteUser(idList: Array) { + return axios.delete('/infra/system-user/batch-delete', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} + /** * 获取用户会话列表 */ diff --git a/orion-visor-ui/src/components/app/app-footer/index.vue b/orion-visor-ui/src/components/app/app-footer/index.vue index d351b0660..e99d2c521 100644 --- a/orion-visor-ui/src/components/app/app-footer/index.vue +++ b/orion-visor-ui/src/components/app/app-footer/index.vue @@ -2,11 +2,9 @@ - - github gitee - 文档 + 文档 License v{{ version }} Community diff --git a/orion-visor-ui/src/components/exec/template/modal/index.vue b/orion-visor-ui/src/components/exec/template/modal/index.vue index a251abb23..51a59b530 100644 --- a/orion-visor-ui/src/components/exec/template/modal/index.vue +++ b/orion-visor-ui/src/components/exec/template/modal/index.vue @@ -49,10 +49,10 @@ :columns="columns" :data="tableRenderData" :pagination="pagination" + :bordered="false" :scroll="{ x: '100%', y: '60vh' }" @page-change="(page) => fetchTableData(page, pagination.pageSize)" - @page-size-change="(size) => fetchTableData(1, size)" - :bordered="false"> + @page-size-change="(size) => fetchTableData(1, size)"> - + @page-size-change="(size) => fetchTableData(1, size)">