GateWayUserInfoController.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.zswl.dataservice.controller;
  2. import com.zswl.dataservice.model.mqtt.*;
  3. import com.zswl.dataservice.service.mqtt.DeviceInfoService;
  4. import com.zswl.dataservice.service.mqtt.GateWayUserInfoService;
  5. import com.zswl.dataservice.utils.result.ResultContent;
  6. import io.swagger.v3.oas.annotations.Operation;
  7. import io.swagger.v3.oas.annotations.Parameter;
  8. import io.swagger.v3.oas.annotations.tags.Tag;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.data.domain.Page;
  11. import org.springframework.data.domain.Pageable;
  12. import org.springframework.data.web.PageableDefault;
  13. import org.springframework.util.Assert;
  14. import org.springframework.validation.annotation.Validated;
  15. import org.springframework.web.bind.annotation.RequestBody;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RequestMethod;
  18. import org.springframework.web.bind.annotation.RestController;
  19. /**
  20. * 连接用户管理 服务
  21. *
  22. * @author TRX
  23. * @date 2024/3/21
  24. */
  25. @RequestMapping("/gateWayUserInfo/free")
  26. @RestController
  27. @Validated
  28. @Tag(name = "连接用户管理")
  29. public class GateWayUserInfoController {
  30. @Autowired
  31. GateWayUserInfoService gateWayUserInfoService;
  32. @Operation(summary = "添加连接用户")
  33. @RequestMapping(value = "addDeviceInfo", method = {RequestMethod.POST})
  34. public ResultContent addDeviceInfo(@RequestBody GateWayUserInfoAddParam param) {
  35. Assert.hasText(param.getUserName(), "连接账号不能为空");
  36. Assert.hasText(param.getPassWord(), "连接密码不能为空");
  37. return gateWayUserInfoService.addGateWayUser(param);
  38. }
  39. @Operation(summary = "连接用户列表-分页查询")
  40. @RequestMapping(value = {"pageGateWayUser"}, method = {RequestMethod.POST})
  41. public ResultContent<Page<GateWayUserInfoModel>> pageGateWayUser(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10, sort = "") Pageable pageable, @Parameter(required = false) GateWayUserInfoSearchParam param) {
  42. return gateWayUserInfoService.pageGateWayUser(pageable, param);
  43. }
  44. @Operation(summary = "删除连接用户")
  45. @RequestMapping(value = "deleteMqttUser", method = {RequestMethod.POST})
  46. public ResultContent deleteMqttUser(GateWayUserInfoNameParam param) {
  47. Assert.hasText(param.getUserName(), "连接账号不能为空");
  48. return gateWayUserInfoService.deleteMqttUser(param);
  49. }
  50. @Operation(summary = "启动-停用连接账号")
  51. @RequestMapping(value = "updateState", method = {RequestMethod.POST})
  52. public ResultContent updateState(GateWayUserInfoNameParam param) {
  53. Assert.hasText(param.getUserName(), "连接账号不能为空");
  54. return gateWayUserInfoService.updateState(param);
  55. }
  56. @Operation(summary = "查询连接账号")
  57. @RequestMapping(value = "getUserByUserName", method = {RequestMethod.POST})
  58. public ResultContent<GateWayUserInfoModel> getUserByUserName(GateWayUserInfoNameParam param) {
  59. Assert.hasText(param.getUserName(), "连接账号不能为空");
  60. return gateWayUserInfoService.getUserByUserName(param.getUserName());
  61. }
  62. }