GatewayRouteController.java 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.yaozhitech.spring5.controller;
  2. import javax.validation.Valid;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.web.bind.annotation.PostMapping;
  5. import org.springframework.web.bind.annotation.RequestBody;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import com.yaozhitech.spring5.form.GatewayRoute;
  9. import com.yaozhitech.spring5.form.GatewayRouteForm;
  10. import com.yaozhitech.spring5.service.impl.GatewayRouteService;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiImplicitParam;
  13. import io.swagger.annotations.ApiOperation;
  14. import lombok.extern.slf4j.Slf4j;
  15. @RestController
  16. @RequestMapping("/gateway/routes")
  17. @Api("gateway routes")
  18. @Slf4j
  19. public class GatewayRouteController {
  20. @Autowired
  21. private GatewayRouteService gatewayRoutService;
  22. @ApiOperation(value = "新增网关路由", notes = "新增一个网关路由")
  23. @ApiImplicitParam(name = "gatewayRoutForm", value = "新增网关路由form表单", required = true, dataType = "GatewayRouteForm")
  24. @PostMapping
  25. public String add(@Valid @RequestBody GatewayRouteForm gatewayRoutForm) {
  26. log.info("name:", gatewayRoutForm);
  27. GatewayRoute gatewayRout = gatewayRoutForm.toPo(GatewayRoute.class);
  28. gatewayRoutService.add(gatewayRout);
  29. return "success";
  30. }
  31. // @ApiOperation(value = "删除网关路由", notes = "根据url的id来指定删除对象")
  32. // @ApiImplicitParam(paramType = "path", name = "id", value = "网关路由ID", required = true, dataType = "long")
  33. // @DeleteMapping(value = "/{id}")
  34. // public Result delete(@PathVariable String id) {
  35. // return Result.success(gatewayRoutService.delete(id));
  36. // }
  37. //
  38. // @ApiOperation(value = "修改网关路由", notes = "修改指定网关路由信息")
  39. // @ApiImplicitParams({
  40. // @ApiImplicitParam(name = "id", value = "网关路由ID", required = true, dataType = "long"),
  41. // @ApiImplicitParam(name = "gatewayRoutForm", value = "网关路由实体", required = true, dataType = "GatewayRouteForm")
  42. // })
  43. // @PutMapping(value = "/{id}")
  44. // public Result update(@PathVariable String id, @Valid @RequestBody GatewayRouteForm gatewayRoutForm) {
  45. // GatewayRoute gatewayRout = gatewayRoutForm.toPo(GatewayRoute.class);
  46. // gatewayRout.setId(id);
  47. // return Result.success(gatewayRoutService.update(gatewayRout));
  48. // }
  49. //
  50. // @ApiOperation(value = "获取网关路由", notes = "根据id获取指定网关路由信息")
  51. // @ApiImplicitParam(paramType = "path", name = "id", value = "网关路由ID", required = true, dataType = "long")
  52. // @GetMapping(value = "/{id}")
  53. // public Result get(@PathVariable String id) {
  54. // log.info("get with id:{}", id);
  55. // return Result.success(new GatewayRouteVo(gatewayRoutService.get(id)));
  56. // }
  57. //
  58. // @ApiOperation(value = "根据uri获取网关路由", notes = "根据uri获取网关路由信息,简单查询")
  59. // @ApiImplicitParam(paramType = "query", name = "name", value = "网关路由路径", required = true, dataType = "string")
  60. // @ApiResponses(
  61. // @ApiResponse(code = 200, message = "处理成功", response = Result.class)
  62. // )
  63. // @GetMapping
  64. // public Result getByUri(@RequestParam String uri) {
  65. // return Result.success(gatewayRoutService.query(new GatewayRouteQueryParam(uri)).stream().findFirst());
  66. // }
  67. //
  68. // @ApiOperation(value = "搜索网关路由", notes = "根据条件查询网关路由信息")
  69. // @ApiImplicitParam(name = "gatewayRoutQueryForm", value = "网关路由查询参数", required = true, dataType = "GatewayRouteQueryForm")
  70. // @ApiResponses(
  71. // @ApiResponse(code = 200, message = "处理成功", response = Result.class)
  72. // )
  73. // @PostMapping(value = "/conditions")
  74. // public Result search(@Valid @RequestBody GatewayRouteQueryForm gatewayRouteQueryForm) {
  75. // return Result.success(gatewayRoutService.query(gatewayRouteQueryForm.toParam(GatewayRouteQueryParam.class)));
  76. // }
  77. //
  78. // @ApiOperation(value = "重载网关路由", notes = "将所以网关的路由全部重载到redis中")
  79. // @ApiResponses(
  80. // @ApiResponse(code = 200, message = "处理成功", response = Result.class)
  81. // )
  82. // @PostMapping(value = "/overload")
  83. // public Result overload() {
  84. // return Result.success(gatewayRoutService.overload());
  85. // }
  86. }