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.TCarTask;
import com.zehong.system.service.ITCarTaskService;
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/task")
public class TCarTaskController extends BaseController
{
    @Autowired
    private ITCarTaskService tCarTaskService;

    /**
     * 查询巡检车任务列表
     */
    //@PreAuthorize("@ss.hasPermi('system:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCarTask tCarTask)
    {
        startPage();
        List<TCarTask> list = tCarTaskService.selectTCarTaskList(tCarTask);
        return getDataTable(list);
    }

    /**
     * 导出巡检车任务列表
     */
    //@PreAuthorize("@ss.hasPermi('system:task:export')")
    @Log(title = "巡检车任务", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TCarTask tCarTask)
    {
        List<TCarTask> list = tCarTaskService.selectTCarTaskList(tCarTask);
        ExcelUtil<TCarTask> util = new ExcelUtil<TCarTask>(TCarTask.class);
        return util.exportExcel(list, "巡检车任务数据");
    }

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

    /**
     * 新增巡检车任务
     */
    //@PreAuthorize("@ss.hasPermi('system:task:add')")
    @Log(title = "巡检车任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCarTask tCarTask)
    {
        return toAjax(tCarTaskService.insertTCarTask(tCarTask));
    }

    /**
     * 修改巡检车任务
     */
    //@PreAuthorize("@ss.hasPermi('system:task:edit')")
    @Log(title = "巡检车任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCarTask tCarTask)
    {
        return toAjax(tCarTaskService.updateTCarTask(tCarTask));
    }

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