56 lines
1.7 KiB
Java
56 lines
1.7 KiB
Java
package com.cdzy.ebikeoperate.controller;
|
|
|
|
import com.cdzy.common.model.EbikeTracking;
|
|
import com.cdzy.common.model.JsonResult;
|
|
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikeTrackingDto;
|
|
import com.cdzy.ebikeoperate.model.dto.response.EbikeTrackingDto;
|
|
import com.cdzy.ebikeoperate.service.EbikeTrackingService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 车辆轨迹查询 控制层。
|
|
*
|
|
* @author dingchao
|
|
* @date 2025/4/2
|
|
* @modified by:
|
|
*/
|
|
@Slf4j
|
|
@RestController
|
|
@RequestMapping("/ebikeTracking")
|
|
public class EbikeTrackingController {
|
|
|
|
@Autowired
|
|
private EbikeTrackingService ebikeTrackingService;
|
|
|
|
/**
|
|
* 保存车辆轨迹。
|
|
*
|
|
* @param ebikeTracking 车辆轨迹
|
|
* @return
|
|
*/
|
|
@PostMapping("save")
|
|
public JsonResult<?> save(@RequestBody EbikeTracking ebikeTracking) {
|
|
boolean result = ebikeTrackingService.save(ebikeTracking);
|
|
return result ? JsonResult.success("保存车辆轨迹成功") : JsonResult.failed("保存车辆轨迹失败");
|
|
}
|
|
|
|
/**
|
|
* 车辆轨迹查询。
|
|
*
|
|
* @param reqEbikeTrackingDto 查询参数
|
|
* @return
|
|
*/
|
|
@PostMapping("query")
|
|
public JsonResult<?> query(@RequestBody ReqEbikeTrackingDto reqEbikeTrackingDto) {
|
|
if (reqEbikeTrackingDto.getInterval() == null|| reqEbikeTrackingDto.getInterval().isEmpty()) {
|
|
reqEbikeTrackingDto.setInterval("10s");
|
|
}
|
|
List<EbikeTrackingDto> result = ebikeTrackingService.query(reqEbikeTrackingDto);
|
|
return JsonResult.success(result);
|
|
}
|
|
}
|