GatewayDynamicRouteController.java
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.bs.gateway.controller;
import com.bs.gateway.service.GatewayDynamicRouteService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import jakarta.annotation.Resource;
/**
* @author leejoker
* @version 1.0
* @date 2021/11/24 14:57
*/
@RestController
@RequestMapping("/gateway")
public class GatewayDynamicRouteController {
@Resource
private GatewayDynamicRouteService gatewayDynamicRouteService;
@GetMapping("")
@Operation(summary = "获取路由列表")
public Flux<RouteDefinition> list() {
return gatewayDynamicRouteService.list();
}
@PostMapping("")
@Operation(summary = "新增路由")
public String add(@RequestBody RouteDefinition entity) {
int result = gatewayDynamicRouteService.add(entity);
return String.valueOf(result);
}
@PutMapping("")
@Operation(summary = "修改路由")
public String update(@RequestBody RouteDefinition entity) {
int result = gatewayDynamicRouteService.update(entity);
return String.valueOf(result);
}
@DeleteMapping("/{id}")
@Operation(summary = "删除路由")
public Mono<ResponseEntity<Object>> delete(@PathVariable("id") String id) {
return gatewayDynamicRouteService.delete(id);
}
}