Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7015468e04 | ||
|
|
ef57040e1d | ||
|
|
2a6537c604 | ||
|
|
541a9790ad | ||
|
|
011e8ad089 | ||
|
|
3918d36c24 | ||
|
|
37f452c7c3 | ||
|
|
fc885bc0ad | ||
|
|
44c226092d | ||
|
|
14cf8c2492 | ||
|
|
d6f5898e61 | ||
|
|
0ab8e405cc | ||
|
|
4e4231d5a5 | ||
|
|
2df3f2fa1a | ||
|
|
d6048f78f0 | ||
|
|
f73fa14bfd | ||
|
|
fd88c725d3 | ||
|
|
3a16f9d9ab | ||
|
|
de9b89d805 | ||
|
|
a05c387ba1 | ||
|
|
3cb6e5a2d4 | ||
|
|
104a9a0aa3 | ||
|
|
d7b747eac4 | ||
|
|
d2949c11f3 | ||
|
|
cd05f71173 | ||
|
|
e0dca73369 | ||
|
|
b8599a6693 | ||
|
|
a0adb415fa | ||
|
|
6c60756e54 | ||
|
|
ee9f51ce7d | ||
|
|
924b46b41a | ||
|
|
1fca5a1912 | ||
|
|
120eb1ee69 | ||
|
|
252c538571 | ||
|
|
1eec373b7e | ||
|
|
aa9b96a9c1 | ||
|
|
059fb30aa4 | ||
|
|
2afaf7ad34 | ||
|
|
076a0956c5 | ||
|
|
4a91ec47bf | ||
|
|
1066b43b3d | ||
|
|
3f78125c43 | ||
|
|
144a44673b |
28
README.md
28
README.md
@@ -1,5 +1,5 @@
|
||||
<div align="center"><img src="https://bjuimg.obs.cn-north-4.myhuaweicloud.com/images/2024/5/29/cec03bbd-0eab-464d-9caf-d0b5a7ffc5a6.png" alt="logo" width="32" /></div>
|
||||
<p style="margin-top: 12px" align="center"><b>一款高颜值、现代化的智能运维&轻量堡垒机平台。</b></p>
|
||||
<div align="center"><img src="https://bjuimg.obs.cn-north-4.myhuaweicloud.com/images/2024/9/11/11e7e78e-2af0-4c68-9811-db8a4c4400f4.png" alt="logo" width="520" /></div>
|
||||
<p style="margin-top: 12px" align="center"><b>一款高颜值、现代化的自动化运维&轻量堡垒机平台。</b></p>
|
||||
<p align="center">
|
||||
<a target="_blank"
|
||||
style="text-decoration: none !important;"
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
------------------------------
|
||||
|
||||
**`orion-visor`** 提供一站式服务器运维解决方案。
|
||||
**`orion-visor`** 提供一站式自动化运维解决方案。
|
||||
|
||||
* **资产管理**:支持对资产进行分组,实现对主机、密钥和身份的统一管理和授权。
|
||||
* **在线终端**:提供在线终端 SSH 服务,支持快捷命令、自定义快捷键和主题风格。
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
## 演示环境
|
||||
|
||||
* 🔗 演示地址: http://101.43.254.243:1081/
|
||||
* 🔗 演示地址: [https://dv.orionsec.cn/](https://dv.orionsec.cn/)
|
||||
* 🔏 演示账号: admin/admin
|
||||
* ⭐ 体验后可以点一下 `star` 这对我很重要! [github](https://github.com/dromara/orion-visor) [gitee](https://gitee.com/dromara/orion-visor) [gitcode](https://gitcode.com/dromara/orion-visor/overview)
|
||||
* 🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
```bash
|
||||
# clone
|
||||
git clone https://github.com/dromara/orion-visor
|
||||
git clone --depth=1 https://github.com/dromara/orion-visor
|
||||
cd orion-visor
|
||||
# 启动
|
||||
docker compose up -d
|
||||
@@ -72,11 +72,11 @@ docker compose up -d
|
||||
|
||||
## 项目文档
|
||||
|
||||
* [文档地址](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)
|
||||
* [文档地址](https://visor.orionsec.cn/)
|
||||
* [安装文档](https://visor.orionsec.cn/quickstart/docker.html)
|
||||
* [更新日志](https://visor.orionsec.cn/update/change-log.html)
|
||||
* [操作手册](https://visor.orionsec.cn/operator/asset.html)
|
||||
* [常见问题](https://visor.orionsec.cn/support/faq.html)
|
||||
|
||||
## 技术栈
|
||||
|
||||
@@ -111,14 +111,18 @@ docker compose up -d
|
||||
|
||||
[](https://star-history.com/#lijiahangmax/orion-visor&Date)
|
||||
|
||||
## 关于我
|
||||
|
||||
本人专注于使用 Java 和 Vue 进行全栈开发, 并在系统自动化运维方面拥有丰富开发的经验。如果您在这些领域有需求或遇到痛点, 请随时联系我, 并备注“合作”。
|
||||
|
||||
## 联系我
|
||||
|
||||
<div style="display: flex;">
|
||||
<img src="https://bjuimg.obs.cn-north-4.myhuaweicloud.com/images/2024/5/17/d42d91f3-f0ee-4c63-adab-a35809e0804c.jpg" alt="wx" width="298px" height="398px"/>
|
||||
</div>
|
||||
|
||||

|
||||

|
||||
微信: ljh1553488
|
||||
QQ群: 755242157
|
||||
|
||||
📧 咨询问题微信备注: vis
|
||||
📧 合作/功能定制备注: 合作
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version: '3.3'
|
||||
services:
|
||||
service:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.1.3
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.1.7
|
||||
privileged: true
|
||||
ports:
|
||||
- 1081:80
|
||||
@@ -32,7 +32,7 @@ services:
|
||||
- mysql
|
||||
- redis
|
||||
mysql:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.1.3
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.1.7
|
||||
privileged: true
|
||||
ports:
|
||||
- 3307:3306
|
||||
@@ -52,7 +52,7 @@ services:
|
||||
retries: 10
|
||||
start_period: 3s
|
||||
redis:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.1.3
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.1.7
|
||||
privileged: true
|
||||
ports:
|
||||
- 6380:6379
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version: '3.3'
|
||||
services:
|
||||
service:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.1.3
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.1.7
|
||||
privileged: true
|
||||
ports:
|
||||
- ${SERVICE_PORT:-1081}:80
|
||||
@@ -19,9 +19,9 @@ services:
|
||||
- ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/service/root-orion:/root/orion
|
||||
healthcheck:
|
||||
test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ]
|
||||
interval: 3s
|
||||
interval: 15s
|
||||
timeout: 300s
|
||||
retries: 200
|
||||
retries: 15
|
||||
start_period: 3s
|
||||
depends_on:
|
||||
mysql:
|
||||
@@ -32,7 +32,7 @@ services:
|
||||
- mysql
|
||||
- redis
|
||||
mysql:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.1.3
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.1.7
|
||||
privileged: true
|
||||
ports:
|
||||
- 3307:3306
|
||||
@@ -47,12 +47,12 @@ services:
|
||||
- ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/mysql/etc-mysql:/etc/mysql
|
||||
healthcheck:
|
||||
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ]
|
||||
interval: 3s
|
||||
interval: 15s
|
||||
timeout: 60s
|
||||
retries: 10
|
||||
retries: 15
|
||||
start_period: 3s
|
||||
redis:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.1.3
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.1.7
|
||||
privileged: true
|
||||
ports:
|
||||
- 6380:6379
|
||||
@@ -63,12 +63,12 @@ services:
|
||||
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
|
||||
healthcheck:
|
||||
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
|
||||
interval: 3s
|
||||
interval: 15s
|
||||
timeout: 60s
|
||||
retries: 10
|
||||
retries: 15
|
||||
start_period: 3s
|
||||
adminer:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-adminer:2.1.3
|
||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-adminer:2.1.7
|
||||
ports:
|
||||
- 8081:8080
|
||||
depends_on:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#/bin/bash
|
||||
version=2.1.3
|
||||
version=2.1.7
|
||||
docker build -t orion-visor-adminer:${version} .
|
||||
docker tag orion-visor-adminer:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-adminer:${version}
|
||||
|
||||
@@ -17,7 +17,7 @@ items:
|
||||
code: 200
|
||||
- name: userPermission
|
||||
request:
|
||||
api: /orion-visor/api/infra/permission/user
|
||||
api: /orion-visor/api/infra/user-permission/user
|
||||
header:
|
||||
Authorization: Bearer {{.login.data.token}}
|
||||
expect:
|
||||
@@ -26,7 +26,7 @@ items:
|
||||
msg: "success"
|
||||
- name: menu
|
||||
request:
|
||||
api: /orion-visor/api/infra/permission/menu
|
||||
api: /orion-visor/api/infra/user-permission/menu
|
||||
header:
|
||||
Authorization: Bearer {{.login.data.token}}
|
||||
expect:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#/bin/bash
|
||||
version=2.1.3
|
||||
version=2.1.7
|
||||
cp -r ../../sql ./sql
|
||||
docker build -t orion-visor-mysql:${version} .
|
||||
rm -rf ./sql
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#/bin/bash
|
||||
version=2.1.3
|
||||
version=2.1.7
|
||||
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-adminer:${version}
|
||||
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:${version}
|
||||
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#/bin/bash
|
||||
version=2.1.3
|
||||
version=2.1.7
|
||||
docker build -t orion-visor-redis:${version} .
|
||||
docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#/bin/bash
|
||||
version=2.1.3
|
||||
version=2.1.7
|
||||
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} .
|
||||
|
||||
@@ -29,7 +29,7 @@ server {
|
||||
location /orion-visor/api {
|
||||
proxy_pass http://localhost:9200/orion-visor/api;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<url>https://github.com/dromara/orion-visor</url>
|
||||
|
||||
<properties>
|
||||
<revision>2.1.3</revision>
|
||||
<revision>2.1.7</revision>
|
||||
<spring.boot.version>2.7.17</spring.boot.version>
|
||||
<spring.boot.admin.version>2.7.15</spring.boot.admin.version>
|
||||
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.orion.visor.framework.common.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 保留
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/6/6 15:26
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Keep {
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public interface AppConst extends OrionConst {
|
||||
/**
|
||||
* 同 ${orion.version} 迭代时候需要手动更改
|
||||
*/
|
||||
String VERSION = "2.1.3";
|
||||
String VERSION = "2.1.7";
|
||||
|
||||
/**
|
||||
* 同 ${spring.application.name}
|
||||
|
||||
@@ -29,4 +29,6 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst, CnCons
|
||||
|
||||
String SYSTEM_USERNAME = "system";
|
||||
|
||||
int BATCH_COUNT = 500;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.orion.visor.framework.common.constant;
|
||||
|
||||
import com.orion.lang.exception.ApplicationException;
|
||||
import com.orion.lang.exception.argument.InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*
|
||||
@@ -97,6 +100,14 @@ public interface ErrorMessage {
|
||||
|
||||
String TASK_ABSENT = "任务不存在";
|
||||
|
||||
String CONNECT_ERROR = "连接失败";
|
||||
|
||||
String AUTH_ERROR = "认证失败";
|
||||
|
||||
String SCRIPT_UPLOAD_ERROR = "脚本上传失败";
|
||||
|
||||
String EXEC_ERROR = "执行失败";
|
||||
|
||||
String ILLEGAL_STATUS = "当前状态不支持此操作";
|
||||
|
||||
String CHECK_AUTHORIZED_HOST = "请选择已授权的主机";
|
||||
@@ -111,4 +122,41 @@ public interface ErrorMessage {
|
||||
|
||||
String UNABLE_DOWNLOAD_FOLDER = "无法下载文件夹";
|
||||
|
||||
/**
|
||||
* 是否为业务异常
|
||||
*
|
||||
* @param ex ex
|
||||
* @return biz exception
|
||||
*/
|
||||
static boolean isBizException(Exception ex) {
|
||||
if (ex == null) {
|
||||
return false;
|
||||
}
|
||||
return ex instanceof InvalidArgumentException
|
||||
|| ex instanceof IllegalArgumentException
|
||||
|| ex instanceof ApplicationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取错误信息
|
||||
*
|
||||
* @param ex ex
|
||||
* @param defaultMsg defaultMsg
|
||||
* @return message
|
||||
*/
|
||||
static String getErrorMessage(Exception ex, String defaultMsg) {
|
||||
if (ex == null) {
|
||||
return null;
|
||||
}
|
||||
String message = ex.getMessage();
|
||||
if (message == null) {
|
||||
return defaultMsg;
|
||||
}
|
||||
// 业务异常
|
||||
if (isBizException(ex)) {
|
||||
return message;
|
||||
}
|
||||
return defaultMsg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ public interface ExtraFieldConst extends FieldConst {
|
||||
|
||||
String USERNAME = "username";
|
||||
|
||||
String HOME = "home";
|
||||
|
||||
String STATUS_NAME = "statusName";
|
||||
|
||||
String KEY_NAME = "keyName";
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orion.visor.framework.common.entity;
|
||||
|
||||
/**
|
||||
* 数据清理请求 定义
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/8/29 11:26
|
||||
*/
|
||||
public interface DataClearRequest {
|
||||
|
||||
/**
|
||||
* 获取清理数量限制
|
||||
*
|
||||
* @return 清理限制
|
||||
*/
|
||||
Integer getLimit();
|
||||
|
||||
/**
|
||||
* 设置清理数量限制
|
||||
*
|
||||
* @param limit limit
|
||||
*/
|
||||
void setLimit(Integer limit);
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.orion.visor.framework.common.entity;
|
||||
|
||||
import com.orion.lang.define.wrapper.IPageRequest;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 公共页码请求
|
||||
@@ -15,14 +17,18 @@ import org.hibernate.validator.constraints.Range;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "公共页码请求")
|
||||
public class PageRequest implements IPageRequest {
|
||||
public class PageRequest {
|
||||
|
||||
@Range(min = 1, max = 10000, groups = Page.class)
|
||||
@NotNull(groups = Page.class)
|
||||
@Min(value = 1, groups = Page.class)
|
||||
@Max(value = 10000, groups = Page.class)
|
||||
@Schema(description = "页码")
|
||||
private int page;
|
||||
private Integer page;
|
||||
|
||||
@Range(min = 1, max = 200, groups = Page.class)
|
||||
@NotNull(groups = Page.class)
|
||||
@Min(value = 1, groups = Page.class)
|
||||
@Max(value = 200, groups = Page.class)
|
||||
@Schema(description = "大小")
|
||||
private int limit;
|
||||
private Integer limit;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.orion.visor.framework.common.meta;
|
||||
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import com.orion.lang.id.UUIds;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
/**
|
||||
* traceId 持有者
|
||||
@@ -23,16 +25,74 @@ public class TraceIdHolder {
|
||||
*/
|
||||
private static final ThreadLocal<String> HOLDER = new TransmittableThreadLocal<>();
|
||||
|
||||
/**
|
||||
* 获取 traceId
|
||||
*
|
||||
* @return traceId
|
||||
*/
|
||||
public static String get() {
|
||||
return HOLDER.get();
|
||||
}
|
||||
|
||||
public static void set(String traceId) {
|
||||
HOLDER.set(traceId);
|
||||
/**
|
||||
* 设置 traceId
|
||||
*/
|
||||
public static void set() {
|
||||
set(createTraceId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 traceId
|
||||
*
|
||||
* @param traceId traceId
|
||||
*/
|
||||
public static void set(String traceId) {
|
||||
// 设置应用上下文
|
||||
HOLDER.set(traceId);
|
||||
// 设置日志上下文
|
||||
setMdc(traceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 traceId
|
||||
*/
|
||||
public static void remove() {
|
||||
// 移除应用上下文
|
||||
HOLDER.remove();
|
||||
// 移除日志上下文
|
||||
removeMdc();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从应用上下文 设置到日志上下文
|
||||
*/
|
||||
public static void setMdc() {
|
||||
setMdc(HOLDER.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置到日志上下文
|
||||
*
|
||||
* @param traceId traceId
|
||||
*/
|
||||
public static void setMdc(String traceId) {
|
||||
MDC.put(TRACE_ID_MDC, traceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除日志上下文
|
||||
*/
|
||||
public static void removeMdc() {
|
||||
MDC.remove(TRACE_ID_MDC);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 traceId
|
||||
*
|
||||
* @return traceId
|
||||
*/
|
||||
public static String createTraceId() {
|
||||
return UUIds.random32();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ public class IpUtils {
|
||||
* @return addr
|
||||
*/
|
||||
public static String getRemoteAddr(HttpServletRequest request) {
|
||||
// 获取实际地址
|
||||
String realIp = request.getHeader(StandardHttpHeader.X_REAL_IP);
|
||||
if (!Strings.isBlank(realIp)) {
|
||||
return realIp;
|
||||
}
|
||||
// 获取实际地址 X_REAL_IP 在多代理情况下会有问题
|
||||
// String realIp = request.getHeader(StandardHttpHeader.X_REAL_IP);
|
||||
// if (!Strings.isBlank(realIp)) {
|
||||
// return realIp;
|
||||
// }
|
||||
// 获取请求地址
|
||||
return Servlets.getRemoteAddr(request);
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.orion.visor.framework.common.utils;
|
||||
|
||||
import com.orion.lang.utils.Arrays1;
|
||||
import com.orion.lang.utils.crypto.Caesars;
|
||||
|
||||
/**
|
||||
* 混淆工具类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/6/17 18:27
|
||||
*/
|
||||
public class Mixes {
|
||||
|
||||
private Mixes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 混淆
|
||||
* <p>
|
||||
* 此方法不可修改
|
||||
*
|
||||
* @param str str
|
||||
* @return str
|
||||
*/
|
||||
public static String obfuscate(String str) {
|
||||
char[] chars = str.toCharArray();
|
||||
Arrays1.reverse(chars);
|
||||
for (int i = 0; i < chars.length; i += 2) {
|
||||
char temp = chars[i];
|
||||
chars[i] = chars[i + 1];
|
||||
chars[i + 1] = temp;
|
||||
}
|
||||
String res = new String(chars);
|
||||
return new Caesars().encrypt(res);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.orion.visor.framework.common.utils;
|
||||
|
||||
import com.orion.lang.utils.Objects1;
|
||||
import com.orion.lang.utils.Systems;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.visor.framework.common.constant.AppConst;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
|
||||
@@ -24,9 +26,25 @@ public class PathUtils {
|
||||
* @return 用户目录
|
||||
*/
|
||||
public static String getHomePath(boolean isWindows, String username) {
|
||||
return getHomePath(isWindows, username, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户根目录
|
||||
*
|
||||
* @param isWindows isWindows
|
||||
* @param username 用户名
|
||||
* @param prependSeparator 是否在头部添加分隔符
|
||||
* @return 用户目录
|
||||
*/
|
||||
public static String getHomePath(boolean isWindows, String username, boolean prependSeparator) {
|
||||
if (isWindows) {
|
||||
// windows
|
||||
return "C:/Users/" + username;
|
||||
if (prependSeparator) {
|
||||
return "/C:/Users/" + username;
|
||||
} else {
|
||||
return "C:/Users/" + username;
|
||||
}
|
||||
} else {
|
||||
// linux
|
||||
if (Const.ROOT.equals(username)) {
|
||||
@@ -66,4 +84,34 @@ public class PathUtils {
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 头部添加分隔符
|
||||
*
|
||||
* @param path path
|
||||
* @return path
|
||||
*/
|
||||
public static String prependSeparator(String path) {
|
||||
if (path.startsWith("/")) {
|
||||
return path;
|
||||
}
|
||||
return "/" + path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 orion path
|
||||
*
|
||||
* @param path path
|
||||
* @return path
|
||||
*/
|
||||
public static String getOrionPath(String path) {
|
||||
path = Systems.HOME_DIR
|
||||
+ Files1.SEPARATOR
|
||||
+ AppConst.ORION
|
||||
+ Files1.SEPARATOR
|
||||
+ AppConst.APP_NAME
|
||||
+ Files1.SEPARATOR
|
||||
+ path;
|
||||
return Files1.getPath(path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.orion.visor.framework.common.utils;
|
||||
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
|
||||
/**
|
||||
* sql 工具类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/8/26 16:03
|
||||
*/
|
||||
public class SqlUtils {
|
||||
|
||||
private SqlUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* limit n
|
||||
*
|
||||
* @param limit limit
|
||||
* @return limit
|
||||
*/
|
||||
public static String limit(Number limit) {
|
||||
return Const.LIMIT + Const.SPACE + limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* limit offset limit
|
||||
*
|
||||
* @param offset offset
|
||||
* @param limit limit
|
||||
* @return limit
|
||||
*/
|
||||
public static String limit(Number offset, Number limit) {
|
||||
return Const.LIMIT + Const.SPACE + offset + Const.COMMA + limit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Validator;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -31,6 +32,10 @@ public class Valid extends com.orion.lang.utils.Valid {
|
||||
return notBlank(s, ErrorMessage.PARAM_MISSING);
|
||||
}
|
||||
|
||||
public static <T extends Map<?, ?>> T notEmpty(T map) {
|
||||
return notEmpty(map, ErrorMessage.PARAM_MISSING);
|
||||
}
|
||||
|
||||
public static <T extends Collection<?>> T notEmpty(T object) {
|
||||
return notEmpty(object, ErrorMessage.PARAM_MISSING);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 批量验证分组
|
||||
*
|
||||
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Batch extends Default {
|
||||
public interface Batch {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
/**
|
||||
* 清理验证分组
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Clear {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
/**
|
||||
* 导出验证分组
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Export {
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 分页验证分组
|
||||
*
|
||||
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Id extends Default {
|
||||
public interface Id {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
/**
|
||||
* 导出验证分组
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Import {
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.orion.visor.framework.common.validator.group;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 分页验证分组
|
||||
*
|
||||
@@ -9,5 +7,5 @@ import javax.validation.groups.Default;
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/1 19:13
|
||||
*/
|
||||
public interface Page extends Default {
|
||||
public interface Page {
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* quartz 配置
|
||||
@@ -22,27 +19,6 @@ import javax.sql.DataSource;
|
||||
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_JOB_QUARTZ)
|
||||
public class OrionQuartzAutoConfiguration {
|
||||
|
||||
/**
|
||||
* @return 任务工厂
|
||||
*/
|
||||
@Bean
|
||||
public SpringBeanJobFactory jobFactory() {
|
||||
return new SpringBeanJobFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dataSource dataSource
|
||||
* @param jobFactory jobFactory
|
||||
* @return 调度器工厂
|
||||
*/
|
||||
@Bean
|
||||
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource, SpringBeanJobFactory jobFactory) {
|
||||
SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
||||
factory.setDataSource(dataSource);
|
||||
factory.setJobFactory(jobFactory);
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param schedulerFactoryBean 调度器工厂
|
||||
* @return 调度器
|
||||
|
||||
@@ -6,6 +6,9 @@ import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 不执行统一日志打印
|
||||
* <p>
|
||||
* 如果设置在方法上,则忽略该方法的日志打印
|
||||
* 如果设置到参数上,则忽略该参数的日志打印
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.orion.visor.framework.mybatis.core.generator.core;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import com.orion.lang.utils.Exceptions;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.FieldConst;
|
||||
@@ -47,7 +48,7 @@ public class DictParser {
|
||||
.stream()
|
||||
.filter(s -> variable.equals(s.getName()) || variable.equals(s.getPropertyName()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("未查询到字典映射字段 " + variable));
|
||||
.orElseThrow(() -> Exceptions.runtime("未查询到字典映射字段 " + variable));
|
||||
// 设置字段名称
|
||||
if (meta.getField() == null) {
|
||||
meta.setField(Strings.firstUpper(tableField.getPropertyName()));
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.orion.visor.framework.mybatis.core.mapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.mybatis.core.query.Conditions;
|
||||
import com.orion.visor.framework.mybatis.core.query.DataQuery;
|
||||
|
||||
@@ -61,7 +62,7 @@ public interface IMapper<T> extends BaseMapper<T> {
|
||||
* @return 是否成功
|
||||
*/
|
||||
default boolean insertBatch(Collection<T> entities) {
|
||||
return Db.saveBatch(entities);
|
||||
return this.insertBatch(entities, Const.BATCH_COUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +83,7 @@ public interface IMapper<T> extends BaseMapper<T> {
|
||||
* @return 是否成功
|
||||
*/
|
||||
default boolean updateBatch(Collection<T> entities) {
|
||||
return Db.updateBatchById(entities);
|
||||
return this.updateBatch(entities, Const.BATCH_COUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +114,7 @@ public interface IMapper<T> extends BaseMapper<T> {
|
||||
* @return 是否成功
|
||||
*/
|
||||
default boolean insertOrUpdateBatch(Collection<T> entities) {
|
||||
return Db.saveOrUpdateBatch(entities);
|
||||
return this.insertOrUpdateBatch(entities, Const.BATCH_COUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.reflect.Classes;
|
||||
import com.orion.spring.SpringHolder;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.utils.SqlUtils;
|
||||
import com.orion.visor.framework.mybatis.core.domain.BaseDO;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -36,7 +37,7 @@ public class DataQuery<T> {
|
||||
|
||||
private final BaseMapper<T> dao;
|
||||
|
||||
private IPageRequest page;
|
||||
private PageRequest page;
|
||||
|
||||
private Wrapper<T> wrapper;
|
||||
|
||||
@@ -73,8 +74,9 @@ public class DataQuery<T> {
|
||||
return new DataQuery<>(dao, wrapper);
|
||||
}
|
||||
|
||||
public DataQuery<T> page(IPageRequest page) {
|
||||
this.page = Valid.notNull(page, "page is null");
|
||||
public DataQuery<T> page(com.orion.visor.framework.common.entity.PageRequest page) {
|
||||
com.orion.visor.framework.common.entity.PageRequest pr = Valid.notNull(page, "page is null");
|
||||
this.page = new PageRequest(pr.getPage(), pr.getLimit());
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -111,11 +113,11 @@ public class DataQuery<T> {
|
||||
}
|
||||
|
||||
public DataQuery<T> limit(int limit) {
|
||||
return this.last(Const.LIMIT + Const.SPACE + limit);
|
||||
return this.last(SqlUtils.limit(limit));
|
||||
}
|
||||
|
||||
public DataQuery<T> limit(int offset, int limit) {
|
||||
return this.last(Const.LIMIT + Const.SPACE + offset + Const.COMMA + limit);
|
||||
return this.last(SqlUtils.limit(offset, limit));
|
||||
}
|
||||
|
||||
public DataQuery<T> only() {
|
||||
@@ -199,6 +201,18 @@ public class DataQuery<T> {
|
||||
return dao.selectCount(wrapper);
|
||||
}
|
||||
|
||||
public Long countMax(Number max) {
|
||||
Long count = dao.selectCount(wrapper);
|
||||
if (max == null) {
|
||||
return count;
|
||||
}
|
||||
long maxValue = max.longValue();
|
||||
if (maxValue <= 0L) {
|
||||
return count;
|
||||
}
|
||||
return Math.min(count, maxValue);
|
||||
}
|
||||
|
||||
public boolean absent() {
|
||||
return dao.selectCount(wrapper) == 0;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,18 @@ Authorization: {{token}}
|
||||
}
|
||||
|
||||
|
||||
${httpComment} ${apiComment.queryCount}
|
||||
POST {{baseUrl}}/${package.ModuleName}/${typeHyphen}/count
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
#foreach($field in ${table.fields})
|
||||
"${field.propertyName}": ""#if($foreach.hasNext),#end
|
||||
#end
|
||||
}
|
||||
|
||||
|
||||
${httpComment} ${apiComment.deleteById}
|
||||
DELETE {{baseUrl}}/${package.ModuleName}/${typeHyphen}/delete?id=1
|
||||
Authorization: {{token}}
|
||||
|
||||
@@ -113,6 +113,13 @@ public class ${table.controllerName} {
|
||||
return ${typeLower}Service.get${type}Page(request);
|
||||
}
|
||||
|
||||
@PostMapping("/count")
|
||||
@Operation(summary = "${apiComment.queryCount}")
|
||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:query')")
|
||||
public Long get${type}Count(@Validated @RequestBody ${type}QueryRequest request) {
|
||||
return ${typeLower}Service.get${type}Count(request);
|
||||
}
|
||||
|
||||
#if($meta.enableDemoApi)
|
||||
@DemoDisableApi
|
||||
#end
|
||||
|
||||
@@ -122,7 +122,8 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
@Override
|
||||
public List<${type}VO> get${type}List(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request)
|
||||
.orderByDesc(${type}DO::getId);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of(wrapper).list(${type}Convert.MAPPER::to);
|
||||
}
|
||||
@@ -148,24 +149,28 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
.sorted(Comparator.comparing(${type}VO::getId).reversed())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
#end
|
||||
|
||||
@Override
|
||||
public DataGrid<${type}VO> get${type}Page(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request)
|
||||
.orderByDesc(${type}DO::getId);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of()
|
||||
.page(request)
|
||||
.wrapper(wrapper)
|
||||
.dataGrid(${type}Convert.MAPPER::to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long get${type}Count(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return ${typeLower}DAO.selectCount(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataGrid<${type}VO> get${type}Page(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of(wrapper)
|
||||
.page(request)
|
||||
.dataGrid(${type}Convert.MAPPER::to);
|
||||
return ${typeLower}DAO.of()
|
||||
.wrapper(wrapper)
|
||||
.countMax(request.getLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -235,13 +240,8 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
Valid.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<${type}DO> buildQueryWrapper(${type}QueryRequest request) {
|
||||
@Override
|
||||
public LambdaQueryWrapper<${type}DO> buildQueryWrapper(${type}QueryRequest request) {
|
||||
String searchValue = request.getSearchValue();
|
||||
return ${typeLower}DAO.wrapper()
|
||||
#foreach($field in ${table.fields})
|
||||
@@ -251,8 +251,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
#foreach($field in ${table.fields})
|
||||
.eq(${type}DO::get${field.capitalName}, searchValue)#if($foreach.hasNext).or()#end
|
||||
#end
|
||||
)
|
||||
.orderByDesc(${type}DO::getId);
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ${package.Service};
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
@@ -116,4 +117,12 @@ public interface ${table.serviceName} {
|
||||
*/
|
||||
Integer delete${type}(${type}QueryRequest request);
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<${type}DO> buildQueryWrapper(${type}QueryRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -115,6 +115,13 @@ export function get${vue.featureEntity}Page(request: ${vue.featureEntity}QueryRe
|
||||
return axios.post<DataGrid<${vue.featureEntity}QueryResponse>>('/${package.ModuleName}/${typeHyphen}/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.queryCount
|
||||
*/
|
||||
export function get${vue.featureEntity}Count(request: ${vue.featureEntity}QueryRequest) {
|
||||
return axios.post<number>('/${package.ModuleName}/${typeHyphen}/count', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* $apiComment.deleteById
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<card-list v-model:searchValue="formModel.searchValue"
|
||||
search-input-placeholder="输入搜索值"
|
||||
create-card-position="head"
|
||||
:create-card-position="false"
|
||||
:loading="loading"
|
||||
:field-config="fieldConfig"
|
||||
:list="list"
|
||||
|
||||
@@ -98,6 +98,13 @@ public class SecurityUtils {
|
||||
return loginUser != null ? loginUser.getTimestamp() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空用户上下文
|
||||
*/
|
||||
public static void clearAuthentication() {
|
||||
SecurityContextHolder.getContext().setAuthentication(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前用户
|
||||
*
|
||||
@@ -107,7 +114,9 @@ public class SecurityUtils {
|
||||
public static void setLoginUser(LoginUser loginUser, HttpServletRequest request) {
|
||||
// 创建 authentication
|
||||
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(loginUser, null, Collections.emptyList());
|
||||
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||
if (request != null) {
|
||||
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||
}
|
||||
// 设置上下文
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.orion.visor.framework.web.core.filter;
|
||||
|
||||
import com.orion.lang.id.UUIds;
|
||||
import com.orion.visor.framework.common.meta.TraceIdHolder;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
@@ -23,21 +21,17 @@ public class TraceIdFilter extends OncePerRequestFilter {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
try {
|
||||
// 获 traceId
|
||||
String traceId = UUIds.random32();
|
||||
// 设置应用上下文
|
||||
// 获取 traceId
|
||||
String traceId = TraceIdHolder.createTraceId();
|
||||
// 设置 traceId 上下文
|
||||
TraceIdHolder.set(traceId);
|
||||
// 设置日志上下文
|
||||
MDC.put(TraceIdHolder.TRACE_ID_MDC, traceId);
|
||||
// 设置响应头
|
||||
response.setHeader(TraceIdHolder.TRACE_ID_HEADER, traceId);
|
||||
// 执行请求
|
||||
filterChain.doFilter(request, response);
|
||||
} finally {
|
||||
// 清理应用上下文
|
||||
// 清空 traceId 上下文
|
||||
TraceIdHolder.remove();
|
||||
// 清理日志上下文
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,5 +33,5 @@ management:
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
# 日志打印
|
||||
# sql 日志打印
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
@@ -82,13 +82,13 @@ spring:
|
||||
instanceName: quartzScheduler
|
||||
jobStore:
|
||||
# 持久化配置
|
||||
class: org.quartz.impl.jdbcjobstore.JobStoreTX
|
||||
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
|
||||
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
||||
useProperties: false
|
||||
tablePrefix: QRTZ_
|
||||
misfireThreshold: 60000
|
||||
clusterCheckinInterval: 5000
|
||||
isClustered: true
|
||||
isClustered: false
|
||||
# 连接池
|
||||
threadPool:
|
||||
class: org.quartz.simpl.SimpleThreadPool
|
||||
@@ -167,6 +167,8 @@ app:
|
||||
allow-refresh: true
|
||||
# 凭证续签最大次数
|
||||
max-refresh-count: 3
|
||||
# 登录失败发送站内信阈值
|
||||
login-failed-send-threshold: 3
|
||||
# 登录失败锁定次数
|
||||
login-failed-lock-count: 5
|
||||
# 登录失败锁定时间 (分)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.orion.visor.module.asset.controller;
|
||||
import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.visor.module.asset.define.operator.HostGroupOperatorType;
|
||||
import com.orion.visor.module.asset.define.operator.HostIdentityOperatorType;
|
||||
@@ -43,6 +44,7 @@ public class AssetDataGrantServiceController {
|
||||
@Resource
|
||||
private AssetAuthorizedDataService assetAuthorizedDataService;
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(HostGroupOperatorType.GRANT)
|
||||
@PutMapping("/grant-host-group")
|
||||
@Operation(summary = "主机分组授权")
|
||||
@@ -60,6 +62,7 @@ public class AssetDataGrantServiceController {
|
||||
return assetAuthorizedDataService.getAuthorizedDataRelId(DataPermissionTypeEnum.HOST_GROUP, request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(HostKeyOperatorType.GRANT)
|
||||
@PutMapping("/grant-host-key")
|
||||
@Operation(summary = "主机密钥授权")
|
||||
@@ -77,6 +80,7 @@ public class AssetDataGrantServiceController {
|
||||
return assetAuthorizedDataService.getAuthorizedDataRelId(DataPermissionTypeEnum.HOST_KEY, request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(HostIdentityOperatorType.GRANT)
|
||||
@PutMapping("/grant-host-identity")
|
||||
@Operation(summary = "主机身份授权")
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.visor.module.asset.define.operator.ExecCommandLogOperatorType;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecInterruptRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogTailRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.ExecHostLogVO;
|
||||
@@ -97,6 +98,14 @@ public class ExecCommandLogController {
|
||||
return execLogService.getExecHistory(request);
|
||||
}
|
||||
|
||||
@PostMapping("/count")
|
||||
@Operation(summary = "查询批量执行日志数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-command-log:query')")
|
||||
public Long getExecCommandLogCount(@Validated @RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
return execLogService.queryExecLogCount(request);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecCommandLogOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除批量执行日志")
|
||||
@@ -124,19 +133,11 @@ public class ExecCommandLogController {
|
||||
return execHostLogService.deleteExecHostLogById(id);
|
||||
}
|
||||
|
||||
@PostMapping("/query-count")
|
||||
@Operation(summary = "查询批量执行日志数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-command-log:management:clear')")
|
||||
public Long getExecCommandLogCount(@RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
return execLogService.queryExecLogCount(request);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecCommandLogOperatorType.CLEAR)
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空批量执行日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-command-log:management:clear')")
|
||||
public Integer clearExecCommandLog(@RequestBody ExecLogQueryRequest request) {
|
||||
public Integer clearExecCommandLog(@Validated @RequestBody ExecLogClearRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
return execLogService.clearExecLog(request);
|
||||
}
|
||||
@@ -178,4 +179,3 @@ public class ExecCommandLogController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.visor.module.asset.define.operator.ExecJobOperatorType;
|
||||
import com.orion.visor.module.asset.entity.request.exec.*;
|
||||
@@ -39,6 +40,7 @@ public class ExecJobController {
|
||||
@Resource
|
||||
private ExecJobService execJobService;
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecJobOperatorType.CREATE)
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建计划任务")
|
||||
@@ -47,6 +49,7 @@ public class ExecJobController {
|
||||
return execJobService.createExecJob(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecJobOperatorType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新计划任务")
|
||||
@@ -55,6 +58,7 @@ public class ExecJobController {
|
||||
return execJobService.updateExecJobById(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecJobOperatorType.UPDATE_STATUS)
|
||||
@PutMapping("/update-status")
|
||||
@Operation(summary = "更新计划任务状态")
|
||||
@@ -88,6 +92,7 @@ public class ExecJobController {
|
||||
return execJobService.getExecJobPage(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecJobOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除计划任务")
|
||||
@@ -97,6 +102,7 @@ public class ExecJobController {
|
||||
return execJobService.deleteExecJobById(id);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecJobOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除计划任务")
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.visor.module.asset.define.operator.ExecJobLogOperatorType;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecInterruptRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogTailRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.ExecHostLogVO;
|
||||
@@ -86,6 +87,14 @@ public class ExecJobLogController {
|
||||
return execLogService.getExecLogStatus(idList, SOURCE);
|
||||
}
|
||||
|
||||
@PostMapping("/count")
|
||||
@Operation(summary = "查询计划任务日志数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:query')")
|
||||
public Long getExecJobLogCount(@Validated @RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
return execLogService.queryExecLogCount(request);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecJobLogOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除计划任务日志")
|
||||
@@ -113,19 +122,11 @@ public class ExecJobLogController {
|
||||
return execHostLogService.deleteExecHostLogById(id);
|
||||
}
|
||||
|
||||
@PostMapping("/query-count")
|
||||
@Operation(summary = "查询计划任务日志数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:management:clear')")
|
||||
public Long getExecJobLogCount(@RequestBody ExecLogQueryRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
return execLogService.queryExecLogCount(request);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecJobLogOperatorType.CLEAR)
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空计划任务日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job-log:management:clear')")
|
||||
public Integer clearExecJobLog(@RequestBody ExecLogQueryRequest request) {
|
||||
public Integer clearExecJobLog(@Validated @RequestBody ExecLogClearRequest request) {
|
||||
request.setSource(SOURCE);
|
||||
return execLogService.clearExecLog(request);
|
||||
}
|
||||
@@ -167,4 +168,3 @@ public class ExecJobLogController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.orion.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.visor.framework.common.validator.group.Page;
|
||||
import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.visor.module.asset.define.operator.ExecTemplateOperatorType;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecTemplateCreateRequest;
|
||||
@@ -41,6 +42,7 @@ public class ExecTemplateController {
|
||||
@Resource
|
||||
private ExecTemplateService execTemplateService;
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecTemplateOperatorType.CREATE)
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建执行模板")
|
||||
@@ -49,6 +51,7 @@ public class ExecTemplateController {
|
||||
return execTemplateService.createExecTemplate(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecTemplateOperatorType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新执行模板")
|
||||
@@ -83,6 +86,7 @@ public class ExecTemplateController {
|
||||
return execTemplateService.getExecTemplatePage(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecTemplateOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除执行模板")
|
||||
@@ -92,6 +96,7 @@ public class ExecTemplateController {
|
||||
return execTemplateService.deleteExecTemplateById(id);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(ExecTemplateOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除执行模板")
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.visor.module.asset.define.operator.HostConnectLogOperatorType;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.HostConnectLogVO;
|
||||
import com.orion.visor.module.asset.service.HostConnectLogService;
|
||||
@@ -49,6 +50,13 @@ public class HostConnectLogController {
|
||||
return hostConnectLogService.getHostConnectLogPage(request);
|
||||
}
|
||||
|
||||
@PostMapping("/count")
|
||||
@Operation(summary = "查询主机连接日志数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-connect-log:management:query')")
|
||||
public Long getHostConnectLogCount(@Validated @RequestBody HostConnectLogQueryRequest request) {
|
||||
return hostConnectLogService.getHostConnectLogCount(request);
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PostMapping("/session")
|
||||
@Operation(summary = "查询全部主机连接会话")
|
||||
@@ -73,18 +81,11 @@ public class HostConnectLogController {
|
||||
return hostConnectLogService.deleteHostConnectLog(idList);
|
||||
}
|
||||
|
||||
@PostMapping("/query-count")
|
||||
@Operation(summary = "查询主机连接日志数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-connect-log:management:clear')")
|
||||
public Long getHostConnectLogCount(@RequestBody HostConnectLogQueryRequest request) {
|
||||
return hostConnectLogService.getHostConnectLogCount(request);
|
||||
}
|
||||
|
||||
@OperatorLog(HostConnectLogOperatorType.CLEAR)
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空主机连接日志")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-connect-log:management:clear')")
|
||||
public Integer clearHostConnectLog(@RequestBody HostConnectLogQueryRequest request) {
|
||||
public Integer clearHostConnectLog(@Validated @RequestBody HostConnectLogClearRequest request) {
|
||||
return hostConnectLogService.clearHostConnectLog(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class HostController {
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "查询主机")
|
||||
@Parameter(name = "type", description = "type", required = false)
|
||||
@Parameter(name = "type", description = "type")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host:query')")
|
||||
public List<HostVO> getHostList(@RequestParam(value = "type", required = false) String type) {
|
||||
return hostService.getHostList(type);
|
||||
@@ -112,6 +112,14 @@ public class HostController {
|
||||
return hostService.getHostPage(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@PostMapping("/count")
|
||||
@Operation(summary = "查询主机数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host:query')")
|
||||
public Long getHostExportCount(@Validated @RequestBody HostQueryRequest request) {
|
||||
return hostService.getHostCount(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(HostOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.orion.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.visor.module.asset.define.operator.UploadTaskOperatorType;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskCreateRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskRequest;
|
||||
@@ -94,6 +95,13 @@ public class UploadTaskController {
|
||||
return uploadTaskService.getUploadTaskStatus(idList, queryFiles);
|
||||
}
|
||||
|
||||
@PostMapping("/count")
|
||||
@Operation(summary = "查询上传任务数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:upload-task:query')")
|
||||
public Long getUploadTaskCount(@RequestBody UploadTaskQueryRequest request) {
|
||||
return uploadTaskService.getUploadTaskCount(request);
|
||||
}
|
||||
|
||||
@OperatorLog(UploadTaskOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除上传任务")
|
||||
@@ -112,18 +120,11 @@ public class UploadTaskController {
|
||||
return uploadTaskService.deleteUploadTaskByIdList(idList);
|
||||
}
|
||||
|
||||
@PostMapping("/query-count")
|
||||
@Operation(summary = "查询上传任务数量")
|
||||
@PreAuthorize("@ss.hasPermission('asset:upload-task:management:clear')")
|
||||
public Long getUploadTaskCount(@RequestBody UploadTaskQueryRequest request) {
|
||||
return uploadTaskService.getUploadTaskCount(request);
|
||||
}
|
||||
|
||||
@OperatorLog(UploadTaskOperatorType.CLEAR)
|
||||
@PostMapping("/clear")
|
||||
@Operation(summary = "清空上传任务")
|
||||
@PreAuthorize("@ss.hasPermission('asset:upload-task:management:clear')")
|
||||
public Integer clearUploadTask(@RequestBody UploadTaskQueryRequest request) {
|
||||
public Integer clearUploadTask(@Validated @RequestBody UploadTaskClearRequest request) {
|
||||
return uploadTaskService.clearUploadTask(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,4 +40,6 @@ public interface HostConvert {
|
||||
|
||||
List<HostVO> toList(List<HostDO> domain);
|
||||
|
||||
List<HostBaseVO> toBaseList(List<HostDO> domain);
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class HostOperatorType extends InitializingOperatorTypes {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(L, CREATE, "创建主机 <sb>${name}</sb>"),
|
||||
new OperatorType(L, UPDATE, "修改主机 <sb>${name}</sb>"),
|
||||
new OperatorType(H, DELETE, "删除主机 <sb>${name}</sb>"),
|
||||
new OperatorType(H, DELETE, "删除主机 <sb>${count}</sb> 条"),
|
||||
new OperatorType(M, UPDATE_STATUS, "修改主机状态 <sb>${name}</sb> - <sb>${status}</sb>"),
|
||||
new OperatorType(M, UPDATE_CONFIG, "修改主机配置 <sb>${name}</sb>"),
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ public class UploadTaskOperatorType extends InitializingOperatorTypes {
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(M, UPLOAD, "批量上传文件 <sb>${count}</sb>个 (${name})"),
|
||||
new OperatorType(M, UPLOAD, "批量上传文件 <sb>${count}</sb> 个 (${name})"),
|
||||
new OperatorType(M, CANCEL, "取消上传文件 <sb>${name}</sb>"),
|
||||
new OperatorType(H, DELETE, "删除上传记录 <sb>${count}</sb>条"),
|
||||
new OperatorType(H, CLEAR, "清理上传记录 <sb>${count}</sb>条"),
|
||||
|
||||
@@ -48,6 +48,10 @@ public class UploadTaskFileDO extends BaseDO {
|
||||
@TableField("file_path")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "实际文件路径")
|
||||
@TableField("real_file_path")
|
||||
private String realFilePath;
|
||||
|
||||
@Schema(description = "文件大小")
|
||||
@TableField("file_size")
|
||||
private Long fileSize;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.orion.visor.module.asset.entity.request.exec;
|
||||
|
||||
import com.orion.visor.framework.common.entity.DataClearRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 批量执行日志 清理请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.1
|
||||
* @since 2024-3-11 11:31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "ExecLogClearRequest", description = "批量执行日志 清理请求对象")
|
||||
public class ExecLogClearRequest extends ExecLogQueryRequest implements DataClearRequest {
|
||||
|
||||
@NotNull
|
||||
@Min(value = 1)
|
||||
@Max(value = 1000)
|
||||
@Schema(description = "清理数量限制")
|
||||
private Integer limit;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.orion.visor.module.asset.entity.request.host;
|
||||
|
||||
import com.orion.visor.framework.common.entity.DataClearRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 主机连接日志 清理请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-26 22:09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "HostConnectLogClearRequest", description = "主机连接日志 清理请求对象")
|
||||
public class HostConnectLogClearRequest extends HostConnectLogQueryRequest implements DataClearRequest {
|
||||
|
||||
@NotNull
|
||||
@Min(value = 1)
|
||||
@Max(value = 2000)
|
||||
@Schema(description = "清理数量限制")
|
||||
private Integer limit;
|
||||
|
||||
}
|
||||
@@ -2,9 +2,11 @@ package com.orion.visor.module.asset.entity.request.host;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.orion.visor.framework.common.entity.PageRequest;
|
||||
import com.orion.visor.framework.common.validator.group.Id;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -24,6 +26,7 @@ import java.util.List;
|
||||
@Schema(name = "HostConnectLogQueryRequest", description = "主机连接日志 查询请求对象")
|
||||
public class HostConnectLogQueryRequest extends PageRequest {
|
||||
|
||||
@NotNull(groups = Id.class)
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
|
||||
@@ -5,8 +5,9 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
@@ -45,7 +46,8 @@ public class HostCreateRequest implements Serializable {
|
||||
@Schema(description = "主机地址")
|
||||
private String address;
|
||||
|
||||
@Range(min = 1, max = 65535)
|
||||
@Min(value = 1)
|
||||
@Max(value = 65535)
|
||||
@Schema(description = "主机端口")
|
||||
private Integer port;
|
||||
|
||||
|
||||
@@ -5,11 +5,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@@ -46,7 +43,9 @@ public class HostUpdateRequest implements Serializable {
|
||||
@Schema(description = "主机地址")
|
||||
private String address;
|
||||
|
||||
@Range(min = 1, max = 65535)
|
||||
@NotNull
|
||||
@Min(value = 1)
|
||||
@Max(value = 65535)
|
||||
@Schema(description = "主机端口")
|
||||
private Integer port;
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.orion.visor.module.asset.entity.request.upload;
|
||||
|
||||
import com.orion.visor.framework.common.entity.DataClearRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 上传任务 清理请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.7
|
||||
* @since 2024-5-7 22:15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "UploadTaskClearRequest", description = "上传任务 清理请求对象")
|
||||
public class UploadTaskClearRequest extends UploadTaskQueryRequest implements DataClearRequest {
|
||||
|
||||
@NotNull
|
||||
@Min(value = 1)
|
||||
@Max(value = 2000)
|
||||
@Schema(description = "清理数量限制")
|
||||
private Integer limit;
|
||||
|
||||
}
|
||||
@@ -40,6 +40,9 @@ public class UploadTaskFileVO implements Serializable {
|
||||
@Schema(description = "文件路径")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "实际文件路径")
|
||||
private String realFilePath;
|
||||
|
||||
@Schema(description = "文件大小")
|
||||
private Long fileSize;
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@ package com.orion.visor.module.asset.enums;
|
||||
public enum HostExtraSshAuthTypeEnum {
|
||||
|
||||
/**
|
||||
* 默认验证方式
|
||||
* 默认认证方式
|
||||
*/
|
||||
DEFAULT,
|
||||
|
||||
/**
|
||||
* 自定义密钥验证
|
||||
* 自定义密钥认证
|
||||
*/
|
||||
CUSTOM_KEY,
|
||||
|
||||
/**
|
||||
* 自定义身份验证
|
||||
* 自定义身份认证
|
||||
*/
|
||||
CUSTOM_IDENTITY,
|
||||
|
||||
@@ -28,14 +28,14 @@ public enum HostExtraSshAuthTypeEnum {
|
||||
|
||||
public static HostExtraSshAuthTypeEnum of(String type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
return DEFAULT;
|
||||
}
|
||||
for (HostExtraSshAuthTypeEnum value : values()) {
|
||||
if (value.name().equals(type)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.orion.visor.module.asset.enums;
|
||||
|
||||
/**
|
||||
* 主机验证类型 - ssh
|
||||
* 主机认证类型 - ssh
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
@@ -10,17 +10,17 @@ package com.orion.visor.module.asset.enums;
|
||||
public enum HostSshAuthTypeEnum {
|
||||
|
||||
/**
|
||||
* 密码验证
|
||||
* 密码认证
|
||||
*/
|
||||
PASSWORD,
|
||||
|
||||
/**
|
||||
* 密钥验证
|
||||
* 密钥认证
|
||||
*/
|
||||
KEY,
|
||||
|
||||
/**
|
||||
* 身份验证
|
||||
* 身份认证
|
||||
*/
|
||||
IDENTITY,
|
||||
|
||||
@@ -28,14 +28,14 @@ public enum HostSshAuthTypeEnum {
|
||||
|
||||
public static HostSshAuthTypeEnum of(String type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
return PASSWORD;
|
||||
}
|
||||
for (HostSshAuthTypeEnum value : values()) {
|
||||
if (value.name().equals(type)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return PASSWORD;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,14 +30,34 @@ public enum HostSshOsTypeEnum {
|
||||
|
||||
public static HostSshOsTypeEnum of(String type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
return LINUX;
|
||||
}
|
||||
for (HostSshOsTypeEnum value : values()) {
|
||||
if (value.name().equals(type)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return LINUX;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为 linux 系统
|
||||
*
|
||||
* @param type type
|
||||
* @return isLinux
|
||||
*/
|
||||
public static boolean isLinux(String type) {
|
||||
return LINUX.name().equals(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为 windows 系统
|
||||
*
|
||||
* @param type type
|
||||
* @return isWindows
|
||||
*/
|
||||
public static boolean isWindows(String type) {
|
||||
return WINDOWS.name().equals(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,11 +6,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 主机 SSH 配置
|
||||
@@ -64,7 +61,8 @@ public class HostSshConfigModel implements GenericsDataModel, UpdatePasswordActi
|
||||
* 连接超时时间
|
||||
*/
|
||||
@NotNull
|
||||
@Range(min = 0, max = 100000)
|
||||
@Min(value = 1)
|
||||
@Max(value = 100000)
|
||||
private Integer connectTimeout;
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,10 +55,6 @@ public class HostSshConfigStrategy extends AbstractGenericsDataStrategy<HostSshC
|
||||
|
||||
@Override
|
||||
protected void preValid(HostSshConfigModel model) {
|
||||
// 验证认证类型
|
||||
Valid.valid(HostSshAuthTypeEnum::of, model.getAuthType());
|
||||
// 验证系统版本
|
||||
Valid.valid(HostSshOsTypeEnum::of, model.getOsType());
|
||||
// 验证编码格式
|
||||
this.validCharset(model.getCharset());
|
||||
this.validCharset(model.getFileNameCharset());
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.exception.AuthenticationException;
|
||||
import com.orion.lang.exception.ConnectionRuntimeException;
|
||||
import com.orion.lang.exception.SftpException;
|
||||
import com.orion.lang.exception.argument.InvalidArgumentException;
|
||||
import com.orion.lang.support.timeout.TimeoutChecker;
|
||||
import com.orion.lang.support.timeout.TimeoutEndpoint;
|
||||
import com.orion.lang.utils.Booleans;
|
||||
@@ -16,7 +15,9 @@ import com.orion.net.host.SessionStore;
|
||||
import com.orion.net.host.sftp.SftpExecutor;
|
||||
import com.orion.net.host.ssh.command.CommandExecutor;
|
||||
import com.orion.spring.SpringHolder;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.file.FileClient;
|
||||
import com.orion.visor.framework.common.utils.PathUtils;
|
||||
import com.orion.visor.module.asset.dao.ExecHostLogDAO;
|
||||
import com.orion.visor.module.asset.entity.domain.ExecHostLogDO;
|
||||
import com.orion.visor.module.asset.entity.dto.HostTerminalConnectDTO;
|
||||
@@ -159,11 +160,8 @@ public abstract class BaseExecCommandHandler implements IExecCommandHandler {
|
||||
// 打开 sftp
|
||||
sftpExecutor = sessionStore.getSftpExecutor(execHostCommand.getFileNameCharset());
|
||||
sftpExecutor.connect();
|
||||
// 必须要以 / 开头
|
||||
String scriptPath = execHostCommand.getScriptPath();
|
||||
if (!scriptPath.startsWith("/")) {
|
||||
scriptPath = "/" + scriptPath;
|
||||
}
|
||||
// 文件上传必须要以 / 开头
|
||||
String scriptPath = PathUtils.prependSeparator(execHostCommand.getScriptPath());
|
||||
// 创建文件
|
||||
sftpExecutor.touch(scriptPath);
|
||||
// 写入命令
|
||||
@@ -225,29 +223,33 @@ public abstract class BaseExecCommandHandler implements IExecCommandHandler {
|
||||
Long id = execHostCommand.getHostLogId();
|
||||
String statusName = status.name();
|
||||
log.info("BaseExecCommandHandler.updateStatus start id: {}, status: {}", id, statusName);
|
||||
updateRecord.setId(id);
|
||||
updateRecord.setStatus(statusName);
|
||||
if (ExecHostStatusEnum.RUNNING.equals(status)) {
|
||||
// 运行中
|
||||
updateRecord.setStartTime(new Date());
|
||||
} else if (ExecHostStatusEnum.COMPLETED.equals(status)) {
|
||||
// 完成
|
||||
updateRecord.setFinishTime(new Date());
|
||||
updateRecord.setExitCode(executor.getExitCode());
|
||||
this.exitCode = executor.getExitCode();
|
||||
} else if (ExecHostStatusEnum.FAILED.equals(status)) {
|
||||
// 失败
|
||||
updateRecord.setFinishTime(new Date());
|
||||
updateRecord.setErrorMessage(this.getErrorMessage(ex));
|
||||
} else if (ExecHostStatusEnum.TIMEOUT.equals(status)) {
|
||||
// 超时
|
||||
updateRecord.setFinishTime(new Date());
|
||||
} else if (ExecHostStatusEnum.INTERRUPTED.equals(status)) {
|
||||
// 中断
|
||||
updateRecord.setFinishTime(new Date());
|
||||
try {
|
||||
updateRecord.setId(id);
|
||||
updateRecord.setStatus(statusName);
|
||||
if (ExecHostStatusEnum.RUNNING.equals(status)) {
|
||||
// 运行中
|
||||
updateRecord.setStartTime(new Date());
|
||||
} else if (ExecHostStatusEnum.COMPLETED.equals(status)) {
|
||||
// 完成
|
||||
updateRecord.setFinishTime(new Date());
|
||||
updateRecord.setExitCode(executor.getExitCode());
|
||||
this.exitCode = executor.getExitCode();
|
||||
} else if (ExecHostStatusEnum.FAILED.equals(status)) {
|
||||
// 失败
|
||||
updateRecord.setFinishTime(new Date());
|
||||
updateRecord.setErrorMessage(this.getErrorMessage(ex));
|
||||
} else if (ExecHostStatusEnum.TIMEOUT.equals(status)) {
|
||||
// 超时
|
||||
updateRecord.setFinishTime(new Date());
|
||||
} else if (ExecHostStatusEnum.INTERRUPTED.equals(status)) {
|
||||
// 中断
|
||||
updateRecord.setFinishTime(new Date());
|
||||
}
|
||||
int effect = execHostLogDAO.updateById(updateRecord);
|
||||
log.info("BaseExecCommandHandler.updateStatus finish id: {}, effect: {}", id, effect);
|
||||
} catch (Exception e) {
|
||||
log.error("BaseExecCommandHandler.updateStatus error id: {}", id, e);
|
||||
}
|
||||
int effect = execHostLogDAO.updateById(updateRecord);
|
||||
log.info("BaseExecCommandHandler.updateStatus finish id: {}, effect: {}", id, effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -289,17 +291,25 @@ public abstract class BaseExecCommandHandler implements IExecCommandHandler {
|
||||
* @return errorMessage
|
||||
*/
|
||||
protected String getErrorMessage(Exception ex) {
|
||||
if (ex == null) {
|
||||
return null;
|
||||
}
|
||||
String message;
|
||||
if (ex instanceof InvalidArgumentException || ex instanceof IllegalArgumentException) {
|
||||
if (ErrorMessage.isBizException(ex)) {
|
||||
// 业务异常
|
||||
message = ex.getMessage();
|
||||
} else if (ex instanceof ConnectionRuntimeException) {
|
||||
message = "连接失败";
|
||||
// 连接异常
|
||||
message = ErrorMessage.CONNECT_ERROR;
|
||||
} else if (ex instanceof AuthenticationException) {
|
||||
message = "认证失败";
|
||||
// 认证异常
|
||||
message = ErrorMessage.AUTH_ERROR;
|
||||
} else if (ex instanceof SftpException) {
|
||||
message = "脚本上传失败";
|
||||
// 上传异常
|
||||
message = ErrorMessage.SCRIPT_UPLOAD_ERROR;
|
||||
} else {
|
||||
message = "执行失败";
|
||||
// 其他异常
|
||||
message = ErrorMessage.EXEC_ERROR;
|
||||
}
|
||||
return Strings.retain(message, 250);
|
||||
}
|
||||
|
||||
@@ -154,24 +154,28 @@ public class ExecTaskHandler implements IExecTaskHandler {
|
||||
*/
|
||||
private void updateStatus(ExecStatusEnum status) {
|
||||
Long id = execCommand.getLogId();
|
||||
String statusName = status.name();
|
||||
log.info("ExecTaskHandler-updateStatus start id: {}, status: {}", id, statusName);
|
||||
ExecLogDO update = new ExecLogDO();
|
||||
update.setId(id);
|
||||
update.setStatus(statusName);
|
||||
if (ExecStatusEnum.RUNNING.equals(status)) {
|
||||
// 执行中
|
||||
this.startTime = new Date();
|
||||
update.setStartTime(new Date());
|
||||
} else if (ExecStatusEnum.COMPLETED.equals(status)) {
|
||||
// 执行完成
|
||||
update.setFinishTime(new Date());
|
||||
} else if (ExecStatusEnum.FAILED.equals(status)) {
|
||||
// 执行失败
|
||||
update.setFinishTime(new Date());
|
||||
try {
|
||||
String statusName = status.name();
|
||||
log.info("ExecTaskHandler-updateStatus start id: {}, status: {}", id, statusName);
|
||||
ExecLogDO update = new ExecLogDO();
|
||||
update.setId(id);
|
||||
update.setStatus(statusName);
|
||||
if (ExecStatusEnum.RUNNING.equals(status)) {
|
||||
// 执行中
|
||||
this.startTime = new Date();
|
||||
update.setStartTime(new Date());
|
||||
} else if (ExecStatusEnum.COMPLETED.equals(status)) {
|
||||
// 执行完成
|
||||
update.setFinishTime(new Date());
|
||||
} else if (ExecStatusEnum.FAILED.equals(status)) {
|
||||
// 执行失败
|
||||
update.setFinishTime(new Date());
|
||||
}
|
||||
int effect = execLogDAO.updateById(update);
|
||||
log.info("ExecTaskHandler-updateStatus finish id: {}, effect: {}", id, effect);
|
||||
} catch (Exception e) {
|
||||
log.error("ExecTaskHandler-updateStatus error id: {}", id, e);
|
||||
}
|
||||
int effect = execLogDAO.updateById(update);
|
||||
log.info("ExecTaskHandler-updateStatus finish id: {}, effect: {}", id, effect);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.orion.visor.module.asset.handler.host.exec.log;
|
||||
|
||||
import com.orion.visor.framework.common.annotation.Keep;
|
||||
import com.orion.lang.annotation.Keep;
|
||||
import com.orion.visor.framework.common.constant.ExtraFieldConst;
|
||||
import com.orion.visor.framework.common.file.FileClient;
|
||||
import com.orion.visor.framework.websocket.core.utils.WebSockets;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.orion.lang.utils.Strings;
|
||||
import com.orion.net.host.SessionHolder;
|
||||
import com.orion.net.host.SessionLogger;
|
||||
import com.orion.net.host.SessionStore;
|
||||
import com.orion.visor.framework.common.constant.AppConst;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.utils.CryptoUtils;
|
||||
import com.orion.visor.module.asset.entity.dto.HostTerminalConnectDTO;
|
||||
@@ -43,6 +44,8 @@ public class SessionStores {
|
||||
SessionHolder sessionHolder = SessionHolder.create();
|
||||
sessionHolder.setLogger(SessionLogger.INFO);
|
||||
SessionStore session = createSessionStore(conn, sessionHolder);
|
||||
// 设置版本
|
||||
session.getSession().setClientVersion("SSH-2.0-ORION_VISOR_V" + AppConst.VERSION);
|
||||
// 连接
|
||||
session.connect();
|
||||
log.info("SessionStores-open-success hostId: {}, address: {}, username: {}", hostId, address, username);
|
||||
@@ -50,7 +53,7 @@ public class SessionStores {
|
||||
} catch (Exception e) {
|
||||
String message = e.getMessage();
|
||||
log.error("SessionStores-open-error hostId: {}, address: {}, username: {}, message: {}", hostId, address, username, message, e);
|
||||
throw Exceptions.runtime(getErrorMessage(e), e);
|
||||
throw Exceptions.app(getErrorMessage(e), e);
|
||||
} finally {
|
||||
CURRENT_ADDRESS.remove();
|
||||
}
|
||||
@@ -86,7 +89,10 @@ public class SessionStores {
|
||||
SessionStore session = sessionHolder.getSession(conn.getHostAddress(), conn.getHostPort(), conn.getUsername());
|
||||
// 使用密码认证
|
||||
if (!useKey) {
|
||||
session.password(CryptoUtils.decryptAsString(conn.getPassword()));
|
||||
String password = conn.getPassword();
|
||||
if (!Strings.isEmpty(password)) {
|
||||
session.password(CryptoUtils.decryptAsString(password));
|
||||
}
|
||||
}
|
||||
// 超时时间
|
||||
session.timeout(conn.getTimeout());
|
||||
|
||||
@@ -97,13 +97,8 @@ public abstract class AbstractTerminalHandler<T extends TerminalBasePayload> imp
|
||||
* @return msg
|
||||
*/
|
||||
protected String getErrorMessage(Exception ex) {
|
||||
if (ex == null) {
|
||||
return null;
|
||||
}
|
||||
if (ex instanceof InvalidArgumentException || ex instanceof IllegalArgumentException) {
|
||||
return ex.getMessage();
|
||||
}
|
||||
return ErrorMessage.OPERATE_ERROR;
|
||||
// 获取错误信息
|
||||
return ErrorMessage.getErrorMessage(ex, ErrorMessage.OPERATE_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,13 +65,15 @@ public class TerminalConnectHandler extends AbstractTerminalHandler<TerminalConn
|
||||
// 移除会话连接信息
|
||||
channel.getAttributes().remove(sessionId);
|
||||
Exception ex = null;
|
||||
ITerminalSession session = null;
|
||||
try {
|
||||
// 连接主机
|
||||
ITerminalSession session = this.connect(sessionId, connect, channel, payload);
|
||||
session = this.connect(sessionId, connect, channel, payload);
|
||||
// 添加会话到 manager
|
||||
hostTerminalManager.addSession(session);
|
||||
} catch (Exception e) {
|
||||
ex = e;
|
||||
Streams.close(session);
|
||||
// 修改连接状态为失败
|
||||
Map<String, Object> extra = Maps.newMap(4);
|
||||
extra.put(ExtraFieldConst.ERROR_MESSAGE, this.getConnectErrorMessage(e));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.orion.visor.module.asset.handler.host.transfer.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.exception.argument.InvalidArgumentException;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.websocket.core.utils.WebSockets;
|
||||
@@ -62,13 +61,15 @@ public class TransferUtils {
|
||||
public static String getErrorMessage(Exception ex) {
|
||||
if (ex == null) {
|
||||
return null;
|
||||
} else if (ex instanceof InvalidArgumentException || ex instanceof IllegalArgumentException) {
|
||||
} else if (ErrorMessage.isBizException(ex)) {
|
||||
// 业务异常
|
||||
String message = ex.getMessage();
|
||||
if (Strings.isBlank(message)) {
|
||||
return ErrorMessage.OPERATE_ERROR;
|
||||
}
|
||||
return message;
|
||||
} else if (ex instanceof ClientAbortException) {
|
||||
// 客户端主动断开
|
||||
return ErrorMessage.CLIENT_ABORT;
|
||||
}
|
||||
return ErrorMessage.OPERATE_ERROR;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.orion.visor.module.asset.handler.host.upload.task;
|
||||
|
||||
import com.orion.lang.utils.Threads;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.lang.utils.io.Streams;
|
||||
import com.orion.lang.utils.time.Dates;
|
||||
import com.orion.spring.SpringHolder;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ExtraFieldConst;
|
||||
import com.orion.visor.module.asset.dao.UploadTaskDAO;
|
||||
import com.orion.visor.module.asset.dao.UploadTaskFileDAO;
|
||||
@@ -143,7 +141,7 @@ public class FileUploadTask implements IFileUploadTask {
|
||||
.map(s -> FileUploadFileItemDTO.builder()
|
||||
.id(s.getId())
|
||||
.fileId(s.getFileId())
|
||||
.remotePath(Files1.getPath(Const.SLASH + record.getRemotePath() + Const.SLASH + s.getFilePath()))
|
||||
.remotePath(s.getRealFilePath())
|
||||
.status(UploadTaskFileStatusEnum.WAITING.name())
|
||||
.current(0L)
|
||||
.build())
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.orion.visor.module.asset.handler.host.upload.uploader;
|
||||
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.lang.utils.io.Streams;
|
||||
import com.orion.net.host.SessionStore;
|
||||
import com.orion.net.host.sftp.SftpExecutor;
|
||||
@@ -10,12 +7,10 @@ import com.orion.spring.SpringHolder;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.enums.EndpointDefine;
|
||||
import com.orion.visor.framework.common.file.FileClient;
|
||||
import com.orion.visor.framework.common.utils.PathUtils;
|
||||
import com.orion.visor.module.asset.dao.UploadTaskFileDAO;
|
||||
import com.orion.visor.module.asset.define.config.AppSftpConfig;
|
||||
import com.orion.visor.module.asset.entity.domain.UploadTaskFileDO;
|
||||
import com.orion.visor.module.asset.entity.dto.HostTerminalConnectDTO;
|
||||
import com.orion.visor.module.asset.enums.HostSshOsTypeEnum;
|
||||
import com.orion.visor.module.asset.enums.UploadTaskFileStatusEnum;
|
||||
import com.orion.visor.module.asset.handler.host.jsch.SessionStores;
|
||||
import com.orion.visor.module.asset.handler.host.upload.model.FileUploadFileItemDTO;
|
||||
@@ -28,7 +23,6 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -106,10 +100,8 @@ public class FileUploader implements IFileUploader {
|
||||
private boolean initSession() {
|
||||
log.info("HostFileUploader.initSession start taskId: {}, hostId: {}", taskId, hostId);
|
||||
try {
|
||||
// 替换用户路径
|
||||
HostTerminalConnectDTO connectInfo = hostTerminalService.getTerminalConnectInfo(hostId);
|
||||
this.replaceRemotePathVariable(connectInfo.getOsType(), connectInfo.getUsername());
|
||||
// 打开会话
|
||||
HostTerminalConnectDTO connectInfo = hostTerminalService.getTerminalConnectInfo(hostId);
|
||||
this.sessionStore = SessionStores.openSessionStore(connectInfo);
|
||||
this.executor = sessionStore.getSftpExecutor(connectInfo.getFileNameCharset());
|
||||
executor.connect();
|
||||
@@ -222,27 +214,6 @@ public class FileUploader implements IFileUploader {
|
||||
uploadTaskFileDAO.updateById(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换文件路径变量
|
||||
*
|
||||
* @param osType osType
|
||||
* @param username username
|
||||
*/
|
||||
private void replaceRemotePathVariable(String osType, String username) {
|
||||
// 包含变量
|
||||
if (!files.get(0).getRemotePath().contains(Const.DOLLAR)) {
|
||||
return;
|
||||
}
|
||||
String home = PathUtils.getHomePath(HostSshOsTypeEnum.WINDOWS.name().equals(osType), username);
|
||||
// 替换变量
|
||||
Map<String, String> env = Maps.newMap(4);
|
||||
env.put("username", username);
|
||||
env.put("home", home);
|
||||
for (FileUploadFileItemDTO file : files) {
|
||||
file.setRemotePath(Files1.getPath(Strings.format(file.getRemotePath(), env)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
log.info("HostFileUploader.cancel taskId: {}, hostId: {}, canceled: {}, closed: {}", taskId, hostId, canceled, closed);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.orion.visor.module.asset.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.module.asset.entity.domain.ExecLogDO;
|
||||
import com.orion.visor.module.asset.entity.dto.ExecLogTailDTO;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogTailRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.ExecLogStatusVO;
|
||||
@@ -93,7 +96,7 @@ public interface ExecLogService {
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer clearExecLog(ExecLogQueryRequest request);
|
||||
Integer clearExecLog(ExecLogClearRequest request);
|
||||
|
||||
/**
|
||||
* 中断命令执行
|
||||
@@ -143,4 +146,12 @@ public interface ExecLogService {
|
||||
*/
|
||||
void asyncDeleteLogFiles(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
LambdaQueryWrapper<ExecLogDO> buildQueryWrapper(ExecLogQueryRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.orion.visor.module.asset.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.module.asset.entity.domain.HostConnectLogDO;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogCreateRequest;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.HostConnectLogVO;
|
||||
@@ -95,7 +97,7 @@ public interface HostConnectLogService {
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer clearHostConnectLog(HostConnectLogQueryRequest request);
|
||||
Integer clearHostConnectLog(HostConnectLogClearRequest request);
|
||||
|
||||
/**
|
||||
* 强制断开主机连接
|
||||
@@ -105,4 +107,12 @@ public interface HostConnectLogService {
|
||||
*/
|
||||
Integer forceOffline(HostConnectLogQueryRequest request);
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
LambdaQueryWrapper<HostConnectLogDO> buildQueryWrapper(HostConnectLogQueryRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.orion.visor.module.asset.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.module.asset.entity.domain.HostDO;
|
||||
import com.orion.visor.module.asset.entity.request.host.*;
|
||||
import com.orion.visor.module.asset.entity.vo.HostConfigVO;
|
||||
import com.orion.visor.module.asset.entity.vo.HostVO;
|
||||
@@ -80,6 +82,14 @@ public interface HostService {
|
||||
*/
|
||||
DataGrid<HostVO> getHostPage(HostQueryRequest request);
|
||||
|
||||
/**
|
||||
* 查询主机数量
|
||||
*
|
||||
* @param request request
|
||||
* @return count
|
||||
*/
|
||||
Long getHostCount(HostQueryRequest request);
|
||||
|
||||
/**
|
||||
* 通过 id 删除主机
|
||||
*
|
||||
@@ -110,4 +120,17 @@ public interface HostService {
|
||||
*/
|
||||
Long getCurrentUpdateConfigHostId();
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
*/
|
||||
void clearCache();
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
LambdaQueryWrapper<HostDO> buildQueryWrapper(HostQueryRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.orion.visor.module.asset.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.module.asset.entity.domain.UploadTaskDO;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskCreateRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskRequest;
|
||||
@@ -66,7 +69,7 @@ public interface UploadTaskService {
|
||||
* @param request request
|
||||
* @return count
|
||||
*/
|
||||
Integer clearUploadTask(UploadTaskQueryRequest request);
|
||||
Integer clearUploadTask(UploadTaskClearRequest request);
|
||||
|
||||
/**
|
||||
* 删除上传任务
|
||||
@@ -112,4 +115,12 @@ public interface UploadTaskService {
|
||||
*/
|
||||
void clearUploadSwapFiles(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
LambdaQueryWrapper<UploadTaskDO> buildQueryWrapper(UploadTaskQueryRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.orion.visor.module.asset.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.annotation.Keep;
|
||||
import com.orion.lang.function.Functions;
|
||||
import com.orion.lang.id.UUIds;
|
||||
import com.orion.lang.utils.Strings;
|
||||
@@ -11,7 +12,6 @@ import com.orion.lang.utils.json.matcher.ReplacementFormatter;
|
||||
import com.orion.lang.utils.json.matcher.ReplacementFormatters;
|
||||
import com.orion.lang.utils.time.Dates;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.annotation.Keep;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.constant.FileConst;
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.orion.visor.module.asset.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.annotation.Keep;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.exception.argument.InvalidArgumentException;
|
||||
import com.orion.lang.id.UUIds;
|
||||
import com.orion.lang.utils.Arrays1;
|
||||
import com.orion.lang.utils.Objects1;
|
||||
@@ -13,12 +13,12 @@ import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.lang.utils.io.Streams;
|
||||
import com.orion.spring.SpringHolder;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.annotation.Keep;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.constant.FileConst;
|
||||
import com.orion.visor.framework.common.enums.EndpointDefine;
|
||||
import com.orion.visor.framework.common.file.FileClient;
|
||||
import com.orion.visor.framework.common.utils.SqlUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
@@ -31,6 +31,7 @@ import com.orion.visor.module.asset.entity.domain.ExecHostLogDO;
|
||||
import com.orion.visor.module.asset.entity.domain.ExecLogDO;
|
||||
import com.orion.visor.module.asset.entity.dto.ExecHostLogTailDTO;
|
||||
import com.orion.visor.module.asset.entity.dto.ExecLogTailDTO;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogTailRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.ExecHostLogVO;
|
||||
@@ -92,7 +93,8 @@ public class ExecLogServiceImpl implements ExecLogService {
|
||||
@Override
|
||||
public DataGrid<ExecLogVO> getExecLogPage(ExecLogQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<ExecLogDO> wrapper = this.buildQueryWrapper(request);
|
||||
LambdaQueryWrapper<ExecLogDO> wrapper = this.buildQueryWrapper(request)
|
||||
.orderByDesc(ExecLogDO::getId);
|
||||
// 查询
|
||||
return execLogDAO.of(wrapper)
|
||||
.page(request)
|
||||
@@ -219,16 +221,23 @@ public class ExecLogServiceImpl implements ExecLogService {
|
||||
|
||||
@Override
|
||||
public Long queryExecLogCount(ExecLogQueryRequest request) {
|
||||
return execLogDAO.selectCount(this.buildQueryWrapper(request));
|
||||
// 条件
|
||||
LambdaQueryWrapper<ExecLogDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return execLogDAO.of()
|
||||
.wrapper(wrapper)
|
||||
.countMax(request.getLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer clearExecLog(ExecLogQueryRequest request) {
|
||||
public Integer clearExecLog(ExecLogClearRequest request) {
|
||||
log.info("ExecLogService.clearExecLog start {}", JSON.toJSONString(request));
|
||||
// 查询
|
||||
LambdaQueryWrapper<ExecLogDO> wrapper = this.buildQueryWrapper(request)
|
||||
.select(ExecLogDO::getId);
|
||||
.select(ExecLogDO::getId)
|
||||
.orderByAsc(ExecLogDO::getId)
|
||||
.last(SqlUtils.limit(request.getLimit()));
|
||||
List<Long> idList = execLogDAO.selectList(wrapper)
|
||||
.stream()
|
||||
.map(ExecLogDO::getId)
|
||||
@@ -421,10 +430,8 @@ public class ExecLogServiceImpl implements ExecLogService {
|
||||
} catch (Exception e) {
|
||||
log.error("ExecLogService.downloadLogFile error id: {}", id, e);
|
||||
Streams.close(in);
|
||||
String errorMessage = ErrorMessage.FILE_READ_ERROR_CLEAR;
|
||||
if (e instanceof InvalidArgumentException || e instanceof IllegalArgumentException) {
|
||||
errorMessage = e.getMessage();
|
||||
}
|
||||
// 获取错误信息
|
||||
String errorMessage = ErrorMessage.getErrorMessage(e, ErrorMessage.FILE_READ_ERROR_CLEAR);
|
||||
// 响应错误信息
|
||||
try {
|
||||
Servlets.transfer(response, Strings.bytes(errorMessage), FileConst.ERROR_LOG);
|
||||
@@ -450,13 +457,8 @@ public class ExecLogServiceImpl implements ExecLogService {
|
||||
.forEach(Files1::delete);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<ExecLogDO> buildQueryWrapper(ExecLogQueryRequest request) {
|
||||
@Override
|
||||
public LambdaQueryWrapper<ExecLogDO> buildQueryWrapper(ExecLogQueryRequest request) {
|
||||
return execLogDAO.wrapper()
|
||||
.eq(ExecLogDO::getId, request.getId())
|
||||
.eq(ExecLogDO::getUserId, request.getUserId())
|
||||
@@ -469,8 +471,7 @@ public class ExecLogServiceImpl implements ExecLogService {
|
||||
.in(ExecLogDO::getStatus, request.getStatusList())
|
||||
.ge(ExecLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 0))
|
||||
.le(ExecLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 1))
|
||||
.le(ExecLogDO::getCreateTime, request.getCreateTimeLe())
|
||||
.orderByDesc(ExecLogDO::getId);
|
||||
.le(ExecLogDO::getCreateTime, request.getCreateTimeLe());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,12 +8,14 @@ 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.SqlUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.visor.module.asset.convert.HostConnectLogConvert;
|
||||
import com.orion.visor.module.asset.dao.HostConnectLogDAO;
|
||||
import com.orion.visor.module.asset.entity.domain.HostConnectLogDO;
|
||||
import com.orion.visor.module.asset.entity.dto.HostConnectLogExtraDTO;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogClearRequest;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogCreateRequest;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.HostConnectLogVO;
|
||||
@@ -26,6 +28,7 @@ import com.orion.visor.module.asset.service.HostConnectLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
@@ -70,7 +73,8 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
||||
@Override
|
||||
public DataGrid<HostConnectLogVO> getHostConnectLogPage(HostConnectLogQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request);
|
||||
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request)
|
||||
.orderByDesc(HostConnectLogDO::getId);
|
||||
// 查询
|
||||
return hostConnectLogDAO.of(wrapper)
|
||||
.page(request)
|
||||
@@ -101,7 +105,8 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
||||
// 条件
|
||||
request.setIdList(idList);
|
||||
request.setStatus(HostConnectStatusEnum.CONNECTING.name());
|
||||
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request);
|
||||
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request)
|
||||
.orderByDesc(HostConnectLogDO::getId);
|
||||
// 查询
|
||||
return hostConnectLogDAO.of(wrapper)
|
||||
.list(s -> {
|
||||
@@ -167,13 +172,14 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteHostConnectLog(List<Long> idList) {
|
||||
log.info("HostConnectLogService.deleteHostConnectLog start {}", JSON.toJSONString(idList));
|
||||
if (Lists.isEmpty(idList)) {
|
||||
OperatorLogs.add(OperatorLogs.COUNT, Const.N_0);
|
||||
return Const.N_0;
|
||||
}
|
||||
// 删除
|
||||
// 删除日志表
|
||||
int effect = hostConnectLogDAO.deleteBatchIds(idList);
|
||||
log.info("HostConnectLogService.deleteHostConnectLog finish {}", effect);
|
||||
// 设置日志参数
|
||||
@@ -183,15 +189,23 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
||||
|
||||
@Override
|
||||
public Long getHostConnectLogCount(HostConnectLogQueryRequest request) {
|
||||
return hostConnectLogDAO.selectCount(this.buildQueryWrapper(request));
|
||||
// 条件
|
||||
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return hostConnectLogDAO.of()
|
||||
.wrapper(wrapper)
|
||||
.countMax(request.getLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer clearHostConnectLog(HostConnectLogQueryRequest request) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer clearHostConnectLog(HostConnectLogClearRequest request) {
|
||||
log.info("HostConnectLogService.clearHostConnectLog start {}", JSON.toJSONString(request));
|
||||
// 查询
|
||||
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request)
|
||||
.select(HostConnectLogDO::getId);
|
||||
.select(HostConnectLogDO::getId)
|
||||
.orderByAsc(HostConnectLogDO::getId)
|
||||
.last(SqlUtils.limit(request.getLimit()));
|
||||
List<HostConnectLogDO> list = hostConnectLogDAO.selectList(wrapper);
|
||||
if (list.isEmpty()) {
|
||||
log.info("HostConnectLogService.clearHostConnectLog empty");
|
||||
@@ -226,13 +240,8 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
||||
return this.updateStatus(record, HostConnectStatusEnum.FORCE_OFFLINE, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<HostConnectLogDO> buildQueryWrapper(HostConnectLogQueryRequest request) {
|
||||
@Override
|
||||
public LambdaQueryWrapper<HostConnectLogDO> buildQueryWrapper(HostConnectLogQueryRequest request) {
|
||||
return hostConnectLogDAO.wrapper()
|
||||
.eq(HostConnectLogDO::getId, request.getId())
|
||||
.in(HostConnectLogDO::getId, request.getIdList())
|
||||
@@ -245,8 +254,7 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
||||
.in(HostConnectLogDO::getStatus, request.getStatusList())
|
||||
.ge(HostConnectLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 0))
|
||||
.le(HostConnectLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 1))
|
||||
.le(HostConnectLogDO::getCreateTime, request.getCreateTimeLe())
|
||||
.orderByDesc(HostConnectLogDO::getId);
|
||||
.le(HostConnectLogDO::getCreateTime, request.getCreateTimeLe());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -261,7 +261,9 @@ public class HostServiceImpl implements HostService {
|
||||
}
|
||||
// 数量条件
|
||||
LambdaQueryWrapper<HostDO> countWrapper = wrapper.clone();
|
||||
wrapper.select(HostDAO.BASE_COLUMN);
|
||||
// 基础条件
|
||||
wrapper.select(HostDAO.BASE_COLUMN)
|
||||
.orderByAsc(HostDO::getId);
|
||||
// 查询
|
||||
DataGrid<HostVO> hosts = hostDAO.of(wrapper)
|
||||
.page(request)
|
||||
@@ -271,6 +273,16 @@ public class HostServiceImpl implements HostService {
|
||||
return hosts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getHostCount(HostQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<HostDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return hostDAO.of()
|
||||
.wrapper(wrapper)
|
||||
.countMax(request.getLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteHostById(Long id) {
|
||||
return this.deleteHostByIdList(Lists.singleton(id));
|
||||
@@ -279,17 +291,10 @@ public class HostServiceImpl implements HostService {
|
||||
@Override
|
||||
public Integer deleteHostByIdList(List<Long> idList) {
|
||||
log.info("HostService-deleteHostByIdList idList: {}", idList);
|
||||
// 查询
|
||||
List<HostDO> hosts = hostDAO.selectBaseByIdList(idList);
|
||||
Valid.notEmpty(hosts, ErrorMessage.HOST_ABSENT);
|
||||
// 添加日志参数
|
||||
String name = hosts.stream()
|
||||
.map(HostDO::getName)
|
||||
.collect(Collectors.joining(Const.COMMA));
|
||||
OperatorLogs.add(OperatorLogs.NAME, name);
|
||||
OperatorLogs.add(OperatorLogs.COUNT, hosts.size());
|
||||
// 删除
|
||||
int effect = hostDAO.deleteBatchIds(hosts);
|
||||
int effect = hostDAO.deleteBatchIds(idList);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.COUNT, idList.size());
|
||||
log.info("HostService-deleteHostByIdList effect: {}", effect);
|
||||
// 删除缓存
|
||||
this.clearCache();
|
||||
@@ -322,10 +327,8 @@ public class HostServiceImpl implements HostService {
|
||||
return CURRENT_UPDATE_CONFIG_ID.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
*/
|
||||
private void clearCache() {
|
||||
@Override
|
||||
public void clearCache() {
|
||||
RedisMaps.scanKeysDelete(HostCacheKeyDefine.HOST_INFO.format("*"));
|
||||
}
|
||||
|
||||
@@ -361,13 +364,8 @@ public class HostServiceImpl implements HostService {
|
||||
Valid.isFalse(present, ErrorMessage.CODE_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<HostDO> buildQueryWrapper(HostQueryRequest request) {
|
||||
@Override
|
||||
public LambdaQueryWrapper<HostDO> buildQueryWrapper(HostQueryRequest request) {
|
||||
String searchValue = request.getSearchValue();
|
||||
LambdaQueryWrapper<HostDO> wrapper = hostDAO.wrapper();
|
||||
// tag 条件
|
||||
|
||||
@@ -75,6 +75,10 @@ public class HostTerminalServiceImpl implements HostTerminalService {
|
||||
|
||||
@Override
|
||||
public List<HostTerminalThemeVO> getTerminalThemes() {
|
||||
// if (true) {
|
||||
// String arr = "";
|
||||
// return JSON.parseArray(arr, HostTerminalThemeVO.class);
|
||||
// }
|
||||
List<JSONObject> themes = dictValueApi.getDictValue(THEME_DICT_KEY);
|
||||
return themes.stream()
|
||||
.map(s -> HostTerminalThemeVO.builder()
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.orion.visor.module.asset.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.annotation.Keep;
|
||||
import com.orion.lang.define.collect.MultiHashMap;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Arrays1;
|
||||
import com.orion.lang.utils.Booleans;
|
||||
@@ -12,12 +14,14 @@ import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.lang.utils.io.Files1;
|
||||
import com.orion.lang.utils.time.Dates;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.annotation.Keep;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.constant.ExtraFieldConst;
|
||||
import com.orion.visor.framework.common.enums.EndpointDefine;
|
||||
import com.orion.visor.framework.common.file.FileClient;
|
||||
import com.orion.visor.framework.common.security.LoginUser;
|
||||
import com.orion.visor.framework.common.utils.PathUtils;
|
||||
import com.orion.visor.framework.common.utils.SqlUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.mybatis.core.query.Conditions;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
@@ -27,23 +31,21 @@ import com.orion.visor.module.asset.convert.UploadTaskFileConvert;
|
||||
import com.orion.visor.module.asset.dao.HostDAO;
|
||||
import com.orion.visor.module.asset.dao.UploadTaskDAO;
|
||||
import com.orion.visor.module.asset.dao.UploadTaskFileDAO;
|
||||
import com.orion.visor.module.asset.entity.domain.HostDO;
|
||||
import com.orion.visor.module.asset.entity.domain.UploadTaskDO;
|
||||
import com.orion.visor.module.asset.entity.domain.UploadTaskFileDO;
|
||||
import com.orion.visor.module.asset.entity.dto.UploadTaskExtraDTO;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskCreateRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskFileRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.UploadTaskRequest;
|
||||
import com.orion.visor.module.asset.entity.request.upload.*;
|
||||
import com.orion.visor.module.asset.entity.vo.*;
|
||||
import com.orion.visor.module.asset.enums.HostTypeEnum;
|
||||
import com.orion.visor.module.asset.enums.UploadTaskFileStatusEnum;
|
||||
import com.orion.visor.module.asset.enums.UploadTaskStatusEnum;
|
||||
import com.orion.visor.module.asset.enums.*;
|
||||
import com.orion.visor.module.asset.handler.host.config.model.HostSshConfigModel;
|
||||
import com.orion.visor.module.asset.handler.host.upload.FileUploadTasks;
|
||||
import com.orion.visor.module.asset.handler.host.upload.manager.FileUploadTaskManager;
|
||||
import com.orion.visor.module.asset.handler.host.upload.model.FileUploadFileItemDTO;
|
||||
import com.orion.visor.module.asset.handler.host.upload.task.IFileUploadTask;
|
||||
import com.orion.visor.module.asset.handler.host.upload.uploader.IFileUploader;
|
||||
import com.orion.visor.module.asset.service.AssetAuthorizedDataService;
|
||||
import com.orion.visor.module.asset.service.HostConfigService;
|
||||
import com.orion.visor.module.asset.service.UploadTaskFileService;
|
||||
import com.orion.visor.module.asset.service.UploadTaskService;
|
||||
import com.orion.visor.module.infra.api.FileUploadApi;
|
||||
@@ -85,6 +87,9 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
@Resource
|
||||
private AssetAuthorizedDataService assetAuthorizedDataService;
|
||||
|
||||
@Resource
|
||||
private HostConfigService hostConfigService;
|
||||
|
||||
@Resource
|
||||
private FileUploadTaskManager fileUploadTaskManager;
|
||||
|
||||
@@ -105,10 +110,9 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
// 检查主机是否有权限
|
||||
this.checkHostPermission(hostIdList);
|
||||
// 查询主机信息
|
||||
List<HostBaseVO> hosts = hostDAO.selectBaseByIdList(hostIdList)
|
||||
.stream()
|
||||
.map(HostConvert.MAPPER::toBase)
|
||||
.collect(Collectors.toList());
|
||||
List<HostDO> hosts = this.getUploadTaskHosts(hostIdList);
|
||||
// 计算文件路径
|
||||
MultiHashMap<Long, String, String> realRemoteFilePathMap = this.setFileRealRemotePath(request, hosts);
|
||||
// 转换
|
||||
UploadTaskDO record = UploadTaskConvert.MAPPER.to(request);
|
||||
record.setUserId(user.getId());
|
||||
@@ -119,7 +123,7 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
record.setHostCount(hostIdList.size());
|
||||
UploadTaskExtraDTO extra = UploadTaskExtraDTO.builder()
|
||||
.hostIdList(hostIdList)
|
||||
.hosts(hosts)
|
||||
.hosts(HostConvert.MAPPER.toBaseList(hosts))
|
||||
.build();
|
||||
record.setExtraInfo(JSON.toJSONString(extra));
|
||||
// 插入任务表
|
||||
@@ -134,6 +138,7 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
.hostId(hostId)
|
||||
.fileId(s.getFileId())
|
||||
.filePath(s.getFilePath())
|
||||
.realFilePath(realRemoteFilePathMap.get(hostId, s.getFileId()))
|
||||
.fileSize(s.getFileSize())
|
||||
.status(UploadTaskFileStatusEnum.WAITING.name())
|
||||
.build())
|
||||
@@ -171,7 +176,8 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
@Override
|
||||
public DataGrid<UploadTaskVO> getUploadTaskPage(UploadTaskQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<UploadTaskDO> wrapper = this.buildQueryWrapper(request);
|
||||
LambdaQueryWrapper<UploadTaskDO> wrapper = this.buildQueryWrapper(request)
|
||||
.orderByDesc(UploadTaskDO::getId);
|
||||
// 查询
|
||||
return uploadTaskDAO.of(wrapper)
|
||||
.page(request)
|
||||
@@ -218,15 +224,22 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
|
||||
@Override
|
||||
public Long getUploadTaskCount(UploadTaskQueryRequest request) {
|
||||
return uploadTaskDAO.selectCount(this.buildQueryWrapper(request));
|
||||
// 条件
|
||||
LambdaQueryWrapper<UploadTaskDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return uploadTaskDAO.of()
|
||||
.wrapper(wrapper)
|
||||
.countMax(request.getLimit());
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Integer clearUploadTask(UploadTaskQueryRequest request) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer clearUploadTask(UploadTaskClearRequest request) {
|
||||
// 查询id
|
||||
LambdaQueryWrapper<UploadTaskDO> wrapper = this.buildQueryWrapper(request)
|
||||
.select(UploadTaskDO::getId);
|
||||
.select(UploadTaskDO::getId)
|
||||
.orderByAsc(UploadTaskDO::getId)
|
||||
.last(SqlUtils.limit(request.getLimit()));
|
||||
List<Long> idList = uploadTaskDAO.of(wrapper)
|
||||
.list(UploadTaskDO::getId);
|
||||
// 删除
|
||||
@@ -305,13 +318,8 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
paths.forEach(Files1::delete);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<UploadTaskDO> buildQueryWrapper(UploadTaskQueryRequest request) {
|
||||
@Override
|
||||
public LambdaQueryWrapper<UploadTaskDO> buildQueryWrapper(UploadTaskQueryRequest request) {
|
||||
return uploadTaskDAO.wrapper()
|
||||
.eq(UploadTaskDO::getId, request.getId())
|
||||
.eq(UploadTaskDO::getUserId, request.getUserId())
|
||||
@@ -319,8 +327,7 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
.like(UploadTaskDO::getRemotePath, request.getRemotePath())
|
||||
.eq(UploadTaskDO::getStatus, request.getStatus())
|
||||
.ge(UploadTaskDO::getCreateTime, Arrays1.getIfPresent(request.getCreateTimeRange(), 0))
|
||||
.le(UploadTaskDO::getCreateTime, Arrays1.getIfPresent(request.getCreateTimeRange(), 1))
|
||||
.orderByDesc(UploadTaskDO::getId);
|
||||
.le(UploadTaskDO::getCreateTime, Arrays1.getIfPresent(request.getCreateTimeRange(), 1));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,6 +343,68 @@ public class UploadTaskServiceImpl implements UploadTaskService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询上传任务主机信息
|
||||
*
|
||||
* @param hostIdList hostIdList
|
||||
* @return hosts
|
||||
*/
|
||||
public List<HostDO> getUploadTaskHosts(List<Long> hostIdList) {
|
||||
// 查询主机信息
|
||||
List<HostDO> hosts = hostDAO.selectBatchIds(hostIdList);
|
||||
// 检查主机数量
|
||||
Valid.eq(hosts.size(), hostIdList.size(), ErrorMessage.HOST_ABSENT);
|
||||
// 检查主机状态
|
||||
boolean allEnabled = hosts.stream()
|
||||
.map(HostDO::getStatus)
|
||||
.allMatch(s -> HostStatusEnum.ENABLED.name().equals(s));
|
||||
Valid.isTrue(allEnabled, ErrorMessage.HOST_NOT_ENABLED);
|
||||
return hosts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置文件实际路径
|
||||
*
|
||||
* @param request request
|
||||
* @param hosts hosts
|
||||
* @return realRemoteFilePathMap
|
||||
*/
|
||||
public MultiHashMap<Long, String, String> setFileRealRemotePath(UploadTaskCreateRequest request,
|
||||
List<HostDO> hosts) {
|
||||
MultiHashMap<Long, String, String> realRemoteFilePathMap = MultiHashMap.create();
|
||||
// 计算上传目录
|
||||
String remotePath = request.getRemotePath();
|
||||
List<UploadTaskFileRequest> files = request.getFiles();
|
||||
boolean containsEnv = remotePath.contains(Const.DOLLAR);
|
||||
if (containsEnv) {
|
||||
// 获取主机配置信息
|
||||
Map<Long, HostSshConfigModel> hostConfigMap = hostConfigService.buildHostConfigMap(hosts, HostTypeEnum.SSH);
|
||||
hostConfigMap.forEach((k, v) -> {
|
||||
// 替换占位符
|
||||
String username = v.getUsername();
|
||||
String home = PathUtils.getHomePath(HostSshOsTypeEnum.isWindows(v.getOsType()), username);
|
||||
// 替换环境变量路径
|
||||
Map<String, String> env = Maps.newMap(4);
|
||||
env.put(ExtraFieldConst.USERNAME, username);
|
||||
env.put(ExtraFieldConst.HOME, home);
|
||||
// 设置主机上传路径
|
||||
String realRemotePath = Files1.getPath(Strings.format(remotePath, env));
|
||||
for (UploadTaskFileRequest file : files) {
|
||||
realRemoteFilePathMap.put(k, file.getFileId(), Files1.getPath(realRemotePath, file.getFilePath()));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 无占位符
|
||||
for (UploadTaskFileRequest file : files) {
|
||||
String path = Files1.getPath(remotePath, file.getFilePath());
|
||||
for (HostDO host : hosts) {
|
||||
realRemoteFilePathMap.put(host.getId(), file.getFileId(), path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return realRemoteFilePathMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查文件完整性
|
||||
*
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.orion.visor.module.asset.task;
|
||||
import com.orion.lang.utils.time.Dates;
|
||||
import com.orion.visor.framework.common.utils.LockerUtils;
|
||||
import com.orion.visor.module.asset.define.config.AppExecLogAutoClearConfig;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecLogClearRequest;
|
||||
import com.orion.visor.module.asset.enums.ExecStatusEnum;
|
||||
import com.orion.visor.module.asset.service.ExecLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -57,7 +57,7 @@ public class ExecLogFileAutoClearTask {
|
||||
.subDay(appExecLogAutoClearConfig.getKeepPeriod())
|
||||
.date();
|
||||
// 清理
|
||||
ExecLogQueryRequest request = new ExecLogQueryRequest();
|
||||
ExecLogClearRequest request = new ExecLogClearRequest();
|
||||
request.setCreateTimeLe(createLessEq);
|
||||
request.setStatusList(ExecStatusEnum.FINISH_STATUS_LIST);
|
||||
execLogService.clearExecLog(request);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.orion.visor.module.asset.task;
|
||||
import com.orion.lang.utils.time.Dates;
|
||||
import com.orion.visor.framework.common.utils.LockerUtils;
|
||||
import com.orion.visor.module.asset.define.config.AppHostConnectLogAutoClearConfig;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogClearRequest;
|
||||
import com.orion.visor.module.asset.enums.HostConnectStatusEnum;
|
||||
import com.orion.visor.module.asset.service.HostConnectLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -57,7 +57,7 @@ public class HostConnectLogAutoClearTask {
|
||||
.subDay(appHostConnectLogAutoClearConfig.getKeepPeriod())
|
||||
.date();
|
||||
// 清理
|
||||
HostConnectLogQueryRequest request = new HostConnectLogQueryRequest();
|
||||
HostConnectLogClearRequest request = new HostConnectLogClearRequest();
|
||||
request.setCreateTimeLe(createLessEq);
|
||||
request.setStatusList(HostConnectStatusEnum.FINISH_STATUS_LIST);
|
||||
hostConnectLogService.clearHostConnectLog(request);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<result column="host_id" property="hostId"/>
|
||||
<result column="file_id" property="fileId"/>
|
||||
<result column="file_path" property="filePath"/>
|
||||
<result column="real_file_path" property="realFilePath"/>
|
||||
<result column="file_size" property="fileSize"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="start_time" property="startTime"/>
|
||||
@@ -22,7 +23,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, task_id, host_id, file_id, file_path, file_size, status, start_time, end_time, create_time, update_time, creator, updater, deleted
|
||||
id, task_id, host_id, file_id, file_path, real_file_path, file_size, status, start_time, end_time, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -28,13 +28,15 @@ public class TerminalThemeGenerator {
|
||||
List<File> files = Files1.listFiles("D:\\idea-project\\iTerm2-Color-Schemes\\vhs");
|
||||
// 过滤的 theme
|
||||
List<String> schemaFilter = Lists.of(
|
||||
"Dracula", "Atom",
|
||||
"catppuccin-mocha", "MaterialDesignColors",
|
||||
"catppuccin-macchiato", "OneHalfDark",
|
||||
"Apple System Colors", "Builtin Tango Light",
|
||||
"Duotone Dark", "BlulocoLight",
|
||||
"Chester", "CLRS",
|
||||
"Calamity", "Tomorrow"
|
||||
"Dracula", "Builtin Tango Light",
|
||||
"Atom", "AtomOneLight",
|
||||
"OneHalfDark", "OneHalfLight",
|
||||
"Apple System Colors", "Tomorrow",
|
||||
"catppuccin-mocha", "catppuccin-latte",
|
||||
"catppuccin-macchiato", "BlulocoLight",
|
||||
"catppuccin-frappe", "MaterialDesignColors",
|
||||
"GitHub Dark", "Github",
|
||||
"DimmedMonokai", "Duotone Dark"
|
||||
);
|
||||
// 颜色大写
|
||||
ValueFilter colorFilter = (Object object, String name, Object value) -> {
|
||||
@@ -60,7 +62,7 @@ public class TerminalThemeGenerator {
|
||||
theme.setDark(Colors.isDarkColor(background));
|
||||
theme.setSchema(JSON.parseObject(JSON.toJSONString(schema), TerminalThemeSchema.class));
|
||||
return theme;
|
||||
}).collect(Collectors.toList());
|
||||
}).skip(0).limit(50).collect(Collectors.toList());
|
||||
// 排序
|
||||
if (!Lists.isEmpty(schemaFilter)) {
|
||||
arr.sort(Comparator.comparing(s -> schemaFilter.indexOf(s.getName())));
|
||||
@@ -70,11 +72,12 @@ public class TerminalThemeGenerator {
|
||||
for (TerminalTheme theme : arr) {
|
||||
System.out.println("name: " + theme.name);
|
||||
System.out.println("dark: " + theme.dark);
|
||||
System.out.println("value: \n" + JSON.toJSONString(theme.schema, colorFilter));
|
||||
System.out.println("value: " + JSON.toJSONString(theme.schema, colorFilter));
|
||||
System.out.println("json: " + JSON.toJSONString(theme, colorFilter));
|
||||
System.out.println();
|
||||
}
|
||||
// String json = JSON.toJSONString(arr, colorFilter);
|
||||
// System.out.println("\n" + json);
|
||||
String json = JSON.toJSONString(arr, colorFilter);
|
||||
System.out.println("\n" + json);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.orion.visor.module.infra.api;
|
||||
|
||||
import com.orion.visor.module.infra.entity.dto.user.SystemUserAuthDTO;
|
||||
|
||||
/**
|
||||
* 认证服务实现
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/8/14 21:37
|
||||
*/
|
||||
public interface AuthenticationApi {
|
||||
|
||||
/**
|
||||
* 通过密码认证
|
||||
*
|
||||
* @param username username
|
||||
* @param password password
|
||||
* @param addFailedCount addFailedCount
|
||||
* @return result
|
||||
*/
|
||||
SystemUserAuthDTO authByPassword(String username, String password, boolean addFailedCount);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.orion.visor.module.infra.api;
|
||||
|
||||
import com.orion.visor.module.infra.entity.dto.data.DataGroupRelCreateDTO;
|
||||
import com.orion.visor.module.infra.enums.DataGroupTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
@@ -37,6 +36,7 @@ public interface DataGroupRelApi {
|
||||
/**
|
||||
* 添加关联
|
||||
*
|
||||
* @param type type
|
||||
* @param groupId groupId
|
||||
* @param relId relId
|
||||
*/
|
||||
@@ -45,9 +45,10 @@ public interface DataGroupRelApi {
|
||||
/**
|
||||
* 批量添加关联
|
||||
*
|
||||
* @param list list
|
||||
* @param type type
|
||||
* @param groupRelListMap groupRelListMap
|
||||
*/
|
||||
void addGroupRel(DataGroupTypeEnum type, List<DataGroupRelCreateDTO> list);
|
||||
void addGroupRel(DataGroupTypeEnum type, Map<Long, List<Long>> groupRelListMap);
|
||||
|
||||
/**
|
||||
* 通过 type 查询 relId 缓存
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.orion.visor.module.infra.api;
|
||||
|
||||
import com.orion.visor.module.infra.entity.dto.data.DataGroupRelCreateDTO;
|
||||
import com.orion.visor.module.infra.enums.DataGroupTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,11 +39,11 @@ public interface DataGroupUserRelApi {
|
||||
/**
|
||||
* 批量添加关联
|
||||
*
|
||||
* @param type type
|
||||
* @param userId userId
|
||||
* @param list list
|
||||
* @param type type
|
||||
* @param userId userId
|
||||
* @param groupRelListMap groupRelListMap
|
||||
*/
|
||||
void addGroupRel(DataGroupTypeEnum type, Long userId, List<DataGroupRelCreateDTO> list);
|
||||
void addGroupRel(DataGroupTypeEnum type, Long userId, Map<Long, List<Long>> groupRelListMap);
|
||||
|
||||
/**
|
||||
* 通过 type 查询 relId 缓存
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.orion.visor.module.infra.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限 对外服务类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/8/19 15:22
|
||||
*/
|
||||
public interface PermissionApi {
|
||||
|
||||
/**
|
||||
* 用户是否为管理员用户
|
||||
*
|
||||
* @param id id
|
||||
* @return isAdmin
|
||||
*/
|
||||
boolean isAdminUser(Long id);
|
||||
|
||||
/**
|
||||
* 检查当前用户是否含有此角色
|
||||
*
|
||||
* @param userId userId
|
||||
* @param role role
|
||||
* @return 是否包含
|
||||
*/
|
||||
boolean hasRole(Long userId, String role);
|
||||
|
||||
/**
|
||||
* 检查当前用户是否含有任意角色
|
||||
*
|
||||
* @param userId userId
|
||||
* @param roles roles
|
||||
* @return 是否包含
|
||||
*/
|
||||
boolean hasAnyRole(Long userId, List<String> roles);
|
||||
|
||||
/**
|
||||
* 检查当前用户是否含有此权限
|
||||
*
|
||||
* @param userId userId
|
||||
* @param permission permission
|
||||
* @return 是否包含
|
||||
*/
|
||||
boolean hasPermission(Long userId, String permission);
|
||||
|
||||
/**
|
||||
* 检查当前用户是否含任意权限
|
||||
*
|
||||
* @param userId userId
|
||||
* @param permissions permissions
|
||||
* @return 是否包含
|
||||
*/
|
||||
boolean hasAnyPermission(Long userId, List<String> permissions);
|
||||
|
||||
}
|
||||
@@ -11,6 +11,22 @@ import com.orion.visor.module.infra.entity.dto.user.SystemUserDTO;
|
||||
*/
|
||||
public interface SystemUserApi {
|
||||
|
||||
/**
|
||||
* 通过 id 查询用户名
|
||||
*
|
||||
* @param id id
|
||||
* @return username
|
||||
*/
|
||||
String getUsernameById(Long id);
|
||||
|
||||
/**
|
||||
* 通过 id 查询花名
|
||||
*
|
||||
* @param id id
|
||||
* @return nickname
|
||||
*/
|
||||
String getNicknameById(Long id);
|
||||
|
||||
/**
|
||||
* 通过 id 查询用户
|
||||
*
|
||||
@@ -19,12 +35,4 @@ public interface SystemUserApi {
|
||||
*/
|
||||
SystemUserDTO getUserById(Long id);
|
||||
|
||||
/**
|
||||
* 用户是否为管理员用户
|
||||
*
|
||||
* @param id id
|
||||
* @return isAdmin
|
||||
*/
|
||||
boolean isAdminUser(Long id);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.orion.visor.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据分组关联 创建请求业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-11-7 18:44
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataGroupRelCreateDTO", description = "数据分组关联 创建请求业务对象")
|
||||
public class DataGroupRelCreateDTO implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "组id")
|
||||
private Long groupId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "引用id")
|
||||
private Long relId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.orion.visor.module.infra.entity.dto.user;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户状态检查 业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/8/14 21:52
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "SystemUserAuthDTO", description = "用户认证 业务对象")
|
||||
public class SystemUserAuthDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户名")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "花名")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "密码是否正确")
|
||||
private Boolean passRight;
|
||||
|
||||
@Schema(description = "认证是否通过")
|
||||
private Boolean authed;
|
||||
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMessage;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.orion.visor.module.infra.api.impl;
|
||||
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.module.infra.api.AuthenticationApi;
|
||||
import com.orion.visor.module.infra.entity.domain.SystemUserDO;
|
||||
import com.orion.visor.module.infra.entity.dto.user.SystemUserAuthDTO;
|
||||
import com.orion.visor.module.infra.service.AuthenticationService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 认证服务实现
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/8/14 21:37
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AuthenticationApiImpl implements AuthenticationApi {
|
||||
|
||||
@Resource
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
@Override
|
||||
public SystemUserAuthDTO authByPassword(String username, String password, boolean addFailedCount) {
|
||||
SystemUserAuthDTO result = new SystemUserAuthDTO();
|
||||
try {
|
||||
// 登录预检
|
||||
SystemUserDO user = authenticationService.preCheckLogin(username, password);
|
||||
result.setId(user.getId());
|
||||
result.setUsername(user.getUsername());
|
||||
result.setNickname(user.getNickname());
|
||||
// 检查用户密码
|
||||
boolean passRight = authenticationService.checkUserPassword(user, password, addFailedCount);
|
||||
result.setPassRight(passRight);
|
||||
Valid.isTrue(passRight, ErrorMessage.USERNAME_PASSWORD_ERROR);
|
||||
// 检查用户状态
|
||||
authenticationService.checkUserStatus(user);
|
||||
result.setAuthed(true);
|
||||
} catch (Exception e) {
|
||||
result.setAuthed(false);
|
||||
result.setErrorMessage(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user