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.app.controller;
import com.iflytop.gd.app.core.CommandHandlerRegistry; import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.common.cmd.CommandHandler; import com.iflytop.gd.common.result.Result; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; 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;
@Tag(name = "前端业务指令") @RestController @RequestMapping("/api/cmd") @RequiredArgsConstructor @Slf4j public class CmdController { private final CommandHandlerRegistry registry;
@Operation(summary = "前端统一调用一个接口") @PostMapping public Result<?> controlMethod(@Valid @RequestBody CmdDTO cmdDTO) throws Exception { String commandName = cmdDTO.getCommand(); CommandHandler commandHandler = registry.getCommandHandler(commandName); log.info("业务指令开始执行"); commandHandler.handle(cmdDTO); return Result.success(); }
}
|