package com.ningdatech.carapi.car.trips.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.car.monitor.model.dto.LoadMonitorPageParamDTO;
import com.ningdatech.carapi.car.monitor.model.vo.SecurityMonitorVO;
import com.ningdatech.carapi.car.trips.manage.VehicleTripsManage;
import com.ningdatech.carapi.car.trips.model.dto.VehicleTripsParamDTO;
import com.ningdatech.carapi.car.trips.model.vo.VehicleTripsCityVO;
import com.ningdatech.carapi.common.util.ExcelDownUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * <p>
 * 车辆单趟记录 前端控制器
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-11-08
 */
@Controller
@RestController
@RequestMapping(value = "/api/car-manage/trips")
@Api(tags = "车辆管理-车辆趟次")
@Validated
@RequiredArgsConstructor
public class VehicleTripsController {

    private final VehicleTripsManage vehicleTripsManage;

    @ApiOperation("车辆趟次查询-按城市维度")
    @GetMapping("/list-groupby-city")
    public PageVo<VehicleTripsCityVO> lictGroupByCity(@Valid @ModelAttribute VehicleTripsParamDTO param) {
        return vehicleTripsManage.lictGroupByCity(param);
    }

    @ApiOperation(value = "车辆趟次导出", notes = "车辆趟次导出")
    @GetMapping("/export-list-groupby-city")
    public void exportGroupByCity(VehicleTripsParamDTO param, HttpServletResponse response) {
        ExcelDownUtil.downXls(response, param, vehicleTripsManage::exportGroupByCity);
    }
}
