mirror of
https://gitee.com/dromara/orion-visor.git
synced 2026-06-10 19:26:52 +08:00
Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5a7ed8980 | ||
|
|
e774531fcb | ||
|
|
238ec20b7c | ||
|
|
4da3fc9356 | ||
|
|
8a1bf72d30 | ||
|
|
0dbdafe138 | ||
|
|
1285db903d | ||
|
|
35d3112339 | ||
|
|
d49952bef4 | ||
|
|
2b316febcd | ||
|
|
e17d15c112 | ||
|
|
8f0cd4ad24 | ||
|
|
b207c5d253 | ||
|
|
5335a8d008 | ||
|
|
1e74659f15 | ||
|
|
58a1a7abd4 | ||
|
|
6c125a1c0d | ||
|
|
5162b99e3e | ||
|
|
263436405c | ||
|
|
2296ca46a4 | ||
|
|
ffcb3baf44 | ||
|
|
501755231a | ||
|
|
f4ddeb3e6c | ||
|
|
40afc03203 | ||
|
|
7c479b1720 | ||
|
|
6c6f69ae24 | ||
|
|
d1cb056adf | ||
|
|
14dc8e0407 | ||
|
|
528cfc90f2 | ||
|
|
327bb72659 | ||
|
|
c6b248ab6f | ||
|
|
0ece84bdf1 | ||
|
|
61fa7a6e32 | ||
|
|
21e7d29077 | ||
|
|
fbf4299a61 | ||
|
|
ad42be8fe8 | ||
|
|
d9c8923b6d | ||
|
|
aa913bce8d | ||
|
|
3e3af89939 | ||
|
|
783baaf8c8 | ||
|
|
a53565e06b | ||
|
|
061495eb13 | ||
|
|
6514363847 | ||
|
|
c3da882950 | ||
|
|
6deebedc75 | ||
|
|
2012f20a09 | ||
|
|
2377c50187 | ||
|
|
91b22297a2 | ||
|
|
5bbf46d141 | ||
|
|
3c7a0947ee | ||
|
|
83c64dddfb | ||
|
|
5d86c330fe | ||
|
|
6a13d3cb22 | ||
|
|
3a8addb4d2 | ||
|
|
90705781f2 | ||
|
|
d8818c3ec2 | ||
|
|
91fecad956 | ||
|
|
9635aa34a7 | ||
|
|
a2f7ab7f9c | ||
|
|
55d0dfd27d | ||
|
|
eb18142926 | ||
|
|
0649c4e3de | ||
|
|
f648e18557 | ||
|
|
9d3b46e9b3 | ||
|
|
14dfe457bf | ||
|
|
9651354317 | ||
|
|
8929aa2f74 | ||
|
|
ea98592012 | ||
|
|
b0be444fba |
@@ -6,7 +6,13 @@ SPRING_PROFILES_ACTIVE=prod
|
||||
DEMO_MODE=false
|
||||
|
||||
API_CORS=true
|
||||
API_IP_HEADERS=X-Forwarded-For,X-Real-IP
|
||||
# api 地址 (需要改为宿主机 IP)
|
||||
API_HOST=0.0.0.0
|
||||
# API_URL=http://127.0.0.1:9200/orion-visor/api
|
||||
# api 密钥 (建议修改)
|
||||
API_EXPOSE_TOKEN=pmqeHOyZaumHm0Wt
|
||||
# 加密密钥 (建议修改)
|
||||
SECRET_KEY=uQeacXV8b3isvKLK
|
||||
|
||||
NGINX_SERVICE_HOST=service
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@@ -17,6 +17,8 @@ body:
|
||||
required: true
|
||||
- label: 我已搜索 [issue](https://github.com/dromara/orion-visor/issues) 并没有找到相关问题
|
||||
required: true
|
||||
- label: 我已 star 了此项目, 否则可能会被自动关闭
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
|
||||
12
README.md
12
README.md
@@ -38,8 +38,8 @@
|
||||
</a>
|
||||
<a target="_blank"
|
||||
style="text-decoration: none !important;"
|
||||
href="https://gitcode.com/dromara/orion-visor">
|
||||
<img src="https://gitcode.com/dromara/orion-visor/star/badge.svg" alt="star"/>
|
||||
href="https://atomgit.com/dromara/orion-visor">
|
||||
<img src="https://atomgit.com/dromara/orion-visor/star/2025top.svg" alt="star" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
* 🔗 演示地址: [https://dv.orionsec.cn/](https://dv.orionsec.cn/)
|
||||
* 🔏 演示账号: admin/admin
|
||||
* ⭐ 体验后可以点一下 `star`
|
||||
这对我很重要! [github](https://github.com/dromara/orion-visor) [gitee](https://gitee.com/dromara/orion-visor) [gitcode](https://gitcode.com/dromara/orion-visor)
|
||||
这对我很重要! [github](https://github.com/dromara/orion-visor) [gitee](https://gitee.com/dromara/orion-visor) [atomgit](https://atomgit.com/dromara/orion-visor)
|
||||
* 🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
|
||||
* 🎭 演示环境部分功能不可用, 完整功能请本地部署!
|
||||
|
||||
@@ -70,6 +70,10 @@
|
||||
# clone
|
||||
git clone --depth=1 https://github.com/dromara/orion-visor
|
||||
cd orion-visor
|
||||
# 复制配置
|
||||
cp .env.example .env
|
||||
# 修改配置
|
||||
vim .env
|
||||
# 启动
|
||||
docker compose up -d
|
||||
# 等待后端服务启动后 (2min±) 访问 http://localhost:1081/
|
||||
@@ -171,6 +175,6 @@ QQ群: 755242157
|
||||
|
||||

|
||||
|
||||
## GitCode 最有影响力的开源项目 G-Star
|
||||
## AtomGit 最有影响力的开源项目 G-Star
|
||||
|
||||

|
||||
|
||||
169
docker-compose-bt.yml
Normal file
169
docker-compose-bt.yml
Normal file
@@ -0,0 +1,169 @@
|
||||
# https://github.com/aaPanel/appstore/tree/main/apps/orion_visor
|
||||
|
||||
services:
|
||||
orion-ui:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-ui:latest
|
||||
ports:
|
||||
- ${HOST_IP}:${WEB_HTTP_PORT}:80
|
||||
environment:
|
||||
NGINX_SERVICE_HOST: ${NGINX_SERVICE_HOST:-orion-service}
|
||||
NGINX_SERVICE_PORT: ${NGINX_SERVICE_PORT:-9200}
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
orion-service:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- baota_net
|
||||
|
||||
orion-service:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:${VERSION}
|
||||
privileged: true
|
||||
ports:
|
||||
- "9200:9200"
|
||||
environment:
|
||||
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-prod}
|
||||
MYSQL_HOST: orion-mysql
|
||||
MYSQL_PORT: ${MYSQL_PORT:-3306}
|
||||
MYSQL_DATABASE: ${MYSQL_DATABASE:-orion_visor}
|
||||
MYSQL_USER: ${MYSQL_USER:-orion}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-Data@123456}
|
||||
REDIS_HOST: orion-redis
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-Data@123456}
|
||||
REDIS_DATABASE: ${REDIS_DATABASE:-0}
|
||||
REDIS_DATA_VERSION: ${REDIS_DATA_VERSION:-1}
|
||||
INFLUXDB_ENABLED: true
|
||||
INFLUXDB_HOST: orion-influxdb
|
||||
INFLUXDB_PORT: ${INFLUXDB_PORT:-8086}
|
||||
INFLUXDB_ORG: ${INFLUXDB_ORG:-orion-visor}
|
||||
INFLUXDB_BUCKET: ${INFLUXDB_BUCKET:-metrics}
|
||||
INFLUXDB_TOKEN: ${INFLUXDB_TOKEN:-Data@123456}
|
||||
GUACD_HOST: orion-guacd
|
||||
GUACD_PORT: ${GUACD_PORT:-4822}
|
||||
GUACD_DRIVE_PATH: ${GUACD_DRIVE_PATH:-/drive}
|
||||
SECRET_KEY: ${SECRET_KEY:-uQeacXV8b3isvKLK}
|
||||
API_EXPOSE_TOKEN: ${API_EXPOSE_TOKEN:-pmqeHOyZaumHm0Wt}
|
||||
API_IP_HEADERS: ${API_IP_HEADERS:-X-Forwarded-For,X-Real-IP}
|
||||
# 这里需要改为具体的服务地址 (宿主机ip)
|
||||
API_HOST: ${HOST_IP}
|
||||
# 若 API_HOST 不满足, 可以修改这里 http://<ip>:<port>/orion-visor/api
|
||||
API_URL: ${API_URL:-}
|
||||
API_CORS: ${API_CORS:-true}
|
||||
DEMO_MODE: ${DEMO_MODE:-false}
|
||||
volumes:
|
||||
- ${APP_PATH}/service/root-orion:/root/orion
|
||||
ulimits:
|
||||
nofile:
|
||||
soft: 65536
|
||||
hard: 65536
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ]
|
||||
interval: 15s
|
||||
timeout: 300s
|
||||
retries: 15
|
||||
start_period: 3s
|
||||
depends_on:
|
||||
orion-mysql:
|
||||
condition: service_healthy
|
||||
orion-redis:
|
||||
condition: service_healthy
|
||||
orion-influxdb:
|
||||
condition: service_healthy
|
||||
labels:
|
||||
createdBy: "bt_apps"
|
||||
networks:
|
||||
- baota_net
|
||||
|
||||
orion-mysql:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:${VERSION}
|
||||
privileged: true
|
||||
environment:
|
||||
- MYSQL_DATABASE=${MYSQL_DATABASE:-orion_visor}
|
||||
- MYSQL_USER=${MYSQL_USER:-orion}
|
||||
- MYSQL_PASSWORD=${MYSQL_PASSWORD:-Data@123456}
|
||||
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-Data@123456}
|
||||
volumes:
|
||||
- ${APP_PATH}/mysql/var-lib-mysql:/var/lib/mysql
|
||||
- ${APP_PATH}/mysql/var-lib-mysql-files:/var/lib/mysql-files
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ]
|
||||
interval: 15s
|
||||
timeout: 60s
|
||||
retries: 15
|
||||
start_period: 3s
|
||||
labels:
|
||||
createdBy: "bt_apps"
|
||||
networks:
|
||||
- baota_net
|
||||
|
||||
orion-redis:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:${VERSION}
|
||||
privileged: true
|
||||
environment:
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD:-Data@123456}
|
||||
volumes:
|
||||
- ${APP_PATH}/redis/data:/data
|
||||
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
|
||||
interval: 15s
|
||||
timeout: 60s
|
||||
retries: 15
|
||||
start_period: 3s
|
||||
labels:
|
||||
createdBy: "bt_apps"
|
||||
networks:
|
||||
- baota_net
|
||||
|
||||
orion-influxdb:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-influxdb:latest
|
||||
privileged: true
|
||||
ports:
|
||||
- "8086:8086"
|
||||
environment:
|
||||
DOCKER_INFLUXDB_INIT_MODE: setup
|
||||
DOCKER_INFLUXDB_INIT_USERNAME: ${INFLUXDB_ADMIN_USERNAME:-admin}
|
||||
DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_ADMIN_PASSWORD:-Data@123456}
|
||||
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: ${INFLUXDB_TOKEN:-Data@123456}
|
||||
DOCKER_INFLUXDB_INIT_ORG: ${INFLUXDB_ORG:-orion-visor}
|
||||
DOCKER_INFLUXDB_INIT_BUCKET: ${INFLUXDB_BUCKET:-metrics}
|
||||
volumes:
|
||||
- ${APP_PATH}/influxdb/data:/var/lib/influxdb2
|
||||
- ${APP_PATH}/influxdb/config:/etc/influxdb2
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/8086" ]
|
||||
interval: 15s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
networks:
|
||||
- baota_net
|
||||
|
||||
orion-guacd:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-guacd:latest
|
||||
ports:
|
||||
- "4822:4822"
|
||||
environment:
|
||||
GUACD_LOG_LEVEL: info
|
||||
GUACD_LOG_FILE: /var/log/guacd.log
|
||||
volumes:
|
||||
- ${APP_PATH}/guacd/drive:${GUACD_DRIVE_PATH:-/drive}
|
||||
- ${APP_PATH}/guacd/var-logs:/var/log
|
||||
- ${APP_PATH}/guacd/local-guacamole-lib:/usr/local/guacamole/lib
|
||||
- ${APP_PATH}/guacd/local-guacamole-extensions:/usr/local/guacamole/extensions
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: [ "CMD", "nc", "-vz", "localhost", "4822" ]
|
||||
interval: 15s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
networks:
|
||||
- baota_net
|
||||
|
||||
networks:
|
||||
baota_net:
|
||||
external: true
|
||||
@@ -1,5 +1,3 @@
|
||||
version: '3.3'
|
||||
|
||||
services:
|
||||
service:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
version: '3.3'
|
||||
|
||||
# latest = 2.5.3
|
||||
# latest = 2.5.7
|
||||
|
||||
# 支持以下源
|
||||
# lijiahangmax/*
|
||||
@@ -32,7 +30,7 @@ services:
|
||||
MYSQL_HOST: ${MYSQL_HOST:-mysql}
|
||||
MYSQL_PORT: ${MYSQL_PORT:-3306}
|
||||
MYSQL_DATABASE: ${MYSQL_DATABASE:-orion_visor}
|
||||
MYSQL_USER: ${MYSQL_USER:-root}
|
||||
MYSQL_USER: ${MYSQL_USER:-orion}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-Data@123456}
|
||||
REDIS_HOST: ${REDIS_HOST:-redis}
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-Data@123456}
|
||||
@@ -49,6 +47,11 @@ services:
|
||||
GUACD_DRIVE_PATH: ${GUACD_DRIVE_PATH:-/drive}
|
||||
SECRET_KEY: ${SECRET_KEY:-uQeacXV8b3isvKLK}
|
||||
API_EXPOSE_TOKEN: ${API_EXPOSE_TOKEN:-pmqeHOyZaumHm0Wt}
|
||||
API_IP_HEADERS: ${API_IP_HEADERS:-X-Forwarded-For,X-Real-IP}
|
||||
# 这里需要改为具体的服务地址 (宿主机ip)
|
||||
API_HOST: ${API_HOST:-0.0.0.0}
|
||||
# 若 API_HOST 不满足, 可以修改这里 http://<ip>:<port>/orion-visor/api
|
||||
API_URL: ${API_URL:-}
|
||||
API_CORS: ${API_CORS:-true}
|
||||
DEMO_MODE: ${DEMO_MODE:-false}
|
||||
volumes:
|
||||
|
||||
@@ -7,7 +7,7 @@ set -e
|
||||
source ./project-build.sh "$@"
|
||||
|
||||
# 版本号
|
||||
version=2.5.3
|
||||
version=2.5.7
|
||||
# 是否推送镜像
|
||||
push_image=false
|
||||
# 是否构建 latest
|
||||
@@ -140,7 +140,7 @@ function modify_dockerfiles() {
|
||||
if [ -f "$file" ]; then
|
||||
echo "备份并修改: $file"
|
||||
cp "$file" "$file$backup_suffix"
|
||||
sed -i 's/--platform=\TARGETPLATFORM//g' "$file"
|
||||
sed -i "s/--platform=\$TARGETPLATFORM//g" "$file"
|
||||
else
|
||||
echo "文件不存在 -> $file"
|
||||
fi
|
||||
@@ -189,7 +189,7 @@ function push_image_to_registry() {
|
||||
# 推送版本
|
||||
docker push "${namespace}/${image_name}:${version}"
|
||||
# 推送 latest
|
||||
if [ "latest_image" = true ]; then
|
||||
if [ "$latest_image" = true ]; then
|
||||
docker push "${namespace}/${image_name}:latest"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -4,7 +4,7 @@ set -e
|
||||
# DockerContext: orion-visor
|
||||
|
||||
# 版本号
|
||||
version=2.5.3
|
||||
version=2.5.7
|
||||
# 是否构建 service
|
||||
export build_service=false
|
||||
# 是否构建 ui
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM --platform=$TARGETPLATFORM openjdk:8-jdk-alpine
|
||||
FROM --platform=$TARGETPLATFORM openjdk:8u171-jdk-alpine3.7
|
||||
|
||||
USER root
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2023 - present Dromara, All rights reserved.
|
||||
*
|
||||
* https://visor.dromara.org
|
||||
* https://visor.dromara.org.cn
|
||||
* https://visor.orionsec.cn
|
||||
*
|
||||
* Members:
|
||||
* Jiahang Li - ljh1553488six@139.com - author
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.common.configuration;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.utils.IpUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* 公共配置类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/6/20 10:34
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class CommonConfiguration {
|
||||
|
||||
@Value("${orion.api.ip-headers}")
|
||||
private String[] ipHeaders;
|
||||
|
||||
/**
|
||||
* 设置 IP 请求头
|
||||
*/
|
||||
@PostConstruct
|
||||
public void setIpHeader() {
|
||||
IpUtils.setIpHeader(ipHeaders);
|
||||
log.info("IpUtils.setIpHeader {}", String.join(",", ipHeaders));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public interface AppConst extends OrionConst {
|
||||
/**
|
||||
* 同 ${orion.version} 迭代时候需要手动更改
|
||||
*/
|
||||
String VERSION = "2.5.3";
|
||||
String VERSION = "2.5.7";
|
||||
|
||||
/**
|
||||
* 同 ${spring.application.name}
|
||||
|
||||
@@ -34,116 +34,116 @@ public interface ConfigKeys {
|
||||
/**
|
||||
* SFTP 文件预览大小
|
||||
*/
|
||||
String SFTP_PREVIEW_SIZE = "sftp_previewSize";
|
||||
String SFTP_PREVIEW_SIZE = "sftp.preview-size";
|
||||
|
||||
/**
|
||||
* SFTP 重复文件备份
|
||||
*/
|
||||
String SFTP_UPLOAD_PRESENT_BACKUP = "sftp_uploadPresentBackup";
|
||||
String SFTP_UPLOAD_PRESENT_BACKUP = "sftp.upload-present-backup";
|
||||
|
||||
/**
|
||||
* SFTP 备份文件名称
|
||||
*/
|
||||
String SFTP_UPLOAD_BACKUP_FILE_NAME = "sftp_uploadBackupFileName";
|
||||
String SFTP_UPLOAD_BACKUP_FILE_NAME = "sftp.upload-backup-file-name";
|
||||
|
||||
/**
|
||||
* 加密公钥
|
||||
*/
|
||||
String ENCRYPT_PUBLIC_KEY = "encrypt_publicKey";
|
||||
String ENCRYPT_PUBLIC_KEY = "encrypt.public-key";
|
||||
|
||||
/**
|
||||
* 加密私钥
|
||||
*/
|
||||
String ENCRYPT_PRIVATE_KEY = "encrypt_privateKey";
|
||||
String ENCRYPT_PRIVATE_KEY = "encrypt.private-key";
|
||||
|
||||
/**
|
||||
* 日志前端显示行数
|
||||
*/
|
||||
String LOG_WEB_SCROLL_LINES = "log_webScrollLines";
|
||||
String LOG_WEB_SCROLL_LINES = "log.web-scroll-lines";
|
||||
|
||||
/**
|
||||
* 日志加载偏移行
|
||||
*/
|
||||
String LOG_TRACKER_LOAD_LINES = "log_trackerLoadLines";
|
||||
String LOG_TRACKER_LOAD_LINES = "log.tracker-load-lines";
|
||||
|
||||
/**
|
||||
* 日志加载间隔毫秒
|
||||
*/
|
||||
String LOG_TRACKER_LOAD_INTERVAL = "log_trackerLoadInterval";
|
||||
String LOG_TRACKER_LOAD_INTERVAL = "log.tracker-load-interval";
|
||||
|
||||
/**
|
||||
* 是否生成详细的执行日志
|
||||
*/
|
||||
String LOG_EXEC_DETAIL_LOG = "log_execDetailLog";
|
||||
String LOG_EXEC_DETAIL_ENABLED = "log.exec-detail.enabled";
|
||||
|
||||
/**
|
||||
* 凭证有效期分
|
||||
* 凭证有效期 分
|
||||
*/
|
||||
String LOGIN_LOGIN_SESSION_TIME = "login_loginSessionTime";
|
||||
String LOGIN_LOGIN_SESSION_TIME = "login.login-session-time";
|
||||
|
||||
/**
|
||||
* 允许多端登录
|
||||
*/
|
||||
String LOGIN_ALLOW_MULTI_DEVICE = "login_allowMultiDevice";
|
||||
String LOGIN_ALLOW_MULTI_DEVICE = "login.allow-multi-device";
|
||||
|
||||
/**
|
||||
* 允许凭证续签
|
||||
*/
|
||||
String LOGIN_ALLOW_REFRESH = "login_allowRefresh";
|
||||
String LOGIN_ALLOW_REFRESH = "login.allow-refresh";
|
||||
|
||||
/**
|
||||
* 凭证续签最大次数
|
||||
*/
|
||||
String LOGIN_MAX_REFRESH_COUNT = "login_maxRefreshCount";
|
||||
String LOGIN_MAX_REFRESH_COUNT = "login.max-refresh-count";
|
||||
|
||||
/**
|
||||
* 凭证续签间隔分
|
||||
*/
|
||||
String LOGIN_REFRESH_INTERVAL = "login_refreshInterval";
|
||||
String LOGIN_REFRESH_INTERVAL = "login.refresh-interval";
|
||||
|
||||
/**
|
||||
* 登录失败锁定
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_LOCK = "login_loginFailedLock";
|
||||
String LOGIN_LOGIN_FAILED_LOCK = "login.login-failed-lock";
|
||||
|
||||
/**
|
||||
* 登录失败锁定阈值分
|
||||
* 登录失败锁定阈值
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_LOCK_THRESHOLD = "login_loginFailedLockThreshold";
|
||||
String LOGIN_LOGIN_FAILED_LOCK_THRESHOLD = "login.login-failed-lock-threshold";
|
||||
|
||||
/**
|
||||
* 登录失败锁定时间分
|
||||
* 登录失败锁定时间 分
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_LOCK_TIME = "login_loginFailedLockTime";
|
||||
String LOGIN_LOGIN_FAILED_LOCK_TIME = "login.login-failed-lock-time";
|
||||
|
||||
/**
|
||||
* 登录失败发信
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_SEND = "login_loginFailedSend";
|
||||
String LOGIN_LOGIN_FAILED_SEND = "login.login-failed-send";
|
||||
|
||||
/**
|
||||
* 登录失败发信阈值
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_SEND_THRESHOLD = "login_loginFailedSendThreshold";
|
||||
String LOGIN_LOGIN_FAILED_SEND_THRESHOLD = "login.login-failed-send-threshold";
|
||||
|
||||
/**
|
||||
* 是否开启自动清理命令记录
|
||||
*/
|
||||
String AUTO_CLEAR_EXEC_LOG_ENABLED = "autoClear_execLogEnabled";
|
||||
String AUTO_CLEAR_EXEC_LOG_ENABLED = "auto-clear.exec-log.enabled";
|
||||
|
||||
/**
|
||||
* 自动清理命令记录保留天数
|
||||
*/
|
||||
String AUTO_CLEAR_EXEC_LOG_KEEP_DAYS = "autoClear_execLogKeepDays";
|
||||
String AUTO_CLEAR_EXEC_LOG_KEEP_DAYS = "auto-clear.exec-log.keep-days";
|
||||
|
||||
/**
|
||||
* 是否开启自动清理终端连接记录
|
||||
*/
|
||||
String AUTO_CLEAR_TERMINAL_LOG_ENABLED = "autoClear_terminalLogEnabled";
|
||||
String AUTO_CLEAR_TERMINAL_LOG_ENABLED = "auto-clear.terminal-log.enabled";
|
||||
|
||||
/**
|
||||
* 自动清理终端连接记录保留天数
|
||||
*/
|
||||
String AUTO_CLEAR_TERMINAL_LOG_KEEP_DAYS = "autoClear_terminalLogKeepDays";
|
||||
String AUTO_CLEAR_TERMINAL_LOG_KEEP_DAYS = "auto-clear.terminal-log.keep-days";
|
||||
|
||||
}
|
||||
|
||||
@@ -55,4 +55,6 @@ public interface Const extends cn.orionsec.kit.lang.constant.Const, FieldConst,
|
||||
|
||||
int BATCH_COUNT = 500;
|
||||
|
||||
String IP_0000 = "0.0.0.0";
|
||||
|
||||
}
|
||||
|
||||
@@ -210,6 +210,12 @@ public interface ErrorMessage {
|
||||
|
||||
String PLEASE_SELECT_SUFFIX_FILE = "请选择 {} 类型的文件";
|
||||
|
||||
String SPEC_FORMAT_INCORRECT = "规格格式不正确";
|
||||
|
||||
String INFLUXDB_UNSUPPORTED = "InfluxDB 服务未开启";
|
||||
|
||||
String AGENT_KEY_NOT_FOUND = "未通过 agentKey 查询到对应的主机 ({})";
|
||||
|
||||
/**
|
||||
* 是否为业务异常
|
||||
*
|
||||
|
||||
@@ -33,6 +33,20 @@ import java.io.Serializable;
|
||||
*/
|
||||
public interface RequestIdentity extends Serializable {
|
||||
|
||||
/**
|
||||
* 获取请求时间戳
|
||||
*
|
||||
* @return timestamp
|
||||
*/
|
||||
Long getTimestamp();
|
||||
|
||||
/**
|
||||
* 设置请求时间戳
|
||||
*
|
||||
* @param timestamp timestamp
|
||||
*/
|
||||
void setTimestamp(Long timestamp);
|
||||
|
||||
/**
|
||||
* 获取请求地址
|
||||
*
|
||||
|
||||
@@ -23,7 +23,10 @@
|
||||
package org.dromara.visor.common.entity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 请求留痕模型
|
||||
@@ -33,9 +36,15 @@ import lombok.Data;
|
||||
* @since 2023/12/29 11:57
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "RequestIdentityModel", description = "请求留痕模型")
|
||||
public class RequestIdentityModel implements RequestIdentity {
|
||||
|
||||
@Schema(description = "时间戳")
|
||||
private Long timestamp;
|
||||
|
||||
@Schema(description = "请求地址")
|
||||
private String address;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.common.handler.data.model;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.common.handler.data.strategy;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.dromara.visor.common.handler.data.model.GenericsDataModel;
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ package org.dromara.visor.common.json;
|
||||
import cn.orionsec.kit.lang.utils.Desensitizes;
|
||||
import cn.orionsec.kit.lang.utils.Objects1;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.alibaba.fastjson2.filter.ValueFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class FieldDesensitizeFilter implements ValueFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object process(Object object, String name, Object value) {
|
||||
public Object apply(Object object, String name, Object value) {
|
||||
if (Lists.isEmpty(desensitizeFields) || !desensitizeFields.contains(name)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
package org.dromara.visor.common.json;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.serializer.PropertyFilter;
|
||||
import com.alibaba.fastjson2.filter.PropertyFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2023 - present Dromara, All rights reserved.
|
||||
*
|
||||
* https://visor.dromara.org
|
||||
* https://visor.dromara.org.cn
|
||||
* https://visor.orionsec.cn
|
||||
*
|
||||
* Members:
|
||||
* Jiahang Li - ljh1553488six@139.com - author
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.common.mapstruct;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* date 转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2025/3/7 17:43
|
||||
*/
|
||||
public class DateConversion {
|
||||
|
||||
private DateConversion() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Long > Date
|
||||
*
|
||||
* @param timestamp timestamp
|
||||
* @return Date
|
||||
*/
|
||||
public static Date longToDate(Long timestamp) {
|
||||
return timestamp != null ? new Date(timestamp) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Date > Long
|
||||
*
|
||||
* @param date date
|
||||
* @return Long
|
||||
*/
|
||||
public static Long dateToLong(Date date) {
|
||||
return date != null ? date.getTime() : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,9 +22,9 @@
|
||||
*/
|
||||
package org.dromara.visor.common.mapstruct;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
||||
/**
|
||||
* json 转换器
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.dromara.visor.common.utils;
|
||||
|
||||
import cn.orionsec.kit.ext.location.Region;
|
||||
import cn.orionsec.kit.ext.location.region.LocationRegions;
|
||||
import cn.orionsec.kit.web.servlet.web.Servlets;
|
||||
import cn.orionsec.kit.lang.utils.net.IPs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -40,6 +40,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class IpUtils {
|
||||
|
||||
private static String[] IP_HEADER = new String[]{"X-Forwarded-For", "X-Real-IP"};
|
||||
|
||||
private static final Map<String, String> CACHE = new HashMap<>();
|
||||
|
||||
private IpUtils() {
|
||||
@@ -52,13 +54,17 @@ public class IpUtils {
|
||||
* @return addr
|
||||
*/
|
||||
public static String getRemoteAddr(HttpServletRequest request) {
|
||||
// 获取实际地址 X_REAL_IP 在多代理情况下会有问题
|
||||
// String realIp = request.getHeader(StandardHttpHeader.X_REAL_IP);
|
||||
// if (!Strings.isBlank(realIp)) {
|
||||
// return realIp;
|
||||
// }
|
||||
// 获取请求地址
|
||||
return Servlets.getRemoteAddr(request);
|
||||
if (request == null) {
|
||||
return null;
|
||||
} else {
|
||||
for (String remoteAddrHeader : IP_HEADER) {
|
||||
String addr = checkIpHeader(request.getHeader(remoteAddrHeader));
|
||||
if (addr != null) {
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
return checkIpHeader(request.getRemoteAddr());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,4 +118,23 @@ public class IpUtils {
|
||||
return Const.CN_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查 ip 请求头
|
||||
*
|
||||
* @param headerValue headerValue
|
||||
* @return header
|
||||
*/
|
||||
private static String checkIpHeader(String headerValue) {
|
||||
if (headerValue == null) {
|
||||
return null;
|
||||
} else {
|
||||
headerValue = headerValue.split(",")[0];
|
||||
return IPs.checkIp(headerValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setIpHeader(String[] ipHeader) {
|
||||
IP_HEADER = ipHeader;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,10 +64,24 @@ public class Requests {
|
||||
.map(ServletRequestAttributes::getRequest)
|
||||
.ifPresent(request -> {
|
||||
String address = IpUtils.getRemoteAddr(request);
|
||||
identity.setTimestamp(System.currentTimeMillis());
|
||||
identity.setAddress(address);
|
||||
identity.setLocation(IpUtils.getLocation(address));
|
||||
identity.setUserAgent(Servlets.getUserAgent(request));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制留痕信息
|
||||
*
|
||||
* @param source source
|
||||
* @param target target
|
||||
*/
|
||||
public static void copyIdentity(RequestIdentityModel source, RequestIdentityModel target) {
|
||||
target.setTimestamp(source.getTimestamp());
|
||||
target.setAddress(source.getAddress());
|
||||
target.setLocation(source.getLocation());
|
||||
target.setUserAgent(source.getUserAgent());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
<url>https://github.com/dromara/orion-visor</url>
|
||||
|
||||
<properties>
|
||||
<revision>2.5.3</revision>
|
||||
<revision>2.5.7</revision>
|
||||
<spring.boot.version>2.7.17</spring.boot.version>
|
||||
<spring.boot.admin.version>2.7.15</spring.boot.admin.version>
|
||||
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
|
||||
<orion.kit.version>2.0.4</orion.kit.version>
|
||||
<orion.kit.version>2.0.6</orion.kit.version>
|
||||
<aspectj.version>1.9.7</aspectj.version>
|
||||
<lombok.version>1.18.26</lombok.version>
|
||||
<springdoc.version>1.6.15</springdoc.version>
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.framework.biz.operator.log.configuration;
|
||||
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.alibaba.fastjson2.filter.Filter;
|
||||
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
|
||||
import org.dromara.visor.common.json.FieldDesensitizeFilter;
|
||||
import org.dromara.visor.common.json.FieldIgnoreFilter;
|
||||
@@ -55,7 +54,7 @@ import javax.annotation.Resource;
|
||||
public class OrionOperatorLogAutoConfiguration {
|
||||
|
||||
@Resource
|
||||
private ValueFilter desensitizeValueFilter;
|
||||
private Filter desensitizeValueFilter;
|
||||
|
||||
/**
|
||||
* 操作日志委托类
|
||||
@@ -82,7 +81,7 @@ public class OrionOperatorLogAutoConfiguration {
|
||||
public OperatorLogAspect operatorLogAspect(OperatorLogConfig operatorLogConfig,
|
||||
OperatorLogFrameworkService service) {
|
||||
// 参数过滤器
|
||||
SerializeFilter[] serializeFilters = new SerializeFilter[]{
|
||||
Filter[] serializeFilters = new Filter[]{
|
||||
// 忽略字段过滤器
|
||||
new FieldIgnoreFilter(operatorLogConfig.getIgnore()),
|
||||
// 脱敏字段过滤器
|
||||
|
||||
@@ -123,8 +123,8 @@ public class OperatorLogModel implements RequestIdentity {
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* 时间戳
|
||||
*/
|
||||
private Date createTime;
|
||||
private Long timestamp;
|
||||
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.Refs;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.json.matcher.ReplacementFormatters;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.filter.Filter;
|
||||
import org.dromara.visor.common.entity.RequestIdentity;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.common.trace.TraceIdHolder;
|
||||
import org.dromara.visor.common.security.LoginUser;
|
||||
import org.dromara.visor.common.trace.TraceIdHolder;
|
||||
import org.dromara.visor.common.utils.Requests;
|
||||
import org.dromara.visor.framework.biz.operator.log.configuration.config.OperatorLogConfig;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.enums.ReturnType;
|
||||
@@ -54,7 +54,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public class OperatorLogFiller implements Gettable<OperatorLogModel> {
|
||||
|
||||
private static SerializeFilter[] serializeFilters;
|
||||
private static Filter[] serializeFilters;
|
||||
|
||||
private static OperatorLogConfig operatorLogConfig;
|
||||
|
||||
@@ -91,6 +91,7 @@ public class OperatorLogFiller implements Gettable<OperatorLogModel> {
|
||||
*/
|
||||
public OperatorLogFiller fillUsedTime(long start) {
|
||||
long end = System.currentTimeMillis();
|
||||
model.setTimestamp(start);
|
||||
model.setDuration((int) (end - start));
|
||||
model.setStartTime(new Date(start));
|
||||
model.setEndTime(new Date(end));
|
||||
@@ -274,7 +275,7 @@ public class OperatorLogFiller implements Gettable<OperatorLogModel> {
|
||||
return model;
|
||||
}
|
||||
|
||||
public static void setSerializeFilters(SerializeFilter[] serializeFilters) {
|
||||
public static void setSerializeFilters(Filter[] serializeFilters) {
|
||||
if (OperatorLogFiller.serializeFilters != null) {
|
||||
// unmodified
|
||||
throw Exceptions.state();
|
||||
|
||||
@@ -25,9 +25,8 @@ package org.dromara.visor.framework.biz.operator.log.core.utils;
|
||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.filter.Filter;
|
||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||
import org.dromara.visor.common.security.LoginUser;
|
||||
|
||||
@@ -44,7 +43,7 @@ public class OperatorLogs implements ExtraFieldConst {
|
||||
|
||||
private static final String UN_SAVE_FLAG = "__un__save__";
|
||||
|
||||
private static SerializeFilter[] serializeFilters;
|
||||
private static Filter[] serializeFilters;
|
||||
|
||||
/**
|
||||
* 拓展信息
|
||||
@@ -98,7 +97,7 @@ public class OperatorLogs implements ExtraFieldConst {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
if (obj instanceof JSONObject || obj instanceof com.alibaba.fastjson2.JSONObject) {
|
||||
if (obj instanceof com.alibaba.fastjson2.JSONObject || obj instanceof com.alibaba.fastjson2.JSONObject) {
|
||||
EXTRA_HOLDER.get().putAll(JSON.parseObject(toJsonString(obj)));
|
||||
} else if (obj instanceof Map) {
|
||||
EXTRA_HOLDER.get().putAll((Map<String, ?>) obj);
|
||||
@@ -204,7 +203,7 @@ public class OperatorLogs implements ExtraFieldConst {
|
||||
.replaceAll("<br/>", "\n");
|
||||
}
|
||||
|
||||
public static void setSerializeFilters(SerializeFilter[] serializeFilters) {
|
||||
public static void setSerializeFilters(Filter[] serializeFilters) {
|
||||
if (OperatorLogs.serializeFilters != null) {
|
||||
// unmodified
|
||||
throw Exceptions.state();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
package org.dromara.visor.framework.biz.push.core.entity;
|
||||
|
||||
import cn.orionsec.kit.lang.able.IJsonObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.framework.biz.push.core.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
package org.dromara.visor.framework.biz.push.core.entity;
|
||||
|
||||
import cn.orionsec.kit.lang.able.IJsonObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
package org.dromara.visor.framework.biz.push.core.entity;
|
||||
|
||||
import cn.orionsec.kit.lang.able.IJsonObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.framework.biz.push.core.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.framework.biz.push.core.enums;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.dromara.visor.framework.biz.push.core.message.*;
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.dromara.visor.framework.biz.push.core.service;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.entity.PushUser;
|
||||
|
||||
@@ -31,7 +31,7 @@ import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.codec.Base64s;
|
||||
import cn.orionsec.kit.lang.utils.crypto.Signatures;
|
||||
import cn.orionsec.kit.lang.utils.math.Hex;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.framework.biz.push.core.annotation.MessageChannel;
|
||||
|
||||
@@ -30,7 +30,7 @@ import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.codec.Base64s;
|
||||
import cn.orionsec.kit.lang.utils.crypto.Signatures;
|
||||
import cn.orionsec.kit.lang.utils.crypto.enums.SecretKeySpecMode;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.utils.Assert;
|
||||
import org.dromara.visor.framework.biz.push.core.annotation.MessageChannel;
|
||||
|
||||
@@ -25,7 +25,7 @@ package org.dromara.visor.framework.biz.push.core.service;
|
||||
import cn.orionsec.kit.http.ok.OkRequests;
|
||||
import cn.orionsec.kit.http.ok.OkResponse;
|
||||
import cn.orionsec.kit.lang.constant.StandardContentType;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.utils.Assert;
|
||||
import org.dromara.visor.framework.biz.push.core.annotation.MessageChannel;
|
||||
|
||||
@@ -28,8 +28,8 @@ import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import cn.orionsec.kit.lang.utils.reflect.Annotations;
|
||||
import cn.orionsec.kit.lang.utils.reflect.Fields;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.filter.ValueFilter;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.framework.desensitize.core.annotation.Desensitize;
|
||||
import org.dromara.visor.framework.desensitize.core.annotation.DesensitizeObject;
|
||||
@@ -53,7 +53,7 @@ public class DesensitizeValueFilter implements ValueFilter {
|
||||
private static final Map<String, Map<String, Desensitize>> DESENSITIZE_FIELDS = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Object process(Object object, String name, Object value) {
|
||||
public Object apply(Object object, String name, Object value) {
|
||||
if (object == null || value == null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.dromara.visor.framework.executor.core.context;
|
||||
|
||||
import cn.orionsec.kit.lang.define.thread.RejectPolicy;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.thread.ThreadPoolMdcTaskExecutor;
|
||||
import org.dromara.visor.framework.executor.configuration.config.ExecutorConfig;
|
||||
|
||||
@@ -30,7 +30,9 @@ import com.influxdb.client.write.Point;
|
||||
import com.influxdb.query.FluxRecord;
|
||||
import com.influxdb.query.FluxTable;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.entity.chart.TimeChartSeries;
|
||||
import org.dromara.visor.common.utils.Assert;
|
||||
import org.dromara.visor.framework.influxdb.core.query.FluxQueryBuilder;
|
||||
|
||||
import java.time.Instant;
|
||||
@@ -66,6 +68,7 @@ public class InfluxdbUtils {
|
||||
* @param points points
|
||||
*/
|
||||
public static void writePoints(List<Point> points) {
|
||||
Assert.notNull(client, ErrorMessage.INFLUXDB_UNSUPPORTED);
|
||||
try (WriteApi api = client.makeWriteApi()) {
|
||||
// 写入指标
|
||||
api.writePoints(points);
|
||||
@@ -79,6 +82,7 @@ public class InfluxdbUtils {
|
||||
* @return points
|
||||
*/
|
||||
public static List<FluxTable> queryTable(String query) {
|
||||
Assert.notNull(client, ErrorMessage.INFLUXDB_UNSUPPORTED);
|
||||
return client.getQueryApi().query(query);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ package org.dromara.visor.framework.log.core.interceptor;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import cn.orionsec.kit.lang.utils.reflect.Classes;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.filter.Filter;
|
||||
import com.alibaba.fastjson2.filter.ValueFilter;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.dromara.visor.common.json.FieldDesensitizeFilter;
|
||||
import org.dromara.visor.common.json.FieldIgnoreFilter;
|
||||
@@ -65,7 +65,7 @@ public abstract class AbstractLogPrinterInterceptor implements LogPrinterInterce
|
||||
/**
|
||||
* 字段过滤器
|
||||
*/
|
||||
protected SerializeFilter[] serializeFilters;
|
||||
protected Filter[] serializeFilters;
|
||||
|
||||
/**
|
||||
* 脱敏配置
|
||||
@@ -91,7 +91,7 @@ public abstract class AbstractLogPrinterInterceptor implements LogPrinterInterce
|
||||
@Override
|
||||
public void init() {
|
||||
// 参数过滤器
|
||||
this.serializeFilters = new SerializeFilter[]{
|
||||
this.serializeFilters = new Filter[]{
|
||||
// 忽略字段过滤器
|
||||
new FieldIgnoreFilter(config.getField().getIgnore()),
|
||||
// 脱敏字段过滤器
|
||||
|
||||
@@ -26,7 +26,7 @@ import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import cn.orionsec.kit.web.servlet.web.Servlets;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.dromara.visor.common.utils.IpUtils;
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.dromara.visor.framework.mybatis.core.generator.core;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
*/
|
||||
package org.dromara.visor.framework.mybatis.core.type;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
*/
|
||||
package org.dromara.visor.framework.mybatis.core.type;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
@@ -25,18 +25,19 @@ package ${package.ServiceImpl};
|
||||
import cn.orionsec.kit.lang.define.wrapper.DataGrid;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.Assert;
|
||||
#if($meta.enableCache)
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
|
||||
import org.dromara.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
#end
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
#if($meta.enableCache)
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisUtils;
|
||||
import org.dromara.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
#end
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
@@ -59,222 +60,222 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
|
||||
@Resource
|
||||
private ${type}DAO ${typeLower}DAO;
|
||||
@Resource
|
||||
private ${type}DAO ${typeLower}DAO;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create${type}(${type}CreateRequest request) {
|
||||
log.info("${type}Service-create${type} request: {}", JSON.toJSONString(request));
|
||||
// 转换
|
||||
${type}DO record = ${type}Convert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.check${type}Present(record);
|
||||
// 插入
|
||||
int effect = ${typeLower}DAO.insert(record);
|
||||
Long id = record.getId();
|
||||
log.info("${type}Service-create${type} id: {}, effect: {}", id, effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisMaps.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer update${type}ById(${type}UpdateRequest request) {
|
||||
Long id = Assert.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
log.info("${type}Service-update${type}ById id: {}, request: {}", id, JSON.toJSONString(request));
|
||||
// 查询
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
Assert.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 转换
|
||||
${type}DO updateRecord = ${type}Convert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.check${type}Present(updateRecord);
|
||||
// 更新
|
||||
int effect = ${typeLower}DAO.updateById(updateRecord);
|
||||
log.info("${type}Service-update${type}ById effect: {}", effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisMaps.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer update${type}(${type}QueryRequest query, ${type}UpdateRequest update) {
|
||||
log.info("${type}Service.update${type} query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update));
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(query);
|
||||
// 转换
|
||||
${type}DO updateRecord = ${type}Convert.MAPPER.to(update);
|
||||
// 更新
|
||||
int effect = ${typeLower}DAO.update(updateRecord, wrapper);
|
||||
log.info("${type}Service.update${type} effect: {}", effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisMaps.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${type}VO get${type}ById(Long id) {
|
||||
// 查询
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
Assert.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 转换
|
||||
return ${type}Convert.MAPPER.to(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${type}VO> get${type}ByIdList(List<Long> idList) {
|
||||
// 查询
|
||||
List<${type}DO> records = ${typeLower}DAO.selectBatchIds(idList);
|
||||
if (records.isEmpty()) {
|
||||
return Lists.empty();
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create${type}(${type}CreateRequest request) {
|
||||
log.info("${type}Service-create${type} request: {}", JSON.toJSONString(request));
|
||||
// 转换
|
||||
${type}DO record = ${type}Convert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.check${type}Present(record);
|
||||
// 插入
|
||||
int effect = ${typeLower}DAO.insert(record);
|
||||
Long id = record.getId();
|
||||
log.info("${type}Service-create${type} id: {}, effect: {}", id, effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisUtils.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return id;
|
||||
}
|
||||
// 转换
|
||||
return ${type}Convert.MAPPER.to(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${type}VO> get${type}List(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of(wrapper)
|
||||
.order(request, ${type}DO::getId)
|
||||
.list(${type}Convert.MAPPER::to);
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer update${type}ById(${type}UpdateRequest request) {
|
||||
Long id = Assert.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
log.info("${type}Service-update${type}ById id: {}, request: {}", id, JSON.toJSONString(request));
|
||||
// 查询
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
Assert.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 转换
|
||||
${type}DO updateRecord = ${type}Convert.MAPPER.to(request);
|
||||
// 查询数据是否冲突
|
||||
this.check${type}Present(updateRecord);
|
||||
// 更新
|
||||
int effect = ${typeLower}DAO.updateById(updateRecord);
|
||||
log.info("${type}Service-update${type}ById effect: {}", effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisUtils.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer update${type}(${type}QueryRequest query, ${type}UpdateRequest update) {
|
||||
log.info("${type}Service.update${type} query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update));
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(query);
|
||||
// 转换
|
||||
${type}DO updateRecord = ${type}Convert.MAPPER.to(update);
|
||||
// 更新
|
||||
int effect = ${typeLower}DAO.update(updateRecord, wrapper);
|
||||
log.info("${type}Service.update${type} effect: {}", effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisUtils.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${type}VO get${type}ById(Long id) {
|
||||
// 查询
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
Assert.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 转换
|
||||
return ${type}Convert.MAPPER.to(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${type}VO> get${type}ByIdList(List<Long> idList) {
|
||||
// 查询
|
||||
List<${type}DO> records = ${typeLower}DAO.selectBatchIds(idList);
|
||||
if (records.isEmpty()) {
|
||||
return Lists.empty();
|
||||
}
|
||||
// 转换
|
||||
return ${type}Convert.MAPPER.to(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${type}VO> get${type}List(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of(wrapper)
|
||||
.order(request, ${type}DO::getId)
|
||||
.list(${type}Convert.MAPPER::to);
|
||||
}
|
||||
#if($meta.enableCache)
|
||||
|
||||
@Override
|
||||
public List<${type}VO> get${type}ListByCache() {
|
||||
// 查询缓存
|
||||
List<${type}CacheDTO> list = RedisMaps.valuesJson(${type}CacheKeyDefine.${typeConst});
|
||||
if (list.isEmpty()) {
|
||||
// 查询数据库
|
||||
list = ${typeLower}DAO.of().list(${type}Convert.MAPPER::toCache);
|
||||
// 设置屏障 防止穿透
|
||||
CacheBarriers.checkBarrier(list, ${type}CacheDTO::new);
|
||||
// 设置缓存
|
||||
RedisMaps.putAllJson(${type}CacheKeyDefine.${typeConst}, s -> s.getId().toString(), list);
|
||||
}
|
||||
// 删除屏障
|
||||
CacheBarriers.removeBarrier(list);
|
||||
// 转换
|
||||
return list.stream()
|
||||
.map(${type}Convert.MAPPER::to)
|
||||
.sorted(Comparator.comparing(${type}VO::getId).reversed())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@Override
|
||||
public List<${type}VO> get${type}ListByCache() {
|
||||
// 查询缓存
|
||||
List<${type}CacheDTO> list = RedisMaps.valuesJson(${type}CacheKeyDefine.${typeConst});
|
||||
if (list.isEmpty()) {
|
||||
// 查询数据库
|
||||
list = ${typeLower}DAO.of().list(${type}Convert.MAPPER::toCache);
|
||||
// 设置屏障 防止穿透
|
||||
CacheBarriers.checkBarrier(list, ${type}CacheDTO::new);
|
||||
// 设置缓存
|
||||
RedisMaps.putAllJson(${type}CacheKeyDefine.${typeConst}, s -> s.getId().toString(), list);
|
||||
}
|
||||
// 删除屏障
|
||||
CacheBarriers.removeBarrier(list);
|
||||
// 转换
|
||||
return list.stream()
|
||||
.map(${type}Convert.MAPPER::to)
|
||||
.sorted(Comparator.comparing(${type}VO::getId).reversed())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
#end
|
||||
|
||||
@Override
|
||||
public DataGrid<${type}VO> get${type}Page(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of()
|
||||
.wrapper(wrapper)
|
||||
.page(request)
|
||||
.order(request, ${type}DO::getId)
|
||||
.dataGrid(${type}Convert.MAPPER::to);
|
||||
}
|
||||
@Override
|
||||
public DataGrid<${type}VO> get${type}Page(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of()
|
||||
.wrapper(wrapper)
|
||||
.page(request)
|
||||
.order(request, ${type}DO::getId)
|
||||
.dataGrid(${type}Convert.MAPPER::to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long get${type}Count(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of()
|
||||
.wrapper(wrapper)
|
||||
.countMax(request.getLimit());
|
||||
}
|
||||
@Override
|
||||
public Long get${type}Count(${type}QueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return ${typeLower}DAO.of()
|
||||
.wrapper(wrapper)
|
||||
.countMax(request.getLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}ById(Long id) {
|
||||
log.info("${type}Service-delete${type}ById id: {}", id);
|
||||
// 检查数据是否存在
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
Assert.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 删除
|
||||
int effect = ${typeLower}DAO.deleteById(id);
|
||||
log.info("${type}Service-delete${type}ById id: {}, effect: {}", id, effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisMaps.delete(${type}CacheKeyDefine.${typeConst}, id);
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}ById(Long id) {
|
||||
log.info("${type}Service-delete${type}ById id: {}", id);
|
||||
// 检查数据是否存在
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
Assert.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 删除
|
||||
int effect = ${typeLower}DAO.deleteById(id);
|
||||
log.info("${type}Service-delete${type}ById id: {}, effect: {}", id, effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisMaps.delete(${type}CacheKeyDefine.${typeConst}, id);
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}ByIdList(List<Long> idList) {
|
||||
log.info("${type}Service-delete${type}ByIdList idList: {}", idList);
|
||||
int effect = ${typeLower}DAO.deleteBatchIds(idList);
|
||||
log.info("${type}Service-delete${type}ByIdList effect: {}", effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisMaps.delete(${type}CacheKeyDefine.${typeConst}, idList);
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}ByIdList(List<Long> idList) {
|
||||
log.info("${type}Service-delete${type}ByIdList idList: {}", idList);
|
||||
int effect = ${typeLower}DAO.deleteBatchIds(idList);
|
||||
log.info("${type}Service-delete${type}ByIdList effect: {}", effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisMaps.delete(${type}CacheKeyDefine.${typeConst}, idList);
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}(${type}QueryRequest request) {
|
||||
log.info("${type}Service.delete${type} request: {}", JSON.toJSONString(request));
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 删除
|
||||
int effect = ${typeLower}DAO.delete(wrapper);
|
||||
log.info("${type}Service.delete${type} effect: {}", effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisMaps.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}(${type}QueryRequest request) {
|
||||
log.info("${type}Service.delete${type} request: {}", JSON.toJSONString(request));
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 删除
|
||||
int effect = ${typeLower}DAO.delete(wrapper);
|
||||
log.info("${type}Service.delete${type} effect: {}", effect);
|
||||
#if($meta.enableCache)
|
||||
// 删除缓存
|
||||
RedisUtils.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查对象是否存在
|
||||
*
|
||||
* @param domain domain
|
||||
*/
|
||||
private void check${type}Present(${type}DO domain) {
|
||||
// 构造条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = ${typeLower}DAO.wrapper()
|
||||
/**
|
||||
* 检查对象是否存在
|
||||
*
|
||||
* @param domain domain
|
||||
*/
|
||||
private void check${type}Present(${type}DO domain) {
|
||||
// 构造条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = ${typeLower}DAO.wrapper()
|
||||
// 更新时忽略当前记录
|
||||
.ne(${type}DO::getId, domain.getId())
|
||||
// 用其他字段做重复校验
|
||||
#foreach($field in ${table.fields})
|
||||
#foreach($field in ${table.fields})
|
||||
#if("$!field.propertyName" != "id")
|
||||
.eq(${type}DO::get${field.capitalName}, domain.get${field.capitalName}())#if(!$foreach.hasNext);#end
|
||||
.eq(${type}DO::get${field.capitalName}, domain.get${field.capitalName}())#if(!$foreach.hasNext);#end
|
||||
#end
|
||||
#end
|
||||
// 检查是否存在
|
||||
boolean present = ${typeLower}DAO.of(wrapper).present();
|
||||
Assert.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
}
|
||||
#end
|
||||
// 检查是否存在
|
||||
boolean present = ${typeLower}DAO.of(wrapper).present();
|
||||
Assert.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapper<${type}DO> buildQueryWrapper(${type}QueryRequest request) {
|
||||
String searchValue = request.getSearchValue();
|
||||
return ${typeLower}DAO.wrapper()
|
||||
@Override
|
||||
public LambdaQueryWrapper<${type}DO> buildQueryWrapper(${type}QueryRequest request) {
|
||||
String searchValue = request.getSearchValue();
|
||||
return ${typeLower}DAO.wrapper()
|
||||
#foreach($field in ${table.fields})
|
||||
.eq(${type}DO::get${field.capitalName}, request.get${field.capitalName}())
|
||||
#end
|
||||
.and(Strings.isNotEmpty(searchValue), c -> c
|
||||
#foreach($field in ${table.fields})
|
||||
.eq(${type}DO::get${field.capitalName}, searchValue)#if($foreach.hasNext).or()#end
|
||||
.eq(${type}DO::get${field.capitalName}, request.get${field.capitalName}())
|
||||
#end
|
||||
);
|
||||
}
|
||||
.and(Strings.isNotEmpty(searchValue), c -> c
|
||||
#foreach($field in ${table.fields})
|
||||
.eq(${type}DO::get${field.capitalName}, searchValue)#if($foreach.hasNext).or()#end
|
||||
#end
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@
|
||||
package ${currentPackage};
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.Assert;
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
#foreach($pkg in ${customProviderFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
#foreach($pkg in ${customProviderFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
@@ -66,7 +66,7 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
log.info("${type}Api.create${type} dto: {}", JSON.toJSONString(dto));
|
||||
Assert.valid(dto);
|
||||
// 转换
|
||||
${type}CreateRequest request = ${type}ProviderConvert.MAPPER.toRequest(dto);
|
||||
${type}CreateRequest request = ${type}ProviderConvert.MAPPER.toRequest(dto);
|
||||
// 创建
|
||||
return ${typeLower}Service.create${type}(request);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
log.info("${type}Api.update${type}ById dto: {}", JSON.toJSONString(dto));
|
||||
Assert.valid(dto);
|
||||
// 转换
|
||||
${type}UpdateRequest request = ${type}ProviderConvert.MAPPER.toRequest(dto);
|
||||
${type}UpdateRequest request = ${type}ProviderConvert.MAPPER.toRequest(dto);
|
||||
// 修改
|
||||
return ${typeLower}Service.update${type}ById(request);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
Assert.valid(update);
|
||||
// 更新
|
||||
int effect = ${typeLower}Service.update${type}(${type}ProviderConvert.MAPPER.toRequest(query),
|
||||
${type}ProviderConvert.MAPPER.toRequest(update));
|
||||
${type}ProviderConvert.MAPPER.toRequest(update));
|
||||
log.info("${type}Api.update${type} effect: {}", effect);
|
||||
return effect;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
log.info("${type}Api.get${type}ById id: {}", id);
|
||||
Assert.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// 修改
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
${type}DO record = ${typeLower}DAO.selectById(id);
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -129,14 +129,14 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
}
|
||||
|
||||
#if($meta.enableCache)
|
||||
@Override
|
||||
public List<${type}DTO> get${type}ListByCache() {
|
||||
return ${typeLower}Service.get${type}ListByCache()
|
||||
.stream()
|
||||
.map(${type}ProviderConvert.MAPPER::to)
|
||||
.sorted(Comparator.comparing(${type}DTO::getId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@Override
|
||||
public List<${type}DTO> get${type}ListByCache() {
|
||||
return ${typeLower}Service.get${type}ListByCache()
|
||||
.stream()
|
||||
.map(${type}ProviderConvert.MAPPER::to)
|
||||
.sorted(Comparator.comparing(${type}DTO::getId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
#end
|
||||
@Override
|
||||
@@ -186,7 +186,7 @@ public class ${type}ApiImpl implements ${type}Api {
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<${type}DO> buildQueryWrapper(${type}QueryDTO dto) {
|
||||
return ${typeLower}DAO.wrapper()
|
||||
return ${typeLower}DAO.wrapper()
|
||||
#foreach($field in ${table.fields})
|
||||
.eq(${type}DO::get${field.capitalName}, dto.get${field.capitalName}())#if(!$foreach.hasNext);#end
|
||||
#end
|
||||
|
||||
@@ -169,7 +169,6 @@
|
||||
Message.success('删除成功');
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -200,7 +199,6 @@
|
||||
pagination.total = data.total;
|
||||
pagination.current = request.page;
|
||||
pagination.pageSize = request.limit;
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -135,8 +135,6 @@
|
||||
}
|
||||
handleClose();
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -139,8 +139,6 @@
|
||||
}
|
||||
handleClose();
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
<a-table row-key="id"
|
||||
#end
|
||||
ref="tableRef"
|
||||
class="table-resize"
|
||||
:loading="loading"
|
||||
:columns="tableColumns"
|
||||
#if($vue.enableRowSelection)
|
||||
@@ -99,6 +100,7 @@
|
||||
:data="tableRenderData"
|
||||
:pagination="pagination"
|
||||
:bordered="false"
|
||||
:column-resizable="true"
|
||||
@page-change="(page: number) => fetchTableData(page, pagination.pageSize)"
|
||||
@page-size-change="(size: number) => fetchTableData(1, size)">
|
||||
#foreach($field in ${table.fields})
|
||||
@@ -200,7 +202,6 @@
|
||||
selectedKeys.value = [];
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -218,7 +219,6 @@
|
||||
Message.success('删除成功');
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -244,7 +244,6 @@
|
||||
#if($vue.enableRowSelection)
|
||||
selectedKeys.value = [];
|
||||
#end
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.dromara.visor.framework.redis.core.utils;
|
||||
|
||||
import cn.orionsec.kit.lang.define.cache.key.CacheKeyDefine;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,7 +27,7 @@ import cn.orionsec.kit.lang.function.Functions;
|
||||
import cn.orionsec.kit.lang.utils.Objects1;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,9 +24,9 @@ package org.dromara.visor.framework.redis.core.utils;
|
||||
|
||||
import cn.orionsec.kit.lang.define.cache.key.CacheKeyDefine;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -24,6 +24,7 @@ package org.dromara.visor.framework.test.core.base;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||
import org.dromara.visor.common.configuration.CommonConfiguration;
|
||||
import org.dromara.visor.common.configuration.SpringConfiguration;
|
||||
import org.dromara.visor.framework.datasource.configuration.OrionDataSourceAutoConfiguration;
|
||||
import org.dromara.visor.framework.mybatis.configuration.OrionMybatisAutoConfiguration;
|
||||
@@ -60,6 +61,7 @@ public class BaseUnitTest {
|
||||
@Import({
|
||||
// spring
|
||||
SpringConfiguration.class,
|
||||
CommonConfiguration.class,
|
||||
// mock
|
||||
OrionMockBeanTestConfiguration.class,
|
||||
OrionMockRedisTestConfiguration.class,
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.dromara.visor.common.constant.AutoConfigureOrderConst;
|
||||
import org.dromara.visor.common.constant.FilterOrderConst;
|
||||
import org.dromara.visor.common.web.WebFilterCreator;
|
||||
import org.dromara.visor.framework.web.configuration.config.ExposeApiConfig;
|
||||
import org.dromara.visor.framework.web.configuration.config.OrionApiConfig;
|
||||
import org.dromara.visor.framework.web.core.aspect.DemoDisableApiAspect;
|
||||
import org.dromara.visor.framework.web.core.aspect.ExposeApiAspect;
|
||||
import org.dromara.visor.framework.web.core.filter.TraceIdFilter;
|
||||
@@ -71,7 +72,7 @@ import java.util.List;
|
||||
@DependsOn({"executorContext"})
|
||||
@AutoConfiguration
|
||||
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_WEB)
|
||||
@EnableConfigurationProperties(ExposeApiConfig.class)
|
||||
@EnableConfigurationProperties({ExposeApiConfig.class, OrionApiConfig.class})
|
||||
public class OrionWebAutoConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Value("${orion.prefix}")
|
||||
|
||||
@@ -36,6 +36,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties("orion.api.expose")
|
||||
public class ExposeApiConfig {
|
||||
|
||||
/**
|
||||
* 对外服务地址
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 对外服务请求头
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2023 - present Dromara, All rights reserved.
|
||||
*
|
||||
* https://visor.dromara.org
|
||||
* https://visor.dromara.org.cn
|
||||
* https://visor.orionsec.cn
|
||||
*
|
||||
* Members:
|
||||
* Jiahang Li - ljh1553488six@139.com - author
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.framework.web.configuration.config;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.net.IPs;
|
||||
import lombok.Data;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* api 配置属性
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2025/12/8 14:00
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties("orion.api")
|
||||
public class OrionApiConfig {
|
||||
|
||||
private static final String URL_TEMPLATE = "http://{}:{}{}";
|
||||
|
||||
/**
|
||||
* 公共 api 前缀
|
||||
*/
|
||||
private String prefix;
|
||||
|
||||
/**
|
||||
* 服务端主机地址
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 服务端口
|
||||
*/
|
||||
@Value("${server.port}")
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* 服务端 url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
public String getHost() {
|
||||
if (Const.IP_0000.equalsIgnoreCase(host)) {
|
||||
// 本机
|
||||
return IPs.IP;
|
||||
} else {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
if (!Strings.isBlank(url)) {
|
||||
return url;
|
||||
}
|
||||
// 构建
|
||||
return Strings.format(URL_TEMPLATE, this.getHost(), port, prefix);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,21 @@
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "是否开启 cors 过滤器."
|
||||
},
|
||||
{
|
||||
"name": "orion.api.host",
|
||||
"type": "java.lang.String",
|
||||
"description": "服务端主机地址."
|
||||
},
|
||||
{
|
||||
"name": "orion.api.url",
|
||||
"type": "java.lang.String",
|
||||
"description": "服务端接口地址."
|
||||
},
|
||||
{
|
||||
"name": "orion.api.ip-headers",
|
||||
"type": "java.lang.String",
|
||||
"description": "获取 IP 的请求头."
|
||||
},
|
||||
{
|
||||
"name": "orion.api.expose.header",
|
||||
"type": "java.lang.String",
|
||||
|
||||
@@ -26,7 +26,7 @@ import cn.orionsec.kit.lang.constant.StandardHttpHeader;
|
||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.Threads;
|
||||
import cn.orionsec.kit.lang.utils.io.Streams;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.framework.websocket.core.constant.CloseCode;
|
||||
|
||||
@@ -14,7 +14,7 @@ spring:
|
||||
port: ${REDIS_PORT:6379}
|
||||
password: ${REDIS_PASSWORD:Data@123456}
|
||||
database: ${REDIS_DATABASE:1}
|
||||
data-version: ${REDIS_DATA_VERSION:1}
|
||||
data-version: ${REDIS_DATA_VERSION:2}
|
||||
mock: false
|
||||
redisson:
|
||||
threads: 2
|
||||
|
||||
@@ -25,7 +25,7 @@ spring:
|
||||
port: ${REDIS_PORT:6379}
|
||||
password: ${REDIS_PASSWORD:Data@123456}
|
||||
database: ${REDIS_DATABASE:0}
|
||||
data-version: ${REDIS_DATA_VERSION:1}
|
||||
data-version: ${REDIS_DATA_VERSION:2}
|
||||
redisson:
|
||||
threads: 4
|
||||
netty-threads: 4
|
||||
@@ -74,6 +74,13 @@ orion:
|
||||
api:
|
||||
# 是否允许跨域
|
||||
cors: ${API_CORS:true}
|
||||
# 服务端主机地址
|
||||
host: ${API_HOST:0.0.0.0}
|
||||
# 服务端接口地址 默认自动生成
|
||||
url: ${API_URL:}
|
||||
# 获取 IP 的请求头
|
||||
ip-headers: ${API_IP_HEADERS:X-Forwarded-For,X-Real-IP}
|
||||
# 对外服务
|
||||
expose:
|
||||
# 暴露接口请求头值
|
||||
token: ${API_EXPOSE_TOKEN:pmqeHOyZaumHm0Wt}
|
||||
|
||||
@@ -175,6 +175,12 @@ orion:
|
||||
prefix: ${orion.prefix}/api
|
||||
# 是否允许跨域
|
||||
cors: true
|
||||
# 服务端主机地址
|
||||
host: 0.0.0.0
|
||||
# 服务端接口地址 默认自动生成
|
||||
url:
|
||||
# 获取 IP 的请求头
|
||||
ip-headers: X-Forwarded-For,X-Real-IP
|
||||
# 对外服务
|
||||
expose:
|
||||
# 暴露接口请求头
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.dromara.visor.launch;
|
||||
|
||||
import cn.orionsec.kit.lang.define.StopWatch;
|
||||
import cn.orionsec.kit.lang.utils.io.FileReaders;
|
||||
import cn.orionsec.kit.lang.utils.io.FileWriters;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 替换 fastjson 版本
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/12/23 10:21
|
||||
*/
|
||||
public class ReplaceFastjson {
|
||||
|
||||
private static final String PATH = new File("").getAbsolutePath();
|
||||
|
||||
public static void main(String[] args) {
|
||||
StopWatch sw = StopWatch.begin();
|
||||
// 扫描文件
|
||||
List<File> files = Files1.listFilesFilter(PATH, file -> file.isFile()
|
||||
&& (file.getName().endsWith(".java") || file.getName().endsWith(".java.vm"))
|
||||
&& !file.getAbsolutePath().contains("generated-sources")
|
||||
&& !file.getAbsolutePath().contains("node_modules"), true, false);
|
||||
sw.tag(" list");
|
||||
// 添加头
|
||||
files.forEach(ReplaceFastjson::replaceFastjson2ToFile);
|
||||
sw.tag("replace");
|
||||
sw.stop();
|
||||
System.out.println();
|
||||
System.out.println(sw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换 license
|
||||
*
|
||||
* @param file file
|
||||
*/
|
||||
private static void replaceFastjson2ToFile(File file) {
|
||||
String path = file.getAbsolutePath().substring(PATH.length());
|
||||
if (path.contains("ReplaceFastjson")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String line = FileReaders.readLine(file);
|
||||
if (line == null) {
|
||||
return;
|
||||
}
|
||||
// 替换文件内容
|
||||
byte[] bytes = new String(FileReaders.readAllBytesFast(file))
|
||||
.replaceAll("com.alibaba.fastjson\\.", "com.alibaba.fastjson2.")
|
||||
.replaceAll("com.alibaba.fastjson2.JSONPath", "com.alibaba.fastjson.JSONPath")
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
// 写入
|
||||
FileWriters.writeFast(file, bytes);
|
||||
System.out.println("OK " + path);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed " + path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,9 +39,9 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class ReplaceVersion {
|
||||
|
||||
private static final String TARGET_VERSION = "2.5.2";
|
||||
private static final String TARGET_VERSION = "2.5.6";
|
||||
|
||||
private static final String REPLACE_VERSION = "2.5.3";
|
||||
private static final String REPLACE_VERSION = "2.5.7";
|
||||
|
||||
private static final String PATH = new File("").getAbsolutePath();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.enums;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.module.asset.entity.dto.host.HostRdpConfigDTO;
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主机探针端点 api
|
||||
@@ -90,9 +91,8 @@ public class HostAgentController {
|
||||
@PostMapping("/install")
|
||||
@Operation(summary = "安装主机探针")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host:install-agent')")
|
||||
public Boolean installAgent(@Validated @RequestBody HostAgentInstallRequest request) {
|
||||
hostAgentService.installAgent(request);
|
||||
return true;
|
||||
public Map<String, Long> installAgent(@Validated @RequestBody HostAgentInstallRequest request) {
|
||||
return hostAgentService.installAgent(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -29,6 +29,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 主机探针状态 视图响应对象
|
||||
@@ -61,4 +62,7 @@ public class HostAgentStatusVO implements Serializable {
|
||||
@Schema(description = "探针在线状态")
|
||||
private Integer agentOnlineStatus;
|
||||
|
||||
@Schema(description = "探针切换在线状态时间")
|
||||
private Date agentOnlineChangeTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
package org.dromara.visor.module.asset.handler.agent.intstall;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.net.host.ssh.command.CommandExecutors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.FileConst;
|
||||
@@ -50,7 +51,7 @@ public class LinuxAgentInstaller extends AbstractAgentInstaller {
|
||||
sftpExecutor.write(agentHomePath + FileConst.CONFIG_YAML, this.replaceContent(params.getConfigFilePath()));
|
||||
log.info("写入配置文件成功");
|
||||
// 写入启动脚本
|
||||
sftpExecutor.write(agentHomePath + startScriptName, this.replaceContent(params.getStartScriptPath()));
|
||||
sftpExecutor.write(agentHomePath + startScriptName, Strings.replaceCRLF(this.replaceContent(params.getStartScriptPath())));
|
||||
log.info("写入启动脚本成功");
|
||||
// 上传探针文件
|
||||
sftpExecutor.uploadFile(agentHomePath + uploadAgentName, params.getAgentFilePath());
|
||||
|
||||
@@ -51,6 +51,16 @@ public class HostSpecExtraModel implements GenericsDataModel {
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 制造商
|
||||
*/
|
||||
private String vendor;
|
||||
|
||||
/**
|
||||
* 型号
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 系统名称
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.dromara.visor.module.asset.entity.vo.HostAgentStatusVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主机探针 服务类
|
||||
@@ -49,8 +50,9 @@ public interface HostAgentService {
|
||||
* 安装探针
|
||||
*
|
||||
* @param request request
|
||||
* @return agentKey:installId
|
||||
*/
|
||||
void installAgent(HostAgentInstallRequest request);
|
||||
Map<String, Long> installAgent(HostAgentInstallRequest request);
|
||||
|
||||
/**
|
||||
* 上传探针发布包
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.dromara.visor.common.handler.data.model.GenericsDataModel;
|
||||
import org.dromara.visor.module.asset.entity.request.host.HostExtraUpdateRequest;
|
||||
import org.dromara.visor.module.asset.handler.host.extra.HostExtraItemEnum;
|
||||
|
||||
@@ -106,7 +106,7 @@ public class HostAgentEndpointServiceImpl implements HostAgentEndpointService {
|
||||
try {
|
||||
// 查询主机信息
|
||||
Long hostId = hostDAO.selectIdByAgentKey(agentKey);
|
||||
Assert.notNull(hostId, ErrorMessage.HOST_ABSENT);
|
||||
Assert.notNull(hostId, ErrorMessage.AGENT_KEY_NOT_FOUND, agentKey);
|
||||
// 查询主机规格信息
|
||||
HostSpecExtraModel spec = hostExtraService.getHostExtra(Const.SYSTEM_USER_ID, hostId, HostExtraItemEnum.SPEC);
|
||||
Boolean synced = Optional.ofNullable(spec)
|
||||
@@ -149,7 +149,7 @@ public class HostAgentEndpointServiceImpl implements HostAgentEndpointService {
|
||||
log.info("HostAgentEndpointService setAgentOffline agentKey: {}", agentKey);
|
||||
// 查询主机信息
|
||||
Long hostId = hostDAO.selectIdByAgentKey(agentKey);
|
||||
Assert.notNull(hostId, ErrorMessage.HOST_ABSENT);
|
||||
Assert.notNull(hostId, ErrorMessage.AGENT_KEY_NOT_FOUND, agentKey);
|
||||
// 修改缓存
|
||||
ONLINE_STATUS_CACHE.put(agentKey, AgentOnlineStatusEnum.OFFLINE.getValue());
|
||||
HEARTBEAT_RECV_CACHE.put(agentKey, 0L);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.service.impl;
|
||||
|
||||
import cn.orionsec.kit.lang.function.Functions;
|
||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
@@ -31,7 +32,6 @@ import cn.orionsec.kit.lang.utils.io.FileReaders;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import cn.orionsec.kit.lang.utils.io.compress.CompressTypeEnum;
|
||||
import cn.orionsec.kit.lang.utils.io.compress.FileDecompressor;
|
||||
import cn.orionsec.kit.lang.utils.net.IPs;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
@@ -41,6 +41,8 @@ import org.dromara.visor.common.utils.Assert;
|
||||
import org.dromara.visor.common.utils.PathUtils;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisStrings;
|
||||
import org.dromara.visor.framework.web.configuration.config.ExposeApiConfig;
|
||||
import org.dromara.visor.framework.web.configuration.config.OrionApiConfig;
|
||||
import org.dromara.visor.module.asset.convert.HostConvert;
|
||||
import org.dromara.visor.module.asset.dao.HostAgentLogDAO;
|
||||
import org.dromara.visor.module.asset.dao.HostDAO;
|
||||
@@ -53,7 +55,6 @@ import org.dromara.visor.module.asset.enums.*;
|
||||
import org.dromara.visor.module.asset.handler.agent.intstall.AgentInstaller;
|
||||
import org.dromara.visor.module.asset.handler.agent.model.AgentInstallParams;
|
||||
import org.dromara.visor.module.asset.service.HostAgentService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -77,8 +78,11 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
|
||||
private String localVersion;
|
||||
|
||||
@Value("${orion.api.expose.token}")
|
||||
private String exposeToken;
|
||||
@Resource
|
||||
private OrionApiConfig orionApiConfig;
|
||||
|
||||
@Resource
|
||||
private ExposeApiConfig exposeApiConfig;
|
||||
|
||||
@Resource
|
||||
private HostDAO hostDAO;
|
||||
@@ -119,7 +123,8 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
.select(HostDO::getId,
|
||||
HostDO::getAgentVersion,
|
||||
HostDO::getAgentInstallStatus,
|
||||
HostDO::getAgentOnlineStatus)
|
||||
HostDO::getAgentOnlineStatus,
|
||||
HostDO::getAgentOnlineChangeTime)
|
||||
.in(HostDO::getId, idList)
|
||||
.then()
|
||||
.stream()
|
||||
@@ -129,7 +134,7 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installAgent(HostAgentInstallRequest request) {
|
||||
public Map<String, Long> installAgent(HostAgentInstallRequest request) {
|
||||
// 查询主机信息
|
||||
List<Long> idList = request.getIdList();
|
||||
List<HostDO> hosts = hostDAO.selectBatchIds(idList);
|
||||
@@ -177,6 +182,12 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
// 执行任务
|
||||
AgentInstaller.start(params);
|
||||
}
|
||||
|
||||
// 返回
|
||||
return agentLogs.stream()
|
||||
.collect(Collectors.toMap(HostAgentLogDO::getAgentKey,
|
||||
HostAgentLogDO::getId,
|
||||
Functions.right()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -301,8 +312,8 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
*/
|
||||
private Map<String, String> getReplaceVars() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("SERVER_HOST", IPs.IP);
|
||||
map.put("SERVER_TOKEN", exposeToken);
|
||||
map.put("SERVER_URL", orionApiConfig.getUrl());
|
||||
map.put("SERVER_TOKEN", exposeApiConfig.getToken());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.dromara.visor.module.asset.service.impl;
|
||||
|
||||
import cn.orionsec.kit.lang.function.Functions;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||
|
||||
@@ -22,10 +22,13 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.service.impl;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.handler.data.model.GenericsDataModel;
|
||||
@@ -44,6 +47,7 @@ import org.dromara.visor.module.infra.enums.DataExtraTypeEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -55,6 +59,7 @@ import java.util.stream.Collectors;
|
||||
* @version 1.0.0
|
||||
* @since 2023/12/20 12:11
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class HostExtraServiceImpl implements HostExtraService {
|
||||
|
||||
@@ -156,40 +161,57 @@ public class HostExtraServiceImpl implements HostExtraService {
|
||||
|
||||
@Override
|
||||
public void syncHostSpec(String key, String taskId, JSONObject spec) {
|
||||
try {
|
||||
// 查询主机id
|
||||
Long id = hostDAO.selectIdByAgentKey(key);
|
||||
Assert.notNull(id, ErrorMessage.HOST_ABSENT);
|
||||
// 设置已同步标识
|
||||
spec.put(Const.SYNCED, true);
|
||||
// 查询配置信息
|
||||
String newSpec;
|
||||
HostSpecExtraModel beforeSpec = this.getHostSpecMap(Lists.singleton(id)).get(id);
|
||||
if (beforeSpec == null) {
|
||||
// 新增
|
||||
newSpec = spec.toString();
|
||||
} else {
|
||||
// 合并
|
||||
JSONObject beforeSpecValue = JSON.parseObject(beforeSpec.serial());
|
||||
spec.forEach((k, v) -> {
|
||||
if (v != null) {
|
||||
beforeSpecValue.put(k, v);
|
||||
// 查询主机id
|
||||
Long id = hostDAO.selectIdByAgentKey(key);
|
||||
Assert.notNull(id, ErrorMessage.HOST_ABSENT);
|
||||
// 设置已同步标识
|
||||
spec.put(Const.SYNCED, true);
|
||||
// 查询配置信息
|
||||
String newSpec;
|
||||
HostSpecExtraModel beforeSpec = this.getHostSpecMap(Lists.singleton(id)).get(id);
|
||||
if (beforeSpec == null) {
|
||||
// 新增
|
||||
newSpec = spec.toString();
|
||||
} else {
|
||||
// 合并
|
||||
JSONObject beforeSpecValue = JSON.parseObject(beforeSpec.serial());
|
||||
spec.forEach((k, v) -> {
|
||||
// 获取原数据
|
||||
Object beforeValue = beforeSpecValue.get(k);
|
||||
// 检查是否存在
|
||||
boolean present = false;
|
||||
if (beforeValue != null) {
|
||||
if (beforeValue instanceof String) {
|
||||
present = !Strings.isBlank((String) beforeValue);
|
||||
} else if (beforeValue instanceof Collection) {
|
||||
present = !Lists.isEmpty((Collection<?>) beforeValue);
|
||||
} else if (beforeValue instanceof Map) {
|
||||
present = !Maps.isEmpty((Map<?, ?>) beforeValue);
|
||||
} else {
|
||||
present = true;
|
||||
}
|
||||
});
|
||||
newSpec = beforeSpecValue.toJSONString();
|
||||
}
|
||||
// 修改规格
|
||||
DataExtraSetDTO update = new DataExtraSetDTO();
|
||||
update.setUserId(Const.SYSTEM_USER_ID);
|
||||
update.setRelId(id);
|
||||
update.setItem(HostExtraItemEnum.SPEC.name());
|
||||
update.setValue(newSpec);
|
||||
dataExtraApi.setExtraItem(update, DataExtraTypeEnum.HOST);
|
||||
// 回调成功
|
||||
} catch (Exception e) {
|
||||
// 回调失败
|
||||
throw e;
|
||||
}
|
||||
// 不存在则覆盖
|
||||
if (!present && v != null) {
|
||||
beforeSpecValue.put(k, v);
|
||||
}
|
||||
});
|
||||
newSpec = beforeSpecValue.toJSONString();
|
||||
}
|
||||
// 检查是否能反解析 防止格式错误导致其他地方报错
|
||||
try {
|
||||
JSON.parseObject(newSpec, HostSpecExtraModel.class);
|
||||
} catch (Exception e) {
|
||||
log.error("HostExtraService-setHostSpec error: {}, spec: {}", e.getMessage(), newSpec, e);
|
||||
throw Exceptions.app(ErrorMessage.SPEC_FORMAT_INCORRECT, e);
|
||||
}
|
||||
// 修改规格
|
||||
DataExtraSetDTO update = new DataExtraSetDTO();
|
||||
update.setUserId(Const.SYSTEM_USER_ID);
|
||||
update.setRelId(id);
|
||||
update.setItem(HostExtraItemEnum.SPEC.name());
|
||||
update.setValue(newSpec);
|
||||
dataExtraApi.setExtraItem(update, DataExtraTypeEnum.HOST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ package org.dromara.visor.module.asset.service.impl;
|
||||
import cn.orionsec.kit.lang.define.wrapper.DataGrid;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -110,7 +110,7 @@ public class HostIdentityServiceImpl implements HostIdentityService {
|
||||
int effect = hostIdentityDAO.insert(record);
|
||||
log.info("HostIdentityService-createHostIdentity effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(HostCacheKeyDefine.HOST_IDENTITY);
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_IDENTITY);
|
||||
return record.getId();
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class HostIdentityServiceImpl implements HostIdentityService {
|
||||
int effect = hostIdentityDAO.update(updateRecord, wrapper);
|
||||
log.info("HostIdentityService-updateHostIdentityById effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(HostCacheKeyDefine.HOST_IDENTITY);
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_IDENTITY);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ public class HostIdentityServiceImpl implements HostIdentityService {
|
||||
.eq(HostIdentityDO::getName, domain.getName());
|
||||
// 检查是否存在
|
||||
boolean present = hostIdentityDAO.of(wrapper).present();
|
||||
Assert.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
Assert.isFalse(present, ErrorMessage.NAME_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ package org.dromara.visor.module.asset.service.impl;
|
||||
import cn.orionsec.kit.lang.define.wrapper.DataGrid;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
@@ -104,7 +104,7 @@ public class HostKeyServiceImpl implements HostKeyService {
|
||||
log.info("HostKeyService-createHostKey effect: {}", effect);
|
||||
Long id = record.getId();
|
||||
// 删除缓存
|
||||
RedisMaps.delete(HostCacheKeyDefine.HOST_KEY);
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_KEY);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class HostKeyServiceImpl implements HostKeyService {
|
||||
int effect = hostKeyDAO.updateById(updateRecord);
|
||||
// 删除缓存
|
||||
if (!record.getName().equals(updateRecord.getName())) {
|
||||
RedisMaps.delete(HostCacheKeyDefine.HOST_KEY);
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_KEY);
|
||||
}
|
||||
log.info("HostKeyService-updateHostKeyById effect: {}", effect);
|
||||
return effect;
|
||||
@@ -242,7 +242,7 @@ public class HostKeyServiceImpl implements HostKeyService {
|
||||
.eq(HostKeyDO::getName, domain.getName());
|
||||
// 检查是否存在
|
||||
boolean present = hostKeyDAO.of(wrapper).present();
|
||||
Assert.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
Assert.isFalse(present, ErrorMessage.NAME_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@ import cn.orionsec.kit.lang.utils.Booleans;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -39,6 +39,7 @@ import org.dromara.visor.common.utils.Assert;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.mybatis.core.query.DataQuery;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisUtils;
|
||||
import org.dromara.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
import org.dromara.visor.module.asset.convert.HostConvert;
|
||||
import org.dromara.visor.module.asset.dao.HostConfigDAO;
|
||||
@@ -376,7 +377,7 @@ public class HostServiceImpl implements HostService {
|
||||
|
||||
@Override
|
||||
public void clearCache() {
|
||||
RedisMaps.scanKeysDelete(HostCacheKeyDefine.HOST_INFO.format("*"));
|
||||
RedisUtils.scanKeysDelete(HostCacheKeyDefine.HOST_INFO.format("*"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.meta;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import cn.orionsec.kit.lang.utils.Colors;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import cn.orionsec.kit.lang.utils.io.FileReaders;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.filter.ValueFilter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -50,12 +50,12 @@ public class AppLogConfig {
|
||||
/**
|
||||
* 是否生成详细的执行日志
|
||||
*/
|
||||
private final ConfigRef<Boolean> execDetailLog;
|
||||
private final ConfigRef<Boolean> execDetailEnabled;
|
||||
|
||||
public AppLogConfig(ConfigStore configStore) {
|
||||
this.trackerLoadLines = configStore.int32(ConfigKeys.LOG_TRACKER_LOAD_LINES);
|
||||
this.trackerLoadInterval = configStore.int32(ConfigKeys.LOG_TRACKER_LOAD_INTERVAL);
|
||||
this.execDetailLog = configStore.bool(ConfigKeys.LOG_EXEC_DETAIL_LOG);
|
||||
this.execDetailEnabled = configStore.bool(ConfigKeys.LOG_EXEC_DETAIL_ENABLED);
|
||||
}
|
||||
|
||||
public Integer getTrackerLoadLines() {
|
||||
@@ -66,8 +66,8 @@ public class AppLogConfig {
|
||||
return trackerLoadInterval.value;
|
||||
}
|
||||
|
||||
public Boolean getExecDetailLog() {
|
||||
return execDetailLog.value;
|
||||
public Boolean getExecDetailEnabled() {
|
||||
return execDetailEnabled.value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.net.host.sftp.SftpExecutor;
|
||||
import cn.orionsec.kit.net.host.sftp.SftpFile;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.dromara.visor.module.common.config.AppSftpConfig;
|
||||
import org.dromara.visor.module.common.entity.dto.SftpFileBackupDTO;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import cn.orionsec.kit.net.host.SessionStore;
|
||||
import cn.orionsec.kit.net.host.sftp.SftpExecutor;
|
||||
import cn.orionsec.kit.net.host.ssh.command.CommandExecutor;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
|
||||
@@ -193,7 +193,7 @@ public class ExecTaskHandler implements IExecTaskHandler {
|
||||
* @return handler
|
||||
*/
|
||||
private IExecCommandHandler createCommandHandler(Long execHostId) {
|
||||
if (Booleans.isTrue(appLogConfig.getExecDetailLog())) {
|
||||
if (Booleans.isTrue(appLogConfig.getExecDetailEnabled())) {
|
||||
// 详细日志
|
||||
return new ExecCommandDetailHandler(execHostId, execLog, builtParams, timeoutChecker);
|
||||
} else {
|
||||
|
||||
@@ -32,8 +32,8 @@ import cn.orionsec.kit.lang.utils.io.FileReaders;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import cn.orionsec.kit.lang.utils.io.Streams;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
|
||||
@@ -25,7 +25,7 @@ package org.dromara.visor.module.exec.service.impl;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
|
||||
@@ -28,7 +28,7 @@ import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import cn.orionsec.kit.lang.utils.time.cron.Cron;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
@@ -408,7 +408,7 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
.eq(ExecJobDO::getName, domain.getName());
|
||||
// 检查是否存在
|
||||
boolean present = execJobDAO.of(wrapper).present();
|
||||
Assert.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
Assert.isFalse(present, ErrorMessage.NAME_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,7 @@ import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import cn.orionsec.kit.lang.utils.io.Streams;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import cn.orionsec.kit.web.servlet.web.Servlets;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.dromara.visor.module.exec.service.impl;
|
||||
|
||||
import cn.orionsec.kit.lang.define.wrapper.DataGrid;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
@@ -208,7 +208,7 @@ public class ExecTemplateServiceImpl implements ExecTemplateService {
|
||||
.eq(ExecTemplateDO::getName, domain.getName());
|
||||
// 检查是否存在
|
||||
boolean present = execTemplateDAO.of(wrapper).present();
|
||||
Assert.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
Assert.isFalse(present, ErrorMessage.NAME_PRESENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
|
||||
@@ -29,7 +29,7 @@ import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import cn.orionsec.kit.lang.utils.json.matcher.NoMatchStrategy;
|
||||
import cn.orionsec.kit.lang.utils.json.matcher.ReplacementFormatter;
|
||||
import cn.orionsec.kit.lang.utils.json.matcher.ReplacementFormatters;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.module.exec.entity.dto.ExecParameterSchemaDTO;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.infra.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,6 +25,7 @@ package org.dromara.visor.module.infra.api.impl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.Assert;
|
||||
import org.dromara.visor.common.utils.Requests;
|
||||
import org.dromara.visor.module.infra.api.AuthenticationApi;
|
||||
import org.dromara.visor.module.infra.entity.domain.SystemUserDO;
|
||||
import org.dromara.visor.module.infra.entity.dto.user.SystemUserAuthDTO;
|
||||
@@ -57,7 +58,11 @@ public class AuthenticationApiImpl implements AuthenticationApi {
|
||||
result.setUsername(user.getUsername());
|
||||
result.setNickname(user.getNickname());
|
||||
// 检查用户密码
|
||||
boolean passRight = authenticationService.checkUserPassword(user, password, addFailedCount);
|
||||
boolean passRight = authenticationService.checkUserPassword(user, password);
|
||||
if (!passRight && addFailedCount) {
|
||||
// 发送站内信
|
||||
authenticationService.addLoginFailedCount(user.getUsername(), Requests.getIdentity());
|
||||
}
|
||||
result.setPassRight(passRight);
|
||||
Assert.isTrue(passRight, ErrorMessage.USERNAME_PASSWORD_ERROR);
|
||||
// 检查用户状态
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.infra.api.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.module.infra.api.DictValueApi;
|
||||
import org.dromara.visor.module.infra.service.DictValueService;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.infra.api.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.Assert;
|
||||
|
||||
@@ -63,9 +63,8 @@ public class AuthenticationController {
|
||||
@PermitAll
|
||||
@Operation(summary = "登录")
|
||||
@PostMapping("/login")
|
||||
public UserLoginVO login(@Validated @RequestBody UserLoginRequest request,
|
||||
HttpServletRequest servletRequest) {
|
||||
return authenticationService.login(request, servletRequest);
|
||||
public UserLoginVO login(@Validated @RequestBody UserLoginRequest request) {
|
||||
return authenticationService.login(request);
|
||||
}
|
||||
|
||||
@OperatorLog(AuthenticationOperatorType.LOGOUT)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
package org.dromara.visor.module.infra.controller;
|
||||
|
||||
import cn.orionsec.kit.lang.define.wrapper.DataGrid;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user