package com.cpxt.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cpxt.biz.domain.StatCar;
import com.cpxt.biz.service.IStatCarService;
import com.cpxt.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cpxt.common.annotation.Log;
import com.cpxt.common.core.controller.BaseController;
import com.cpxt.common.core.domain.AjaxResult;
import com.cpxt.common.enums.BusinessType;
import com.cpxt.common.core.page.TableDataInfo;

/**
 * 车辆统计Controller
 * 
 * @author ruoyi
 * @date 2024-12-31
 */
@RestController
@RequestMapping("/system/car")
public class StatCarController extends BaseController
{
    @Autowired
    private IStatCarService statCarService;

    /**
     * 查询车辆统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:car:list')")
    @GetMapping("/list")
    public TableDataInfo list(StatCar statCar)
    {
        startPage();
        List<StatCar> list = statCarService.selectStatCarList(statCar);
        return getDataTable(list);
    }

    /**
     * 导出车辆统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:car:export')")
    @Log(title = "车辆统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StatCar statCar)
    {
        List<StatCar> list = statCarService.selectStatCarList(statCar);
        ExcelUtil<StatCar> util = new ExcelUtil<StatCar>(StatCar.class);
        util.exportExcel(response, list, "车辆统计数据");
    }

    /**
     * 获取车辆统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:car:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(statCarService.selectStatCarById(id));
    }

    /**
     * 新增车辆统计
     */
    @PreAuthorize("@ss.hasPermi('system:car:add')")
    @Log(title = "车辆统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StatCar statCar)
    {
        return toAjax(statCarService.insertStatCar(statCar));
    }

    /**
     * 修改车辆统计
     */
    @PreAuthorize("@ss.hasPermi('system:car:edit')")
    @Log(title = "车辆统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StatCar statCar)
    {
        return toAjax(statCarService.updateStatCar(statCar));
    }

    /**
     * 删除车辆统计
     */
    @PreAuthorize("@ss.hasPermi('system:car:remove')")
    @Log(title = "车辆统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(statCarService.deleteStatCarByIds(ids));
    }
}
