|
@ -1,6 +1,7 @@ |
|
|
package com.iflytop.gd.debug.controller; |
|
|
package com.iflytop.gd.debug.controller; |
|
|
|
|
|
|
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
|
|
|
import com.iflytop.gd.app.service.WebSocketService; |
|
|
import com.iflytop.gd.app.service.exceptions.UnSupportCommandException; |
|
|
import com.iflytop.gd.app.service.exceptions.UnSupportCommandException; |
|
|
import com.iflytop.gd.common.result.Result; |
|
|
import com.iflytop.gd.common.result.Result; |
|
|
import com.iflytop.gd.common.cmd.CommandHandler; |
|
|
import com.iflytop.gd.common.cmd.CommandHandler; |
|
@ -15,6 +16,8 @@ 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") |
|
@ -28,10 +31,11 @@ public class CmdDebugController { |
|
|
public Result<?> controlMethod(@Valid @RequestBody CmdDTO cmdDTO) { |
|
|
public Result<?> controlMethod(@Valid @RequestBody CmdDTO cmdDTO) { |
|
|
String commandName = cmdDTO.getCommand(); |
|
|
String commandName = cmdDTO.getCommand(); |
|
|
try { |
|
|
try { |
|
|
|
|
|
log.info("收到调试指令{}", commandName); |
|
|
CommandHandler commandHandler = registry.getCommandHandler(commandName); |
|
|
CommandHandler commandHandler = registry.getCommandHandler(commandName); |
|
|
log.info("调试指令{}开始执行", commandName); |
|
|
|
|
|
commandHandler.handle(cmdDTO); |
|
|
|
|
|
log.info("调试指令{}执行结束", commandName); |
|
|
|
|
|
|
|
|
log.info("找到指令处理器{}", commandHandler.getClass().getName()); |
|
|
|
|
|
CompletableFuture.runAsync(() -> commandHandler.handle(cmdDTO)); |
|
|
|
|
|
log.info("指令处理器提交异步执行"); |
|
|
} catch (UnSupportCommandException exception) { |
|
|
} catch (UnSupportCommandException exception) { |
|
|
log.error("未找到对应的调试指令{}", commandName); |
|
|
log.error("未找到对应的调试指令{}", commandName); |
|
|
String errorMsg = "未找到对应的调试指令, commandName=" + commandName; |
|
|
String errorMsg = "未找到对应的调试指令, commandName=" + commandName; |
|
|