mirror of
https://gitee.com/dromara/orion-visor.git
synced 2026-06-10 11:16:57 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3daacbd8f | ||
|
|
bd76eb255d | ||
|
|
876e763fcc | ||
|
|
6774376418 | ||
|
|
cb59390fed | ||
|
|
670e40f6f0 | ||
|
|
a8de5ab713 | ||
|
|
8d46e1d44d | ||
|
|
ca4ec20e49 | ||
|
|
a0a7240191 | ||
|
|
2b52697cdc | ||
|
|
5ab3f168d8 | ||
|
|
e214fbde5c | ||
|
|
0d0eadc3bf | ||
|
|
edcc2cf0c8 | ||
|
|
7d35f839df | ||
|
|
f1a4e049ca | ||
|
|
3895476ff8 | ||
|
|
964c1daa2c | ||
|
|
9d06f0ae87 |
@@ -6,13 +6,7 @@ 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,8 +17,6 @@ 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://atomgit.com/dromara/orion-visor">
|
||||
<img src="https://atomgit.com/dromara/orion-visor/star/2025top.svg" alt="star" />
|
||||
href="https://gitcode.com/dromara/orion-visor">
|
||||
<img src="https://gitcode.com/dromara/orion-visor/star/badge.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) [atomgit](https://atomgit.com/dromara/orion-visor)
|
||||
这对我很重要! [github](https://github.com/dromara/orion-visor) [gitee](https://gitee.com/dromara/orion-visor) [gitcode](https://gitcode.com/dromara/orion-visor)
|
||||
* 🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
|
||||
* 🎭 演示环境部分功能不可用, 完整功能请本地部署!
|
||||
|
||||
@@ -70,10 +70,6 @@
|
||||
# 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/
|
||||
@@ -175,6 +171,6 @@ QQ群: 755242157
|
||||
|
||||

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

|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
version: '3.3'
|
||||
|
||||
services:
|
||||
service:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# latest = 2.5.7
|
||||
version: '3.3'
|
||||
|
||||
# latest = 2.5.3
|
||||
|
||||
# 支持以下源
|
||||
# lijiahangmax/*
|
||||
@@ -30,7 +32,7 @@ services:
|
||||
MYSQL_HOST: ${MYSQL_HOST:-mysql}
|
||||
MYSQL_PORT: ${MYSQL_PORT:-3306}
|
||||
MYSQL_DATABASE: ${MYSQL_DATABASE:-orion_visor}
|
||||
MYSQL_USER: ${MYSQL_USER:-orion}
|
||||
MYSQL_USER: ${MYSQL_USER:-root}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-Data@123456}
|
||||
REDIS_HOST: ${REDIS_HOST:-redis}
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-Data@123456}
|
||||
@@ -47,11 +49,6 @@ 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.7
|
||||
version=2.5.3
|
||||
# 是否推送镜像
|
||||
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.7
|
||||
version=2.5.3
|
||||
# 是否构建 service
|
||||
export build_service=false
|
||||
# 是否构建 ui
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM --platform=$TARGETPLATFORM openjdk:8u171-jdk-alpine3.7
|
||||
FROM --platform=$TARGETPLATFORM openjdk:8-jdk-alpine
|
||||
|
||||
USER root
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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.7";
|
||||
String VERSION = "2.5.3";
|
||||
|
||||
/**
|
||||
* 同 ${spring.application.name}
|
||||
|
||||
@@ -34,116 +34,116 @@ public interface ConfigKeys {
|
||||
/**
|
||||
* SFTP 文件预览大小
|
||||
*/
|
||||
String SFTP_PREVIEW_SIZE = "sftp.preview-size";
|
||||
String SFTP_PREVIEW_SIZE = "sftp_previewSize";
|
||||
|
||||
/**
|
||||
* SFTP 重复文件备份
|
||||
*/
|
||||
String SFTP_UPLOAD_PRESENT_BACKUP = "sftp.upload-present-backup";
|
||||
String SFTP_UPLOAD_PRESENT_BACKUP = "sftp_uploadPresentBackup";
|
||||
|
||||
/**
|
||||
* SFTP 备份文件名称
|
||||
*/
|
||||
String SFTP_UPLOAD_BACKUP_FILE_NAME = "sftp.upload-backup-file-name";
|
||||
String SFTP_UPLOAD_BACKUP_FILE_NAME = "sftp_uploadBackupFileName";
|
||||
|
||||
/**
|
||||
* 加密公钥
|
||||
*/
|
||||
String ENCRYPT_PUBLIC_KEY = "encrypt.public-key";
|
||||
String ENCRYPT_PUBLIC_KEY = "encrypt_publicKey";
|
||||
|
||||
/**
|
||||
* 加密私钥
|
||||
*/
|
||||
String ENCRYPT_PRIVATE_KEY = "encrypt.private-key";
|
||||
String ENCRYPT_PRIVATE_KEY = "encrypt_privateKey";
|
||||
|
||||
/**
|
||||
* 日志前端显示行数
|
||||
*/
|
||||
String LOG_WEB_SCROLL_LINES = "log.web-scroll-lines";
|
||||
String LOG_WEB_SCROLL_LINES = "log_webScrollLines";
|
||||
|
||||
/**
|
||||
* 日志加载偏移行
|
||||
*/
|
||||
String LOG_TRACKER_LOAD_LINES = "log.tracker-load-lines";
|
||||
String LOG_TRACKER_LOAD_LINES = "log_trackerLoadLines";
|
||||
|
||||
/**
|
||||
* 日志加载间隔毫秒
|
||||
*/
|
||||
String LOG_TRACKER_LOAD_INTERVAL = "log.tracker-load-interval";
|
||||
String LOG_TRACKER_LOAD_INTERVAL = "log_trackerLoadInterval";
|
||||
|
||||
/**
|
||||
* 是否生成详细的执行日志
|
||||
*/
|
||||
String LOG_EXEC_DETAIL_ENABLED = "log.exec-detail.enabled";
|
||||
String LOG_EXEC_DETAIL_LOG = "log_execDetailLog";
|
||||
|
||||
/**
|
||||
* 凭证有效期 分
|
||||
* 凭证有效期分
|
||||
*/
|
||||
String LOGIN_LOGIN_SESSION_TIME = "login.login-session-time";
|
||||
String LOGIN_LOGIN_SESSION_TIME = "login_loginSessionTime";
|
||||
|
||||
/**
|
||||
* 允许多端登录
|
||||
*/
|
||||
String LOGIN_ALLOW_MULTI_DEVICE = "login.allow-multi-device";
|
||||
String LOGIN_ALLOW_MULTI_DEVICE = "login_allowMultiDevice";
|
||||
|
||||
/**
|
||||
* 允许凭证续签
|
||||
*/
|
||||
String LOGIN_ALLOW_REFRESH = "login.allow-refresh";
|
||||
String LOGIN_ALLOW_REFRESH = "login_allowRefresh";
|
||||
|
||||
/**
|
||||
* 凭证续签最大次数
|
||||
*/
|
||||
String LOGIN_MAX_REFRESH_COUNT = "login.max-refresh-count";
|
||||
String LOGIN_MAX_REFRESH_COUNT = "login_maxRefreshCount";
|
||||
|
||||
/**
|
||||
* 凭证续签间隔分
|
||||
*/
|
||||
String LOGIN_REFRESH_INTERVAL = "login.refresh-interval";
|
||||
String LOGIN_REFRESH_INTERVAL = "login_refreshInterval";
|
||||
|
||||
/**
|
||||
* 登录失败锁定
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_LOCK = "login.login-failed-lock";
|
||||
String LOGIN_LOGIN_FAILED_LOCK = "login_loginFailedLock";
|
||||
|
||||
/**
|
||||
* 登录失败锁定阈值
|
||||
* 登录失败锁定阈值分
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_LOCK_THRESHOLD = "login.login-failed-lock-threshold";
|
||||
String LOGIN_LOGIN_FAILED_LOCK_THRESHOLD = "login_loginFailedLockThreshold";
|
||||
|
||||
/**
|
||||
* 登录失败锁定时间 分
|
||||
* 登录失败锁定时间分
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_LOCK_TIME = "login.login-failed-lock-time";
|
||||
String LOGIN_LOGIN_FAILED_LOCK_TIME = "login_loginFailedLockTime";
|
||||
|
||||
/**
|
||||
* 登录失败发信
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_SEND = "login.login-failed-send";
|
||||
String LOGIN_LOGIN_FAILED_SEND = "login_loginFailedSend";
|
||||
|
||||
/**
|
||||
* 登录失败发信阈值
|
||||
*/
|
||||
String LOGIN_LOGIN_FAILED_SEND_THRESHOLD = "login.login-failed-send-threshold";
|
||||
String LOGIN_LOGIN_FAILED_SEND_THRESHOLD = "login_loginFailedSendThreshold";
|
||||
|
||||
/**
|
||||
* 是否开启自动清理命令记录
|
||||
*/
|
||||
String AUTO_CLEAR_EXEC_LOG_ENABLED = "auto-clear.exec-log.enabled";
|
||||
String AUTO_CLEAR_EXEC_LOG_ENABLED = "autoClear_execLogEnabled";
|
||||
|
||||
/**
|
||||
* 自动清理命令记录保留天数
|
||||
*/
|
||||
String AUTO_CLEAR_EXEC_LOG_KEEP_DAYS = "auto-clear.exec-log.keep-days";
|
||||
String AUTO_CLEAR_EXEC_LOG_KEEP_DAYS = "autoClear_execLogKeepDays";
|
||||
|
||||
/**
|
||||
* 是否开启自动清理终端连接记录
|
||||
*/
|
||||
String AUTO_CLEAR_TERMINAL_LOG_ENABLED = "auto-clear.terminal-log.enabled";
|
||||
String AUTO_CLEAR_TERMINAL_LOG_ENABLED = "autoClear_terminalLogEnabled";
|
||||
|
||||
/**
|
||||
* 自动清理终端连接记录保留天数
|
||||
*/
|
||||
String AUTO_CLEAR_TERMINAL_LOG_KEEP_DAYS = "auto-clear.terminal-log.keep-days";
|
||||
String AUTO_CLEAR_TERMINAL_LOG_KEEP_DAYS = "autoClear_terminalLogKeepDays";
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,4 @@ public interface Const extends cn.orionsec.kit.lang.constant.Const, FieldConst,
|
||||
|
||||
int BATCH_COUNT = 500;
|
||||
|
||||
String IP_0000 = "0.0.0.0";
|
||||
|
||||
}
|
||||
|
||||
@@ -210,12 +210,6 @@ public interface ErrorMessage {
|
||||
|
||||
String PLEASE_SELECT_SUFFIX_FILE = "请选择 {} 类型的文件";
|
||||
|
||||
String SPEC_FORMAT_INCORRECT = "规格格式不正确";
|
||||
|
||||
String INFLUXDB_UNSUPPORTED = "InfluxDB 服务未开启";
|
||||
|
||||
String AGENT_KEY_NOT_FOUND = "未通过 agentKey 查询到对应的主机 ({})";
|
||||
|
||||
/**
|
||||
* 是否为业务异常
|
||||
*
|
||||
|
||||
@@ -33,20 +33,6 @@ import java.io.Serializable;
|
||||
*/
|
||||
public interface RequestIdentity extends Serializable {
|
||||
|
||||
/**
|
||||
* 获取请求时间戳
|
||||
*
|
||||
* @return timestamp
|
||||
*/
|
||||
Long getTimestamp();
|
||||
|
||||
/**
|
||||
* 设置请求时间戳
|
||||
*
|
||||
* @param timestamp timestamp
|
||||
*/
|
||||
void setTimestamp(Long timestamp);
|
||||
|
||||
/**
|
||||
* 获取请求地址
|
||||
*
|
||||
|
||||
@@ -23,10 +23,7 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求留痕模型
|
||||
@@ -36,15 +33,9 @@ import lombok.NoArgsConstructor;
|
||||
* @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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.common.handler.data.strategy;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.filter.ValueFilter;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class FieldDesensitizeFilter implements ValueFilter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(Object object, String name, Object value) {
|
||||
public Object process(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.fastjson2.filter.PropertyFilter;
|
||||
import com.alibaba.fastjson.serializer.PropertyFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.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.lang.utils.net.IPs;
|
||||
import cn.orionsec.kit.web.servlet.web.Servlets;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -40,8 +40,6 @@ 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() {
|
||||
@@ -54,17 +52,13 @@ public class IpUtils {
|
||||
* @return addr
|
||||
*/
|
||||
public static String getRemoteAddr(HttpServletRequest 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());
|
||||
}
|
||||
// 获取实际地址 X_REAL_IP 在多代理情况下会有问题
|
||||
// String realIp = request.getHeader(StandardHttpHeader.X_REAL_IP);
|
||||
// if (!Strings.isBlank(realIp)) {
|
||||
// return realIp;
|
||||
// }
|
||||
// 获取请求地址
|
||||
return Servlets.getRemoteAddr(request);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,23 +112,4 @@ 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,24 +64,10 @@ 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.7</revision>
|
||||
<revision>2.5.3</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.6</orion.kit.version>
|
||||
<orion.kit.version>2.0.4</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,7 +22,8 @@
|
||||
*/
|
||||
package org.dromara.visor.framework.biz.operator.log.configuration;
|
||||
|
||||
import com.alibaba.fastjson2.filter.Filter;
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
|
||||
import org.dromara.visor.common.json.FieldDesensitizeFilter;
|
||||
import org.dromara.visor.common.json.FieldIgnoreFilter;
|
||||
@@ -54,7 +55,7 @@ import javax.annotation.Resource;
|
||||
public class OrionOperatorLogAutoConfiguration {
|
||||
|
||||
@Resource
|
||||
private Filter desensitizeValueFilter;
|
||||
private ValueFilter desensitizeValueFilter;
|
||||
|
||||
/**
|
||||
* 操作日志委托类
|
||||
@@ -81,7 +82,7 @@ public class OrionOperatorLogAutoConfiguration {
|
||||
public OperatorLogAspect operatorLogAspect(OperatorLogConfig operatorLogConfig,
|
||||
OperatorLogFrameworkService service) {
|
||||
// 参数过滤器
|
||||
Filter[] serializeFilters = new Filter[]{
|
||||
SerializeFilter[] serializeFilters = new SerializeFilter[]{
|
||||
// 忽略字段过滤器
|
||||
new FieldIgnoreFilter(operatorLogConfig.getIgnore()),
|
||||
// 脱敏字段过滤器
|
||||
|
||||
@@ -123,8 +123,8 @@ public class OperatorLogModel implements RequestIdentity {
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
* 创建时间
|
||||
*/
|
||||
private Long timestamp;
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.filter.Filter;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import org.dromara.visor.common.entity.RequestIdentity;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.common.security.LoginUser;
|
||||
import org.dromara.visor.common.trace.TraceIdHolder;
|
||||
import org.dromara.visor.common.security.LoginUser;
|
||||
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 Filter[] serializeFilters;
|
||||
private static SerializeFilter[] serializeFilters;
|
||||
|
||||
private static OperatorLogConfig operatorLogConfig;
|
||||
|
||||
@@ -91,7 +91,6 @@ 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));
|
||||
@@ -275,7 +274,7 @@ public class OperatorLogFiller implements Gettable<OperatorLogModel> {
|
||||
return model;
|
||||
}
|
||||
|
||||
public static void setSerializeFilters(Filter[] serializeFilters) {
|
||||
public static void setSerializeFilters(SerializeFilter[] serializeFilters) {
|
||||
if (OperatorLogFiller.serializeFilters != null) {
|
||||
// unmodified
|
||||
throw Exceptions.state();
|
||||
|
||||
@@ -25,8 +25,9 @@ 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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.filter.Filter;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||
import org.dromara.visor.common.security.LoginUser;
|
||||
|
||||
@@ -43,7 +44,7 @@ public class OperatorLogs implements ExtraFieldConst {
|
||||
|
||||
private static final String UN_SAVE_FLAG = "__un__save__";
|
||||
|
||||
private static Filter[] serializeFilters;
|
||||
private static SerializeFilter[] serializeFilters;
|
||||
|
||||
/**
|
||||
* 拓展信息
|
||||
@@ -97,7 +98,7 @@ public class OperatorLogs implements ExtraFieldConst {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
if (obj instanceof com.alibaba.fastjson2.JSONObject || obj instanceof com.alibaba.fastjson2.JSONObject) {
|
||||
if (obj instanceof 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);
|
||||
@@ -203,7 +204,7 @@ public class OperatorLogs implements ExtraFieldConst {
|
||||
.replaceAll("<br/>", "\n");
|
||||
}
|
||||
|
||||
public static void setSerializeFilters(Filter[] serializeFilters) {
|
||||
public static void setSerializeFilters(SerializeFilter[] 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.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson.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.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson.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.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson.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.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson.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.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.filter.ValueFilter;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.serializer.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 apply(Object object, String name, Object value) {
|
||||
public Object process(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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.thread.ThreadPoolMdcTaskExecutor;
|
||||
import org.dromara.visor.framework.executor.configuration.config.ExecutorConfig;
|
||||
|
||||
@@ -30,9 +30,7 @@ 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;
|
||||
@@ -68,7 +66,6 @@ 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);
|
||||
@@ -82,7 +79,6 @@ 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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.filter.Filter;
|
||||
import com.alibaba.fastjson2.filter.ValueFilter;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
||||
import com.alibaba.fastjson.serializer.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 Filter[] serializeFilters;
|
||||
protected SerializeFilter[] serializeFilters;
|
||||
|
||||
/**
|
||||
* 脱敏配置
|
||||
@@ -91,7 +91,7 @@ public abstract class AbstractLogPrinterInterceptor implements LogPrinterInterce
|
||||
@Override
|
||||
public void init() {
|
||||
// 参数过滤器
|
||||
this.serializeFilters = new Filter[]{
|
||||
this.serializeFilters = new SerializeFilter[]{
|
||||
// 忽略字段过滤器
|
||||
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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
@@ -25,19 +25,18 @@ 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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.RedisUtils;
|
||||
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.barrier.CacheBarriers;
|
||||
#end
|
||||
#foreach($pkg in ${customModuleFilePackages})
|
||||
import ${pkg}.*;
|
||||
#end
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
@@ -60,222 +59,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)
|
||||
// 删除缓存
|
||||
RedisUtils.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return id;
|
||||
}
|
||||
@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)
|
||||
// 删除缓存
|
||||
RedisUtils.delete(${type}CacheKeyDefine.${typeConst});
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
@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)
|
||||
// 删除缓存
|
||||
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)
|
||||
// 删除缓存
|
||||
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 ${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}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);
|
||||
}
|
||||
@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)
|
||||
// 删除缓存
|
||||
RedisUtils.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)
|
||||
// 删除缓存
|
||||
RedisMaps.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})
|
||||
#if("$!field.propertyName" != "id")
|
||||
.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);
|
||||
}
|
||||
|
||||
@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
|
||||
#if("$!field.propertyName" != "id")
|
||||
.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);
|
||||
}
|
||||
|
||||
@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}, searchValue)#if($foreach.hasNext).or()#end
|
||||
#end
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@
|
||||
package ${currentPackage};
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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,6 +169,7 @@
|
||||
Message.success('删除成功');
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -199,6 +200,7 @@
|
||||
pagination.total = data.total;
|
||||
pagination.current = request.page;
|
||||
pagination.pageSize = request.limit;
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@
|
||||
<a-table row-key="id"
|
||||
#end
|
||||
ref="tableRef"
|
||||
class="table-resize"
|
||||
:loading="loading"
|
||||
:columns="tableColumns"
|
||||
#if($vue.enableRowSelection)
|
||||
@@ -100,7 +99,6 @@
|
||||
: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})
|
||||
@@ -202,6 +200,7 @@
|
||||
selectedKeys.value = [];
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -219,6 +218,7 @@
|
||||
Message.success('删除成功');
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -244,6 +244,7 @@
|
||||
#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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -24,7 +24,6 @@ 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;
|
||||
@@ -61,7 +60,6 @@ public class BaseUnitTest {
|
||||
@Import({
|
||||
// spring
|
||||
SpringConfiguration.class,
|
||||
CommonConfiguration.class,
|
||||
// mock
|
||||
OrionMockBeanTestConfiguration.class,
|
||||
OrionMockRedisTestConfiguration.class,
|
||||
|
||||
@@ -29,7 +29,6 @@ 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;
|
||||
@@ -72,7 +71,7 @@ import java.util.List;
|
||||
@DependsOn({"executorContext"})
|
||||
@AutoConfiguration
|
||||
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_WEB)
|
||||
@EnableConfigurationProperties({ExposeApiConfig.class, OrionApiConfig.class})
|
||||
@EnableConfigurationProperties(ExposeApiConfig.class)
|
||||
public class OrionWebAutoConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Value("${orion.prefix}")
|
||||
|
||||
@@ -36,11 +36,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties("orion.api.expose")
|
||||
public class ExposeApiConfig {
|
||||
|
||||
/**
|
||||
* 对外服务地址
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 对外服务请求头
|
||||
*/
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* 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,21 +33,6 @@
|
||||
"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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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:2}
|
||||
data-version: ${REDIS_DATA_VERSION:1}
|
||||
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:2}
|
||||
data-version: ${REDIS_DATA_VERSION:1}
|
||||
redisson:
|
||||
threads: 4
|
||||
netty-threads: 4
|
||||
@@ -74,13 +74,6 @@ 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,12 +175,6 @@ orion:
|
||||
prefix: ${orion.prefix}/api
|
||||
# 是否允许跨域
|
||||
cors: true
|
||||
# 服务端主机地址
|
||||
host: 0.0.0.0
|
||||
# 服务端接口地址 默认自动生成
|
||||
url:
|
||||
# 获取 IP 的请求头
|
||||
ip-headers: X-Forwarded-For,X-Real-IP
|
||||
# 对外服务
|
||||
expose:
|
||||
# 暴露接口请求头
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
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.6";
|
||||
private static final String TARGET_VERSION = "2.5.2";
|
||||
|
||||
private static final String REPLACE_VERSION = "2.5.7";
|
||||
private static final String REPLACE_VERSION = "2.5.3";
|
||||
|
||||
private static final String PATH = new File("").getAbsolutePath();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.enums;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.module.asset.entity.dto.host.HostRdpConfigDTO;
|
||||
|
||||
@@ -45,7 +45,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主机探针端点 api
|
||||
@@ -91,8 +90,9 @@ public class HostAgentController {
|
||||
@PostMapping("/install")
|
||||
@Operation(summary = "安装主机探针")
|
||||
@PreAuthorize("@ss.hasPermission('asset:host:install-agent')")
|
||||
public Map<String, Long> installAgent(@Validated @RequestBody HostAgentInstallRequest request) {
|
||||
return hostAgentService.installAgent(request);
|
||||
public Boolean installAgent(@Validated @RequestBody HostAgentInstallRequest request) {
|
||||
hostAgentService.installAgent(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -29,7 +29,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 主机探针状态 视图响应对象
|
||||
@@ -62,7 +61,4 @@ public class HostAgentStatusVO implements Serializable {
|
||||
@Schema(description = "探针在线状态")
|
||||
private Integer agentOnlineStatus;
|
||||
|
||||
@Schema(description = "探针切换在线状态时间")
|
||||
private Date agentOnlineChangeTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
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;
|
||||
@@ -51,7 +50,7 @@ public class LinuxAgentInstaller extends AbstractAgentInstaller {
|
||||
sftpExecutor.write(agentHomePath + FileConst.CONFIG_YAML, this.replaceContent(params.getConfigFilePath()));
|
||||
log.info("写入配置文件成功");
|
||||
// 写入启动脚本
|
||||
sftpExecutor.write(agentHomePath + startScriptName, Strings.replaceCRLF(this.replaceContent(params.getStartScriptPath())));
|
||||
sftpExecutor.write(agentHomePath + startScriptName, this.replaceContent(params.getStartScriptPath()));
|
||||
log.info("写入启动脚本成功");
|
||||
// 上传探针文件
|
||||
sftpExecutor.uploadFile(agentHomePath + uploadAgentName, params.getAgentFilePath());
|
||||
|
||||
@@ -51,16 +51,6 @@ public class HostSpecExtraModel implements GenericsDataModel {
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 制造商
|
||||
*/
|
||||
private String vendor;
|
||||
|
||||
/**
|
||||
* 型号
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 系统名称
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.dromara.visor.module.asset.entity.vo.HostAgentStatusVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主机探针 服务类
|
||||
@@ -50,9 +49,8 @@ public interface HostAgentService {
|
||||
* 安装探针
|
||||
*
|
||||
* @param request request
|
||||
* @return agentKey:installId
|
||||
*/
|
||||
Map<String, Long> installAgent(HostAgentInstallRequest request);
|
||||
void installAgent(HostAgentInstallRequest request);
|
||||
|
||||
/**
|
||||
* 上传探针发布包
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.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.AGENT_KEY_NOT_FOUND, agentKey);
|
||||
Assert.notNull(hostId, ErrorMessage.HOST_ABSENT);
|
||||
// 查询主机规格信息
|
||||
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.AGENT_KEY_NOT_FOUND, agentKey);
|
||||
Assert.notNull(hostId, ErrorMessage.HOST_ABSENT);
|
||||
// 修改缓存
|
||||
ONLINE_STATUS_CACHE.put(agentKey, AgentOnlineStatusEnum.OFFLINE.getValue());
|
||||
HEARTBEAT_RECV_CACHE.put(agentKey, 0L);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
*/
|
||||
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;
|
||||
@@ -32,6 +31,7 @@ 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,8 +41,6 @@ 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;
|
||||
@@ -55,6 +53,7 @@ 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;
|
||||
|
||||
@@ -78,11 +77,8 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
|
||||
private String localVersion;
|
||||
|
||||
@Resource
|
||||
private OrionApiConfig orionApiConfig;
|
||||
|
||||
@Resource
|
||||
private ExposeApiConfig exposeApiConfig;
|
||||
@Value("${orion.api.expose.token}")
|
||||
private String exposeToken;
|
||||
|
||||
@Resource
|
||||
private HostDAO hostDAO;
|
||||
@@ -123,8 +119,7 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
.select(HostDO::getId,
|
||||
HostDO::getAgentVersion,
|
||||
HostDO::getAgentInstallStatus,
|
||||
HostDO::getAgentOnlineStatus,
|
||||
HostDO::getAgentOnlineChangeTime)
|
||||
HostDO::getAgentOnlineStatus)
|
||||
.in(HostDO::getId, idList)
|
||||
.then()
|
||||
.stream()
|
||||
@@ -134,7 +129,7 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Long> installAgent(HostAgentInstallRequest request) {
|
||||
public void installAgent(HostAgentInstallRequest request) {
|
||||
// 查询主机信息
|
||||
List<Long> idList = request.getIdList();
|
||||
List<HostDO> hosts = hostDAO.selectBatchIds(idList);
|
||||
@@ -182,12 +177,6 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
// 执行任务
|
||||
AgentInstaller.start(params);
|
||||
}
|
||||
|
||||
// 返回
|
||||
return agentLogs.stream()
|
||||
.collect(Collectors.toMap(HostAgentLogDO::getAgentKey,
|
||||
HostAgentLogDO::getId,
|
||||
Functions.right()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -312,8 +301,8 @@ public class HostAgentServiceImpl implements HostAgentService {
|
||||
*/
|
||||
private Map<String, String> getReplaceVars() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("SERVER_URL", orionApiConfig.getUrl());
|
||||
map.put("SERVER_TOKEN", exposeApiConfig.getToken());
|
||||
map.put("SERVER_HOST", IPs.IP);
|
||||
map.put("SERVER_TOKEN", exposeToken);
|
||||
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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||
|
||||
@@ -22,13 +22,10 @@
|
||||
*/
|
||||
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 cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.handler.data.model.GenericsDataModel;
|
||||
@@ -47,7 +44,6 @@ 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;
|
||||
@@ -59,7 +55,6 @@ import java.util.stream.Collectors;
|
||||
* @version 1.0.0
|
||||
* @since 2023/12/20 12:11
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class HostExtraServiceImpl implements HostExtraService {
|
||||
|
||||
@@ -161,57 +156,40 @@ public class HostExtraServiceImpl implements HostExtraService {
|
||||
|
||||
@Override
|
||||
public void syncHostSpec(String key, String taskId, JSONObject spec) {
|
||||
// 查询主机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;
|
||||
}
|
||||
}
|
||||
// 不存在则覆盖
|
||||
if (!present && v != null) {
|
||||
beforeSpecValue.put(k, v);
|
||||
}
|
||||
});
|
||||
newSpec = beforeSpecValue.toJSONString();
|
||||
}
|
||||
// 检查是否能反解析 防止格式错误导致其他地方报错
|
||||
try {
|
||||
JSON.parseObject(newSpec, HostSpecExtraModel.class);
|
||||
// 查询主机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);
|
||||
}
|
||||
});
|
||||
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) {
|
||||
log.error("HostExtraService-setHostSpec error: {}, spec: {}", e.getMessage(), newSpec, e);
|
||||
throw Exceptions.app(ErrorMessage.SPEC_FORMAT_INCORRECT, e);
|
||||
// 回调失败
|
||||
throw 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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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);
|
||||
// 删除缓存
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_IDENTITY);
|
||||
RedisMaps.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);
|
||||
// 删除缓存
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_IDENTITY);
|
||||
RedisMaps.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.NAME_PRESENT);
|
||||
Assert.isFalse(present, ErrorMessage.DATA_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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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();
|
||||
// 删除缓存
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_KEY);
|
||||
RedisMaps.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())) {
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_KEY);
|
||||
RedisMaps.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.NAME_PRESENT);
|
||||
Assert.isFalse(present, ErrorMessage.DATA_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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -39,7 +39,6 @@ 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;
|
||||
@@ -377,7 +376,7 @@ public class HostServiceImpl implements HostService {
|
||||
|
||||
@Override
|
||||
public void clearCache() {
|
||||
RedisUtils.scanKeysDelete(HostCacheKeyDefine.HOST_INFO.format("*"));
|
||||
RedisMaps.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> execDetailEnabled;
|
||||
private final ConfigRef<Boolean> execDetailLog;
|
||||
|
||||
public AppLogConfig(ConfigStore configStore) {
|
||||
this.trackerLoadLines = configStore.int32(ConfigKeys.LOG_TRACKER_LOAD_LINES);
|
||||
this.trackerLoadInterval = configStore.int32(ConfigKeys.LOG_TRACKER_LOAD_INTERVAL);
|
||||
this.execDetailEnabled = configStore.bool(ConfigKeys.LOG_EXEC_DETAIL_ENABLED);
|
||||
this.execDetailLog = configStore.bool(ConfigKeys.LOG_EXEC_DETAIL_LOG);
|
||||
}
|
||||
|
||||
public Integer getTrackerLoadLines() {
|
||||
@@ -66,8 +66,8 @@ public class AppLogConfig {
|
||||
return trackerLoadInterval.value;
|
||||
}
|
||||
|
||||
public Boolean getExecDetailEnabled() {
|
||||
return execDetailEnabled.value;
|
||||
public Boolean getExecDetailLog() {
|
||||
return execDetailLog.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.getExecDetailEnabled())) {
|
||||
if (Booleans.isTrue(appLogConfig.getExecDetailLog())) {
|
||||
// 详细日志
|
||||
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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.NAME_PRESENT);
|
||||
Assert.isFalse(present, ErrorMessage.DATA_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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.NAME_PRESENT);
|
||||
Assert.isFalse(present, ErrorMessage.DATA_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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,7 +25,6 @@ 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;
|
||||
@@ -58,11 +57,7 @@ public class AuthenticationApiImpl implements AuthenticationApi {
|
||||
result.setUsername(user.getUsername());
|
||||
result.setNickname(user.getNickname());
|
||||
// 检查用户密码
|
||||
boolean passRight = authenticationService.checkUserPassword(user, password);
|
||||
if (!passRight && addFailedCount) {
|
||||
// 发送站内信
|
||||
authenticationService.addLoginFailedCount(user.getUsername(), Requests.getIdentity());
|
||||
}
|
||||
boolean passRight = authenticationService.checkUserPassword(user, password, addFailedCount);
|
||||
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.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.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.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.Assert;
|
||||
|
||||
@@ -63,8 +63,9 @@ public class AuthenticationController {
|
||||
@PermitAll
|
||||
@Operation(summary = "登录")
|
||||
@PostMapping("/login")
|
||||
public UserLoginVO login(@Validated @RequestBody UserLoginRequest request) {
|
||||
return authenticationService.login(request);
|
||||
public UserLoginVO login(@Validated @RequestBody UserLoginRequest request,
|
||||
HttpServletRequest servletRequest) {
|
||||
return authenticationService.login(request, servletRequest);
|
||||
}
|
||||
|
||||
@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.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.dromara.visor.module.infra.define.operator.SystemUserOperatorType;
|
||||
import org.dromara.visor.module.infra.entity.request.user.*;
|
||||
import org.dromara.visor.module.infra.entity.vo.LoginHistoryVO;
|
||||
import org.dromara.visor.module.infra.entity.vo.SystemUserVO;
|
||||
import org.dromara.visor.module.infra.entity.vo.UserLockedVO;
|
||||
import org.dromara.visor.module.infra.entity.vo.UserSessionVO;
|
||||
import org.dromara.visor.module.infra.service.OperatorLogService;
|
||||
import org.dromara.visor.module.infra.service.SystemUserManagementService;
|
||||
@@ -191,33 +190,7 @@ public class SystemUserController {
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/locked/list")
|
||||
@Operation(summary = "获取锁定的用户列表")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:query-lock')")
|
||||
public List<UserLockedVO> getLockedUserList() {
|
||||
return systemUserManagementService.getLockedUserList();
|
||||
}
|
||||
|
||||
@OperatorLog(SystemUserOperatorType.UNLOCK)
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PutMapping("/locked/unlock")
|
||||
@Operation(summary = "解锁用户")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:management:unlock')")
|
||||
public Boolean unlockLockedUser(@RequestBody UserUnlockRequest request) {
|
||||
systemUserManagementService.unlockLockedUser(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/session/users/list")
|
||||
@Operation(summary = "获取全部用户会话列表")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:query-session')")
|
||||
public List<UserSessionVO> getUsersSessionList() {
|
||||
return systemUserManagementService.getUsersSessionList();
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/session/user/list")
|
||||
@GetMapping("/session/list")
|
||||
@Operation(summary = "获取用户会话列表")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:query-session')")
|
||||
public List<UserSessionVO> getUserSessionList(@RequestParam("id") Long id) {
|
||||
|
||||
@@ -22,24 +22,16 @@
|
||||
*/
|
||||
package org.dromara.visor.module.infra.controller;
|
||||
|
||||
import cn.orionsec.kit.lang.define.wrapper.DataGrid;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
import org.dromara.visor.framework.web.core.annotation.RestWrapper;
|
||||
import org.dromara.visor.module.infra.define.operator.TagOperatorType;
|
||||
import org.dromara.visor.module.infra.entity.request.tag.TagCreateRequest;
|
||||
import org.dromara.visor.module.infra.entity.request.tag.TagQueryRequest;
|
||||
import org.dromara.visor.module.infra.entity.request.tag.TagUpdateRequest;
|
||||
import org.dromara.visor.module.infra.entity.vo.TagVO;
|
||||
import org.dromara.visor.module.infra.service.TagService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -47,13 +39,13 @@ import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据标签 api
|
||||
* 标签枚举 api
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-9-5 11:58
|
||||
*/
|
||||
@Tag(name = "infra - 数据标签服务")
|
||||
@Tag(name = "infra - 标签枚举服务")
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RestWrapper
|
||||
@@ -64,32 +56,12 @@ public class TagController {
|
||||
@Resource
|
||||
private TagService tagService;
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(TagOperatorType.CREATE)
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建标签")
|
||||
@PreAuthorize("@ss.hasPermission('infra:tag:create')")
|
||||
public Long createTag(@Validated @RequestBody TagCreateRequest request) {
|
||||
return tagService.createTag(request);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(TagOperatorType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改标签")
|
||||
@PreAuthorize("@ss.hasPermission('infra:tag:update')")
|
||||
public Integer updateTag(@Validated @RequestBody TagUpdateRequest request) {
|
||||
return tagService.updateTag(request);
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PostMapping("/query")
|
||||
@Operation(summary = "分页查询标签")
|
||||
@PreAuthorize("@ss.hasPermission('infra:tag:query')")
|
||||
public DataGrid<TagVO> getTagPage(@Validated(Page.class) @RequestBody TagQueryRequest request) {
|
||||
return tagService.getTagPage(request);
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "查询标签")
|
||||
@@ -98,14 +70,12 @@ public class TagController {
|
||||
return tagService.getTagList(type);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(TagOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "通过 id 删除标签")
|
||||
@Parameter(name = "id", description = "id", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:tag:delete')")
|
||||
public Integer deleteTag(@RequestParam("id") Long id) {
|
||||
return tagService.deleteTagById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,12 @@
|
||||
*/
|
||||
package org.dromara.visor.module.infra.convert;
|
||||
|
||||
import org.dromara.visor.common.mapstruct.DateConversion;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||
import org.dromara.visor.module.infra.entity.domain.OperatorLogDO;
|
||||
import org.dromara.visor.module.infra.entity.request.operator.OperatorLogQueryRequest;
|
||||
import org.dromara.visor.module.infra.entity.vo.LoginHistoryVO;
|
||||
import org.dromara.visor.module.infra.entity.vo.OperatorLogVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
@@ -39,12 +37,11 @@ import org.mapstruct.factory.Mappers;
|
||||
* @version 1.0.0
|
||||
* @since 2023-10-10 17:08
|
||||
*/
|
||||
@Mapper(uses = DateConversion.class)
|
||||
@Mapper
|
||||
public interface OperatorLogConvert {
|
||||
|
||||
OperatorLogConvert MAPPER = Mappers.getMapper(OperatorLogConvert.class);
|
||||
|
||||
@Mapping(source = "timestamp", target = "createTime")
|
||||
OperatorLogDO to(OperatorLogModel model);
|
||||
|
||||
OperatorLogDO to(OperatorLogQueryRequest request);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user