60 lines
1.8 KiB
Java
60 lines
1.8 KiB
Java
package com.cdzy.operations.controller;
|
|
|
|
|
|
import com.cdzy.common.model.dto.EbikeTracking;
|
|
import com.cdzy.common.model.response.JsonResult;
|
|
import com.cdzy.common.model.dto.EbikeTrackingDto;
|
|
import com.cdzy.common.model.dto.ReqEbikeTrackingDto;
|
|
import com.cdzy.operations.service.EbikeTrackingService;
|
|
import jakarta.annotation.Resource;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 车辆轨迹查询 控制层。
|
|
*
|
|
* @author attiya
|
|
* @since 2025/4/2
|
|
*/
|
|
@Slf4j
|
|
@RestController
|
|
@RequestMapping("/ebikeTracking")
|
|
public class EbikeTrackingController {
|
|
|
|
@Resource
|
|
private EbikeTrackingService ebikeTrackingService;
|
|
|
|
|
|
|
|
/**
|
|
* 保存车辆轨迹。
|
|
*
|
|
* @param ebikeTracking 车辆轨迹
|
|
*/
|
|
@PostMapping("save")
|
|
public JsonResult<?> save(@RequestBody EbikeTracking ebikeTracking) {
|
|
boolean result = ebikeTrackingService.save(ebikeTracking);
|
|
return result ? JsonResult.success("保存车辆轨迹成功") : JsonResult.failed("保存车辆轨迹失败");
|
|
}
|
|
|
|
/**
|
|
* 车辆轨迹查询。
|
|
*
|
|
* @param reqEbikeTrackingDto 查询参数
|
|
*/
|
|
@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);
|
|
}
|
|
|
|
}
|