You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package com.iflytop.gd.debug.controller;
import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.exceptions.UnSupportCommandException; import com.iflytop.gd.common.result.Result; import com.iflytop.gd.app.service.cmd.CommandHandler; import com.iflytop.gd.app.service.cmd.CommandHandlerRegistry; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.CompletableFuture;
@Tag(name = "前端调试指令") @RestController @RequestMapping("/api/debug/cmd") @RequiredArgsConstructor @Slf4j public class CmdDebugController { private final CommandHandlerRegistry registry;
@Operation(summary = "前端调试指令") @PostMapping public Result<?> controlMethod(@RequestBody CmdDTO cmdDTO) { String moduleName = cmdDTO.getModuleName(); String commandName = cmdDTO.getCommandName(); try { CommandHandler commandHandler = registry.getCommandHandler(moduleName, commandName); log.info("业务指令开始执行"); commandHandler.handle(cmdDTO); } catch (UnSupportCommandException exception) { log.error("未找到对应的业务指令"); return Result.failed(exception.getMessage()); } catch (Exception e) { log.error("执行业务指令发生异常: {}", cmdDTO, e); return Result.failed(e.getMessage()); } return Result.success(); }
}
|