package com.muyu.event.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.event.domian.AddCarInformation;
import com.muyu.event.domian.CarInformation;
import com.muyu.event.service.IoTDBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * iotdb数据CRUD
 * @author 刘武
 * @package：com.muyu.event.controller
 * @name：ItodbController
 * @date：2024/9/28 19:17
 */
@RestController()
public class IoTDBController {

    @Autowired
    private IoTDBService tdbService;


    /**
     * 查询实时车辆信息列表
     * @return list
     */
    @GetMapping("findIoTDBList")
    private Result<List<CarInformation>> findIoTDBList(){
        List<CarInformation> list=tdbService.findIoTDBList();
        return Result.success(list);
    };

    /**
     * 根据车辆vin 查询车辆实时信息
     * @param carVin
     * @return
     */
    @GetMapping("findIoTDBByVin")
    public Result<CarInformation> findIoTDBByVin(@RequestParam("carVin") String carVin){
        CarInformation carInformation=tdbService.findIoTDBByVin(carVin);
        return Result.success(carInformation);
    };


    /**
     * 车辆添加
     * @param addCarInformation
     * @return
     */
    @GetMapping("insertIoTDB")
    public Result insertIoTDB(@RequestBody AddCarInformation addCarInformation){
        tdbService.insertIoTDB(addCarInformation);
        return Result.success("添加成功");
    };













}
