package com.ruoyi.web.controller.weighbridge;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.domain.entity.DibangDriver;
import com.ruoyi.weighbridge.service.IDibangDriverService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 司机管理Controller
 * 
 * @author liuhj
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/weighbridge/dibangDriver")
public class DibangDriverController extends BaseController
{
    @Autowired
    private IDibangDriverService dibangDriverService;

    /**
     * 查询司机管理列表
     */
    @PreAuthorize("@ss.hasPermi('weighbridge:dibangDriver:list')")
    @GetMapping("/list")
    public TableDataInfo list(DibangDriver dibangDriver)
    {
        startPage();
        List<DibangDriver> list = dibangDriverService.selectDibangDriverList(dibangDriver);
        return getDataTable(list);
    }

    /**
     * 导出司机管理列表
     */
    @PreAuthorize("@ss.hasPermi('weighbridge:dibangDriver:export')")
    @Log(title = "司机管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DibangDriver dibangDriver)
    {
        List<DibangDriver> list = dibangDriverService.selectDibangDriverList(dibangDriver);
        ExcelUtil<DibangDriver> util = new ExcelUtil<DibangDriver>(DibangDriver.class);
        util.exportExcel(response, list, "司机管理数据");
    }

    /**
     * 获取司机管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('weighbridge:dibangDriver:query')")
    @GetMapping(value = "/{driverId}")
    public AjaxResult getInfo(@PathVariable("driverId") String driverId)
    {
        return AjaxResult.success(dibangDriverService.selectDibangDriverByDriverId(driverId));
    }

    /**
     * 新增司机管理
     */
    @PreAuthorize("@ss.hasPermi('weighbridge:dibangDriver:add')")
    @Log(title = "司机管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DibangDriver dibangDriver)
    {
        return toAjax(dibangDriverService.insertDibangDriver(dibangDriver));
    }

    /**
     * 修改司机管理
     */
    @PreAuthorize("@ss.hasPermi('weighbridge:dibangDriver:edit')")
    @Log(title = "司机管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DibangDriver dibangDriver)
    {
        return toAjax(dibangDriverService.updateDibangDriver(dibangDriver));
    }

    /**
     * 删除司机管理
     */
    @PreAuthorize("@ss.hasPermi('weighbridge:dibangDriver:remove')")
    @Log(title = "司机管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{driverIds}")
    public AjaxResult remove(@PathVariable String[] driverIds)
    {
        return toAjax(dibangDriverService.deleteDibangDriverByDriverIds(driverIds));
    }
}
