服务注册
This commit is contained in:
parent
37f93355df
commit
0c4ca50b3f
@ -17,10 +17,10 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>cn.iocoder.cloud</groupId>
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
<artifactId>yudao-common</artifactId>
|
<artifactId>yudao-common</artifactId>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
<!-- Web 相关 -->
|
<!-- Web 相关 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package cn.iocoder.yudao.module.grpc.api;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.grpc.enums.ApiConstants;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||||
|
@Tag(name = "GRPC 服务 - 调用机器人")
|
||||||
|
public interface GrpcServiceApi {
|
||||||
|
|
||||||
|
@PostMapping("/grpc/robot/onVehiclePoseUpdatedG")
|
||||||
|
@Operation(summary = "订阅车体位姿更新")
|
||||||
|
String onVehiclePoseUpdated();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package cn.iocoder.yudao.module.grpc.enums;
|
||||||
|
|
||||||
|
|
||||||
|
public class ApiConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务名
|
||||||
|
*
|
||||||
|
* 注意,需要保证和 spring.application.name 保持一致
|
||||||
|
*/
|
||||||
|
public static final String NAME = "grpc-server";
|
||||||
|
|
||||||
|
public static final String PREFIX = "/rpc-api/grpc";
|
||||||
|
|
||||||
|
public static final String VERSION = "1.0.0";
|
||||||
|
|
||||||
|
}
|
@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.grpc;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class GrpcServerApplication {
|
public class GrpcServerApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.grpc.controller;
|
package cn.iocoder.yudao.module.grpc.controller;
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
||||||
import cn.iocoder.yudao.module.grpc.service.geometry.GeometryService;
|
import cn.iocoder.yudao.module.grpc.service.geometry.GeometryService;
|
||||||
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;
|
||||||
@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.annotation.security.PermitAll;
|
import javax.annotation.security.PermitAll;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
|
|
||||||
@Tag(name = "测试demo")
|
@Tag(name = "测试demo")
|
||||||
@RestController
|
@RestController
|
||||||
@ -26,7 +24,7 @@ public class GeometryController {
|
|||||||
@PostMapping("/onVehiclePoseUpdated")
|
@PostMapping("/onVehiclePoseUpdated")
|
||||||
@Operation(summary = "测试GRPC调用")
|
@Operation(summary = "测试GRPC调用")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
public CommonResult<String> onVehiclePoseUpdated() {
|
public String onVehiclePoseUpdated() {
|
||||||
return success(geometryService.onVehiclePoseUpdated());
|
return geometryService.onVehiclePoseUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package cn.iocoder.yudao.module.grpc.service.api;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.grpc.api.GrpcServiceApi;
|
||||||
|
import cn.iocoder.yudao.module.grpc.service.geometry.GeometryService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||||
|
@Validated
|
||||||
|
public class GrpcServiceImpl implements GrpcServiceApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GeometryService geometryService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onVehiclePoseUpdated() {
|
||||||
|
return geometryService.onVehiclePoseUpdated();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user