Skip to content

Commit bec9ffb

Browse files
author
YunaiV
committed
soul 示例项目
1 parent 19df98f commit bec9ffb

File tree

4 files changed

+67
-23
lines changed

4 files changed

+67
-23
lines changed

lab-60/lab-60-soul-spring-boot-demo/src/main/java/cn/iocoder/springboot/lab60/controller/DemoController.java

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package cn.iocoder.springboot.lab60.controller;
2+
3+
import cn.iocoder.springboot.lab60.dto.UserCreateDTO;
4+
import org.dromara.soul.client.common.annotation.SoulClient;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import org.springframework.web.bind.annotation.*;
8+
9+
@RestController
10+
@RequestMapping("/user")
11+
public class UserController {
12+
13+
private Logger logger = LoggerFactory.getLogger(getClass());
14+
15+
@GetMapping("/get")
16+
@SoulClient(path = "/user/get", desc = "获得用户详细")
17+
public String getUser(@RequestParam("id") Integer id) {
18+
return "DEMO:" + id;
19+
}
20+
21+
@PostMapping("/create")
22+
@SoulClient(path = "/user/create", desc = "创建用户")
23+
public Integer createUser(@RequestBody UserCreateDTO createDTO) {
24+
logger.info("[createUser][username({}) password({})]", createDTO.getNickname(), createDTO.getGender());
25+
return 1;
26+
}
27+
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package cn.iocoder.springboot.lab60.dto;
2+
3+
/**
4+
* 用户创建 DTO
5+
*/
6+
public class UserCreateDTO {
7+
8+
/**
9+
* 昵称
10+
*/
11+
private String nickname;
12+
/**
13+
* 性别
14+
*/
15+
private Integer gender;
16+
17+
public String getNickname() {
18+
return nickname;
19+
}
20+
21+
public UserCreateDTO setNickname(String nickname) {
22+
this.nickname = nickname;
23+
return this;
24+
}
25+
26+
public Integer getGender() {
27+
return gender;
28+
}
29+
30+
public UserCreateDTO setGender(Integer gender) {
31+
this.gender = gender;
32+
return this;
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
soul:
22
# Soul 针对 SpringMVC 的配置项,对应 SoulHttpConfig 配置类
33
http:
4-
admin-url: http://127.0.0.1:9095
5-
context-path: /demo-api
6-
app-name: demo-service
7-
zookeeper-url: 127.0.0.1:2181
4+
admin-url: http://127.0.0.1:9095 # Soul Admin 地址
5+
context-path: /sb-demo-api # 设置在 Soul 网关的路由前缀,例如说 /order、/product 等等。
6+
# 后续,网关会根据该 context-path 来进行路由
7+
app-name: sb-demo-service # 应用名。未配置情况下,默认使用 `spring.application.name` 配置项
8+
zookeeper-url: 127.0.0.1:2181 # 使用 Zookeeper 作为注册中心的地址

0 commit comments

Comments
 (0)