package com.zy.bms.controller.wx; import com.zy.bms.common.ServerResponse; import com.zy.bms.common.controller.BaseController; import com.zy.bms.common.io.wechat.DeviceHistoryIO; import com.zy.bms.service.DeviceLocationService; import com.zy.bms.service.RelationService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; /** * 设备定位相关 * * @author yang xiao kun * create on 2021/1/21 */ @RestController @RequestMapping("zy4g/api/location") public class LocationController extends BaseController { @Resource private DeviceLocationService locationService; @Resource private RelationService relationService; /** * 通过设备ID获取最新的定位信息 */ @GetMapping("getLocation.do") public ServerResponse getLocation(String deviceId) { if (!relationService.checkDeviceIsBelongByDeviceId(getUserId(), deviceId)) { return ServerResponse.createByIllegal(); } return ServerResponse.createBySuccess(locationService.getLocation(deviceId)); } /** * 查看设备历史轨迹 */ @PostMapping("getHistory.do") public ServerResponse getHistory(DeviceHistoryIO io) { return ServerResponse.createBySuccess(locationService.getHistory(io)); } }