🚧 定义sftp操作处理器.
This commit is contained in:
@@ -75,20 +75,71 @@ public enum InputTypeEnum {
|
||||
new String[]{"type", "sessionId", "showHiddenFile", "path"},
|
||||
SftpListRequest.class),
|
||||
|
||||
/**
|
||||
* SFTP 创建文件夹
|
||||
*/
|
||||
SFTP_MKDIR("mk",
|
||||
SftpMakeDirectoryHandler.class,
|
||||
new String[]{"type", "sessionId", "path"},
|
||||
SftpBaseRequest.class),
|
||||
|
||||
/**
|
||||
* SFTP 创建文件
|
||||
*/
|
||||
SFTP_TOUCH("to",
|
||||
SftpTouchHandler.class,
|
||||
new String[]{"type", "sessionId", "path"},
|
||||
SftpBaseRequest.class),
|
||||
|
||||
/**
|
||||
* SFTP 移动文件
|
||||
*/
|
||||
SFTP_MOVE("mv",
|
||||
SftpMoveHandler.class,
|
||||
new String[]{"type", "sessionId", "path", "target"},
|
||||
SftpMoveRequest.class),
|
||||
|
||||
/**
|
||||
* SFTP 删除文件
|
||||
*/
|
||||
SFTP_REMOVE("rm",
|
||||
SftpRemoveHandler.class,
|
||||
new String[]{"type", "sessionId", "paths"},
|
||||
SftpRemoveRequest.class),
|
||||
|
||||
/**
|
||||
* SFTP 截断文件
|
||||
*/
|
||||
SFTP_TRUNCATE("tc",
|
||||
SftpTruncateHandler.class,
|
||||
new String[]{"type", "sessionId", "path"},
|
||||
SftpBaseRequest.class),
|
||||
|
||||
/**
|
||||
* SFTP 修改文件权限
|
||||
*/
|
||||
SFTP_CHMOD("cm",
|
||||
SftpChangeModHandler.class,
|
||||
new String[]{"type", "sessionId", "path", "mod"},
|
||||
SftpChangeModRequest.class),
|
||||
|
||||
/**
|
||||
* SFTP 获取内容
|
||||
*/
|
||||
SFTP_GET_CONTENT("gc",
|
||||
SftpGetContentHandler.class,
|
||||
new String[]{"type", "sessionId", "path"},
|
||||
SftpBaseRequest.class),
|
||||
|
||||
/**
|
||||
* SFTP 修改内容
|
||||
*/
|
||||
SFTP_SET_CONTENT("sc",
|
||||
SftpSetContentHandler.class,
|
||||
new String[]{"type", "sessionId", "path", "content"},
|
||||
SftpSetContentRequest.class),
|
||||
|
||||
// TODO
|
||||
// MKDIR
|
||||
// TOUCH
|
||||
|
||||
// REMOVE
|
||||
// MOVE
|
||||
// TRUNCATE
|
||||
|
||||
// CHMOD
|
||||
|
||||
// GET
|
||||
// SAVE
|
||||
|
||||
// COPY
|
||||
// UPLOAD
|
||||
// DOWNLOAD
|
||||
|
||||
@@ -43,7 +43,47 @@ public enum OutputTypeEnum {
|
||||
/**
|
||||
* SFTP 文件列表
|
||||
*/
|
||||
SFTP_LIST("ls", "${type}|${sessionId}|${result}|${path}|${body}"),
|
||||
SFTP_LIST("ls", "${type}|${sessionId}|${path}|${result}|${body}"),
|
||||
|
||||
/**
|
||||
* SFTP 创建文件夹
|
||||
*/
|
||||
SFTP_MKDIR("md", "${type}|${sessionId}|${result}|${msg}"),
|
||||
|
||||
/**
|
||||
* SFTP 创建文件
|
||||
*/
|
||||
SFTP_TOUCH("to", "${type}|${sessionId}${result}|${msg}"),
|
||||
|
||||
/**
|
||||
* SFTP 移动文件
|
||||
*/
|
||||
SFTP_MOVE("mv", "${type}|${sessionId}|${result}|${msg}"),
|
||||
|
||||
/**
|
||||
* SFTP 删除文件
|
||||
*/
|
||||
SFTP_REMOVE("rm", "${type}|${sessionId}|${result}|${msg}"),
|
||||
|
||||
/**
|
||||
* SFTP 截断文件
|
||||
*/
|
||||
SFTP_TRUNCATE("tc", "${type}|${sessionId}|${result}|${msg}"),
|
||||
|
||||
/**
|
||||
* SFTP 修改文件权限
|
||||
*/
|
||||
SFTP_CHMOD("cm", "${type}|${sessionId}|${result}|${msg}"),
|
||||
|
||||
/**
|
||||
* SFTP 获取文件内容
|
||||
*/
|
||||
SFTP_GET_CONTENT("gc", "${type}|${sessionId}|${path}|${result}|${content}"),
|
||||
|
||||
/**
|
||||
* SFTP 修改文件内容
|
||||
*/
|
||||
SFTP_SET_CONTENT("sc", "${type}|${sessionId}|${result}|${msg}"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpChangeModRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* sftp 修改文件权限
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/19 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SftpChangeModHandler extends AbstractTerminalHandler<SftpChangeModRequest> {
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpChangeModRequest payload) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpBaseRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* sftp 获取文件内容
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/19 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SftpGetContentHandler extends AbstractTerminalHandler<SftpBaseRequest> {
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpBaseRequest payload) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,17 +4,14 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.ops.framework.common.enums.BooleanBit;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.manager.TerminalManager;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpListRequest;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpFileResponse;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpFileVO;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpListResponse;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.session.ISftpSession;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.session.ITerminalSession;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -28,39 +25,34 @@ import java.util.List;
|
||||
@Component
|
||||
public class SftpListHandler extends AbstractTerminalHandler<SftpListRequest> {
|
||||
|
||||
@Resource
|
||||
private TerminalManager terminalManager;
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpListRequest payload) {
|
||||
// 获取会话
|
||||
ITerminalSession session = terminalManager.getSession(channel.getId(), payload.getSessionId());
|
||||
ISftpSession session = terminalManager.getSession(channel.getId(), payload.getSessionId());
|
||||
String path = payload.getPath();
|
||||
log.info("SftpListHandler-handle session: {}, path: {}", payload.getSessionId(), path);
|
||||
if (session instanceof ISftpSession) {
|
||||
Exception ex = null;
|
||||
List<SftpFileResponse> list = null;
|
||||
try {
|
||||
// 空目录则直接获取 home 目录
|
||||
if (Strings.isBlank(path)) {
|
||||
path = ((ISftpSession) session).getHome();
|
||||
}
|
||||
// 文件列表
|
||||
list = ((ISftpSession) session).list(path, BooleanBit.toBoolean(payload.getShowHiddenFile()));
|
||||
} catch (Exception e) {
|
||||
log.error("SftpListHandler-handle error", e);
|
||||
ex = e;
|
||||
Exception ex = null;
|
||||
List<SftpFileVO> list = null;
|
||||
try {
|
||||
// 空目录则直接获取 home 目录
|
||||
if (Strings.isBlank(path)) {
|
||||
path = session.getHome();
|
||||
}
|
||||
// 返回
|
||||
this.send(channel,
|
||||
OutputTypeEnum.SFTP_LIST,
|
||||
SftpListResponse.builder()
|
||||
.sessionId(payload.getSessionId())
|
||||
.result(BooleanBit.of(ex == null).getValue())
|
||||
.path(path)
|
||||
.body(list == null ? null : JSON.toJSONString(list))
|
||||
.build());
|
||||
// 文件列表
|
||||
list = session.list(path, BooleanBit.toBoolean(payload.getShowHiddenFile()));
|
||||
} catch (Exception e) {
|
||||
log.error("SftpListHandler-handle error", e);
|
||||
ex = e;
|
||||
}
|
||||
// 返回
|
||||
this.send(channel,
|
||||
OutputTypeEnum.SFTP_LIST,
|
||||
SftpListResponse.builder()
|
||||
.sessionId(payload.getSessionId())
|
||||
.result(BooleanBit.of(ex == null).getValue())
|
||||
.path(path)
|
||||
.body(list == null ? null : JSON.toJSONString(list))
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import com.orion.ops.framework.common.enums.BooleanBit;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpBaseRequest;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpBaseResponse;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.session.ISftpSession;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* sftp 创建文件夹
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/19 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SftpMakeDirectoryHandler extends AbstractTerminalHandler<SftpBaseRequest> {
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpBaseRequest payload) {
|
||||
// 获取会话
|
||||
ISftpSession session = terminalManager.getSession(channel.getId(), payload.getSessionId());
|
||||
String path = payload.getPath();
|
||||
log.info("SftpMakeDirectoryHandler-handle session: {}, path: {}", payload.getSessionId(), path);
|
||||
Exception ex = null;
|
||||
try {
|
||||
session.mkdir(path);
|
||||
} catch (Exception e) {
|
||||
log.error("SftpMakeDirectoryHandler-handle error", e);
|
||||
ex = e;
|
||||
}
|
||||
// 返回
|
||||
this.send(channel,
|
||||
OutputTypeEnum.SFTP_MKDIR,
|
||||
SftpBaseResponse.builder()
|
||||
.sessionId(payload.getSessionId())
|
||||
.result(BooleanBit.of(ex == null).getValue())
|
||||
.msg(ex == null ? null : ex.getMessage())
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpMoveRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* sftp 移动文件
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/19 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SftpMoveHandler extends AbstractTerminalHandler<SftpMoveRequest> {
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpMoveRequest payload) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpRemoveRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* sftp 删除文件
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/19 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SftpRemoveHandler extends AbstractTerminalHandler<SftpRemoveRequest> {
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpRemoveRequest payload) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpSetContentRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* sftp 设置文件内容
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/19 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SftpSetContentHandler extends AbstractTerminalHandler<SftpSetContentRequest> {
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpSetContentRequest payload) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import com.orion.ops.framework.common.enums.BooleanBit;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpBaseRequest;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpBaseResponse;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.session.ISftpSession;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* sftp 创建文件
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/19 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SftpTouchHandler extends AbstractTerminalHandler<SftpBaseRequest> {
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpBaseRequest payload) {
|
||||
// 获取会话
|
||||
ISftpSession session = terminalManager.getSession(channel.getId(), payload.getSessionId());
|
||||
String path = payload.getPath();
|
||||
log.info("SftpTouchHandler-handle session: {}, path: {}", payload.getSessionId(), path);
|
||||
Exception ex = null;
|
||||
try {
|
||||
session.touch(path);
|
||||
} catch (Exception e) {
|
||||
log.error("SftpTouchHandler-handle error", e);
|
||||
ex = e;
|
||||
}
|
||||
// 返回
|
||||
this.send(channel,
|
||||
OutputTypeEnum.SFTP_TOUCH,
|
||||
SftpBaseResponse.builder()
|
||||
.sessionId(payload.getSessionId())
|
||||
.result(BooleanBit.of(ex == null).getValue())
|
||||
.msg(ex == null ? null : ex.getMessage())
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.request.SftpBaseRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* sftp 截断文件
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/19 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SftpTruncateHandler extends AbstractTerminalHandler<SftpBaseRequest> {
|
||||
|
||||
@Override
|
||||
public void handle(WebSocketSession channel, SftpBaseRequest payload) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,21 +9,19 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* sftp 创建文件 实体对象
|
||||
* <p>
|
||||
* i|eff00a1|path
|
||||
* sftp 基础请求 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/6 13:31
|
||||
* @since 2024/2/19 17:46
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpTouchRequest", description = "sftp 创建文件 实体对象")
|
||||
public class SftpTouchRequest extends TerminalBasePayload {
|
||||
@Schema(name = "SftpBaseRequest", description = "sftp 基础请求 实体对象")
|
||||
public class SftpBaseRequest extends TerminalBasePayload {
|
||||
|
||||
@Schema(description = "path")
|
||||
private String path;
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.request;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.TerminalBasePayload;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -23,10 +22,7 @@ import lombok.experimental.SuperBuilder;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpChangeModRequest", description = "sftp 修改文件权限 实体对象")
|
||||
public class SftpChangeModRequest extends TerminalBasePayload {
|
||||
|
||||
@Schema(description = "path")
|
||||
private String path;
|
||||
public class SftpChangeModRequest extends SftpBaseRequest {
|
||||
|
||||
@Schema(description = "10进制的8进制 权限")
|
||||
private Integer mod;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.request;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.TerminalBasePayload;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -23,10 +22,7 @@ import lombok.experimental.SuperBuilder;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpListRequest", description = "sftp 列表请求 实体对象")
|
||||
public class SftpListRequest extends TerminalBasePayload {
|
||||
|
||||
@Schema(description = "path")
|
||||
private String path;
|
||||
public class SftpListRequest extends SftpBaseRequest {
|
||||
|
||||
@Schema(description = "是否显示隐藏文件")
|
||||
private Integer showHiddenFile;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.request;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.TerminalBasePayload;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -11,7 +10,7 @@ import lombok.experimental.SuperBuilder;
|
||||
/**
|
||||
* sftp 移动文件 实体对象
|
||||
* <p>
|
||||
* i|eff00a1|source|target
|
||||
* i|eff00a1|path|target
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
@@ -23,10 +22,7 @@ import lombok.experimental.SuperBuilder;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpMoveRequest", description = "sftp 移动文件 实体对象")
|
||||
public class SftpMoveRequest extends TerminalBasePayload {
|
||||
|
||||
@Schema(description = "source")
|
||||
private String source;
|
||||
public class SftpMoveRequest extends SftpBaseRequest {
|
||||
|
||||
@Schema(description = "target")
|
||||
private String target;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.request;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.TerminalBasePayload;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -25,7 +24,7 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpRemoveRequest", description = "sftp 删除文件 实体对象")
|
||||
public class SftpRemoveRequest extends TerminalBasePayload {
|
||||
public class SftpRemoveRequest extends SftpBaseRequest {
|
||||
|
||||
@Schema(description = "paths 多个用|分割")
|
||||
private List<String> paths;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.request;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* sftp 设置文件内容 实体对象
|
||||
* <p>
|
||||
* i|eff00a1|path|content
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/6 13:31
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpSetContentRequest", description = "sftp 设置文件内容 实体对象")
|
||||
public class SftpSetContentRequest extends SftpBaseRequest {
|
||||
|
||||
@Schema(description = "content")
|
||||
private String content;
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.request;
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.response;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.TerminalBasePayload;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -9,23 +9,24 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* sftp 创建文件夹 实体对象
|
||||
* <p>
|
||||
* i|eff00a1|path
|
||||
* sftp 基础响应 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/6 13:31
|
||||
* @since 2024/2/19 17:46
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpMakeDirectoryRequest", description = "sftp 创建文件夹 实体对象")
|
||||
public class SftpMakeDirectoryRequest extends TerminalBasePayload {
|
||||
@Schema(name = "SftpBaseResponse", description = "sftp 基础响应 实体对象")
|
||||
public class SftpBaseResponse extends TerminalBasePayload {
|
||||
|
||||
@Schema(description = "path")
|
||||
private String path;
|
||||
@Schema(description = "结果")
|
||||
private Integer result;
|
||||
|
||||
@Schema(description = "消息")
|
||||
private String msg;
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import java.util.Date;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "SftpFileResponse", description = "sftp 文件响应 实体对象")
|
||||
public class SftpFileResponse {
|
||||
public class SftpFileVO {
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.request;
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.response;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.TerminalBasePayload;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -9,23 +8,24 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* sftp 截断文件 实体对象
|
||||
* <p>
|
||||
* i|eff00a1|path
|
||||
* sftp 获取内容响应 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/6 13:31
|
||||
* @since 2024/2/6 16:20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpTruncateRequest", description = "sftp 截断文件 实体对象")
|
||||
public class SftpTruncateRequest extends TerminalBasePayload {
|
||||
@Schema(name = "SftpGetContentResponse", description = "sftp 获取内容响应 实体对象")
|
||||
public class SftpGetContentResponse extends SftpBaseResponse {
|
||||
|
||||
@Schema(description = "path")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "content")
|
||||
private String content;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.model.response;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.TerminalBasePayload;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -21,14 +20,11 @@ import lombok.experimental.SuperBuilder;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "SftpListResponse", description = "sftp 列表响应 实体对象")
|
||||
public class SftpListResponse extends TerminalBasePayload {
|
||||
public class SftpListResponse extends SftpBaseResponse {
|
||||
|
||||
@Schema(description = "path")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "结果")
|
||||
private Integer result;
|
||||
|
||||
@Schema(description = "body")
|
||||
private String body;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.orion.ops.module.asset.handler.host.terminal.session;
|
||||
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpFileResponse;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpFileVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,7 +32,7 @@ public interface ISftpSession extends ITerminalSession {
|
||||
* @param showHiddenFile 是否显示隐藏文件
|
||||
* @return list
|
||||
*/
|
||||
List<SftpFileResponse> list(String path, boolean showHiddenFile);
|
||||
List<SftpFileVO> list(String path, boolean showHiddenFile);
|
||||
|
||||
/**
|
||||
* 创建文件夹
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.orion.net.host.sftp.SftpFile;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.TerminalConfig;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpFileResponse;
|
||||
import com.orion.ops.module.asset.handler.host.terminal.model.response.SftpFileVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SftpSession extends TerminalSession implements ISftpSession {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SftpFileResponse> list(String path, boolean showHiddenFile) {
|
||||
public List<SftpFileVO> list(String path, boolean showHiddenFile) {
|
||||
path = Files1.getPath(path);
|
||||
// 查询文件
|
||||
List<SftpFile> files = executor.listFilesFilter(path,
|
||||
@@ -149,8 +149,8 @@ public class SftpSession extends TerminalSession implements ISftpSession {
|
||||
* @param sftpFile sftpFile
|
||||
* @return file
|
||||
*/
|
||||
private static SftpFileResponse fileMapping(SftpFile sftpFile) {
|
||||
SftpFileResponse file = new SftpFileResponse();
|
||||
private static SftpFileVO fileMapping(SftpFile sftpFile) {
|
||||
SftpFileVO file = new SftpFileVO();
|
||||
file.setName(sftpFile.getName());
|
||||
file.setPath(sftpFile.getPath());
|
||||
file.setSuffix(Files1.getSuffix(sftpFile.getName()));
|
||||
|
||||
Reference in New Issue
Block a user