mirror of
https://gitee.com/yudaocode/SpringBoot-Labs.git
synced 2026-09-03 05:53:54 +08:00
soul 示例项目
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
package cn.iocoder.springboot.lab60.controller;
|
||||
|
||||
import org.dromara.soul.client.common.annotation.SoulClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/demo")
|
||||
public class DemoController {
|
||||
|
||||
@GetMapping("/get")
|
||||
@SoulClient(path = "/demo/get", desc = "示例接口")
|
||||
public String get(@RequestParam("id") Integer id) {
|
||||
return "DEMO:" + id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.iocoder.springboot.lab60.controller;
|
||||
|
||||
import cn.iocoder.springboot.lab60.dto.UserCreateDTO;
|
||||
import org.dromara.soul.client.common.annotation.SoulClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@GetMapping("/get")
|
||||
@SoulClient(path = "/user/get", desc = "获得用户详细")
|
||||
public String getUser(@RequestParam("id") Integer id) {
|
||||
return "DEMO:" + id;
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@SoulClient(path = "/user/create", desc = "创建用户")
|
||||
public Integer createUser(@RequestBody UserCreateDTO createDTO) {
|
||||
logger.info("[createUser][username({}) password({})]", createDTO.getNickname(), createDTO.getGender());
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.springboot.lab60.dto;
|
||||
|
||||
/**
|
||||
* 用户创建 DTO
|
||||
*/
|
||||
public class UserCreateDTO {
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public UserCreateDTO setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public UserCreateDTO setGender(Integer gender) {
|
||||
this.gender = gender;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
soul:
|
||||
# Soul 针对 SpringMVC 的配置项,对应 SoulHttpConfig 配置类
|
||||
http:
|
||||
admin-url: http://127.0.0.1:9095
|
||||
context-path: /demo-api
|
||||
app-name: demo-service
|
||||
zookeeper-url: 127.0.0.1:2181
|
||||
admin-url: http://127.0.0.1:9095 # Soul Admin 地址
|
||||
context-path: /sb-demo-api # 设置在 Soul 网关的路由前缀,例如说 /order、/product 等等。
|
||||
# 后续,网关会根据该 context-path 来进行路由
|
||||
app-name: sb-demo-service # 应用名。未配置情况下,默认使用 `spring.application.name` 配置项
|
||||
zookeeper-url: 127.0.0.1:2181 # 使用 Zookeeper 作为注册中心的地址
|
||||
|
||||
Reference in New Issue
Block a user