|
@ -1,10 +1,9 @@ |
|
|
package com.iflytop.gd.app.controller; |
|
|
package com.iflytop.gd.app.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.iflytop.gd.app.core.CommandHandlerRegistry; |
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
import com.iflytop.gd.common.exception.UnSupportCommandException; |
|
|
|
|
|
import com.iflytop.gd.common.result.Result; |
|
|
|
|
|
import com.iflytop.gd.common.cmd.CommandHandler; |
|
|
import com.iflytop.gd.common.cmd.CommandHandler; |
|
|
import com.iflytop.gd.app.core.CommandHandlerRegistry; |
|
|
|
|
|
|
|
|
import com.iflytop.gd.common.result.Result; |
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
import jakarta.validation.Valid; |
|
|
import jakarta.validation.Valid; |
|
@ -15,8 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
|
|
|
|
|
@Tag(name = "前端调试指令") |
|
|
@Tag(name = "前端调试指令") |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/api/debug/cmd") |
|
|
@RequestMapping("/api/debug/cmd") |
|
@ -27,22 +24,11 @@ public class CmdDebugController { |
|
|
|
|
|
|
|
|
@Operation(summary = "前端调试指令") |
|
|
@Operation(summary = "前端调试指令") |
|
|
@PostMapping |
|
|
@PostMapping |
|
|
public Result<?> controlMethod(@Valid @RequestBody CmdDTO cmdDTO) { |
|
|
|
|
|
|
|
|
public Result<?> controlMethod(@Valid @RequestBody CmdDTO cmdDTO) throws Exception { |
|
|
String commandName = cmdDTO.getCommand(); |
|
|
String commandName = cmdDTO.getCommand(); |
|
|
try { |
|
|
|
|
|
log.info("收到调试指令{}", commandName); |
|
|
|
|
|
CommandHandler commandHandler = registry.getCommandHandler(commandName); |
|
|
|
|
|
log.info("找到指令处理器{}", commandHandler.getClass().getName()); |
|
|
|
|
|
commandHandler.handle(cmdDTO); |
|
|
|
|
|
log.info("指令处理器提交异步执行"); |
|
|
|
|
|
} catch (UnSupportCommandException exception) { |
|
|
|
|
|
log.error("未找到对应的调试指令{}", commandName); |
|
|
|
|
|
String errorMsg = "未找到对应的调试指令, commandName=" + commandName; |
|
|
|
|
|
return Result.failed(errorMsg); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("执行调试指令发生异常: {}", cmdDTO, e); |
|
|
|
|
|
return Result.failed(e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
CommandHandler commandHandler = registry.getCommandHandler(commandName); |
|
|
|
|
|
log.info("调试指令开始执行"); |
|
|
|
|
|
commandHandler.handle(cmdDTO); |
|
|
return Result.success(); |
|
|
return Result.success(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|