package com.cpxt.web.controller.biz;

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

import com.cpxt.biz.domain.StatDriver;
import com.cpxt.biz.service.IStatDriverService;
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.utils.poi.ExcelUtil;
import com.cpxt.common.core.page.TableDataInfo;

/**
 * 司机统计Controller
 * 
 * @author ruoyi
 * @date 2024-12-31
 */
@RestController
@RequestMapping("/system/driver")
public class StatDriverController extends BaseController
{
    @Autowired
    private IStatDriverService statDriverService;

    /**
     * 查询司机统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:driver:list')")
    @GetMapping("/list")
    public TableDataInfo list(StatDriver statDriver)
    {
        startPage();
        List<StatDriver> list = statDriverService.selectStatDriverList(statDriver);
        return getDataTable(list);
    }

    /**
     * 查询司机统计
     */
    @GetMapping("/statics")
    public AjaxResult statics(StatDriver statDriver)
    {
        return AjaxResult.success(statDriverService.statics(statDriver));
    }

    /**
     * 导出司机统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:driver:export')")
    @Log(title = "司机统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StatDriver statDriver)
    {
        List<StatDriver> list = statDriverService.selectStatDriverList(statDriver);
        ExcelUtil<StatDriver> util = new ExcelUtil<StatDriver>(StatDriver.class);
        util.exportExcel(response, list, "司机统计数据");
    }

    /**
     * 获取司机统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:driver:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(statDriverService.selectStatDriverById(id));
    }

    /**
     * 新增司机统计
     */
    @PreAuthorize("@ss.hasPermi('system:driver:add')")
    @Log(title = "司机统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StatDriver statDriver)
    {
        return toAjax(statDriverService.insertStatDriver(statDriver));
    }

    /**
     * 修改司机统计
     */
    @PreAuthorize("@ss.hasPermi('system:driver:edit')")
    @Log(title = "司机统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StatDriver statDriver)
    {
        return toAjax(statDriverService.updateStatDriver(statDriver));
    }

    /**
     * 删除司机统计
     */
    @PreAuthorize("@ss.hasPermi('system:driver:remove')")
    @Log(title = "司机统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(statDriverService.deleteStatDriverByIds(ids));
    }
}
