package com.njzscloud.supervisory.hsoa.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.hsoa.Hsoa;
import com.njzscloud.supervisory.hsoa.constant.PushType;
import com.njzscloud.supervisory.hsoa.pojo.entity.HsoaRecode;
import com.njzscloud.supervisory.hsoa.pojo.param.PushProvincialSaveParam;
import com.njzscloud.supervisory.hsoa.pojo.param.PushVehicleTrajectoryParam;
import com.njzscloud.supervisory.hsoa.pojo.result.HsoaResult;
import com.njzscloud.supervisory.hsoa.service.HsoaService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequiredArgsConstructor
@RequestMapping("/hsoa")
public class HsoaController {

    private final HsoaService hsoaService;

    @PostMapping("/push_vehicle_trajectory")
    public R<?> pushVehicleTrajectory(@RequestBody PushVehicleTrajectoryParam pushVehicleTrajectoryParam) {
        HsoaResult<?> objectHsoaResult = Hsoa.pushVehicleTrajectory(pushVehicleTrajectoryParam);
        return R.success(objectHsoaResult);
    }

    @PostMapping("/push_provincial")
    public R<?> pushProvincial(@RequestParam PushProvincialSaveParam param) {
        HsoaResult<?> hsoaResult = Hsoa.pushProvincial(param);
        return R.success(hsoaResult);
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<HsoaRecode>> paging(PageParam pageParam,
                                            @RequestParam("pushType") PushType pushType,
                                            @RequestParam(value = "orderSn", required = false) String orderSn,
                                            @RequestParam(value = "licensePlate", required = false) String licensePlate,
                                            @RequestParam(value = "success", required = false) Boolean success,
                                            @RequestParam(value = "startTime", required = false) LocalDateTime startTime,
                                            @RequestParam(value = "endTime", required = false) LocalDateTime endTime
    ) {
        return R.success(hsoaService.paging(pageParam, orderSn, licensePlate, pushType, success, startTime, endTime));
    }

}
