⚡ 拆分模块.
This commit is contained in:
@@ -17,8 +17,6 @@ package com.orion.visor.framework.common.utils;
|
||||
|
||||
import com.orion.ext.location.Region;
|
||||
import com.orion.ext.location.region.LocationRegions;
|
||||
import com.orion.lang.constant.StandardHttpHeader;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.web.servlet.web.Servlets;
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ orion:
|
||||
# 下面引用了 需要注意
|
||||
field:
|
||||
ignore:
|
||||
- password,beforePassword,newPassword,useNewPassword,publicKey,privateKey,token
|
||||
- password,beforePassword,newPassword,useNewPassword,publicKey,privateKey,privateKeyPassword
|
||||
- metrics
|
||||
desensitize:
|
||||
storage:
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 终端连接日志 api
|
||||
@@ -83,7 +84,7 @@ public class TerminalConnectLogController {
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PostMapping("/latest-connect")
|
||||
@Operation(summary = "查询用户最近连接的主机")
|
||||
public List<Long> getLatestConnectHostId(@RequestBody TerminalConnectLogQueryRequest request) {
|
||||
public Set<Long> getLatestConnectHostId(@RequestBody TerminalConnectLogQueryRequest request) {
|
||||
return terminalConnectLogService.getLatestConnectHostId(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ import com.orion.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.visor.framework.web.core.annotation.IgnoreWrapper;
|
||||
import com.orion.visor.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostSftpLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.HostSftpLogVO;
|
||||
import com.orion.visor.module.asset.service.HostSftpService;
|
||||
import com.orion.visor.module.asset.entity.request.host.TerminalSftpLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.TerminalSftpLogVO;
|
||||
import com.orion.visor.module.asset.service.TerminalSftpService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -53,27 +53,27 @@ import java.util.List;
|
||||
@Validated
|
||||
@RestWrapper
|
||||
@RestController
|
||||
@RequestMapping("/asset/host-sftp")
|
||||
public class HostSftpLogController {
|
||||
@RequestMapping("/asset/terminal-sftp")
|
||||
public class TerminalSftpController {
|
||||
|
||||
@Resource
|
||||
private HostSftpService hostSftpService;
|
||||
private TerminalSftpService terminalSftpService;
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PostMapping("/query-log")
|
||||
@Operation(summary = "分页查询 SFTP 操作日志")
|
||||
@PreAuthorize("@ss.hasAnyPermission('infra:operator-log:query', 'asset:host-sftp-log:management:query')")
|
||||
public DataGrid<HostSftpLogVO> getHostSftpLogPage(@Validated(Page.class) @RequestBody HostSftpLogQueryRequest request) {
|
||||
return hostSftpService.getHostSftpLogPage(request);
|
||||
@PreAuthorize("@ss.hasAnyPermission('infra:operator-log:query', 'asset:terminal-sftp-log:management:query')")
|
||||
public DataGrid<TerminalSftpLogVO> getTerminalSftpLogPage(@Validated(Page.class) @RequestBody TerminalSftpLogQueryRequest request) {
|
||||
return terminalSftpService.getTerminalSftpLogPage(request);
|
||||
}
|
||||
|
||||
@OperatorLog(TerminalOperatorType.DELETE_SFTP_LOG)
|
||||
@DeleteMapping("/delete-log")
|
||||
@Operation(summary = "删除 SFTP 操作日志")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasAnyPermission('infra:operator-log:delete', 'asset:host-sftp-log:management:delete')")
|
||||
public Integer deleteHostSftpLog(@RequestParam("idList") List<Long> idList) {
|
||||
return hostSftpService.deleteHostSftpLog(idList);
|
||||
@PreAuthorize("@ss.hasAnyPermission('infra:operator-log:delete', 'asset:terminal-sftp-log:management:delete')")
|
||||
public Integer deleteTerminalSftpLog(@RequestParam("idList") List<Long> idList) {
|
||||
return terminalSftpService.deleteTerminalSftpLog(idList);
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@@ -81,7 +81,7 @@ public class HostSftpLogController {
|
||||
@Operation(summary = "获取文件内容")
|
||||
@Parameter(name = "token", description = "token", required = true)
|
||||
public void getFileContentByToken(@RequestParam("token") String token, HttpServletResponse response) throws Exception {
|
||||
hostSftpService.getFileContentByToken(token, response);
|
||||
terminalSftpService.getFileContentByToken(token, response);
|
||||
}
|
||||
|
||||
@PostMapping("/set-content")
|
||||
@@ -90,7 +90,7 @@ public class HostSftpLogController {
|
||||
@Parameter(name = "file", description = "file", required = true)
|
||||
public Boolean setFileContentByToken(@RequestParam("token") String token,
|
||||
@RequestParam("file") MultipartFile file) throws Exception {
|
||||
hostSftpService.setFileContentByToken(token, file);
|
||||
terminalSftpService.setFileContentByToken(token, file);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class HostSftpLogController {
|
||||
public StreamingResponseBody downloadWithTransferToken(@RequestParam("channelId") String channelId,
|
||||
@RequestParam("transferToken") String transferToken,
|
||||
HttpServletResponse response) {
|
||||
return hostSftpService.downloadWithTransferToken(channelId, transferToken, response);
|
||||
return terminalSftpService.downloadWithTransferToken(channelId, transferToken, response);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.orion.visor.module.asset.convert;
|
||||
|
||||
import com.orion.visor.module.asset.entity.vo.HostSftpLogVO;
|
||||
import com.orion.visor.module.asset.entity.vo.TerminalSftpLogVO;
|
||||
import com.orion.visor.module.infra.entity.dto.operator.OperatorLogDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
@@ -29,11 +29,11 @@ import org.mapstruct.factory.Mappers;
|
||||
* @since 2023-12-26 22:09
|
||||
*/
|
||||
@Mapper
|
||||
public interface HostSftpLogConvert {
|
||||
public interface TerminalSftpLogConvert {
|
||||
|
||||
HostSftpLogConvert MAPPER = Mappers.getMapper(HostSftpLogConvert.class);
|
||||
TerminalSftpLogConvert MAPPER = Mappers.getMapper(TerminalSftpLogConvert.class);
|
||||
|
||||
@Mapping(target = "extra", ignore = true)
|
||||
HostSftpLogVO to(OperatorLogDTO request);
|
||||
TerminalSftpLogVO to(OperatorLogDTO request);
|
||||
|
||||
}
|
||||
@@ -35,8 +35,8 @@ import java.util.Date;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "HostSftpLogQueryRequest", description = "SFTP 操作日志 查询请求对象")
|
||||
public class HostSftpLogQueryRequest extends PageRequest {
|
||||
@Schema(name = "TerminalSftpLogQueryRequest", description = "SFTP 操作日志 查询请求对象")
|
||||
public class TerminalSftpLogQueryRequest extends PageRequest {
|
||||
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
@@ -48,7 +48,4 @@ public class AuthorizedHostWrapperVO {
|
||||
@Schema(description = "分组树节点映射 groupId:hostIdList")
|
||||
private Map<String, Set<Long>> treeNodes;
|
||||
|
||||
@Schema(description = "最近访问的主机")
|
||||
private Set<Long> latestHosts;
|
||||
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ import java.util.Map;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "HostSftpLogVO", description = "SFTP 操作日志 实体对象")
|
||||
public class HostSftpLogVO implements Serializable {
|
||||
@Schema(name = "TerminalSftpLogVO", description = "SFTP 操作日志 实体对象")
|
||||
public class TerminalSftpLogVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -28,8 +28,8 @@ import com.orion.visor.framework.common.enums.BooleanBit;
|
||||
import com.orion.visor.framework.websocket.core.utils.WebSockets;
|
||||
import com.orion.visor.module.asset.dao.HostDAO;
|
||||
import com.orion.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import com.orion.visor.module.asset.entity.domain.TerminalConnectLogDO;
|
||||
import com.orion.visor.module.asset.entity.domain.HostDO;
|
||||
import com.orion.visor.module.asset.entity.domain.TerminalConnectLogDO;
|
||||
import com.orion.visor.module.asset.entity.dto.TerminalConnectDTO;
|
||||
import com.orion.visor.module.asset.entity.request.host.TerminalConnectLogCreateRequest;
|
||||
import com.orion.visor.module.asset.enums.TerminalConnectStatusEnum;
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.utils.io.Streams;
|
||||
import com.orion.visor.module.asset.handler.host.transfer.handler.ITransferHandler;
|
||||
import com.orion.visor.module.asset.handler.host.transfer.handler.TransferHandler;
|
||||
import com.orion.visor.module.asset.handler.host.transfer.manager.HostTransferManager;
|
||||
import com.orion.visor.module.asset.handler.host.transfer.manager.TerminalTransferManager;
|
||||
import com.orion.visor.module.asset.handler.host.transfer.model.TransferOperatorRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -43,19 +43,19 @@ import javax.annotation.Resource;
|
||||
public class TransferMessageDispatcher extends AbstractWebSocketHandler {
|
||||
|
||||
@Resource
|
||||
private HostTransferManager hostTransferManager;
|
||||
private TerminalTransferManager terminalTransferManager;
|
||||
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session) {
|
||||
log.info("TransferMessageHandler-afterConnectionEstablished id: {}", session.getId());
|
||||
// 添加处理器
|
||||
hostTransferManager.putHandler(session.getId(), new TransferHandler(session));
|
||||
terminalTransferManager.putHandler(session.getId(), new TransferHandler(session));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTextMessage(WebSocketSession session, TextMessage message) {
|
||||
// 获取处理器
|
||||
ITransferHandler handler = hostTransferManager.getHandler(session.getId());
|
||||
ITransferHandler handler = terminalTransferManager.getHandler(session.getId());
|
||||
// 处理消息
|
||||
handler.handleMessage(JSON.parseObject(message.getPayload(), TransferOperatorRequest.class));
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class TransferMessageDispatcher extends AbstractWebSocketHandler {
|
||||
@Override
|
||||
protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) {
|
||||
// 获取处理器
|
||||
ITransferHandler handler = hostTransferManager.getHandler(session.getId());
|
||||
ITransferHandler handler = terminalTransferManager.getHandler(session.getId());
|
||||
// 添加数据
|
||||
handler.handleMessage(message.getPayload().array());
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class TransferMessageDispatcher extends AbstractWebSocketHandler {
|
||||
String id = session.getId();
|
||||
log.info("TransferMessageHandler-afterConnectionClosed id: {}, code: {}, reason: {}", id, status.getCode(), status.getReason());
|
||||
// 关闭会话
|
||||
Streams.close(hostTransferManager.removeHandler(id));
|
||||
Streams.close(terminalTransferManager.removeHandler(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 主机传输管理器
|
||||
* 终端传输管理器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/6/4 17:58
|
||||
*/
|
||||
@Component
|
||||
public class HostTransferManager {
|
||||
public class TerminalTransferManager {
|
||||
|
||||
private final ConcurrentHashMap<String, ITransferHandler> handlers = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.orion.visor.module.asset.enums.TerminalConnectTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 终端连接日志 服务类
|
||||
@@ -79,16 +79,7 @@ public interface TerminalConnectLogService {
|
||||
* @param request request
|
||||
* @return hostId
|
||||
*/
|
||||
List<Long> getLatestConnectHostId(TerminalConnectLogQueryRequest request);
|
||||
|
||||
/**
|
||||
* 查询用户最近连接的主机
|
||||
*
|
||||
* @param type type
|
||||
* @param userId userId
|
||||
* @return hostId
|
||||
*/
|
||||
Future<List<Long>> getLatestConnectHostIdAsync(TerminalConnectTypeEnum type, Long userId);
|
||||
Set<Long> getLatestConnectHostId(TerminalConnectLogQueryRequest request);
|
||||
|
||||
/**
|
||||
* 删除终端连接日志
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
package com.orion.visor.module.asset.service;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostSftpLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.HostSftpLogVO;
|
||||
import com.orion.visor.module.asset.entity.request.host.TerminalSftpLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.TerminalSftpLogVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-26 22:09
|
||||
*/
|
||||
public interface HostSftpService {
|
||||
public interface TerminalSftpService {
|
||||
|
||||
/**
|
||||
* 分页查询 SFTP 操作日志
|
||||
@@ -40,7 +40,7 @@ public interface HostSftpService {
|
||||
* @param request request
|
||||
* @return rows
|
||||
*/
|
||||
DataGrid<HostSftpLogVO> getHostSftpLogPage(HostSftpLogQueryRequest request);
|
||||
DataGrid<TerminalSftpLogVO> getTerminalSftpLogPage(TerminalSftpLogQueryRequest request);
|
||||
|
||||
/**
|
||||
* 删除 SFTP 操作日志
|
||||
@@ -48,7 +48,7 @@ public interface HostSftpService {
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteHostSftpLog(List<Long> idList);
|
||||
Integer deleteTerminalSftpLog(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 设置文件内容
|
||||
@@ -18,7 +18,6 @@ package com.orion.visor.module.asset.service.impl;
|
||||
import com.orion.lang.function.Functions;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.lang.utils.collect.Sets;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.utils.TreeUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
@@ -26,12 +25,14 @@ import com.orion.visor.module.asset.convert.HostGroupConvert;
|
||||
import com.orion.visor.module.asset.dao.HostDAO;
|
||||
import com.orion.visor.module.asset.entity.request.asset.AssetAuthorizedDataQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.*;
|
||||
import com.orion.visor.module.asset.enums.TerminalConnectTypeEnum;
|
||||
import com.orion.visor.module.asset.enums.HostExtraItemEnum;
|
||||
import com.orion.visor.module.asset.enums.HostStatusEnum;
|
||||
import com.orion.visor.module.asset.enums.HostTypeEnum;
|
||||
import com.orion.visor.module.asset.handler.host.extra.model.HostLabelExtraModel;
|
||||
import com.orion.visor.module.asset.service.*;
|
||||
import com.orion.visor.module.asset.service.AssetAuthorizedDataService;
|
||||
import com.orion.visor.module.asset.service.HostIdentityService;
|
||||
import com.orion.visor.module.asset.service.HostKeyService;
|
||||
import com.orion.visor.module.asset.service.HostService;
|
||||
import com.orion.visor.module.infra.api.*;
|
||||
import com.orion.visor.module.infra.entity.dto.data.DataGroupDTO;
|
||||
import com.orion.visor.module.infra.entity.dto.tag.TagDTO;
|
||||
@@ -78,9 +79,6 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic
|
||||
@Resource
|
||||
private HostIdentityService hostIdentityService;
|
||||
|
||||
@Resource
|
||||
private TerminalConnectLogService terminalConnectLogService;
|
||||
|
||||
@Resource
|
||||
private FavoriteApi favoriteApi;
|
||||
|
||||
@@ -144,14 +142,11 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic
|
||||
.groupTree(Lists.empty())
|
||||
.treeNodes(Maps.empty())
|
||||
.hostList(Lists.empty())
|
||||
.latestHosts(Sets.empty())
|
||||
.build();
|
||||
}
|
||||
AuthorizedHostWrapperVO wrapper = new AuthorizedHostWrapperVO();
|
||||
// 查询我的收藏
|
||||
Future<List<Long>> favoriteResult = favoriteApi.getFavoriteRelIdListAsync(FavoriteTypeEnum.HOST, userId);
|
||||
// 查询最近连接的主机
|
||||
Future<List<Long>> latestConnectHostIdList = terminalConnectLogService.getLatestConnectHostIdAsync(TerminalConnectTypeEnum.of(type), userId);
|
||||
// 查询主机拓展信息
|
||||
Future<Map<Long, String>> labelExtraResult = dataExtraApi.getExtraItemValuesByCacheAsync(userId,
|
||||
DataExtraTypeEnum.HOST,
|
||||
@@ -172,8 +167,6 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic
|
||||
this.getAuthorizedHostExtra(wrapper.getHostList(),
|
||||
favoriteResult.get(),
|
||||
labelExtraResult.get());
|
||||
// 设置最近连接的主机
|
||||
wrapper.setLatestHosts(new LinkedHashSet<>(latestConnectHostIdList.get()));
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,15 +41,12 @@ import com.orion.visor.module.asset.handler.host.terminal.model.TerminalConfig;
|
||||
import com.orion.visor.module.asset.handler.host.terminal.session.ITerminalSession;
|
||||
import com.orion.visor.module.asset.service.TerminalConnectLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -175,15 +172,10 @@ public class TerminalConnectLogServiceImpl implements TerminalConnectLogService
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getLatestConnectHostId(TerminalConnectLogQueryRequest request) {
|
||||
return terminalConnectLogDAO.selectLatestConnectHostId(SecurityUtils.getLoginUserId(), request.getType(), request.getLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public Future<List<Long>> getLatestConnectHostIdAsync(TerminalConnectTypeEnum type, Long userId) {
|
||||
List<Long> hostIdList = terminalConnectLogDAO.selectLatestConnectHostId(userId, type.name(), Const.N_10);
|
||||
return CompletableFuture.completedFuture(hostIdList);
|
||||
public Set<Long> getLatestConnectHostId(TerminalConnectLogQueryRequest request) {
|
||||
// 查询最近连接的主机
|
||||
List<Long> hostIdList = terminalConnectLogDAO.selectLatestConnectHostId(SecurityUtils.getLoginUserId(), request.getType(), request.getLimit());
|
||||
return new LinkedHashSet<>(hostIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,19 +34,19 @@ import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.constant.ExtraFieldConst;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.visor.module.asset.convert.HostSftpLogConvert;
|
||||
import com.orion.visor.module.asset.convert.TerminalSftpLogConvert;
|
||||
import com.orion.visor.module.asset.define.cache.TerminalCacheKeyDefine;
|
||||
import com.orion.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import com.orion.visor.module.asset.entity.dto.TerminalConnectDTO;
|
||||
import com.orion.visor.module.asset.entity.dto.SftpGetContentCacheDTO;
|
||||
import com.orion.visor.module.asset.entity.dto.SftpSetContentCacheDTO;
|
||||
import com.orion.visor.module.asset.entity.request.host.HostSftpLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.HostSftpLogVO;
|
||||
import com.orion.visor.module.asset.entity.dto.TerminalConnectDTO;
|
||||
import com.orion.visor.module.asset.entity.request.host.TerminalSftpLogQueryRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.TerminalSftpLogVO;
|
||||
import com.orion.visor.module.asset.handler.host.jsch.SessionStores;
|
||||
import com.orion.visor.module.asset.handler.host.transfer.manager.HostTransferManager;
|
||||
import com.orion.visor.module.asset.handler.host.transfer.manager.TerminalTransferManager;
|
||||
import com.orion.visor.module.asset.handler.host.transfer.session.DownloadSession;
|
||||
import com.orion.visor.module.asset.service.HostSftpService;
|
||||
import com.orion.visor.module.asset.service.TerminalService;
|
||||
import com.orion.visor.module.asset.service.TerminalSftpService;
|
||||
import com.orion.visor.module.infra.api.OperatorLogApi;
|
||||
import com.orion.visor.module.infra.entity.dto.operator.OperatorLogQueryDTO;
|
||||
import com.orion.web.servlet.web.Servlets;
|
||||
@@ -72,26 +72,26 @@ import java.util.Optional;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class HostSftpServiceImpl implements HostSftpService {
|
||||
public class TerminalSftpServiceImpl implements TerminalSftpService {
|
||||
|
||||
@Resource
|
||||
private OperatorLogApi operatorLogApi;
|
||||
|
||||
@Resource
|
||||
private HostTransferManager hostTransferManager;
|
||||
|
||||
@Resource
|
||||
private TerminalService terminalService;
|
||||
|
||||
@Resource
|
||||
private TerminalTransferManager terminalTransferManager;
|
||||
|
||||
@Override
|
||||
public DataGrid<HostSftpLogVO> getHostSftpLogPage(HostSftpLogQueryRequest request) {
|
||||
public DataGrid<TerminalSftpLogVO> getTerminalSftpLogPage(TerminalSftpLogQueryRequest request) {
|
||||
// 查询
|
||||
OperatorLogQueryDTO query = this.buildQueryInfo(request);
|
||||
// 转换
|
||||
return operatorLogApi.getOperatorLogPage(query)
|
||||
.map(s -> {
|
||||
JSONObject extra = JSON.parseObject(s.getExtra());
|
||||
HostSftpLogVO vo = HostSftpLogConvert.MAPPER.to(s);
|
||||
TerminalSftpLogVO vo = TerminalSftpLogConvert.MAPPER.to(s);
|
||||
vo.setHostId(extra.getLong(ExtraFieldConst.HOST_ID));
|
||||
vo.setHostName(extra.getString(ExtraFieldConst.HOST_NAME));
|
||||
vo.setHostAddress(extra.getString(ExtraFieldConst.ADDRESS));
|
||||
@@ -105,10 +105,10 @@ public class HostSftpServiceImpl implements HostSftpService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteHostSftpLog(List<Long> idList) {
|
||||
log.info("HostSftpLogService.deleteSftpLog start {}", JSON.toJSONString(idList));
|
||||
public Integer deleteTerminalSftpLog(List<Long> idList) {
|
||||
log.info("TerminalSftpService.deleteSftpLog start {}", JSON.toJSONString(idList));
|
||||
Integer effect = operatorLogApi.deleteOperatorLog(idList);
|
||||
log.info("HostSftpLogService.deleteSftpLog finish {}", effect);
|
||||
log.info("TerminalSftpService.deleteSftpLog finish {}", effect);
|
||||
// 设置日志参数
|
||||
OperatorLogs.add(OperatorLogs.COUNT, effect);
|
||||
return effect;
|
||||
@@ -185,7 +185,7 @@ public class HostSftpServiceImpl implements HostSftpService {
|
||||
public StreamingResponseBody downloadWithTransferToken(String channelId, String transferToken, HttpServletResponse response) {
|
||||
// 获取会话
|
||||
DownloadSession session = (DownloadSession) Optional.ofNullable(channelId)
|
||||
.map(hostTransferManager::getHandler)
|
||||
.map(terminalTransferManager::getHandler)
|
||||
.map(s -> s.getSessionByToken(transferToken))
|
||||
.filter(s -> s instanceof DownloadSession)
|
||||
.orElse(null);
|
||||
@@ -206,7 +206,7 @@ public class HostSftpServiceImpl implements HostSftpService {
|
||||
* @param request request
|
||||
* @return query
|
||||
*/
|
||||
private OperatorLogQueryDTO buildQueryInfo(HostSftpLogQueryRequest request) {
|
||||
private OperatorLogQueryDTO buildQueryInfo(TerminalSftpLogQueryRequest request) {
|
||||
Long hostId = request.getHostId();
|
||||
String type = request.getType();
|
||||
// 构建参数
|
||||
@@ -36,8 +36,8 @@ import com.orion.visor.module.infra.entity.vo.SystemMenuVO;
|
||||
import com.orion.visor.module.infra.enums.MenuStatusEnum;
|
||||
import com.orion.visor.module.infra.enums.MenuTypeEnum;
|
||||
import com.orion.visor.module.infra.enums.MenuVisibleEnum;
|
||||
import com.orion.visor.module.infra.service.UserPermissionService;
|
||||
import com.orion.visor.module.infra.service.SystemMenuService;
|
||||
import com.orion.visor.module.infra.service.UserPermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.function.Functions;
|
||||
import com.orion.lang.utils.Booleans;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.visor.module.infra.convert.SystemMessageConvert;
|
||||
import com.orion.visor.module.infra.dao.SystemMessageDAO;
|
||||
|
||||
@@ -31,8 +31,8 @@ import com.orion.visor.module.infra.entity.domain.SystemRoleDO;
|
||||
import com.orion.visor.module.infra.entity.domain.SystemRoleMenuDO;
|
||||
import com.orion.visor.module.infra.entity.dto.SystemMenuCacheDTO;
|
||||
import com.orion.visor.module.infra.entity.request.menu.SystemRoleGrantMenuRequest;
|
||||
import com.orion.visor.module.infra.service.UserPermissionService;
|
||||
import com.orion.visor.module.infra.service.SystemRoleMenuService;
|
||||
import com.orion.visor.module.infra.service.UserPermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -35,9 +35,9 @@ import com.orion.visor.module.infra.entity.request.role.SystemRoleUpdateRequest;
|
||||
import com.orion.visor.module.infra.entity.vo.SystemRoleVO;
|
||||
import com.orion.visor.module.infra.enums.RoleStatusEnum;
|
||||
import com.orion.visor.module.infra.service.DataPermissionService;
|
||||
import com.orion.visor.module.infra.service.UserPermissionService;
|
||||
import com.orion.visor.module.infra.service.SystemRoleService;
|
||||
import com.orion.visor.module.infra.service.SystemUserRoleService;
|
||||
import com.orion.visor.module.infra.service.UserPermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PathBookmarkGroupQueryResponse } from '@/api/asset/path-bookmark-group';
|
||||
import type { PathBookmarkGroupQueryResponse } from './path-bookmark-group';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ import qs from 'query-string';
|
||||
/**
|
||||
* SFTP 操作日志 查询请求
|
||||
*/
|
||||
export interface HostSftpLogQueryRequest extends Pagination {
|
||||
export interface TerminalSftpLogQueryRequest extends Pagination {
|
||||
userId?: number;
|
||||
hostId?: number;
|
||||
type?: string;
|
||||
@@ -18,7 +18,7 @@ export interface HostSftpLogQueryRequest extends Pagination {
|
||||
/**
|
||||
* SFTP 操作日志 查询响应
|
||||
*/
|
||||
export interface HostSftpLogQueryResponse extends TableData {
|
||||
export interface TerminalSftpLogQueryResponse extends TableData {
|
||||
id: number;
|
||||
userId: number;
|
||||
username: number;
|
||||
@@ -32,13 +32,13 @@ export interface HostSftpLogQueryResponse extends TableData {
|
||||
type: string;
|
||||
result: string;
|
||||
startTime: number;
|
||||
extra: HostSftpLogExtra;
|
||||
extra: TerminalSftpLogExtra;
|
||||
}
|
||||
|
||||
/**
|
||||
* SFTP 操作日志 拓展对象
|
||||
*/
|
||||
export interface HostSftpLogExtra {
|
||||
export interface TerminalSftpLogExtra {
|
||||
mod: number;
|
||||
target: string;
|
||||
maxCount: number;
|
||||
@@ -47,15 +47,15 @@ export interface HostSftpLogExtra {
|
||||
/**
|
||||
* 分页查询 SFTP 操作日志
|
||||
*/
|
||||
export function getHostSftpLogPage(request: HostSftpLogQueryRequest) {
|
||||
return axios.post<DataGrid<HostSftpLogQueryResponse>>('/asset/host-sftp/query-log', request);
|
||||
export function getTerminalSftpLogPage(request: TerminalSftpLogQueryRequest) {
|
||||
return axios.post<DataGrid<TerminalSftpLogQueryResponse>>('/asset/terminal-sftp/query-log', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 SFTP 操作日志
|
||||
*/
|
||||
export function deleteHostSftpLog(idList: Array<number>) {
|
||||
return axios.delete('/asset/host-sftp/delete-log', {
|
||||
export function deleteTerminalSftpLog(idList: Array<number>) {
|
||||
return axios.delete('/asset/terminal-sftp/delete-log', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
@@ -67,7 +67,7 @@ export function deleteHostSftpLog(idList: Array<number>) {
|
||||
* 获取 SFTP 文件内容
|
||||
*/
|
||||
export function getSftpFileContent(token: string) {
|
||||
return axios.get<string>('/asset/host-sftp/get-content', {
|
||||
return axios.get<string>('/asset/terminal-sftp/get-content', {
|
||||
unwrap: true,
|
||||
params: { token },
|
||||
timeout: 60000
|
||||
@@ -81,7 +81,7 @@ export function setSftpFileContent(token: string, content: string) {
|
||||
const formData = new FormData();
|
||||
formData.append('token', token);
|
||||
formData.append('file', new File([content], Date.now() + '', { type: 'text/plain' }));
|
||||
return axios.post<boolean>('/asset/host-sftp/set-content', formData, {
|
||||
return axios.post<boolean>('/asset/terminal-sftp/set-content', formData, {
|
||||
timeout: 60000,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
@@ -93,5 +93,5 @@ export function setSftpFileContent(token: string, content: string) {
|
||||
* 下载文件
|
||||
*/
|
||||
export function getDownloadTransferUrl(channelId: string, transferToken: string) {
|
||||
return `${httpBaseUrl}/asset/host-sftp/download?channelId=${channelId}&transferToken=${transferToken}`;
|
||||
return `${httpBaseUrl}/asset/terminal-sftp/download?channelId=${channelId}&transferToken=${transferToken}`;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import type { TerminalTheme, TerminalThemeSchema } from '@/api/asset/terminal';
|
||||
import { getTerminalThemes } from '@/api/asset/terminal';
|
||||
import { defineStore } from 'pinia';
|
||||
import { getPreference, updatePreference } from '@/api/user/preference';
|
||||
import { getLatestConnectHostId } from '@/api/asset/terminal-connect-log';
|
||||
import { nextId } from '@/utils';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { PanelSessionType, TerminalTabs } from '@/views/host/terminal/types/const';
|
||||
@@ -128,10 +129,15 @@ export default defineStore('terminal', {
|
||||
if (this.hosts.hostList?.length) {
|
||||
return;
|
||||
}
|
||||
// 查询授权主机
|
||||
const { data } = await getCurrentAuthorizedHost('SSH');
|
||||
Object.keys(data).forEach(k => {
|
||||
this.hosts[k as keyof AuthorizedHostQueryResponse] = data[k as keyof AuthorizedHostQueryResponse] as any;
|
||||
});
|
||||
this.hosts.latestHosts = [];
|
||||
// 查询最近连接的主机
|
||||
const { data: latestHosts } = await getLatestConnectHostId('SSH', 30);
|
||||
this.hosts.latestHosts = latestHosts;
|
||||
},
|
||||
|
||||
// 打开会话
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
position="br"
|
||||
type="warning"
|
||||
@ok="deleteSelectRows">
|
||||
<a-button v-permission="['infra:operator-log:delete', 'asset:host-sftp-log:management:delete']"
|
||||
<a-button v-permission="['infra:operator-log:delete', 'asset:terminal-sftp-log:management:delete']"
|
||||
type="primary"
|
||||
status="danger"
|
||||
:disabled="selectedKeys.length === 0">
|
||||
@@ -164,7 +164,7 @@
|
||||
position="left"
|
||||
type="warning"
|
||||
@ok="deleteRow(record)">
|
||||
<a-button v-permission="['infra:operator-log:delete', 'asset:host-sftp-log:management:delete']"
|
||||
<a-button v-permission="['infra:operator-log:delete', 'asset:terminal-sftp-log:management:delete']"
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger">
|
||||
@@ -184,9 +184,9 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { HostSftpLogQueryRequest, HostSftpLogQueryResponse } from '@/api/asset/host-sftp';
|
||||
import type { TerminalSftpLogQueryRequest, TerminalSftpLogQueryResponse } from '@/api/asset/terminal-sftp';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { getHostSftpLogPage, deleteHostSftpLog } from '@/api/asset/host-sftp';
|
||||
import { getTerminalSftpLogPage, deleteTerminalSftpLog } from '@/api/asset/terminal-sftp';
|
||||
import { sftpOperatorTypeKey, sftpOperatorResultKey, SftpOperatorType, showPathMaxCount } from '../types/const';
|
||||
import { useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
import { useDictStore } from '@/store';
|
||||
@@ -203,9 +203,9 @@
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { toOptions, getDictValue } = useDictStore();
|
||||
|
||||
const tableRenderData = ref<Array<HostSftpLogQueryResponse>>([]);
|
||||
const tableRenderData = ref<Array<TerminalSftpLogQueryResponse>>([]);
|
||||
const selectedKeys = ref<Array<number>>([]);
|
||||
const formModel = reactive<HostSftpLogQueryRequest>({
|
||||
const formModel = reactive<TerminalSftpLogQueryRequest>({
|
||||
userId: undefined,
|
||||
hostId: undefined,
|
||||
type: undefined,
|
||||
@@ -214,11 +214,11 @@
|
||||
});
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: HostSftpLogQueryRequest) => {
|
||||
const doFetchTableData = async (request: TerminalSftpLogQueryRequest) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 查询
|
||||
const { data } = await getHostSftpLogPage(request);
|
||||
const { data } = await getTerminalSftpLogPage(request);
|
||||
// 设置最大数量
|
||||
data.rows.forEach(s => {
|
||||
s.extra.maxCount = showPathMaxCount;
|
||||
@@ -244,7 +244,7 @@
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteHostSftpLog(selectedKeys.value);
|
||||
await deleteTerminalSftpLog(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
@@ -256,11 +256,11 @@
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async (record: HostSftpLogQueryResponse) => {
|
||||
const deleteRow = async (record: TerminalSftpLogQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteHostSftpLog([record.id]);
|
||||
await deleteTerminalSftpLog([record.id]);
|
||||
Message.success('删除成功');
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { openSftpCreateModalKey, openSftpMoveModalKey, openSftpChmodModalKey, openSftpUploadModalKey } from '../../types/const';
|
||||
import { getSftpFileContent, setSftpFileContent } from '@/api/asset/host-sftp';
|
||||
import { getSftpFileContent, setSftpFileContent } from '@/api/asset/terminal-sftp';
|
||||
import { isString } from '@/utils/is';
|
||||
import SftpTableHeader from './sftp-table-header.vue';
|
||||
import SftpTable from './sftp-table.vue';
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { SftpTransferItem } from '../types/define';
|
||||
import { TransferStatus } from '../types/const';
|
||||
import { getFileName, openDownloadFile } from '@/utils/file';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { getDownloadTransferUrl } from '@/api/asset/host-sftp';
|
||||
import { getDownloadTransferUrl } from '@/api/asset/terminal-sftp';
|
||||
import SftpTransferHandler from './sftp-transfer-handler';
|
||||
|
||||
// sftp 下载器实现
|
||||
|
||||
@@ -400,8 +400,8 @@ INSERT INTO `system_menu` VALUES (155, 148, '强制断开连接', 'asset:termina
|
||||
INSERT INTO `system_menu` VALUES (156, 122, '删除操作日志', 'infra:operator-log:delete', 3, 20, 1, 1, 1, 0, NULL, NULL, NULL, '2024-03-04 17:06:55', '2024-03-04 17:08:22', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (157, 122, '清空操作日志', 'infra:operator-log:management:clear', 3, 30, 1, 1, 1, 0, NULL, NULL, NULL, '2024-03-04 17:07:25', '2024-04-11 11:16:17', '1', '2', 0);
|
||||
INSERT INTO `system_menu` VALUES (158, 152, '文件操作日志', NULL, 2, 40, 1, 1, 1, 0, 'IconFile', NULL, 'sftpLog', '2024-03-05 15:30:13', '2024-08-04 20:23:19', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (159, 158, '查询文件操作日志', 'asset:host-sftp-log:management:query', 3, 10, 1, 1, 1, 0, NULL, NULL, NULL, '2024-03-05 15:31:02', '2024-04-12 14:49:18', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (160, 158, '删除文件操作日志', 'asset:host-sftp-log:management:delete', 3, 20, 1, 1, 1, 0, NULL, NULL, NULL, '2024-03-05 15:31:17', '2024-04-12 14:49:21', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (159, 158, '查询文件操作日志', 'asset:terminal-sftp-log:management:query', 3, 10, 1, 1, 1, 0, NULL, NULL, NULL, '2024-03-05 15:31:02', '2024-04-12 14:49:18', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (160, 158, '删除文件操作日志', 'asset:terminal-sftp-log:management:delete', 3, 20, 1, 1, 1, 0, NULL, NULL, NULL, '2024-03-05 15:31:17', '2024-04-12 14:49:21', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (161, 176, '执行模板', NULL, 2, 50, 1, 1, 1, 0, 'IconBookmark', NULL, 'execTemplate', '2024-03-07 18:32:41', '2024-05-14 15:58:51', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (162, 161, '查询执行模板', 'asset:exec-template:query', 3, 10, 1, 1, 1, 0, NULL, NULL, NULL, '2024-03-07 18:32:41', '2024-03-07 18:32:41', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (163, 161, '创建执行模板', 'asset:exec-template:create', 3, 20, 1, 1, 1, 0, NULL, NULL, NULL, '2024-03-07 18:32:41', '2024-03-07 18:32:41', '1', '1', 0);
|
||||
|
||||
Reference in New Issue
Block a user