package com.zehong.web.controller.car;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TCar;
import com.zehong.system.service.ITCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 巡检车Controller
 * 
 * @author zehong
 * @date 2026-05-15
 */
@RestController
@RequestMapping("/car/info")
public class TCarController extends BaseController
{
    @Autowired
    private ITCarService tCarService;

    /**
     * 查询巡检车列表
     */
    //@PreAuthorize("@ss.hasPermi('system:car:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCar tCar)
    {
        startPage();
        List<TCar> list = tCarService.selectTCarList(tCar);
        return getDataTable(list);
    }

    /**
     * 导出巡检车列表
     */
    //@PreAuthorize("@ss.hasPermi('system:car:export')")
    @Log(title = "巡检车", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TCar tCar)
    {
        List<TCar> list = tCarService.selectTCarList(tCar);
        ExcelUtil<TCar> util = new ExcelUtil<TCar>(TCar.class);
        return util.exportExcel(list, "巡检车数据");
    }

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

    /**
     * 新增巡检车
     */
    //@PreAuthorize("@ss.hasPermi('system:car:add')")
    @Log(title = "巡检车", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCar tCar)
    {
        return toAjax(tCarService.insertTCar(tCar));
    }

    /**
     * 修改巡检车
     */
    //@PreAuthorize("@ss.hasPermi('system:car:edit')")
    @Log(title = "巡检车", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCar tCar)
    {
        return toAjax(tCarService.updateTCar(tCar));
    }

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