package com.muyu.event.controller;

import com.muyu.demos.model.Result;
import com.muyu.event.common.VehicleEvent;
import com.muyu.event.service.EventService;
import com.muyu.mqtt.dao.MessageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 事件处理器控制层 EventController
 *
 * @author Yangle
 * Date 2024/6/17 19:53
 */
@RestController("/event")
public class EventController {


    @Autowired
    private EventService eventService;

    @PostMapping("/selectVehicleEvent")
    public Result<List<VehicleEvent>> selectVehicleEvent() {
        return Result.success(eventService.selectVehicleEvent());
    }
    @PostMapping("/bindingEvent")
    public Result<List<VehicleEvent>> bindingEvent(@RequestBody VehicleEvent vehicleEvent) {
        return Result.success(eventService.getCarEventList(vehicleEvent));
    }

    @PostMapping("/selectEvent")
    public Result selectEvent(@RequestBody VehicleEvent vehicleEvent) {
        Result<MessageData> messageDataResult = eventService.selectEvent(vehicleEvent);
        return messageDataResult;
    }

    @PostMapping("/eventAddRedis")
    public Result eventAddRedis(@RequestBody VehicleEvent vehicleEvent) {
        eventService.eventAddRedis(vehicleEvent);
        return Result.success();
    }

    @PostMapping("/getMaximumCoordinate")
    public Result getMaximumCoordinate(@RequestBody VehicleEvent vehicleEvent) {

        return eventService.getMaximumCoordinate(vehicleEvent.getVin());
    }
}
