package com.zcloud.personnel.positioning.web;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.personnel.positioning.api.PositionVehicleServiceI;
import com.zcloud.personnel.positioning.dto.PositionVehiclePageQry;
import com.zcloud.personnel.positioning.dto.clientobject.OptionCO;
import com.zcloud.personnel.positioning.dto.clientobject.PositionVehicleCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "定位车辆菜单")
@RestController
@RequiredArgsConstructor
@RequestMapping("/${application.gateway}/positionVehicle")
public class PositionVehicleController {
    private final PositionVehicleServiceI positionVehicleService;

    @ApiOperation("定位车辆分页查询，暂未对接车辆数据")
    @PostMapping("/list")
    public PageResponse<PositionVehicleCO> list(
            @RequestBody(required = false) PositionVehiclePageQry qry) {
        return positionVehicleService.list(qry);
    }

    @ApiOperation("定位车辆公司选项，暂未对接车辆数据")
    @GetMapping("/company/options")
    public MultiResponse<OptionCO> companyOptions(
            @RequestParam(value = "keyword", required = false) String keyword) {
        return MultiResponse.of(positionVehicleService.listCompanyOptions(keyword));
    }

    @ApiOperation("定位车辆详情查询，暂未对接车辆数据")
    @GetMapping("/{vehicleId}")
    public SingleResponse<PositionVehicleCO> queryById(@PathVariable("vehicleId") Long vehicleId) {
        return SingleResponse.of(positionVehicleService.queryById(vehicleId));
    }
}
