Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
318e9f30b8 | ||
|
|
39a1001510 | ||
|
|
5e7b7ebfa7 | ||
|
|
8d85cdf173 | ||
|
|
79d95d1997 | ||
|
|
1eb07d0b24 | ||
|
|
601564b573 | ||
|
|
41384fab17 | ||
|
|
f0a122d862 | ||
|
|
b08d75be62 | ||
|
|
02f5bef6b4 | ||
|
|
ef10c8b8b6 | ||
|
|
6c4e9cd5c6 | ||
|
|
8dec40553d | ||
|
|
9ae5a6c627 | ||
|
|
2ec1678f01 | ||
|
|
f9e436e885 | ||
|
|
2a49e7670d | ||
|
|
95d8988f11 | ||
|
|
e04a972df5 | ||
|
|
1ca9311625 | ||
|
|
630a1fd3cd | ||
|
|
0f6d84dab2 | ||
|
|
f64eb395a8 | ||
|
|
2e69c67de0 | ||
|
|
7747b4e52e | ||
|
|
830622aafb | ||
|
|
2919950c5b | ||
|
|
d56cfbba82 | ||
|
|
cfe1924f11 | ||
|
|
dfd2ec45f4 | ||
|
|
19c7e31f53 | ||
|
|
f618aef988 | ||
|
|
af97f752f5 | ||
|
|
bfb80afee2 |
22
.github/workflows/e2e.yaml
vendored
Normal file
22
.github/workflows/e2e.yaml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: E2E
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{github.workflow}} - ${{github.ref}}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
testing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: E2E Testing
|
||||||
|
run: |
|
||||||
|
sudo curl -L https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
|
||||||
|
sudo chmod u+x /usr/local/bin/docker-compose
|
||||||
|
docker compose -f docker-compose-testing.yml up --build testing --exit-code-from testing --remove-orphans
|
||||||
22
README.md
22
README.md
@@ -13,27 +13,27 @@
|
|||||||
</a>
|
</a>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
style="text-decoration: none !important;"
|
style="text-decoration: none !important;"
|
||||||
href="https://github.com/lijiahangmax/orion-visor/releases">
|
href="https://github.com/dromara/orion-visor/releases">
|
||||||
<img src="https://img.shields.io/github/v/release/lijiahangmax/orion-visor" alt="release" />
|
<img src="https://img.shields.io/github/v/release/lijiahangmax/orion-visor" alt="release" />
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
style="text-decoration: none !important;"
|
style="text-decoration: none !important;"
|
||||||
href="https://gitee.com/lijiahangmax/orion-visor/stargazers">
|
href="https://gitee.com/dromara/orion-visor/stargazers">
|
||||||
<img src="https://gitee.com/lijiahangmax/orion-visor/badge/star.svg?theme=dark" alt="star" />
|
<img src="https://gitee.com/dromara/orion-visor/badge/star.svg?theme=dark" alt="star" />
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
style="text-decoration: none !important;"
|
style="text-decoration: none !important;"
|
||||||
href="https://gitee.com/lijiahangmax/orion-visor/members">
|
href="https://gitee.com/dromara/orion-visor/members">
|
||||||
<img src="https://gitee.com/lijiahangmax/orion-visor/badge/fork.svg?theme=dark" alt="fork" />
|
<img src="https://gitee.com/dromara/orion-visor/badge/fork.svg?theme=dark" alt="fork" />
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
style="text-decoration: none !important;"
|
style="text-decoration: none !important;"
|
||||||
href="https://github.com/lijiahangmax/orion-visor">
|
href="https://github.com/dromara/orion-visor">
|
||||||
<img src="https://img.shields.io/github/stars/lijiahangmax/orion-visor" alt="star" />
|
<img src="https://img.shields.io/github/stars/lijiahangmax/orion-visor" alt="star" />
|
||||||
</a>
|
</a>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
style="text-decoration: none !important;"
|
style="text-decoration: none !important;"
|
||||||
href="https://github.com/lijiahangmax/orion-visor">
|
href="https://github.com/dromara/orion-visor">
|
||||||
<img src="https://img.shields.io/github/forks/lijiahangmax/orion-visor" alt="star" />
|
<img src="https://img.shields.io/github/forks/lijiahangmax/orion-visor" alt="star" />
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
* 🔗 演示地址: http://101.43.254.243:1081/
|
* 🔗 演示地址: http://101.43.254.243:1081/
|
||||||
* 🔏 演示账号: admin/admin
|
* 🔏 演示账号: admin/admin
|
||||||
* ⭐ 体验后可以点一下 `star` 这对我很重要! [github](https://github.com/lijiahangmax/orion-visor) [gitee](https://gitee.com/lijiahangmax/orion-visor)
|
* ⭐ 体验后可以点一下 `star` 这对我很重要! [github](https://github.com/dromara/orion-visor) [gitee](https://gitee.com/dromara/orion-visor)
|
||||||
* 🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
|
* 🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
|
||||||
* 🎭 演示环境部分功能不可用, 完整功能请本地部署!
|
* 🎭 演示环境部分功能不可用, 完整功能请本地部署!
|
||||||
* 📛 演示环境请不要随便删除数据!
|
* 📛 演示环境请不要随便删除数据!
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# clone
|
# clone
|
||||||
git clone https://github.com/lijiahangmax/orion-visor
|
git clone https://github.com/dromara/orion-visor
|
||||||
cd orion-visor
|
cd orion-visor
|
||||||
# 启动
|
# 启动
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
@@ -131,8 +131,8 @@ docker compose up -d
|
|||||||
|
|
||||||
## 免责声明
|
## 免责声明
|
||||||
|
|
||||||
在使用本项目之前, 请确保您已经了解并同意相关的使用协议和隐私政策。[免责声明](https://github.com/lijiahangmax/orion-visor/blob/main/DISCLAIMER.md)
|
在使用本项目之前, 请确保您已经了解并同意相关的使用协议和隐私政策。[免责声明](https://github.com/dromara/orion-visor/blob/main/DISCLAIMER.md)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
本项目遵循 [Apache-2.0](https://github.com/lijiahangmax/orion-visor/blob/main/LICENSE) 开源许可证。
|
本项目遵循 [Apache-2.0](https://github.com/dromara/orion-visor/blob/main/LICENSE) 开源许可证。
|
||||||
|
|||||||
79
docker-compose-testing.yml
Normal file
79
docker-compose-testing.yml
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
version: '3.3'
|
||||||
|
services:
|
||||||
|
orion-visor-service:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.10
|
||||||
|
privileged: true
|
||||||
|
ports:
|
||||||
|
- 1081:80
|
||||||
|
environment:
|
||||||
|
- MYSQL_HOST=orion-visor-mysql
|
||||||
|
- MYSQL_PORT=3306
|
||||||
|
- MYSQL_DATABASE=orion_visor
|
||||||
|
- MYSQL_USER=root
|
||||||
|
- MYSQL_PASSWORD=Data@123456
|
||||||
|
- REDIS_HOST=orion-visor-redis
|
||||||
|
- REDIS_PASSWORD=Data@123456
|
||||||
|
- SECRET_KEY=uQeacXV8b3isvKLK
|
||||||
|
- DEMO_MODE=false
|
||||||
|
volumes:
|
||||||
|
- /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
|
||||||
|
timeout: 300s
|
||||||
|
retries: 200
|
||||||
|
start_period: 3s
|
||||||
|
depends_on:
|
||||||
|
orion-visor-mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
orion-visor-redis:
|
||||||
|
condition: service_healthy
|
||||||
|
links:
|
||||||
|
- orion-visor-mysql
|
||||||
|
- orion-visor-redis
|
||||||
|
orion-visor-mysql:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.10
|
||||||
|
privileged: true
|
||||||
|
ports:
|
||||||
|
- 3307:3306
|
||||||
|
environment:
|
||||||
|
- MYSQL_DATABASE=orion_visor
|
||||||
|
- MYSQL_USER=orion
|
||||||
|
- MYSQL_PASSWORD=Data@123456
|
||||||
|
- MYSQL_ROOT_PASSWORD=Data@123456
|
||||||
|
volumes:
|
||||||
|
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql:/var/lib/mysql
|
||||||
|
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql-files:/var/lib/mysql-files
|
||||||
|
- /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
|
||||||
|
timeout: 60s
|
||||||
|
retries: 10
|
||||||
|
start_period: 3s
|
||||||
|
orion-visor-redis:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.10
|
||||||
|
privileged: true
|
||||||
|
ports:
|
||||||
|
- 6380:6379
|
||||||
|
environment:
|
||||||
|
- REDIS_PASSWORD=Data@123456
|
||||||
|
volumes:
|
||||||
|
- /data/orion-visor-space/docker-volumes/redis/data:/data
|
||||||
|
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
|
||||||
|
interval: 3s
|
||||||
|
timeout: 60s
|
||||||
|
retries: 10
|
||||||
|
start_period: 3s
|
||||||
|
testing:
|
||||||
|
build:
|
||||||
|
context: ./docker/e2e
|
||||||
|
environment:
|
||||||
|
SERVER: http://orion-visor-service:80
|
||||||
|
depends_on:
|
||||||
|
orion-visor-service:
|
||||||
|
condition: service_healthy
|
||||||
|
links:
|
||||||
|
- orion-visor-service
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
version: '3.3'
|
version: '3.3'
|
||||||
services:
|
services:
|
||||||
orion-visor-service:
|
orion-visor-service:
|
||||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.7
|
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-service:2.0.10
|
||||||
|
privileged: true
|
||||||
ports:
|
ports:
|
||||||
- 1081:80
|
- 1081:80
|
||||||
environment:
|
environment:
|
||||||
@@ -15,12 +16,23 @@ services:
|
|||||||
- SECRET_KEY=uQeacXV8b3isvKLK
|
- SECRET_KEY=uQeacXV8b3isvKLK
|
||||||
- DEMO_MODE=false
|
- DEMO_MODE=false
|
||||||
volumes:
|
volumes:
|
||||||
- /data/orion-visor-space/docker-volumes/orion-visor-service/root-orion:/root/orion
|
- /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
|
||||||
|
timeout: 300s
|
||||||
|
retries: 200
|
||||||
|
start_period: 3s
|
||||||
depends_on:
|
depends_on:
|
||||||
|
orion-visor-mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
orion-visor-redis:
|
||||||
|
condition: service_healthy
|
||||||
|
links:
|
||||||
- orion-visor-mysql
|
- orion-visor-mysql
|
||||||
- orion-visor-redis
|
- orion-visor-redis
|
||||||
orion-visor-mysql:
|
orion-visor-mysql:
|
||||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.7
|
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-mysql:2.0.10
|
||||||
privileged: true
|
privileged: true
|
||||||
ports:
|
ports:
|
||||||
- 3307:3306
|
- 3307:3306
|
||||||
@@ -30,19 +42,31 @@ services:
|
|||||||
- MYSQL_PASSWORD=Data@123456
|
- MYSQL_PASSWORD=Data@123456
|
||||||
- MYSQL_ROOT_PASSWORD=Data@123456
|
- MYSQL_ROOT_PASSWORD=Data@123456
|
||||||
volumes:
|
volumes:
|
||||||
- /data/orion-visor-space/docker-volumes/orion-visor-mysql/var-lib-mysql:/var/lib/mysql
|
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql:/var/lib/mysql
|
||||||
- /data/orion-visor-space/docker-volumes/orion-visor-mysql/var-lib-mysql-files:/var/lib/mysql-files
|
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql-files:/var/lib/mysql-files
|
||||||
- /data/orion-visor-space/docker-volumes/orion-visor-mysql/etc-mysql:/etc/mysql
|
- /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
|
||||||
|
timeout: 60s
|
||||||
|
retries: 10
|
||||||
|
start_period: 3s
|
||||||
orion-visor-redis:
|
orion-visor-redis:
|
||||||
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.7
|
image: registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:2.0.10
|
||||||
privileged: true
|
privileged: true
|
||||||
ports:
|
ports:
|
||||||
- 6380:6379
|
- 6380:6379
|
||||||
environment:
|
environment:
|
||||||
- REDIS_PASSWORD=Data@123456
|
- REDIS_PASSWORD=Data@123456
|
||||||
volumes:
|
volumes:
|
||||||
- /data/orion-visor-space/docker-volumes/orion-visor-redis/data:/data
|
- /data/orion-visor-space/docker-volumes/redis/data:/data
|
||||||
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
|
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
|
||||||
|
interval: 3s
|
||||||
|
timeout: 60s
|
||||||
|
retries: 10
|
||||||
|
start_period: 3s
|
||||||
orion-visor-adminer:
|
orion-visor-adminer:
|
||||||
image: adminer
|
image: adminer
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#/bin/bash
|
#/bin/bash
|
||||||
docker compose down
|
docker compose down
|
||||||
sh ./pull.sh
|
|
||||||
# demo 启动
|
# demo 启动
|
||||||
if [ "$1" == "demo" ]; then
|
if [ "$1" == "demo" ]; then
|
||||||
sed -i 's/DEMO_MODE=false/DEMO_MODE=true/g' docker-compose.yml
|
sed -i 's/DEMO_MODE=false/DEMO_MODE=true/g' docker-compose.yml
|
||||||
|
|||||||
7
docker/e2e/Dockerfile
Normal file
7
docker/e2e/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FROM ghcr.io/linuxsuren/api-testing:v0.0.17
|
||||||
|
|
||||||
|
WORKDIR /workspace
|
||||||
|
COPY . .
|
||||||
|
RUN chmod 777 *
|
||||||
|
|
||||||
|
CMD [ "/workspace/entrypoint.sh" ]
|
||||||
3
docker/e2e/entrypoint.sh
Normal file
3
docker/e2e/entrypoint.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
atest run -p testsuite.yaml --report md
|
||||||
57
docker/e2e/testsuite.yaml
Normal file
57
docker/e2e/testsuite.yaml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#!api-testing
|
||||||
|
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json
|
||||||
|
name: orion-visor
|
||||||
|
api: |
|
||||||
|
{{default "http://orion-visor-service:80" (env "SERVER")}}
|
||||||
|
items:
|
||||||
|
- name: login
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/infra/auth/login
|
||||||
|
method: POST
|
||||||
|
header:
|
||||||
|
Content-type: application/json
|
||||||
|
body: |
|
||||||
|
{"username":"admin","password":"21232f297a57a5a743894a0e4a801fc3"}
|
||||||
|
expect:
|
||||||
|
bodyFieldsExpect:
|
||||||
|
code: 200
|
||||||
|
- name: userPermission
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/infra/permission/user
|
||||||
|
header:
|
||||||
|
Authorization: Bearer {{.login.data.token}}
|
||||||
|
expect:
|
||||||
|
bodyFieldsExpect:
|
||||||
|
code: 200
|
||||||
|
msg: "success"
|
||||||
|
- name: menu
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/infra/permission/menu
|
||||||
|
header:
|
||||||
|
Authorization: Bearer {{.login.data.token}}
|
||||||
|
expect:
|
||||||
|
bodyFieldsExpect:
|
||||||
|
code: 200
|
||||||
|
msg: "success"
|
||||||
|
- name: haveUnRead
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/infra/system-message/has-unread
|
||||||
|
header:
|
||||||
|
Authorization: Bearer {{.login.data.token}}
|
||||||
|
- name: queryOperatorLog
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/infra/mine/query-operator-log
|
||||||
|
method: POST
|
||||||
|
header:
|
||||||
|
Authorization: Bearer {{.login.data.token}}
|
||||||
|
- name: hostList
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/infra/tag/list?type=HOST
|
||||||
|
header:
|
||||||
|
Authorization: Bearer {{.login.data.token}}
|
||||||
|
- name: queryHost
|
||||||
|
request:
|
||||||
|
api: /orion-visor/api/asset/host/query
|
||||||
|
method: POST
|
||||||
|
header:
|
||||||
|
Authorization: Bearer {{.login.data.token}}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#/bin/bash
|
#/bin/bash
|
||||||
version=2.0.7
|
version=2.0.10
|
||||||
cp -r ../../sql ./sql
|
cp -r ../../sql ./sql
|
||||||
docker build -t orion-visor-mysql:${version} .
|
docker build -t orion-visor-mysql:${version} .
|
||||||
rm -rf ./sql
|
rm -rf ./sql
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#/bin/bash
|
#/bin/bash
|
||||||
version=2.0.7
|
version=2.0.10
|
||||||
docker build -t orion-visor-redis:${version} .
|
docker build -t orion-visor-redis:${version} .
|
||||||
docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
|
docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
|
||||||
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
|
docker push registry.cn-hangzhou.aliyuncs.com/lijiahangmax/orion-visor-redis:${version}
|
||||||
@@ -8,6 +8,7 @@ RUN \
|
|||||||
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
|
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
|
||||||
apk update && \
|
apk update && \
|
||||||
apk add tzdata && \
|
apk add tzdata && \
|
||||||
|
apk add dmidecode && \
|
||||||
apk add openjdk8
|
apk add openjdk8
|
||||||
# 设置时区
|
# 设置时区
|
||||||
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
|
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#/bin/bash
|
#/bin/bash
|
||||||
version=2.0.7
|
version=2.0.10
|
||||||
mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar
|
mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar
|
||||||
mv ../../orion-visor-ui/dist ./dist
|
mv ../../orion-visor-ui/dist ./dist
|
||||||
docker build -t orion-visor-service:${version} .
|
docker build -t orion-visor-service:${version} .
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
|
|
||||||
<description>项目所有依赖</description>
|
<description>项目所有依赖</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.0.7</revision>
|
<revision>2.0.10</revision>
|
||||||
<spring.boot.version>2.7.17</spring.boot.version>
|
<spring.boot.version>2.7.17</spring.boot.version>
|
||||||
<spring.boot.admin.version>2.7.15</spring.boot.admin.version>
|
<spring.boot.admin.version>2.7.15</spring.boot.admin.version>
|
||||||
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
|
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目公共基准包</description>
|
<description>项目公共基准包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,14 +14,17 @@ public interface AppConst extends OrionConst {
|
|||||||
/**
|
/**
|
||||||
* 同 ${orion.version} 迭代时候需要手动更改
|
* 同 ${orion.version} 迭代时候需要手动更改
|
||||||
*/
|
*/
|
||||||
String VERSION = "2.0.7";
|
String VERSION = "2.0.10";
|
||||||
|
|
||||||
String ORION_VISOR = "orion-visor";
|
/**
|
||||||
|
* 同 ${spring.application.name}
|
||||||
|
*/
|
||||||
|
String APP_NAME = "orion-visor";
|
||||||
|
|
||||||
String GITHUB = "https://github.com/lijiahangmax/orion-visor";
|
String GITHUB = "https://github.com/dromara/orion-visor";
|
||||||
|
|
||||||
String GITEE = "https://gitee.com/lijiahangmax/orion-visor";
|
String GITEE = "https://gitee.com/dromara/orion-visor";
|
||||||
|
|
||||||
String ISSUES = "https://github.com/lijiahangmax/orion-visor/issues";
|
String ISSUES = "https://github.com/dromara/orion-visor/issues";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,8 @@ public interface CnConst {
|
|||||||
|
|
||||||
String CN_ROLE = "角色";
|
String CN_ROLE = "角色";
|
||||||
|
|
||||||
|
String CN_UNKNOWN = "未知";
|
||||||
|
|
||||||
|
String CN_INTRANET_IP = "内网IP";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst, CnCons
|
|||||||
|
|
||||||
int MD5_LEN = 32;
|
int MD5_LEN = 32;
|
||||||
|
|
||||||
String UNKNOWN = "未知";
|
|
||||||
|
|
||||||
String INTRANET_IP = "内网IP";
|
|
||||||
|
|
||||||
Long ROOT_PARENT_ID = 0L;
|
Long ROOT_PARENT_ID = 0L;
|
||||||
|
|
||||||
Integer DEFAULT_SORT = 10;
|
Integer DEFAULT_SORT = 10;
|
||||||
|
|||||||
@@ -83,8 +83,12 @@ public interface ErrorMessage {
|
|||||||
|
|
||||||
String UNKNOWN_TYPE = "未知类型";
|
String UNKNOWN_TYPE = "未知类型";
|
||||||
|
|
||||||
|
String ERROR_TYPE = "错误的类型";
|
||||||
|
|
||||||
String FILE_ABSENT = "文件不存在";
|
String FILE_ABSENT = "文件不存在";
|
||||||
|
|
||||||
|
String FILE_ABSENT_CLEAR = "文件不存在 (可能已被清理)";
|
||||||
|
|
||||||
String LOG_ABSENT = "日志不存在";
|
String LOG_ABSENT = "日志不存在";
|
||||||
|
|
||||||
String TASK_ABSENT = "任务不存在";
|
String TASK_ABSENT = "任务不存在";
|
||||||
@@ -95,6 +99,8 @@ public interface ErrorMessage {
|
|||||||
|
|
||||||
String FILE_READ_ERROR = "文件读取失败";
|
String FILE_READ_ERROR = "文件读取失败";
|
||||||
|
|
||||||
|
String FILE_READ_ERROR_CLEAR = "文件读取失败 (可能已被清理)";
|
||||||
|
|
||||||
String PLEASE_CHECK_HOST_SSH = "请检查主机 {} 是否存在/权限/SSH配置";
|
String PLEASE_CHECK_HOST_SSH = "请检查主机 {} 是否存在/权限/SSH配置";
|
||||||
|
|
||||||
String CLIENT_ABORT = "手动中断";
|
String CLIENT_ABORT = "手动中断";
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.orion.visor.framework.common.constant;
|
package com.orion.visor.framework.common.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路径常量
|
* 文件常量
|
||||||
*
|
*
|
||||||
* @author Jiahang Li
|
* @author Jiahang Li
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @since 2024/4/17 10:35
|
* @since 2024/4/17 10:35
|
||||||
*/
|
*/
|
||||||
public interface PathConst {
|
public interface FileConst {
|
||||||
|
|
||||||
String ERROR_LOG = "error.log";
|
String ERROR_LOG = "error.log";
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.orion.visor.framework.common.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动清理配置
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2024/6/24 15:03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AutoClearConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启
|
||||||
|
*/
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保留周期 (天)
|
||||||
|
*/
|
||||||
|
private Integer keepPeriod;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.orion.visor.framework.common.enums;
|
||||||
|
|
||||||
|
import com.orion.lang.utils.Strings;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 端点定义
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2024/6/21 19:15
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum EndpointDefine {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传临时分区
|
||||||
|
*/
|
||||||
|
UPLOAD_SWAP("/upload/swap/{}"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量执行日志
|
||||||
|
*/
|
||||||
|
EXEC_LOG("/exec/{}/{}.log"),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 端点
|
||||||
|
*/
|
||||||
|
private final String endpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化
|
||||||
|
*
|
||||||
|
* @param params params
|
||||||
|
* @return path
|
||||||
|
*/
|
||||||
|
public String format(Object... params) {
|
||||||
|
return Strings.format(this.endpoint, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.orion.visor.framework.common.handler.data;
|
package com.orion.visor.framework.common.handler.data;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.orion.spring.SpringHolder;
|
import com.orion.spring.SpringHolder;
|
||||||
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
||||||
import com.orion.visor.framework.common.handler.data.strategy.MapDataStrategy;
|
import com.orion.visor.framework.common.handler.data.strategy.GenericsDataStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标准数据定义
|
* 标准数据定义
|
||||||
@@ -12,45 +11,50 @@ import com.orion.visor.framework.common.handler.data.strategy.MapDataStrategy;
|
|||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @since 2023/12/21 0:07
|
* @since 2023/12/21 0:07
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public interface GenericsDataDefinition {
|
public interface GenericsDataDefinition {
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取数据模型类型
|
|
||||||
*
|
|
||||||
* @return class
|
|
||||||
*/
|
|
||||||
Class<? extends GenericsDataModel> getModel();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据处理策略
|
* 获取数据处理策略
|
||||||
*
|
*
|
||||||
* @return class
|
* @return class
|
||||||
*/
|
*/
|
||||||
Class<? extends MapDataStrategy<? extends GenericsDataModel>> getStrategy();
|
Class<? extends GenericsDataStrategy<? extends GenericsDataModel>> getStrategyClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据模型策略处理器
|
* 获取数据模型策略处理器
|
||||||
*
|
*
|
||||||
* @param <Model> Model
|
* @param <M> Model
|
||||||
* @param <Strategy> Strategy
|
* @param <S> Strategy
|
||||||
* @return StrategyBean
|
* @return Strategy Bean
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
default <M extends GenericsDataModel, S extends GenericsDataStrategy<M>> S getStrategy() {
|
||||||
default <Model extends GenericsDataModel, Strategy extends MapDataStrategy<Model>> Strategy getStrategyBean() {
|
return (S) SpringHolder.getBean(this.getStrategyClass());
|
||||||
return (Strategy) SpringHolder.getBean(this.getStrategy());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 反序列化对象
|
* 反序列化对象
|
||||||
*
|
*
|
||||||
* @param json json
|
* @param serialModel serialModel
|
||||||
* @param <Model> Model
|
* @param <M> Model
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
default <M extends GenericsDataModel> M parse(String serialModel) {
|
||||||
default <Model extends GenericsDataModel> Model parse(String json) {
|
return (M) this.getStrategy().parse(serialModel);
|
||||||
return (Model) JSON.parseObject(json, this.getModel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转为视图对象
|
||||||
|
*
|
||||||
|
* @param serialModel serialModel
|
||||||
|
* @param <M> Model
|
||||||
|
* @return viewModel
|
||||||
|
*/
|
||||||
|
default <M extends GenericsDataModel> M toView(String serialModel) {
|
||||||
|
GenericsDataStrategy<GenericsDataModel> strategy = this.getStrategy();
|
||||||
|
GenericsDataModel model = strategy.parse(serialModel);
|
||||||
|
strategy.toView(model);
|
||||||
|
return (M) model;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.orion.visor.framework.common.handler.data.model;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标准数据模型
|
* 标准数据模型
|
||||||
*
|
*
|
||||||
@@ -20,4 +22,14 @@ public interface GenericsDataModel {
|
|||||||
return JSON.toJSONString(this);
|
return JSON.toJSONString(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转为 map
|
||||||
|
*
|
||||||
|
* @return map
|
||||||
|
*/
|
||||||
|
default Map<String, Object> toMap() {
|
||||||
|
return JSON.parseObject(this.serial());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.orion.visor.framework.common.handler.data.strategy;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准数据处理策略 基类
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2024/6/11 21:44
|
||||||
|
*/
|
||||||
|
public abstract class AbstractGenericsDataStrategy<M extends GenericsDataModel> implements GenericsDataStrategy<M> {
|
||||||
|
|
||||||
|
protected final Class<M> modelClass;
|
||||||
|
|
||||||
|
public AbstractGenericsDataStrategy(Class<M> modelClass) {
|
||||||
|
this.modelClass = modelClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新填充
|
||||||
|
*
|
||||||
|
* @param beforeModel 修改前的配置
|
||||||
|
* @param afterModel 修改后的配置
|
||||||
|
*/
|
||||||
|
protected void updateFill(M beforeModel, M afterModel) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预校验参数
|
||||||
|
*
|
||||||
|
* @param model model
|
||||||
|
*/
|
||||||
|
protected void preValid(M model) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验参数
|
||||||
|
*
|
||||||
|
* @param model model
|
||||||
|
*/
|
||||||
|
protected void valid(M model) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doValid(M beforeModel, M afterModel) {
|
||||||
|
// 预校验参数
|
||||||
|
this.preValid(afterModel);
|
||||||
|
// 更新填充
|
||||||
|
this.updateFill(beforeModel, afterModel);
|
||||||
|
// 校验参数
|
||||||
|
this.valid(afterModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public M parse(String serialModel) {
|
||||||
|
return JSON.parseObject(serialModel, modelClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toView(M model) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,60 +9,38 @@ import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
|||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @since 2023/12/20 22:09
|
* @since 2023/12/20 22:09
|
||||||
*/
|
*/
|
||||||
public interface GenericsDataStrategy<Model extends GenericsDataModel, View> {
|
public interface GenericsDataStrategy<M extends GenericsDataModel> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取默认值
|
* 获取默认值
|
||||||
*
|
*
|
||||||
* @return 默认值
|
* @return 默认值
|
||||||
*/
|
*/
|
||||||
Model getDefault();
|
M getDefault();
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新填充
|
|
||||||
*
|
|
||||||
* @param beforeModel 修改前的配置
|
|
||||||
* @param afterModel 修改后的配置
|
|
||||||
*/
|
|
||||||
void updateFill(Model beforeModel, Model afterModel);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预校验参数
|
|
||||||
*
|
|
||||||
* @param model model
|
|
||||||
*/
|
|
||||||
void preValid(Model model);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验参数
|
|
||||||
*
|
|
||||||
* @param model model
|
|
||||||
*/
|
|
||||||
void valid(Model model);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行完整验证链
|
* 执行完整验证链
|
||||||
* <p>
|
* <p>
|
||||||
* preValid > updateFill > preValid
|
* preValid > updateFill > valid
|
||||||
*
|
*
|
||||||
* @param beforeModel beforeModel
|
* @param beforeModel beforeModel
|
||||||
* @param afterModel afterModel
|
* @param afterModel afterModel
|
||||||
*/
|
*/
|
||||||
default void doValidChain(Model beforeModel, Model afterModel) {
|
void doValid(M beforeModel, M afterModel);
|
||||||
// 预校验参数
|
|
||||||
this.preValid(afterModel);
|
/**
|
||||||
// 更新填充
|
* 解析数据
|
||||||
this.updateFill(beforeModel, afterModel);
|
*
|
||||||
// 校验参数
|
* @param serialModel serialModel
|
||||||
this.valid(afterModel);
|
* @return model
|
||||||
}
|
*/
|
||||||
|
M parse(String serialModel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转为视图配置
|
* 转为视图配置
|
||||||
*
|
*
|
||||||
* @param model model
|
* @param model model
|
||||||
* @return 视图配置
|
|
||||||
*/
|
*/
|
||||||
View toView(String model);
|
void toView(M model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.orion.visor.framework.common.handler.data.strategy;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* map 数据处理策略
|
|
||||||
*
|
|
||||||
* @author Jiahang Li
|
|
||||||
* @version 1.0.0
|
|
||||||
* @since 2023/12/20 22:11
|
|
||||||
*/
|
|
||||||
public interface MapDataStrategy<Model extends GenericsDataModel> extends GenericsDataStrategy<Model, Map<String, Object>> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default Map<String, Object> toView(String model) {
|
|
||||||
return JSONObject.parseObject(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,8 +2,12 @@ package com.orion.visor.framework.common.utils;
|
|||||||
|
|
||||||
import com.orion.ext.location.Region;
|
import com.orion.ext.location.Region;
|
||||||
import com.orion.ext.location.region.LocationRegions;
|
import com.orion.ext.location.region.LocationRegions;
|
||||||
|
import com.orion.lang.constant.StandardHttpHeader;
|
||||||
|
import com.orion.lang.utils.Strings;
|
||||||
import com.orion.visor.framework.common.constant.Const;
|
import com.orion.visor.framework.common.constant.Const;
|
||||||
|
import com.orion.web.servlet.web.Servlets;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -21,6 +25,22 @@ public class IpUtils {
|
|||||||
private IpUtils() {
|
private IpUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取请求地址
|
||||||
|
*
|
||||||
|
* @param request request
|
||||||
|
* @return addr
|
||||||
|
*/
|
||||||
|
public static String getRemoteAddr(HttpServletRequest request) {
|
||||||
|
// 获取实际地址
|
||||||
|
String realIp = request.getHeader(StandardHttpHeader.X_REAL_IP);
|
||||||
|
if (!Strings.isBlank(realIp)) {
|
||||||
|
return realIp;
|
||||||
|
}
|
||||||
|
// 获取请求地址
|
||||||
|
return Servlets.getRemoteAddr(request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 ip 位置
|
* 获取 ip 位置
|
||||||
*
|
*
|
||||||
@@ -29,7 +49,7 @@ public class IpUtils {
|
|||||||
*/
|
*/
|
||||||
public static String getLocation(String ip) {
|
public static String getLocation(String ip) {
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
return Const.UNKNOWN;
|
return Const.CN_UNKNOWN;
|
||||||
}
|
}
|
||||||
// 查询缓存
|
// 查询缓存
|
||||||
return CACHE.computeIfAbsent(ip, IpUtils::queryLocation);
|
return CACHE.computeIfAbsent(ip, IpUtils::queryLocation);
|
||||||
@@ -43,21 +63,21 @@ public class IpUtils {
|
|||||||
*/
|
*/
|
||||||
private static String queryLocation(String ip) {
|
private static String queryLocation(String ip) {
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
return Const.UNKNOWN;
|
return Const.CN_UNKNOWN;
|
||||||
}
|
}
|
||||||
Region region;
|
Region region;
|
||||||
try {
|
try {
|
||||||
region = LocationRegions.getRegion(ip, 3);
|
region = LocationRegions.getRegion(ip, 3);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Const.UNKNOWN;
|
return Const.CN_UNKNOWN;
|
||||||
}
|
}
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
String net = region.getNet();
|
String net = region.getNet();
|
||||||
String province = region.getProvince();
|
String province = region.getProvince();
|
||||||
if (net.equals(Const.INTRANET_IP)) {
|
if (net.equals(Const.CN_INTRANET_IP)) {
|
||||||
return net;
|
return net;
|
||||||
}
|
}
|
||||||
if (province.equals(Const.UNKNOWN)) {
|
if (province.equals(Const.CN_UNKNOWN)) {
|
||||||
return province;
|
return province;
|
||||||
}
|
}
|
||||||
StringBuilder location = new StringBuilder()
|
StringBuilder location = new StringBuilder()
|
||||||
@@ -69,7 +89,7 @@ public class IpUtils {
|
|||||||
location.append(" (").append(net).append(')');
|
location.append(" (").append(net).append(')');
|
||||||
return location.toString();
|
return location.toString();
|
||||||
}
|
}
|
||||||
return Const.UNKNOWN;
|
return Const.CN_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ public class PathUtils {
|
|||||||
public static String getAppPath(boolean isWindows, String username) {
|
public static String getAppPath(boolean isWindows, String username) {
|
||||||
return getHomePath(isWindows, username)
|
return getHomePath(isWindows, username)
|
||||||
+ "/" + AppConst.ORION
|
+ "/" + AppConst.ORION
|
||||||
+ "/" + AppConst.ORION_VISOR;
|
+ "/" + AppConst.APP_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class Requests {
|
|||||||
.map(s -> (ServletRequestAttributes) s)
|
.map(s -> (ServletRequestAttributes) s)
|
||||||
.map(ServletRequestAttributes::getRequest)
|
.map(ServletRequestAttributes::getRequest)
|
||||||
.ifPresent(request -> {
|
.ifPresent(request -> {
|
||||||
String address = Servlets.getRemoteAddr(request);
|
String address = IpUtils.getRemoteAddr(request);
|
||||||
identity.setAddress(address);
|
identity.setAddress(address);
|
||||||
identity.setLocation(IpUtils.getLocation(address));
|
identity.setLocation(IpUtils.getLocation(address));
|
||||||
identity.setUserAgent(Servlets.getUserAgent(request));
|
identity.setUserAgent(Servlets.getUserAgent(request));
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
{
|
{
|
||||||
"name": "orion.async.executor.core-pool-size",
|
"name": "orion.async.executor.core-pool-size",
|
||||||
"type": "java.lang.Integer",
|
"type": "java.lang.Integer",
|
||||||
"description": "核心线程数量",
|
"description": "核心线程数量.",
|
||||||
"defaultValue": "8"
|
"defaultValue": "8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目 banner 打印包</description>
|
<description>项目 banner 打印包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class BannerApplicationRunner implements ApplicationRunner {
|
|||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) {
|
public void run(ApplicationArguments args) {
|
||||||
AnsiAppender appender = AnsiAppender.create()
|
AnsiAppender appender = AnsiAppender.create()
|
||||||
.append(AnsiForeground.BRIGHT_GREEN, ":: orion-visor-launch v" + version + " 服务已启动(" + env + ") ::\n");
|
.append(AnsiForeground.BRIGHT_GREEN, ":: orion-visor v" + version + " 服务已启动(" + env + ") ::\n");
|
||||||
// swagger 地址
|
// swagger 地址
|
||||||
if (apiDocsEnabled) {
|
if (apiDocsEnabled) {
|
||||||
appender.append(AnsiForeground.BRIGHT_GREEN, ":: swagger 文档 ")
|
appender.append(AnsiForeground.BRIGHT_GREEN, ":: swagger 文档 ")
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目操作日志包</description>
|
<description>项目操作日志包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目数据源配置包</description>
|
<description>项目数据源配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目数据脱敏包</description>
|
<description>项目数据脱敏包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目定时任务配置包</description>
|
<description>项目定时任务配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目日志配置包</description>
|
<description>项目日志配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.orion.visor.framework.log.configuration.config;
|
package com.orion.visor.framework.log.configuration.config;
|
||||||
|
|
||||||
import com.orion.visor.framework.common.utils.ConfigUtils;
|
import com.orion.visor.framework.common.utils.ConfigUtils;
|
||||||
|
import com.orion.visor.framework.log.core.enums.LogPrinterMode;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
@@ -17,6 +18,11 @@ import java.util.List;
|
|||||||
@ConfigurationProperties("orion.logging.printer")
|
@ConfigurationProperties("orion.logging.printer")
|
||||||
public class LogPrinterConfig {
|
public class LogPrinterConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型
|
||||||
|
*/
|
||||||
|
private LogPrinterMode mode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段配置
|
* 字段配置
|
||||||
*/
|
*/
|
||||||
@@ -32,12 +38,31 @@ public class LogPrinterConfig {
|
|||||||
*/
|
*/
|
||||||
private String expression;
|
private String expression;
|
||||||
|
|
||||||
public void setField(LogPrinterFieldConfig field) {
|
|
||||||
this.field = field;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeaders(List<String> headers) {
|
public void setHeaders(List<String> headers) {
|
||||||
this.headers = ConfigUtils.parseStringList(headers, String::toLowerCase);
|
this.headers = ConfigUtils.parseStringList(headers, String::toLowerCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class LogPrinterFieldConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略的字段
|
||||||
|
*/
|
||||||
|
private List<String> ignore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 脱敏的字段
|
||||||
|
*/
|
||||||
|
private List<String> desensitize;
|
||||||
|
|
||||||
|
public void setIgnore(List<String> ignore) {
|
||||||
|
this.ignore = ConfigUtils.parseStringList(ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDesensitize(List<String> desensitize) {
|
||||||
|
this.desensitize = ConfigUtils.parseStringList(desensitize);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.orion.visor.framework.log.configuration.config;
|
|
||||||
|
|
||||||
import com.orion.visor.framework.common.utils.ConfigUtils;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志打印字段配置
|
|
||||||
*
|
|
||||||
* @author Jiahang Li
|
|
||||||
* @version 1.0.0
|
|
||||||
* @since 2023/6/28 22:36
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class LogPrinterFieldConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 忽略的字段
|
|
||||||
*/
|
|
||||||
private List<String> ignore;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 脱敏的字段
|
|
||||||
*/
|
|
||||||
private List<String> desensitize;
|
|
||||||
|
|
||||||
public void setIgnore(List<String> ignore) {
|
|
||||||
this.ignore = ConfigUtils.parseStringList(ignore);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDesensitize(List<String> desensitize) {
|
|
||||||
this.desensitize = ConfigUtils.parseStringList(desensitize);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@ package com.orion.visor.framework.log.core.interceptor;
|
|||||||
import com.orion.lang.utils.Exceptions;
|
import com.orion.lang.utils.Exceptions;
|
||||||
import com.orion.lang.utils.Strings;
|
import com.orion.lang.utils.Strings;
|
||||||
import com.orion.lang.utils.time.Dates;
|
import com.orion.lang.utils.time.Dates;
|
||||||
|
import com.orion.visor.framework.common.utils.IpUtils;
|
||||||
import com.orion.visor.framework.common.utils.SwaggerUtils;
|
import com.orion.visor.framework.common.utils.SwaggerUtils;
|
||||||
import com.orion.visor.framework.log.configuration.config.LogPrinterConfig;
|
import com.orion.visor.framework.log.configuration.config.LogPrinterConfig;
|
||||||
import com.orion.web.servlet.web.Servlets;
|
import com.orion.web.servlet.web.Servlets;
|
||||||
@@ -60,7 +61,7 @@ public class PrettyLogPrinterInterceptor extends AbstractLogPrinterInterceptor {
|
|||||||
// http
|
// http
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
// remoteAddr
|
// remoteAddr
|
||||||
requestLog.append("\tremoteAddr: ").append(Servlets.getRemoteAddr(request)).append('\n');
|
requestLog.append("\tremoteAddr: ").append(IpUtils.getRemoteAddr(request)).append('\n');
|
||||||
// header
|
// header
|
||||||
Servlets.getHeaderMap(request).forEach((hk, hv) -> {
|
Servlets.getHeaderMap(request).forEach((hk, hv) -> {
|
||||||
if (headerFilter.test(hk.toLowerCase())) {
|
if (headerFilter.test(hk.toLowerCase())) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.orion.lang.utils.Exceptions;
|
import com.orion.lang.utils.Exceptions;
|
||||||
import com.orion.lang.utils.Strings;
|
import com.orion.lang.utils.Strings;
|
||||||
import com.orion.lang.utils.time.Dates;
|
import com.orion.lang.utils.time.Dates;
|
||||||
|
import com.orion.visor.framework.common.utils.IpUtils;
|
||||||
import com.orion.visor.framework.common.utils.SwaggerUtils;
|
import com.orion.visor.framework.common.utils.SwaggerUtils;
|
||||||
import com.orion.visor.framework.log.configuration.config.LogPrinterConfig;
|
import com.orion.visor.framework.log.configuration.config.LogPrinterConfig;
|
||||||
import com.orion.visor.framework.log.core.enums.LogFieldConst;
|
import com.orion.visor.framework.log.core.enums.LogFieldConst;
|
||||||
@@ -61,7 +62,7 @@ public class RowLogPrinterInterceptor extends AbstractLogPrinterInterceptor impl
|
|||||||
// http
|
// http
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
// remoteAddr
|
// remoteAddr
|
||||||
fields.put(REMOTE_ADDR, Servlets.getRemoteAddr(request));
|
fields.put(REMOTE_ADDR, IpUtils.getRemoteAddr(request));
|
||||||
// header
|
// header
|
||||||
Map<String, Object> headers = new LinkedHashMap<>();
|
Map<String, Object> headers = new LinkedHashMap<>();
|
||||||
Servlets.getHeaderMap(request).forEach((hk, hv) -> {
|
Servlets.getHeaderMap(request).forEach((hk, hv) -> {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目监控配置包</description>
|
<description>项目监控配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目 mybatis 配置包</description>
|
<description>项目 mybatis 配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目 redis 配置包</description>
|
<description>项目 redis 配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目 security 配置包</description>
|
<description>项目 security 配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package com.orion.visor.framework.security.configuration;
|
|||||||
|
|
||||||
import com.orion.visor.framework.common.constant.AutoConfigureOrderConst;
|
import com.orion.visor.framework.common.constant.AutoConfigureOrderConst;
|
||||||
import com.orion.visor.framework.common.crypto.ValueCrypto;
|
import com.orion.visor.framework.common.crypto.ValueCrypto;
|
||||||
import com.orion.visor.framework.security.configuration.config.CryptoConfig;
|
import com.orion.visor.framework.security.configuration.config.AesCryptoConfig;
|
||||||
import com.orion.visor.framework.security.core.crypto.PrimaryValueCrypto;
|
import com.orion.visor.framework.security.core.crypto.PrimaryValueCrypto;
|
||||||
import com.orion.visor.framework.security.core.crypto.aes.AesCryptoProcessor;
|
import com.orion.visor.framework.security.core.crypto.processor.AesCryptoProcessor;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
@@ -12,8 +12,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目加密解密配置
|
* 项目加密解密配置
|
||||||
*
|
*
|
||||||
@@ -22,13 +20,10 @@ import javax.annotation.Resource;
|
|||||||
* @since 2023/7/7 23:59
|
* @since 2023/7/7 23:59
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@EnableConfigurationProperties(CryptoConfig.class)
|
@EnableConfigurationProperties({AesCryptoConfig.class})
|
||||||
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_SECURITY_CRYPTO)
|
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_SECURITY_CRYPTO)
|
||||||
public class OrionCryptoAutoConfiguration {
|
public class OrionCryptoAutoConfiguration {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CryptoConfig config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 默认加密器
|
* @return 默认加密器
|
||||||
*/
|
*/
|
||||||
@@ -43,8 +38,8 @@ public class OrionCryptoAutoConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean(initMethod = "init")
|
@Bean(initMethod = "init")
|
||||||
@ConditionalOnProperty(value = "orion.crypto.aes.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "orion.crypto.aes.enabled", havingValue = "true")
|
||||||
public ValueCrypto aesValueCrypto() {
|
public ValueCrypto aesValueCrypto(AesCryptoConfig config) {
|
||||||
return new AesCryptoProcessor(config.getAes());
|
return new AesCryptoProcessor(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.orion.visor.framework.security.core.crypto.aes;
|
package com.orion.visor.framework.security.configuration.config;
|
||||||
|
|
||||||
import com.orion.lang.utils.crypto.CryptoConst;
|
import com.orion.lang.utils.crypto.CryptoConst;
|
||||||
import com.orion.lang.utils.crypto.enums.PaddingMode;
|
import com.orion.lang.utils.crypto.enums.PaddingMode;
|
||||||
@@ -6,6 +6,7 @@ import com.orion.lang.utils.crypto.enums.WorkingMode;
|
|||||||
import com.orion.visor.framework.security.core.crypto.CryptoConfig;
|
import com.orion.visor.framework.security.core.crypto.CryptoConfig;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* aes 加密器配置
|
* aes 加密器配置
|
||||||
@@ -16,6 +17,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ConfigurationProperties("orion.crypto.aes")
|
||||||
public class AesCryptoConfig extends CryptoConfig {
|
public class AesCryptoConfig extends CryptoConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.orion.visor.framework.security.configuration.config;
|
|
||||||
|
|
||||||
import com.orion.visor.framework.security.core.crypto.aes.AesCryptoConfig;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加密配置
|
|
||||||
*
|
|
||||||
* @author Jiahang Li
|
|
||||||
* @version 1.0.0
|
|
||||||
* @since 2023/7/8 0:01
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ConfigurationProperties("orion.crypto")
|
|
||||||
public class CryptoConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* aes 加密器配置
|
|
||||||
*/
|
|
||||||
private AesCryptoConfig aes;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.orion.visor.framework.security.core.crypto.aes;
|
package com.orion.visor.framework.security.core.crypto.processor;
|
||||||
|
|
||||||
import com.orion.lang.utils.Strings;
|
import com.orion.lang.utils.Strings;
|
||||||
import com.orion.lang.utils.crypto.Keys;
|
import com.orion.lang.utils.crypto.Keys;
|
||||||
@@ -6,6 +6,7 @@ import com.orion.lang.utils.crypto.enums.CipherAlgorithm;
|
|||||||
import com.orion.lang.utils.crypto.enums.WorkingMode;
|
import com.orion.lang.utils.crypto.enums.WorkingMode;
|
||||||
import com.orion.lang.utils.crypto.symmetric.SymmetricBuilder;
|
import com.orion.lang.utils.crypto.symmetric.SymmetricBuilder;
|
||||||
import com.orion.lang.utils.crypto.symmetric.SymmetricCrypto;
|
import com.orion.lang.utils.crypto.symmetric.SymmetricCrypto;
|
||||||
|
import com.orion.visor.framework.security.configuration.config.AesCryptoConfig;
|
||||||
import com.orion.visor.framework.security.core.crypto.CryptoProcessor;
|
import com.orion.visor.framework.security.core.crypto.CryptoProcessor;
|
||||||
|
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
@@ -5,15 +5,10 @@
|
|||||||
"type": "com.orion.visor.framework.security.configuration.config.SecurityConfig",
|
"type": "com.orion.visor.framework.security.configuration.config.SecurityConfig",
|
||||||
"sourceType": "com.orion.visor.framework.security.configuration.config.SecurityConfig"
|
"sourceType": "com.orion.visor.framework.security.configuration.config.SecurityConfig"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "orion.crypto",
|
|
||||||
"type": "com.orion.visor.framework.security.configuration.config.CryptoConfig",
|
|
||||||
"sourceType": "com.orion.visor.framework.security.configuration.config.CryptoConfig"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "orion.crypto.aes",
|
"name": "orion.crypto.aes",
|
||||||
"type": "com.orion.visor.framework.security.core.crypto.aes.AesCryptoConfig",
|
"type": "com.orion.visor.framework.security.configuration.config.AesCryptoConfig",
|
||||||
"sourceType": "com.orion.visor.framework.security.core.crypto.aes.AesCryptoConfig"
|
"sourceType": "com.orion.visor.framework.security.configuration.config.AesCryptoConfig"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"properties": [
|
"properties": [
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目存储层配置包</description>
|
<description>项目存储层配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ package com.orion.visor.framework.storage.configuration;
|
|||||||
|
|
||||||
import com.orion.visor.framework.common.constant.AutoConfigureOrderConst;
|
import com.orion.visor.framework.common.constant.AutoConfigureOrderConst;
|
||||||
import com.orion.visor.framework.common.file.FileClient;
|
import com.orion.visor.framework.common.file.FileClient;
|
||||||
import com.orion.visor.framework.storage.configuration.config.StorageConfig;
|
import com.orion.visor.framework.storage.configuration.config.LocalStorageConfig;
|
||||||
|
import com.orion.visor.framework.storage.configuration.config.LogsStorageConfig;
|
||||||
import com.orion.visor.framework.storage.core.client.PrimaryFileClient;
|
import com.orion.visor.framework.storage.core.client.PrimaryFileClient;
|
||||||
import com.orion.visor.framework.storage.core.client.local.LocalFileClient;
|
import com.orion.visor.framework.storage.core.client.local.LocalFileClient;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
@@ -12,8 +13,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储配置类
|
* 存储配置类
|
||||||
*
|
*
|
||||||
@@ -25,12 +24,9 @@ import javax.annotation.Resource;
|
|||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_STORAGE)
|
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_STORAGE)
|
||||||
@EnableConfigurationProperties(StorageConfig.class)
|
@EnableConfigurationProperties({LocalStorageConfig.class, LogsStorageConfig.class})
|
||||||
public class OrionStorageAutoConfiguration {
|
public class OrionStorageAutoConfiguration {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private StorageConfig config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 默认文件客户端
|
* @return 默认文件客户端
|
||||||
*/
|
*/
|
||||||
@@ -45,8 +41,8 @@ public class OrionStorageAutoConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "orion.storage.local.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "orion.storage.local.enabled", havingValue = "true")
|
||||||
public FileClient localFileClient() {
|
public FileClient localFileClient(LocalStorageConfig config) {
|
||||||
return new LocalFileClient(config.getLocal());
|
return new LocalFileClient(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,8 +50,8 @@ public class OrionStorageAutoConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "orion.storage.logs.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "orion.storage.logs.enabled", havingValue = "true")
|
||||||
public FileClient logsFileClient() {
|
public FileClient logsFileClient(LogsStorageConfig config) {
|
||||||
return new LocalFileClient(config.getLogs());
|
return new LocalFileClient(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,27 +2,19 @@ package com.orion.visor.framework.storage.configuration.config;
|
|||||||
|
|
||||||
import com.orion.visor.framework.storage.core.client.local.LocalFileClientConfig;
|
import com.orion.visor.framework.storage.core.client.local.LocalFileClientConfig;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储配置
|
* 本地存储配置
|
||||||
*
|
*
|
||||||
* @author Jiahang Li
|
* @author Jiahang Li
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @since 2023/6/30 18:40
|
* @since 2023/6/30 18:40
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ConfigurationProperties(prefix = "orion.storage")
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class StorageConfig {
|
@ConfigurationProperties(prefix = "orion.storage.local")
|
||||||
|
public class LocalStorageConfig extends LocalFileClientConfig {
|
||||||
/**
|
|
||||||
* 本地文件客户端 配置
|
|
||||||
*/
|
|
||||||
private LocalFileClientConfig local;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志文件客户端 配置
|
|
||||||
*/
|
|
||||||
private LocalFileClientConfig logs;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.orion.visor.framework.storage.configuration.config;
|
||||||
|
|
||||||
|
import com.orion.visor.framework.storage.core.client.local.LocalFileClientConfig;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志存储配置
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2023/6/30 18:40
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ConfigurationProperties(prefix = "orion.storage.logs")
|
||||||
|
public class LogsStorageConfig extends LocalFileClientConfig {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
{
|
{
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
|
||||||
"name": "orion.storage",
|
|
||||||
"type": "com.orion.visor.framework.storage.configuration.config.StorageConfig",
|
|
||||||
"sourceType": "com.orion.visor.framework.storage.configuration.config.StorageConfig"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "orion.storage.local",
|
"name": "orion.storage.local",
|
||||||
"type": "com.orion.visor.framework.storage.core.client.local.LocalFileClientConfig",
|
"type": "com.orion.visor.framework.storage.configuration.config.LocalStorageConfig",
|
||||||
"sourceType": "com.orion.visor.framework.storage.core.client.local.LocalFileClientConfig"
|
"sourceType": "com.orion.visor.framework.storage.configuration.config.LocalStorageConfig"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "orion.storage.logs",
|
"name": "orion.storage.logs",
|
||||||
"type": "com.orion.visor.framework.storage.core.client.local.LocalFileClientConfig",
|
"type": "com.orion.visor.framework.storage.configuration.config.LogsStorageConfig",
|
||||||
"sourceType": "com.orion.visor.framework.storage.core.client.local.LocalFileClientConfig"
|
"sourceType": "com.orion.visor.framework.storage.configuration.config.LogsStorageConfig"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"properties": [
|
"properties": [
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目 swagger 配置包</description>
|
<description>项目 swagger 配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目单元测试包</description>
|
<description>项目单元测试包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目 web 包</description>
|
<description>项目 web 包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目 websocket 配置包</description>
|
<description>项目 websocket 配置包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
{
|
{
|
||||||
"name": "orion.websocket.prefix",
|
"name": "orion.websocket.prefix",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
"description": "公共 websocket 前缀"
|
"description": "公共 websocket 前缀."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "orion.websocket.binary-buffer-size",
|
"name": "orion.websocket.binary-buffer-size",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<description>项目组件包</description>
|
<description>项目组件包</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>orion-visor-framework-common</module>
|
<module>orion-visor-framework-common</module>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>后端服务主项目容器 按需引用 orion-visor-module-xxx 依赖</description>
|
<description>后端服务主项目容器 按需引用 orion-visor-module-xxx 依赖</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- spring boot 配置所需依赖 -->
|
<!-- spring boot 配置所需依赖 -->
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ server:
|
|||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: orion-visor-launch
|
name: orion-visor
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
main:
|
main:
|
||||||
@@ -142,7 +142,7 @@ knife4j:
|
|||||||
|
|
||||||
logging:
|
logging:
|
||||||
file:
|
file:
|
||||||
path: ${user.home}/orion/logs/orion-visor
|
path: ${user.home}/orion/logs/${spring.application.name}
|
||||||
name: ${logging.file.path}/app.log
|
name: ${logging.file.path}/app.log
|
||||||
logback:
|
logback:
|
||||||
rollingpolicy:
|
rollingpolicy:
|
||||||
@@ -189,10 +189,16 @@ app:
|
|||||||
exec-log:
|
exec-log:
|
||||||
# 是否拼接 ansi 执行状态日志
|
# 是否拼接 ansi 执行状态日志
|
||||||
append-ansi: true
|
append-ansi: true
|
||||||
# 自动清理执行文件
|
# 自动清理配置
|
||||||
auto-clear: true
|
auto-clear:
|
||||||
# 保留周期 (天)
|
# 批量执行日志
|
||||||
keep-period: 30
|
exec-log:
|
||||||
|
enabled: false
|
||||||
|
keep-period: 30
|
||||||
|
# 主机连接日志
|
||||||
|
host-connect-log:
|
||||||
|
enabled: false
|
||||||
|
keep-period: 30
|
||||||
|
|
||||||
# orion framework config
|
# orion framework config
|
||||||
orion:
|
orion:
|
||||||
@@ -220,10 +226,10 @@ orion:
|
|||||||
title: orion-visor 运维平台
|
title: orion-visor 运维平台
|
||||||
description: 一站式运维服务平台
|
description: 一站式运维服务平台
|
||||||
version: ${orion.version}
|
version: ${orion.version}
|
||||||
url: https://github.com/lijiahangmax/orion-visor
|
url: https://github.com/dromara/orion-visor
|
||||||
email: ljh1553488six@139.com
|
email: ljh1553488six@139.com
|
||||||
license: Apache-2.0
|
license: Apache-2.0
|
||||||
license-url: https://github.com/lijiahangmax/orion-visor/blob/main/LICENSE
|
license-url: https://github.com/dromara/orion-visor/blob/main/LICENSE
|
||||||
grouped-api:
|
grouped-api:
|
||||||
infra:
|
infra:
|
||||||
group: "infra - 基建模块"
|
group: "infra - 基建模块"
|
||||||
@@ -253,14 +259,14 @@ orion:
|
|||||||
timestamp-prefix: false
|
timestamp-prefix: false
|
||||||
date-directory: false
|
date-directory: false
|
||||||
storage-path: ${user.home}
|
storage-path: ${user.home}
|
||||||
base-path: /orion/orion-visor/storage
|
base-path: /orion/${spring.application.name}/storage
|
||||||
# 日志文件存储
|
# 日志文件存储
|
||||||
logs:
|
logs:
|
||||||
enabled: true
|
enabled: true
|
||||||
timestamp-prefix: false
|
timestamp-prefix: false
|
||||||
date-directory: false
|
date-directory: false
|
||||||
storage-path: ${user.home}
|
storage-path: ${user.home}
|
||||||
base-path: /orion/orion-visor/logs
|
base-path: /orion/${spring.application.name}/logs
|
||||||
security:
|
security:
|
||||||
password-encoder-length: 4
|
password-encoder-length: 4
|
||||||
# 匿名接口
|
# 匿名接口
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目资产模块</description>
|
<description>项目资产模块</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<description>项目资产模块</description>
|
<description>项目资产模块</description>
|
||||||
<url>https://github.com/lijiahangmax/orion-visor</url>
|
<url>https://github.com/dromara/orion-visor</url>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.orion.visor.module.asset.define.config;
|
||||||
|
|
||||||
|
import com.orion.visor.framework.common.entity.AutoClearConfig;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量执行日志自动清理配置
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2024/6/24 15:01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ConfigurationProperties(prefix = "app.auto-clear.exec-log")
|
||||||
|
public class AppExecLogAutoClearConfig extends AutoClearConfig {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,20 +21,8 @@ public class AppExecLogConfig {
|
|||||||
*/
|
*/
|
||||||
private Boolean appendAnsi;
|
private Boolean appendAnsi;
|
||||||
|
|
||||||
/**
|
|
||||||
* 自动清理执行文件
|
|
||||||
*/
|
|
||||||
private Boolean autoClear;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保留周期 (天)
|
|
||||||
*/
|
|
||||||
private Integer keepPeriod;
|
|
||||||
|
|
||||||
public AppExecLogConfig() {
|
public AppExecLogConfig() {
|
||||||
this.appendAnsi = true;
|
this.appendAnsi = true;
|
||||||
this.autoClear = true;
|
|
||||||
this.keepPeriod = 30;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.orion.visor.module.asset.define.config;
|
||||||
|
|
||||||
|
import com.orion.visor.framework.common.entity.AutoClearConfig;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主机连接日志自动清理配置
|
||||||
|
*
|
||||||
|
* @author Jiahang Li
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2024/6/24 15:01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ConfigurationProperties(prefix = "app.auto-clear.host-connect-log")
|
||||||
|
public class AppHostConnectLogAutoClearConfig extends AutoClearConfig {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import lombok.*;
|
|||||||
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量执行日志 查询请求对象
|
* 批量执行日志 查询请求对象
|
||||||
@@ -54,4 +55,11 @@ public class ExecLogQueryRequest extends PageRequest {
|
|||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date[] startTimeRange;
|
private Date[] startTimeRange;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间 <=")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeLe;
|
||||||
|
|
||||||
|
@Schema(description = "状态")
|
||||||
|
private List<String> statusList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,4 +56,11 @@ public class HostConnectLogQueryRequest extends PageRequest {
|
|||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date[] startTimeRange;
|
private Date[] startTimeRange;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间 <=")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeLe;
|
||||||
|
|
||||||
|
@Schema(description = "状态")
|
||||||
|
private List<String> statusList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.orion.visor.module.asset.enums;
|
package com.orion.visor.module.asset.enums;
|
||||||
|
|
||||||
|
import com.orion.lang.utils.collect.Lists;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量执行状态
|
* 批量执行状态
|
||||||
*
|
*
|
||||||
@@ -36,6 +39,8 @@ public enum ExecStatusEnum {
|
|||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
public static final List<String> FINISH_STATUS_LIST = Lists.of(COMPLETED.name(), FAILED.name());
|
||||||
|
|
||||||
private final boolean closeable;
|
private final boolean closeable;
|
||||||
|
|
||||||
public static ExecStatusEnum of(String status) {
|
public static ExecStatusEnum of(String status) {
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ package com.orion.visor.module.asset.enums;
|
|||||||
import com.orion.visor.framework.common.enums.EnableStatus;
|
import com.orion.visor.framework.common.enums.EnableStatus;
|
||||||
import com.orion.visor.framework.common.handler.data.GenericsDataDefinition;
|
import com.orion.visor.framework.common.handler.data.GenericsDataDefinition;
|
||||||
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
||||||
import com.orion.visor.framework.common.handler.data.strategy.MapDataStrategy;
|
import com.orion.visor.framework.common.handler.data.strategy.GenericsDataStrategy;
|
||||||
import com.orion.visor.module.asset.handler.host.config.model.HostSshConfigModel;
|
|
||||||
import com.orion.visor.module.asset.handler.host.config.strategy.HostSshConfigStrategy;
|
import com.orion.visor.module.asset.handler.host.config.strategy.HostSshConfigStrategy;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -24,7 +23,6 @@ public enum HostConfigTypeEnum implements GenericsDataDefinition {
|
|||||||
* SSH 配置
|
* SSH 配置
|
||||||
*/
|
*/
|
||||||
SSH("ssh",
|
SSH("ssh",
|
||||||
HostSshConfigModel.class,
|
|
||||||
HostSshConfigStrategy.class,
|
HostSshConfigStrategy.class,
|
||||||
EnableStatus.ENABLED.getValue()),
|
EnableStatus.ENABLED.getValue()),
|
||||||
|
|
||||||
@@ -32,9 +30,7 @@ public enum HostConfigTypeEnum implements GenericsDataDefinition {
|
|||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
private final Class<? extends GenericsDataModel> model;
|
private final Class<? extends GenericsDataStrategy<? extends GenericsDataModel>> strategyClass;
|
||||||
|
|
||||||
private final Class<? extends MapDataStrategy<? extends GenericsDataModel>> strategy;
|
|
||||||
|
|
||||||
private final Integer defaultStatus;
|
private final Integer defaultStatus;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.orion.visor.module.asset.enums;
|
package com.orion.visor.module.asset.enums;
|
||||||
|
|
||||||
|
import com.orion.lang.utils.collect.Lists;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主机连接状态
|
* 主机连接状态
|
||||||
*
|
*
|
||||||
@@ -31,6 +35,8 @@ public enum HostConnectStatusEnum {
|
|||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
public static final List<String> FINISH_STATUS_LIST = Lists.of(COMPLETE.name(), FAILED.name(), FORCE_OFFLINE.name());
|
||||||
|
|
||||||
public static HostConnectStatusEnum of(String type) {
|
public static HostConnectStatusEnum of(String type) {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package com.orion.visor.module.asset.enums;
|
|||||||
|
|
||||||
import com.orion.visor.framework.common.handler.data.GenericsDataDefinition;
|
import com.orion.visor.framework.common.handler.data.GenericsDataDefinition;
|
||||||
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
||||||
import com.orion.visor.framework.common.handler.data.strategy.MapDataStrategy;
|
import com.orion.visor.framework.common.handler.data.strategy.GenericsDataStrategy;
|
||||||
import com.orion.visor.module.asset.handler.host.extra.model.HostLabelExtraModel;
|
|
||||||
import com.orion.visor.module.asset.handler.host.extra.model.HostSshExtraModel;
|
|
||||||
import com.orion.visor.module.asset.handler.host.extra.strategy.HostLabelExtraStrategy;
|
import com.orion.visor.module.asset.handler.host.extra.strategy.HostLabelExtraStrategy;
|
||||||
import com.orion.visor.module.asset.handler.host.extra.strategy.HostSshExtraStrategy;
|
import com.orion.visor.module.asset.handler.host.extra.strategy.HostSshExtraStrategy;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -24,20 +22,18 @@ public enum HostExtraItemEnum implements GenericsDataDefinition {
|
|||||||
/**
|
/**
|
||||||
* SSH 额外配置
|
* SSH 额外配置
|
||||||
*/
|
*/
|
||||||
SSH("ssh", HostSshExtraModel.class, HostSshExtraStrategy.class),
|
SSH("ssh", HostSshExtraStrategy.class),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签额外配置
|
* 标签额外配置
|
||||||
*/
|
*/
|
||||||
LABEL("label", HostLabelExtraModel.class, HostLabelExtraStrategy.class),
|
LABEL("label", HostLabelExtraStrategy.class),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String item;
|
private final String item;
|
||||||
|
|
||||||
private final Class<? extends GenericsDataModel> model;
|
private final Class<? extends GenericsDataStrategy<? extends GenericsDataModel>> strategyClass;
|
||||||
|
|
||||||
private final Class<? extends MapDataStrategy<? extends GenericsDataModel>> strategy;
|
|
||||||
|
|
||||||
public static HostExtraItemEnum of(String type) {
|
public static HostExtraItemEnum of(String type) {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package com.orion.visor.module.asset.handler.host.config.strategy;
|
package com.orion.visor.module.asset.handler.host.config.strategy;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.orion.lang.utils.Booleans;
|
import com.orion.lang.utils.Booleans;
|
||||||
import com.orion.lang.utils.Charsets;
|
import com.orion.lang.utils.Charsets;
|
||||||
import com.orion.lang.utils.Exceptions;
|
import com.orion.lang.utils.Exceptions;
|
||||||
import com.orion.lang.utils.Strings;
|
import com.orion.lang.utils.Strings;
|
||||||
import com.orion.visor.framework.common.constant.Const;
|
import com.orion.visor.framework.common.constant.Const;
|
||||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.visor.framework.common.handler.data.strategy.MapDataStrategy;
|
import com.orion.visor.framework.common.handler.data.strategy.AbstractGenericsDataStrategy;
|
||||||
import com.orion.visor.framework.common.security.PasswordModifier;
|
import com.orion.visor.framework.common.security.PasswordModifier;
|
||||||
import com.orion.visor.framework.common.utils.Valid;
|
import com.orion.visor.framework.common.utils.Valid;
|
||||||
import com.orion.visor.module.asset.dao.HostIdentityDAO;
|
import com.orion.visor.module.asset.dao.HostIdentityDAO;
|
||||||
@@ -18,7 +17,6 @@ import com.orion.visor.module.asset.handler.host.config.model.HostSshConfigModel
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主机 SSH 配置策略
|
* 主机 SSH 配置策略
|
||||||
@@ -28,7 +26,7 @@ import java.util.Map;
|
|||||||
* @since 2023/9/19 14:26
|
* @since 2023/9/19 14:26
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class HostSshConfigStrategy implements MapDataStrategy<HostSshConfigModel> {
|
public class HostSshConfigStrategy extends AbstractGenericsDataStrategy<HostSshConfigModel> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private HostKeyDAO hostKeyDAO;
|
private HostKeyDAO hostKeyDAO;
|
||||||
@@ -40,6 +38,10 @@ public class HostSshConfigStrategy implements MapDataStrategy<HostSshConfigModel
|
|||||||
|
|
||||||
private static final String USERNAME = "root";
|
private static final String USERNAME = "root";
|
||||||
|
|
||||||
|
public HostSshConfigStrategy() {
|
||||||
|
super(HostSshConfigModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostSshConfigModel getDefault() {
|
public HostSshConfigModel getDefault() {
|
||||||
return HostSshConfigModel.builder()
|
return HostSshConfigModel.builder()
|
||||||
@@ -55,7 +57,7 @@ public class HostSshConfigStrategy implements MapDataStrategy<HostSshConfigModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preValid(HostSshConfigModel model) {
|
protected void preValid(HostSshConfigModel model) {
|
||||||
// 验证认证类型
|
// 验证认证类型
|
||||||
Valid.valid(HostSshAuthTypeEnum::of, model.getAuthType());
|
Valid.valid(HostSshAuthTypeEnum::of, model.getAuthType());
|
||||||
// 验证系统版本
|
// 验证系统版本
|
||||||
@@ -77,13 +79,13 @@ public class HostSshConfigStrategy implements MapDataStrategy<HostSshConfigModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valid(HostSshConfigModel model) {
|
protected void valid(HostSshConfigModel model) {
|
||||||
// 验证填充后的参数
|
// 验证填充后的参数
|
||||||
Valid.valid(model);
|
Valid.valid(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateFill(HostSshConfigModel beforeModel, HostSshConfigModel afterModel) {
|
protected void updateFill(HostSshConfigModel beforeModel, HostSshConfigModel afterModel) {
|
||||||
// 加密密码
|
// 加密密码
|
||||||
this.checkEncryptPassword(beforeModel, afterModel);
|
this.checkEncryptPassword(beforeModel, afterModel);
|
||||||
afterModel.setHasPassword(null);
|
afterModel.setHasPassword(null);
|
||||||
@@ -91,14 +93,12 @@ public class HostSshConfigStrategy implements MapDataStrategy<HostSshConfigModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> toView(String config) {
|
public void toView(HostSshConfigModel model) {
|
||||||
if (config == null) {
|
if (model == null) {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
HostSshConfigModel model = JSON.parseObject(config, HostSshConfigModel.class);
|
|
||||||
model.setHasPassword(Strings.isNotBlank(model.getPassword()));
|
model.setHasPassword(Strings.isNotBlank(model.getPassword()));
|
||||||
model.setPassword(null);
|
model.setPassword(null);
|
||||||
return JSON.parseObject(JSON.toJSONString(model));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler {
|
|||||||
// 拼接启动日志
|
// 拼接启动日志
|
||||||
AnsiAppender appender = AnsiAppender.create()
|
AnsiAppender appender = AnsiAppender.create()
|
||||||
.append(AnsiForeground.BRIGHT_GREEN, "> 准备执行命令 ")
|
.append(AnsiForeground.BRIGHT_GREEN, "> 准备执行命令 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine()
|
.newLine()
|
||||||
.append(AnsiForeground.BRIGHT_BLUE, "执行记录: ")
|
.append(AnsiForeground.BRIGHT_BLUE, "执行记录: ")
|
||||||
.append(execCommand.getLogId())
|
.append(execCommand.getLogId())
|
||||||
@@ -81,7 +81,7 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler {
|
|||||||
// 非脚本执行拼接开始执行日志
|
// 非脚本执行拼接开始执行日志
|
||||||
if (!Booleans.isTrue(execCommand.getScriptExec())) {
|
if (!Booleans.isTrue(execCommand.getScriptExec())) {
|
||||||
appender.append(AnsiForeground.BRIGHT_GREEN, "> 开始执行命令 ")
|
appender.append(AnsiForeground.BRIGHT_GREEN, "> 开始执行命令 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine();
|
.newLine();
|
||||||
}
|
}
|
||||||
this.appendLog(appender);
|
this.appendLog(appender);
|
||||||
@@ -94,7 +94,7 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler {
|
|||||||
AnsiAppender startAppender = AnsiAppender.create()
|
AnsiAppender startAppender = AnsiAppender.create()
|
||||||
.newLine()
|
.newLine()
|
||||||
.append(AnsiForeground.BRIGHT_GREEN, "> 准备上传脚本 ")
|
.append(AnsiForeground.BRIGHT_GREEN, "> 准备上传脚本 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine()
|
.newLine()
|
||||||
.append(AnsiForeground.BRIGHT_BLUE, "文件路径: ")
|
.append(AnsiForeground.BRIGHT_BLUE, "文件路径: ")
|
||||||
.append(execHostCommand.getScriptPath())
|
.append(execHostCommand.getScriptPath())
|
||||||
@@ -105,18 +105,18 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler {
|
|||||||
// 拼接完成日志
|
// 拼接完成日志
|
||||||
AnsiAppender finishAppender = AnsiAppender.create()
|
AnsiAppender finishAppender = AnsiAppender.create()
|
||||||
.append(AnsiForeground.BRIGHT_GREEN, "< 脚本上传成功 ")
|
.append(AnsiForeground.BRIGHT_GREEN, "< 脚本上传成功 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine()
|
.newLine()
|
||||||
.newLine()
|
.newLine()
|
||||||
.append(AnsiForeground.BRIGHT_GREEN, "> 开始执行脚本 ")
|
.append(AnsiForeground.BRIGHT_GREEN, "> 开始执行脚本 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine();
|
.newLine();
|
||||||
this.appendLog(finishAppender);
|
this.appendLog(finishAppender);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 拼接失败日志
|
// 拼接失败日志
|
||||||
AnsiAppender errorAppender = AnsiAppender.create()
|
AnsiAppender errorAppender = AnsiAppender.create()
|
||||||
.append(AnsiForeground.BRIGHT_RED, "< 脚本上传失败 ")
|
.append(AnsiForeground.BRIGHT_RED, "< 脚本上传失败 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine();
|
.newLine();
|
||||||
this.appendLog(errorAppender);
|
this.appendLog(errorAppender);
|
||||||
throw e;
|
throw e;
|
||||||
@@ -133,12 +133,12 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler {
|
|||||||
if (this.status == ExecHostStatusEnum.INTERRUPTED) {
|
if (this.status == ExecHostStatusEnum.INTERRUPTED) {
|
||||||
// 中断执行
|
// 中断执行
|
||||||
appender.append(AnsiForeground.BRIGHT_YELLOW, "< 命令执行中断 ")
|
appender.append(AnsiForeground.BRIGHT_YELLOW, "< 命令执行中断 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine();
|
.newLine();
|
||||||
} else if (this.status == ExecHostStatusEnum.FAILED) {
|
} else if (this.status == ExecHostStatusEnum.FAILED) {
|
||||||
// 执行失败
|
// 执行失败
|
||||||
appender.append(AnsiForeground.BRIGHT_RED, "< 命令执行失败 ")
|
appender.append(AnsiForeground.BRIGHT_RED, "< 命令执行失败 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine()
|
.newLine()
|
||||||
.append(AnsiForeground.BRIGHT_RED, "错误原因: ")
|
.append(AnsiForeground.BRIGHT_RED, "错误原因: ")
|
||||||
.append(this.getErrorMessage(e))
|
.append(this.getErrorMessage(e))
|
||||||
@@ -146,14 +146,14 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler {
|
|||||||
} else if (this.status == ExecHostStatusEnum.TIMEOUT) {
|
} else if (this.status == ExecHostStatusEnum.TIMEOUT) {
|
||||||
// 更新执行超时
|
// 更新执行超时
|
||||||
appender.append(AnsiForeground.BRIGHT_YELLOW, "< 命令执行超时 ")
|
appender.append(AnsiForeground.BRIGHT_YELLOW, "< 命令执行超时 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine();
|
.newLine();
|
||||||
} else {
|
} else {
|
||||||
long ms = updateRecord.getFinishTime().getTime() - updateRecord.getStartTime().getTime();
|
long ms = updateRecord.getFinishTime().getTime() - updateRecord.getStartTime().getTime();
|
||||||
Integer exitCode = updateRecord.getExitCode();
|
Integer exitCode = updateRecord.getExitCode();
|
||||||
// 执行完成
|
// 执行完成
|
||||||
appender.append(AnsiForeground.BRIGHT_GREEN, "< 命令执行完成 ")
|
appender.append(AnsiForeground.BRIGHT_GREEN, "< 命令执行完成 ")
|
||||||
.append(Dates.current())
|
.append(this.getCurrentTime())
|
||||||
.newLine()
|
.newLine()
|
||||||
.append(AnsiForeground.BRIGHT_BLUE, "exit: ");
|
.append(AnsiForeground.BRIGHT_BLUE, "exit: ");
|
||||||
if (ExitCode.isSuccess(exitCode)) {
|
if (ExitCode.isSuccess(exitCode)) {
|
||||||
@@ -173,4 +173,13 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler {
|
|||||||
this.appendLog(appender);
|
this.appendLog(appender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前时间
|
||||||
|
*
|
||||||
|
* @return 当前时间
|
||||||
|
*/
|
||||||
|
private String getCurrentTime() {
|
||||||
|
return Const.SPACE + Dates.current();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.orion.visor.module.asset.handler.host.extra.strategy;
|
package com.orion.visor.module.asset.handler.host.extra.strategy;
|
||||||
|
|
||||||
import com.orion.visor.framework.common.constant.Const;
|
import com.orion.visor.framework.common.constant.Const;
|
||||||
import com.orion.visor.framework.common.handler.data.strategy.MapDataStrategy;
|
import com.orion.visor.framework.common.handler.data.strategy.AbstractGenericsDataStrategy;
|
||||||
import com.orion.visor.module.asset.handler.host.extra.model.HostLabelExtraModel;
|
import com.orion.visor.module.asset.handler.host.extra.model.HostLabelExtraModel;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -13,7 +13,11 @@ import org.springframework.stereotype.Component;
|
|||||||
* @since 2024/2/29 23:16
|
* @since 2024/2/29 23:16
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class HostLabelExtraStrategy implements MapDataStrategy<HostLabelExtraModel> {
|
public class HostLabelExtraStrategy extends AbstractGenericsDataStrategy<HostLabelExtraModel> {
|
||||||
|
|
||||||
|
public HostLabelExtraStrategy() {
|
||||||
|
super(HostLabelExtraModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostLabelExtraModel getDefault() {
|
public HostLabelExtraModel getDefault() {
|
||||||
@@ -36,12 +40,4 @@ public class HostLabelExtraStrategy implements MapDataStrategy<HostLabelExtraMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void preValid(HostLabelExtraModel model) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valid(HostLabelExtraModel model) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.orion.visor.module.asset.handler.host.extra.strategy;
|
package com.orion.visor.module.asset.handler.host.extra.strategy;
|
||||||
|
|
||||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.visor.framework.common.handler.data.strategy.MapDataStrategy;
|
import com.orion.visor.framework.common.handler.data.strategy.AbstractGenericsDataStrategy;
|
||||||
import com.orion.visor.framework.common.utils.Valid;
|
import com.orion.visor.framework.common.utils.Valid;
|
||||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||||
import com.orion.visor.module.asset.dao.HostIdentityDAO;
|
import com.orion.visor.module.asset.dao.HostIdentityDAO;
|
||||||
@@ -22,7 +22,7 @@ import javax.annotation.Resource;
|
|||||||
* @since 2023/12/20 22:17
|
* @since 2023/12/20 22:17
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class HostSshExtraStrategy implements MapDataStrategy<HostSshExtraModel> {
|
public class HostSshExtraStrategy extends AbstractGenericsDataStrategy<HostSshExtraModel> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private HostKeyDAO hostKeyDAO;
|
private HostKeyDAO hostKeyDAO;
|
||||||
@@ -33,6 +33,10 @@ public class HostSshExtraStrategy implements MapDataStrategy<HostSshExtraModel>
|
|||||||
@Resource
|
@Resource
|
||||||
private DataPermissionApi dataPermissionApi;
|
private DataPermissionApi dataPermissionApi;
|
||||||
|
|
||||||
|
public HostSshExtraStrategy() {
|
||||||
|
super(HostSshExtraModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostSshExtraModel getDefault() {
|
public HostSshExtraModel getDefault() {
|
||||||
return HostSshExtraModel.builder()
|
return HostSshExtraModel.builder()
|
||||||
@@ -40,10 +44,6 @@ public class HostSshExtraStrategy implements MapDataStrategy<HostSshExtraModel>
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateFill(HostSshExtraModel beforeModel, HostSshExtraModel afterModel) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preValid(HostSshExtraModel model) {
|
public void preValid(HostSshExtraModel model) {
|
||||||
HostExtraSshAuthTypeEnum authType = Valid.valid(HostExtraSshAuthTypeEnum::of, model.getAuthType());
|
HostExtraSshAuthTypeEnum authType = Valid.valid(HostExtraSshAuthTypeEnum::of, model.getAuthType());
|
||||||
@@ -79,8 +79,4 @@ public class HostSshExtraStrategy implements MapDataStrategy<HostSshExtraModel>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valid(HostSshExtraModel model) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.orion.visor.framework.common.enums.BooleanBit;
|
|||||||
import com.orion.visor.framework.websocket.core.utils.WebSockets;
|
import com.orion.visor.framework.websocket.core.utils.WebSockets;
|
||||||
import com.orion.visor.module.asset.dao.HostDAO;
|
import com.orion.visor.module.asset.dao.HostDAO;
|
||||||
import com.orion.visor.module.asset.define.operator.HostTerminalOperatorType;
|
import com.orion.visor.module.asset.define.operator.HostTerminalOperatorType;
|
||||||
|
import com.orion.visor.module.asset.entity.domain.HostConnectLogDO;
|
||||||
import com.orion.visor.module.asset.entity.domain.HostDO;
|
import com.orion.visor.module.asset.entity.domain.HostDO;
|
||||||
import com.orion.visor.module.asset.entity.dto.HostTerminalConnectDTO;
|
import com.orion.visor.module.asset.entity.dto.HostTerminalConnectDTO;
|
||||||
import com.orion.visor.module.asset.entity.request.host.HostConnectLogCreateRequest;
|
import com.orion.visor.module.asset.entity.request.host.HostConnectLogCreateRequest;
|
||||||
@@ -95,9 +96,9 @@ public class TerminalCheckHandler extends AbstractTerminalHandler<TerminalCheckR
|
|||||||
log.error("TerminalCheckHandler-handle exception userId: {}, hostId: {}, sessionId: {}", userId, hostId, sessionId, e);
|
log.error("TerminalCheckHandler-handle exception userId: {}, hostId: {}, sessionId: {}", userId, hostId, sessionId, e);
|
||||||
}
|
}
|
||||||
// 记录主机日志
|
// 记录主机日志
|
||||||
Long logId = this.saveHostLog(channel, userId, host, startTime, ex, sessionId, connectType);
|
HostConnectLogDO connectLog = this.saveHostLog(channel, userId, host, startTime, ex, sessionId, connectType);
|
||||||
if (connect != null) {
|
if (connect != null) {
|
||||||
connect.setLogId(logId);
|
connect.setLogId(connectLog.getId());
|
||||||
}
|
}
|
||||||
// 响应检查结果
|
// 响应检查结果
|
||||||
this.send(channel,
|
this.send(channel,
|
||||||
@@ -170,15 +171,15 @@ public class TerminalCheckHandler extends AbstractTerminalHandler<TerminalCheckR
|
|||||||
* @param ex ex
|
* @param ex ex
|
||||||
* @param sessionId sessionId
|
* @param sessionId sessionId
|
||||||
* @param connectType connectType
|
* @param connectType connectType
|
||||||
* @return logId
|
* @return connectLog
|
||||||
*/
|
*/
|
||||||
private Long saveHostLog(WebSocketSession channel,
|
private HostConnectLogDO saveHostLog(WebSocketSession channel,
|
||||||
Long userId,
|
Long userId,
|
||||||
HostDO host,
|
HostDO host,
|
||||||
long startTime,
|
long startTime,
|
||||||
Exception ex,
|
Exception ex,
|
||||||
String sessionId,
|
String sessionId,
|
||||||
HostConnectTypeEnum connectType) {
|
HostConnectTypeEnum connectType) {
|
||||||
Long hostId = host.getId();
|
Long hostId = host.getId();
|
||||||
String hostName = host.getName();
|
String hostName = host.getName();
|
||||||
String username = WebSockets.getAttr(channel, ExtraFieldConst.USERNAME);
|
String username = WebSockets.getAttr(channel, ExtraFieldConst.USERNAME);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.orion.net.host.SessionStore;
|
|||||||
import com.orion.net.host.sftp.SftpExecutor;
|
import com.orion.net.host.sftp.SftpExecutor;
|
||||||
import com.orion.spring.SpringHolder;
|
import com.orion.spring.SpringHolder;
|
||||||
import com.orion.visor.framework.common.constant.Const;
|
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.file.FileClient;
|
||||||
import com.orion.visor.framework.common.utils.PathUtils;
|
import com.orion.visor.framework.common.utils.PathUtils;
|
||||||
import com.orion.visor.module.asset.dao.UploadTaskFileDAO;
|
import com.orion.visor.module.asset.dao.UploadTaskFileDAO;
|
||||||
@@ -18,7 +19,6 @@ import com.orion.visor.module.asset.enums.HostSshOsTypeEnum;
|
|||||||
import com.orion.visor.module.asset.enums.UploadTaskFileStatusEnum;
|
import com.orion.visor.module.asset.enums.UploadTaskFileStatusEnum;
|
||||||
import com.orion.visor.module.asset.handler.host.upload.model.FileUploadFileItemDTO;
|
import com.orion.visor.module.asset.handler.host.upload.model.FileUploadFileItemDTO;
|
||||||
import com.orion.visor.module.asset.service.HostTerminalService;
|
import com.orion.visor.module.asset.service.HostTerminalService;
|
||||||
import com.orion.visor.module.asset.service.UploadTaskService;
|
|
||||||
import com.orion.visor.module.asset.utils.SftpUtils;
|
import com.orion.visor.module.asset.utils.SftpUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -134,7 +134,7 @@ public class FileUploader implements IFileUploader {
|
|||||||
this.updateStatus(file, UploadTaskFileStatusEnum.UPLOADING);
|
this.updateStatus(file, UploadTaskFileStatusEnum.UPLOADING);
|
||||||
try {
|
try {
|
||||||
// 获取本地文件路径
|
// 获取本地文件路径
|
||||||
String endpoint = Strings.format(UploadTaskService.SWAP_ENDPOINT, taskId);
|
String endpoint = EndpointDefine.UPLOAD_SWAP.format(taskId);
|
||||||
String localPath = localFileClient.getReturnPath(endpoint + Const.SLASH + file.getFileId());
|
String localPath = localFileClient.getReturnPath(endpoint + Const.SLASH + file.getFileId());
|
||||||
// 检查文件是否存在
|
// 检查文件是否存在
|
||||||
String remotePath = file.getRemotePath();
|
String remotePath = file.getRemotePath();
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ public interface ExecLogService {
|
|||||||
*/
|
*/
|
||||||
Integer deleteExecLogByIdList(List<Long> idList, String source);
|
Integer deleteExecLogByIdList(List<Long> idList, String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除批量执行日志
|
||||||
|
*
|
||||||
|
* @param idList idList
|
||||||
|
* @return effect
|
||||||
|
*/
|
||||||
|
Integer deleteExecLogByIdList(List<Long> idList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询批量执行日志数量
|
* 查询批量执行日志数量
|
||||||
*
|
*
|
||||||
@@ -128,4 +136,11 @@ public interface ExecLogService {
|
|||||||
*/
|
*/
|
||||||
void downloadLogFile(Long id, String source, HttpServletResponse response);
|
void downloadLogFile(Long id, String source, HttpServletResponse response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步删除日志文件
|
||||||
|
*
|
||||||
|
* @param idList idList
|
||||||
|
*/
|
||||||
|
void asyncDeleteLogFiles(List<Long> idList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.orion.visor.module.asset.service;
|
package com.orion.visor.module.asset.service;
|
||||||
|
|
||||||
import com.orion.lang.define.wrapper.DataGrid;
|
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.HostConnectLogCreateRequest;
|
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.request.host.HostConnectLogQueryRequest;
|
||||||
import com.orion.visor.module.asset.entity.vo.HostConnectLogVO;
|
import com.orion.visor.module.asset.entity.vo.HostConnectLogVO;
|
||||||
@@ -25,9 +26,9 @@ public interface HostConnectLogService {
|
|||||||
*
|
*
|
||||||
* @param type type
|
* @param type type
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return id
|
* @return record
|
||||||
*/
|
*/
|
||||||
Long create(HostConnectTypeEnum type, HostConnectLogCreateRequest request);
|
HostConnectLogDO create(HostConnectTypeEnum type, HostConnectLogCreateRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询主机连接日志
|
* 分页查询主机连接日志
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface UploadTaskService {
|
public interface UploadTaskService {
|
||||||
|
|
||||||
String SWAP_ENDPOINT = "/upload/swap/{}";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建上传任务
|
* 创建上传任务
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ public class CommandSnippetGroupServiceImpl implements CommandSnippetGroupServic
|
|||||||
.createWrapper()
|
.createWrapper()
|
||||||
.select(CommandSnippetDO::getUserId, CommandSnippetDO::getGroupId)
|
.select(CommandSnippetDO::getUserId, CommandSnippetDO::getGroupId)
|
||||||
.isNotNull(CommandSnippetDO::getGroupId)
|
.isNotNull(CommandSnippetDO::getGroupId)
|
||||||
|
.groupBy(CommandSnippetDO::getUserId)
|
||||||
.groupBy(CommandSnippetDO::getGroupId)
|
.groupBy(CommandSnippetDO::getGroupId)
|
||||||
.then()
|
.then()
|
||||||
.stream()
|
.stream()
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ 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.annotation.Keep;
|
||||||
import com.orion.visor.framework.common.constant.Const;
|
import com.orion.visor.framework.common.constant.Const;
|
||||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.visor.framework.common.constant.PathConst;
|
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.file.FileClient;
|
||||||
import com.orion.visor.framework.common.security.LoginUser;
|
import com.orion.visor.framework.common.security.LoginUser;
|
||||||
import com.orion.visor.framework.common.utils.PathUtils;
|
import com.orion.visor.framework.common.utils.PathUtils;
|
||||||
@@ -140,10 +141,10 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
execLogDAO.insert(execLog);
|
execLogDAO.insert(execLog);
|
||||||
Long execId = execLog.getId();
|
Long execId = execLog.getId();
|
||||||
// 获取内置参数
|
// 获取内置参数
|
||||||
Map<String, Object> builtinsParams = this.getBaseBuiltinsParams(execId, request);
|
Map<String, Object> builtinParams = this.getBaseBuiltinParams(execId, request);
|
||||||
// 设置主机日志
|
// 设置主机日志
|
||||||
List<ExecHostLogDO> execHostLogs = hosts.stream()
|
List<ExecHostLogDO> execHostLogs = hosts.stream()
|
||||||
.map(s -> this.convertExecHostLog(s, execLog, hostConfigMap.get(s.getId()), builtinsParams))
|
.map(s -> this.convertExecHostLog(s, execLog, hostConfigMap.get(s.getId()), builtinParams))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
execHostLogDAO.insertBatch(execHostLogs);
|
execHostLogDAO.insertBatch(execHostLogs);
|
||||||
// 操作日志
|
// 操作日志
|
||||||
@@ -228,16 +229,16 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
/**
|
/**
|
||||||
* 转换为 execHostLog
|
* 转换为 execHostLog
|
||||||
*
|
*
|
||||||
* @param host host
|
* @param host host
|
||||||
* @param execLog execLog
|
* @param execLog execLog
|
||||||
* @param config config
|
* @param config config
|
||||||
* @param builtinsParams builtinsParams
|
* @param builtinParams builtinParams
|
||||||
* @return execHostLog
|
* @return execHostLog
|
||||||
*/
|
*/
|
||||||
private ExecHostLogDO convertExecHostLog(HostDO host,
|
private ExecHostLogDO convertExecHostLog(HostDO host,
|
||||||
ExecLogDO execLog,
|
ExecLogDO execLog,
|
||||||
HostSshConfigModel config,
|
HostSshConfigModel config,
|
||||||
Map<String, Object> builtinsParams) {
|
Map<String, Object> builtinParams) {
|
||||||
Long execId = execLog.getId();
|
Long execId = execLog.getId();
|
||||||
Long hostId = host.getId();
|
Long hostId = host.getId();
|
||||||
// 脚本路径
|
// 脚本路径
|
||||||
@@ -246,7 +247,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
scriptPath = this.buildScriptPath(config.getUsername(), config.getOsType(), execId, hostId);
|
scriptPath = this.buildScriptPath(config.getUsername(), config.getOsType(), execId, hostId);
|
||||||
}
|
}
|
||||||
// 获取参数
|
// 获取参数
|
||||||
String parameter = JSON.toJSONString(this.getHostParams(builtinsParams, host, config, scriptPath));
|
String parameter = JSON.toJSONString(this.getHostParams(builtinParams, host, config, scriptPath));
|
||||||
return ExecHostLogDO.builder()
|
return ExecHostLogDO.builder()
|
||||||
.logId(execId)
|
.logId(execId)
|
||||||
.hostId(hostId)
|
.hostId(hostId)
|
||||||
@@ -267,7 +268,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
* @param request request
|
* @param request request
|
||||||
* @return params
|
* @return params
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> getBaseBuiltinsParams(Long execId, ExecCommandExecDTO request) {
|
private Map<String, Object> getBaseBuiltinParams(Long execId, ExecCommandExecDTO request) {
|
||||||
String uuid = UUIds.random();
|
String uuid = UUIds.random();
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
// 输入参数
|
// 输入参数
|
||||||
@@ -353,8 +354,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
* @return logPath
|
* @return logPath
|
||||||
*/
|
*/
|
||||||
private String buildLogPath(Long logId, Long hostId) {
|
private String buildLogPath(Long logId, Long hostId) {
|
||||||
String logFile = "/" + PathConst.EXEC + "/" + logId + "/" + logId + "_" + hostId + ".log";
|
return logsFileClient.getReturnPath(EndpointDefine.EXEC_LOG.format(logId, hostId));
|
||||||
return logsFileClient.getReturnPath(logFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -368,11 +368,11 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
*/
|
*/
|
||||||
private String buildScriptPath(String username, String osType, Long logId, Long hostId) {
|
private String buildScriptPath(String username, String osType, Long logId, Long hostId) {
|
||||||
HostSshOsTypeEnum os = HostSshOsTypeEnum.of(osType);
|
HostSshOsTypeEnum os = HostSshOsTypeEnum.of(osType);
|
||||||
String name = PathConst.EXEC
|
String name = FileConst.EXEC
|
||||||
+ "_" + logId
|
+ "/" + logId
|
||||||
+ "_" + hostId
|
+ "/" + hostId
|
||||||
+ os.getScriptSuffix();
|
+ os.getScriptSuffix();
|
||||||
return PathUtils.buildAppPath(HostSshOsTypeEnum.WINDOWS.equals(os), username, PathConst.SCRIPT, name);
|
return PathUtils.buildAppPath(HostSshOsTypeEnum.WINDOWS.equals(os), username, FileConst.SCRIPT, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ import com.orion.lang.utils.Strings;
|
|||||||
import com.orion.lang.utils.collect.Lists;
|
import com.orion.lang.utils.collect.Lists;
|
||||||
import com.orion.lang.utils.io.Files1;
|
import com.orion.lang.utils.io.Files1;
|
||||||
import com.orion.lang.utils.io.Streams;
|
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.biz.operator.log.core.utils.OperatorLogs;
|
||||||
import com.orion.visor.framework.common.annotation.Keep;
|
import com.orion.visor.framework.common.annotation.Keep;
|
||||||
import com.orion.visor.framework.common.constant.Const;
|
import com.orion.visor.framework.common.constant.Const;
|
||||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.visor.framework.common.constant.PathConst;
|
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.file.FileClient;
|
||||||
import com.orion.visor.framework.common.utils.Valid;
|
import com.orion.visor.framework.common.utils.Valid;
|
||||||
import com.orion.visor.framework.redis.core.utils.RedisStrings;
|
import com.orion.visor.framework.redis.core.utils.RedisStrings;
|
||||||
@@ -46,11 +48,13 @@ import com.orion.visor.module.asset.service.ExecLogService;
|
|||||||
import com.orion.visor.module.asset.service.HostConfigService;
|
import com.orion.visor.module.asset.service.HostConfigService;
|
||||||
import com.orion.web.servlet.web.Servlets;
|
import com.orion.web.servlet.web.Servlets;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -173,20 +177,7 @@ public class ExecLogServiceImpl implements ExecLogService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Integer deleteExecLogById(Long id, String source) {
|
public Integer deleteExecLogById(Long id, String source) {
|
||||||
log.info("ExecLogService-deleteExecLogById id: {}", id);
|
return this.deleteExecLogByIdList(Lists.singleton(id), source);
|
||||||
// 检查数据是否存在
|
|
||||||
ExecLogDO record = execLogDAO.selectByIdSource(id, source);
|
|
||||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
|
||||||
// 中断命令执行
|
|
||||||
this.interruptTask(Lists.singleton(id));
|
|
||||||
// 删除执行日志
|
|
||||||
int effect = execLogDAO.deleteById(id);
|
|
||||||
// 删除主机日志
|
|
||||||
execHostLogService.deleteExecHostLogByLogId(Lists.singleton(id));
|
|
||||||
log.info("ExecLogService-deleteExecLogById id: {}, effect: {}", id, effect);
|
|
||||||
// 设置日志参数
|
|
||||||
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
|
||||||
return effect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,15 +192,28 @@ public class ExecLogServiceImpl implements ExecLogService {
|
|||||||
.count()
|
.count()
|
||||||
.intValue();
|
.intValue();
|
||||||
Valid.isTrue(idList.size() == count, ErrorMessage.DATA_MODIFIED);
|
Valid.isTrue(idList.size() == count, ErrorMessage.DATA_MODIFIED);
|
||||||
|
// 删除
|
||||||
|
return this.deleteExecLogByIdList(idList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleteExecLogByIdList(List<Long> idList) {
|
||||||
|
log.info("ExecLogService-deleteExecLogByIdList start: {}", idList);
|
||||||
|
if (Lists.isEmpty(idList)) {
|
||||||
|
OperatorLogs.add(OperatorLogs.COUNT, Const.N_0);
|
||||||
|
return Const.N_0;
|
||||||
|
}
|
||||||
// 中断命令执行
|
// 中断命令执行
|
||||||
this.interruptTask(idList);
|
this.interruptTask(idList);
|
||||||
// 删除执行日志
|
// 删除执行日志
|
||||||
int effect = execLogDAO.deleteBatchIds(idList);
|
int effect = execLogDAO.deleteBatchIds(idList);
|
||||||
// 删除主机日志
|
// 删除主机日志
|
||||||
execHostLogService.deleteExecHostLogByLogId(idList);
|
execHostLogService.deleteExecHostLogByLogId(idList);
|
||||||
log.info("ExecLogService-deleteExecLogByIdList effect: {}", effect);
|
log.info("ExecLogService-deleteExecLogByIdList end effect: {}", effect);
|
||||||
// 设置日志参数
|
// 设置日志参数
|
||||||
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
||||||
|
// 异步删除文件
|
||||||
|
SpringHolder.getBean(ExecLogService.class).asyncDeleteLogFiles(idList);
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,19 +233,8 @@ public class ExecLogServiceImpl implements ExecLogService {
|
|||||||
.stream()
|
.stream()
|
||||||
.map(ExecLogDO::getId)
|
.map(ExecLogDO::getId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
int effect = 0;
|
// 删除
|
||||||
if (!idList.isEmpty()) {
|
return this.deleteExecLogByIdList(idList);
|
||||||
// 中断命令执行
|
|
||||||
this.interruptTask(idList);
|
|
||||||
// 删除执行日志
|
|
||||||
effect = execLogDAO.delete(wrapper);
|
|
||||||
// 删除主机日志
|
|
||||||
execHostLogService.deleteExecHostLogByLogId(idList);
|
|
||||||
}
|
|
||||||
log.info("ExecLogService.clearExecLog finish {}", effect);
|
|
||||||
// 设置日志参数
|
|
||||||
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
|
||||||
return effect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -428,19 +421,35 @@ public class ExecLogServiceImpl implements ExecLogService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("ExecLogService.downloadLogFile error id: {}", id, e);
|
log.error("ExecLogService.downloadLogFile error id: {}", id, e);
|
||||||
Streams.close(in);
|
Streams.close(in);
|
||||||
String errorMessage = ErrorMessage.FILE_READ_ERROR;
|
String errorMessage = ErrorMessage.FILE_READ_ERROR_CLEAR;
|
||||||
if (e instanceof InvalidArgumentException) {
|
if (e instanceof InvalidArgumentException) {
|
||||||
errorMessage = e.getMessage();
|
errorMessage = e.getMessage();
|
||||||
}
|
}
|
||||||
// 响应错误信息
|
// 响应错误信息
|
||||||
try {
|
try {
|
||||||
Servlets.transfer(response, Strings.bytes(errorMessage), PathConst.ERROR_LOG);
|
Servlets.transfer(response, Strings.bytes(errorMessage), FileConst.ERROR_LOG);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("ExecLogService.downloadLogFile transfer-error id: {}", id, ex);
|
log.error("ExecLogService.downloadLogFile transfer-error id: {}", id, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Async("asyncExecutor")
|
||||||
|
public void asyncDeleteLogFiles(List<Long> idList) {
|
||||||
|
if (Lists.isEmpty(idList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
idList.stream()
|
||||||
|
.map(s -> EndpointDefine.EXEC_LOG.format(s, Const.EMPTY))
|
||||||
|
.map(logsFileClient::getReturnPath)
|
||||||
|
.map(logsFileClient::getAbsolutePath)
|
||||||
|
.map(Files1::getParentPath)
|
||||||
|
.map(File::new)
|
||||||
|
.forEach(Files1::delete);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建查询 wrapper
|
* 构建查询 wrapper
|
||||||
*
|
*
|
||||||
@@ -457,8 +466,10 @@ public class ExecLogServiceImpl implements ExecLogService {
|
|||||||
.like(ExecLogDO::getDescription, request.getDescription())
|
.like(ExecLogDO::getDescription, request.getDescription())
|
||||||
.like(ExecLogDO::getCommand, request.getCommand())
|
.like(ExecLogDO::getCommand, request.getCommand())
|
||||||
.eq(ExecLogDO::getStatus, request.getStatus())
|
.eq(ExecLogDO::getStatus, request.getStatus())
|
||||||
|
.in(ExecLogDO::getStatus, request.getStatusList())
|
||||||
.ge(ExecLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 0))
|
.ge(ExecLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 0))
|
||||||
.le(ExecLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 1))
|
.le(ExecLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 1))
|
||||||
|
.le(ExecLogDO::getCreateTime, request.getCreateTimeLe())
|
||||||
.orderByDesc(ExecLogDO::getId);
|
.orderByDesc(ExecLogDO::getId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.orion.visor.framework.common.constant.ErrorMessage;
|
|||||||
import com.orion.visor.framework.common.enums.BooleanBit;
|
import com.orion.visor.framework.common.enums.BooleanBit;
|
||||||
import com.orion.visor.framework.common.enums.EnableStatus;
|
import com.orion.visor.framework.common.enums.EnableStatus;
|
||||||
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
import com.orion.visor.framework.common.handler.data.model.GenericsDataModel;
|
||||||
import com.orion.visor.framework.common.handler.data.strategy.MapDataStrategy;
|
import com.orion.visor.framework.common.handler.data.strategy.GenericsDataStrategy;
|
||||||
import com.orion.visor.framework.common.utils.Valid;
|
import com.orion.visor.framework.common.utils.Valid;
|
||||||
import com.orion.visor.module.asset.convert.HostConfigConvert;
|
import com.orion.visor.module.asset.convert.HostConfigConvert;
|
||||||
import com.orion.visor.module.asset.dao.HostConfigDAO;
|
import com.orion.visor.module.asset.dao.HostConfigDAO;
|
||||||
@@ -53,7 +53,7 @@ public class HostConfigServiceImpl implements HostConfigService {
|
|||||||
// 转换
|
// 转换
|
||||||
HostConfigVO vo = HostConfigConvert.MAPPER.to(config);
|
HostConfigVO vo = HostConfigConvert.MAPPER.to(config);
|
||||||
// 获取配置
|
// 获取配置
|
||||||
Map<String, Object> configMap = configType.getStrategyBean().toView(config.getConfig());
|
Map<String, Object> configMap = configType.toView(config.getConfig()).toMap();
|
||||||
vo.setConfig(configMap);
|
vo.setConfig(configMap);
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
@@ -121,10 +121,10 @@ public class HostConfigServiceImpl implements HostConfigService {
|
|||||||
OperatorLogs.add(OperatorLogs.TYPE, type.getType());
|
OperatorLogs.add(OperatorLogs.TYPE, type.getType());
|
||||||
// 检查版本
|
// 检查版本
|
||||||
Valid.eq(record.getVersion(), request.getVersion(), ErrorMessage.DATA_MODIFIED);
|
Valid.eq(record.getVersion(), request.getVersion(), ErrorMessage.DATA_MODIFIED);
|
||||||
MapDataStrategy<GenericsDataModel> strategy = type.getStrategyBean();
|
GenericsDataStrategy<GenericsDataModel> strategy = type.getStrategy();
|
||||||
GenericsDataModel beforeConfig = type.parse(record.getConfig());
|
GenericsDataModel beforeConfig = type.parse(record.getConfig());
|
||||||
// 更新前校验
|
// 更新前校验
|
||||||
strategy.doValidChain(beforeConfig, newConfig);
|
strategy.doValid(beforeConfig, newConfig);
|
||||||
// 修改配置
|
// 修改配置
|
||||||
HostConfigDO update = new HostConfigDO();
|
HostConfigDO update = new HostConfigDO();
|
||||||
update.setId(record.getId());
|
update.setId(record.getId());
|
||||||
@@ -225,7 +225,7 @@ public class HostConfigServiceImpl implements HostConfigService {
|
|||||||
insert.setHostId(hostId);
|
insert.setHostId(hostId);
|
||||||
insert.setType(type.getType());
|
insert.setType(type.getType());
|
||||||
insert.setStatus(type.getDefaultStatus());
|
insert.setStatus(type.getDefaultStatus());
|
||||||
insert.setConfig(type.getStrategyBean().getDefault().serial());
|
insert.setConfig(type.getStrategy().getDefault().serial());
|
||||||
insert.setVersion(Const.DEFAULT_VERSION);
|
insert.setVersion(Const.DEFAULT_VERSION);
|
||||||
return insert;
|
return insert;
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ public class HostConfigServiceImpl implements HostConfigService {
|
|||||||
}
|
}
|
||||||
// 转为视图
|
// 转为视图
|
||||||
HostConfigVO vo = HostConfigConvert.MAPPER.to(row);
|
HostConfigVO vo = HostConfigConvert.MAPPER.to(row);
|
||||||
Map<String, Object> config = type.getStrategyBean().toView(row.getConfig());
|
Map<String, Object> config = type.toView(row.getConfig()).toMap();
|
||||||
vo.setConfig(config);
|
vo.setConfig(config);
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package com.orion.visor.module.asset.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.orion.lang.constant.Const;
|
|
||||||
import com.orion.lang.define.wrapper.DataGrid;
|
import com.orion.lang.define.wrapper.DataGrid;
|
||||||
import com.orion.lang.utils.Arrays1;
|
import com.orion.lang.utils.Arrays1;
|
||||||
import com.orion.lang.utils.Valid;
|
|
||||||
import com.orion.lang.utils.collect.Lists;
|
import com.orion.lang.utils.collect.Lists;
|
||||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
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.constant.ErrorMessage;
|
||||||
|
import com.orion.visor.framework.common.utils.Valid;
|
||||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||||
import com.orion.visor.module.asset.convert.HostConnectLogConvert;
|
import com.orion.visor.module.asset.convert.HostConnectLogConvert;
|
||||||
import com.orion.visor.module.asset.dao.HostConnectLogDAO;
|
import com.orion.visor.module.asset.dao.HostConnectLogDAO;
|
||||||
@@ -52,7 +52,7 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
|||||||
private HostTerminalManager hostTerminalManager;
|
private HostTerminalManager hostTerminalManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long create(HostConnectTypeEnum type, HostConnectLogCreateRequest request) {
|
public HostConnectLogDO create(HostConnectTypeEnum type, HostConnectLogCreateRequest request) {
|
||||||
HostConnectLogDO record = HostConnectLogConvert.MAPPER.to(request);
|
HostConnectLogDO record = HostConnectLogConvert.MAPPER.to(request);
|
||||||
record.setType(type.name());
|
record.setType(type.name());
|
||||||
String status = request.getStatus();
|
String status = request.getStatus();
|
||||||
@@ -64,7 +64,7 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
|||||||
record.setEndTime(new Date());
|
record.setEndTime(new Date());
|
||||||
}
|
}
|
||||||
hostConnectLogDAO.insert(record);
|
hostConnectLogDAO.insert(record);
|
||||||
return record.getId();
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -169,6 +169,11 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
|||||||
@Override
|
@Override
|
||||||
public Integer deleteHostConnectLog(List<Long> idList) {
|
public Integer deleteHostConnectLog(List<Long> idList) {
|
||||||
log.info("HostConnectLogService.deleteHostConnectLog start {}", JSON.toJSONString(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);
|
int effect = hostConnectLogDAO.deleteBatchIds(idList);
|
||||||
log.info("HostConnectLogService.deleteHostConnectLog finish {}", effect);
|
log.info("HostConnectLogService.deleteHostConnectLog finish {}", effect);
|
||||||
// 设置日志参数
|
// 设置日志参数
|
||||||
@@ -184,13 +189,21 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
|||||||
@Override
|
@Override
|
||||||
public Integer clearHostConnectLog(HostConnectLogQueryRequest request) {
|
public Integer clearHostConnectLog(HostConnectLogQueryRequest request) {
|
||||||
log.info("HostConnectLogService.clearHostConnectLog start {}", JSON.toJSONString(request));
|
log.info("HostConnectLogService.clearHostConnectLog start {}", JSON.toJSONString(request));
|
||||||
|
// 查询
|
||||||
|
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request)
|
||||||
|
.select(HostConnectLogDO::getId);
|
||||||
|
List<HostConnectLogDO> list = hostConnectLogDAO.selectList(wrapper);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
log.info("HostConnectLogService.clearHostConnectLog empty");
|
||||||
|
// 设置日志参数
|
||||||
|
OperatorLogs.add(OperatorLogs.COUNT, Const.N_0);
|
||||||
|
return Const.N_0;
|
||||||
|
}
|
||||||
// 删除
|
// 删除
|
||||||
LambdaQueryWrapper<HostConnectLogDO> wrapper = this.buildQueryWrapper(request);
|
List<Long> idList = list.stream()
|
||||||
int effect = hostConnectLogDAO.delete(wrapper);
|
.map(HostConnectLogDO::getId)
|
||||||
log.info("HostConnectLogService.clearHostConnectLog finish {}", effect);
|
.collect(Collectors.toList());
|
||||||
// 设置日志参数
|
return this.deleteHostConnectLog(idList);
|
||||||
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
|
||||||
return effect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -229,8 +242,10 @@ public class HostConnectLogServiceImpl implements HostConnectLogService {
|
|||||||
.eq(HostConnectLogDO::getType, request.getType())
|
.eq(HostConnectLogDO::getType, request.getType())
|
||||||
.like(HostConnectLogDO::getToken, request.getToken())
|
.like(HostConnectLogDO::getToken, request.getToken())
|
||||||
.eq(HostConnectLogDO::getStatus, request.getStatus())
|
.eq(HostConnectLogDO::getStatus, request.getStatus())
|
||||||
|
.in(HostConnectLogDO::getStatus, request.getStatusList())
|
||||||
.ge(HostConnectLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 0))
|
.ge(HostConnectLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 0))
|
||||||
.le(HostConnectLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 1))
|
.le(HostConnectLogDO::getStartTime, Arrays1.getIfPresent(request.getStartTimeRange(), 1))
|
||||||
|
.le(HostConnectLogDO::getCreateTime, request.getCreateTimeLe())
|
||||||
.orderByDesc(HostConnectLogDO::getId);
|
.orderByDesc(HostConnectLogDO::getId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user