LocationController.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.zy.bms.controller.wx;
  2. import com.zy.bms.common.ServerResponse;
  3. import com.zy.bms.common.controller.BaseController;
  4. import com.zy.bms.common.io.wechat.DeviceHistoryIO;
  5. import com.zy.bms.service.DeviceLocationService;
  6. import com.zy.bms.service.RelationService;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PostMapping;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RestController;
  11. import javax.annotation.Resource;
  12. /**
  13. * 设备定位相关
  14. *
  15. * @author yang xiao kun
  16. * create on 2021/1/21
  17. */
  18. @RestController
  19. @RequestMapping("zy4g/api/location")
  20. public class LocationController extends BaseController {
  21. @Resource
  22. private DeviceLocationService locationService;
  23. @Resource
  24. private RelationService relationService;
  25. /**
  26. * 通过设备ID获取最新的定位信息
  27. */
  28. @GetMapping("getLocation.do")
  29. public ServerResponse getLocation(String deviceId) {
  30. if (!relationService.checkDeviceIsBelongByDeviceId(getUserId(), deviceId)) {
  31. return ServerResponse.createByIllegal();
  32. }
  33. return ServerResponse.createBySuccess(locationService.getLocation(deviceId));
  34. }
  35. /**
  36. * 查看设备历史轨迹
  37. */
  38. @PostMapping("getHistory.do")
  39. public ServerResponse getHistory(DeviceHistoryIO io) {
  40. return ServerResponse.createBySuccess(locationService.getHistory(io));
  41. }
  42. }