package com.clx.performance.controller.pc.vehiclewarn;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.param.pc.vehiclewarn.PageVehicleWarnInfoParam;
import com.clx.performance.param.pc.vehiclewarn.VehicleWarnInfoResolveUpdateParam;
import com.clx.performance.param.pc.vehiclewarn.VehicleWarnInfoSuspendUpdateParam;
import com.clx.performance.service.vehiclewarn.VehicleWarnInfoService;
import com.clx.performance.vo.pc.vehiclewarn.VehicleTraceVO;
import com.clx.performance.vo.pc.vehiclewarn.VehicleWarnInfoVO;
import com.msl.common.base.PageData;
import com.msl.common.result.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.constraints.NotNull;


@Slf4j
@RestController
@Validated
@Tag(name = "车辆预警-预警信息")
@RequestMapping(value="/pc/owner/vehicleWarnInfo")
public class VehicleWarnInfoController {

    @Autowired
    private VehicleWarnInfoService vehicleWarnInfoService;


    @Operation(summary = "更新预警暂停", description = "<br>By:艾庆国")
    @PostMapping("/updateSuspend")
    public Result<Void> updateSuspend(@RequestBody @Validated VehicleWarnInfoSuspendUpdateParam param) {
        vehicleWarnInfoService.updateSuspend(param);
        return Result.ok();
    }

    @Operation(summary = "更新处理", description = "<br>By:艾庆国")
    @PostMapping("/updateResolve")
    public Result<Void> updateConfig(@RequestBody @Validated VehicleWarnInfoResolveUpdateParam param) {
        vehicleWarnInfoService.updateResolve(param);
        return Result.ok();
    }

    @Operation(summary = "获取轨迹",description = "<br>By:艾庆国")
    @GetMapping("/getTrace")
    public Result<VehicleTraceVO> getTrace(@NotNull(message = "id不能为空") @Validated Integer id) {
        return Result.ok(vehicleWarnInfoService.getTrace(id));
    }

    @Operation(summary = "获取预警信息",description = "<br>By:艾庆国")
    @GetMapping("/getInfo")
    public Result<VehicleWarnInfoVO> getInfo(@NotNull(message = "id不能为空") @Validated Integer id) {
        return Result.ok(vehicleWarnInfoService.getInfo(id));
    }

    @Operation(summary = "分页搜索预警信息列表",description = "<br>By:艾庆国")
    @PostMapping("/pageInfo")
    public Result<PageData<VehicleWarnInfoVO>> pageInfo(@RequestBody @Validated PageVehicleWarnInfoParam param) {
        IPage<VehicleWarnInfoVO> page = vehicleWarnInfoService.pageInfo(param);
        return Result.page(page.getRecords(), page.getTotal(), page.getPages());
    }

}
