GateWayController.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.zswl.dataservice.controller;
  2. import com.zswl.dataservice.model.mqtt.*;
  3. import com.zswl.dataservice.service.mqtt.GateWayInfoService;
  4. import com.zswl.dataservice.utils.result.ResultContent;
  5. import io.swagger.v3.oas.annotations.Operation;
  6. import io.swagger.v3.oas.annotations.Parameter;
  7. import io.swagger.v3.oas.annotations.tags.Tag;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.data.domain.Page;
  10. import org.springframework.data.domain.Pageable;
  11. import org.springframework.data.web.PageableDefault;
  12. import org.springframework.util.Assert;
  13. import org.springframework.validation.annotation.Validated;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestMethod;
  17. import org.springframework.web.bind.annotation.RestController;
  18. /**
  19. * 网关管理 服务
  20. *
  21. * @author TRX
  22. * @date 2024/3/21
  23. */
  24. @RequestMapping("/gateWay/free")
  25. @RestController
  26. @Validated
  27. @Tag(name = "网关管理")
  28. public class GateWayController {
  29. @Autowired
  30. GateWayInfoService gateWayInfoService;
  31. @Operation(summary = "添加网关")
  32. @RequestMapping(value = "addDeviceInfo", method = {RequestMethod.POST})
  33. public ResultContent addDeviceInfo(@RequestBody GateWayInfoAddParam param) {
  34. Assert.hasText(param.getGateWayId(), "网关ID不能为空");
  35. Assert.hasText(param.getGateWayName(), "网关名称不能为空");
  36. return gateWayInfoService.addGateWayInfo(param);
  37. }
  38. @Operation(summary = "网关列表-分页查询")
  39. @RequestMapping(value = {"pageGateWay"}, method = {RequestMethod.POST})
  40. public ResultContent<Page<GateWayInfoModel>> pageGateWay(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, GateWayInfoSearchParam param) {
  41. return gateWayInfoService.pageGateWay(pageable, param);
  42. }
  43. @Operation(summary = "删除网关")
  44. @RequestMapping(value = "deleteGateWayInfo", method = {RequestMethod.GET})
  45. public ResultContent deleteGateWayInfo(String gateWayId) {
  46. return gateWayInfoService.deleteGateWayInfo(gateWayId);
  47. }
  48. @Operation(summary = "查询网关")
  49. @RequestMapping(value = "getGateWayById", method = {RequestMethod.GET})
  50. public ResultContent<GateWayInfoModel> getGateWayById(String deviceId) {
  51. return gateWayInfoService.getById(deviceId);
  52. }
  53. @Operation(summary = "网关绑定设备、连接账号")
  54. @RequestMapping(value = "gateWayBindDevice", method = {RequestMethod.POST})
  55. public ResultContent gateWayBindDevice(@RequestBody GateWayBindDeviceParam param) {
  56. Assert.hasText(param.getGateWayId(), "网关ID不能为空");
  57. Assert.hasText(param.getUserName(), "连接账号不能为空");
  58. return gateWayInfoService.gateWayBindDevice(param);
  59. }
  60. }