package com.uavps.system.controller;

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.uavps.common.annotation.Log;
import com.uavps.common.core.controller.BaseController;
import com.uavps.common.core.domain.AjaxResult;
import com.uavps.common.enums.BusinessType;
import com.uavps.system.domain.UavpsTask;
import com.uavps.system.service.IUavpsTaskService;
import com.uavps.common.utils.poi.ExcelUtil;
import com.uavps.common.core.page.TableDataInfo;

/**
 * 任务数据Controller
 * 
 * @author ruoyi
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/system/task")
public class UavpsTaskController extends BaseController
{
    @Autowired
    private IUavpsTaskService uavpsTaskService;

    /**
     * 查询任务数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(UavpsTask uavpsTask)
    {
        startPage();
        List<UavpsTask> list = uavpsTaskService.selectUavpsTaskList(uavpsTask);
        return getDataTable(list);
    }

    /**
     * 导出任务数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:task:export')")
    @Log(title = "任务数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UavpsTask uavpsTask)
    {
        List<UavpsTask> list = uavpsTaskService.selectUavpsTaskList(uavpsTask);
        ExcelUtil<UavpsTask> util = new ExcelUtil<UavpsTask>(UavpsTask.class);
        util.exportExcel(response, list, "任务数据数据");
    }

    /**
     * 获取任务数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:task:query')")
    @GetMapping(value = "/{bizId}")
    public AjaxResult getInfo(@PathVariable("bizId") Long bizId)
    {
        return success(uavpsTaskService.selectUavpsTaskByBizId(bizId));
    }

    /**
     * 新增任务数据
     */
    @PreAuthorize("@ss.hasPermi('system:task:add')")
    @Log(title = "任务数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UavpsTask uavpsTask)
    {
        return toAjax(uavpsTaskService.insertUavpsTask(uavpsTask));
    }

    /**
     * 修改任务数据
     */
    @PreAuthorize("@ss.hasPermi('system:task:edit')")
    @Log(title = "任务数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UavpsTask uavpsTask)
    {
        return toAjax(uavpsTaskService.updateUavpsTask(uavpsTask));
    }

    /**
     * 删除任务数据
     */
    @PreAuthorize("@ss.hasPermi('system:task:remove')")
    @Log(title = "任务数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bizIds}")
    public AjaxResult remove(@PathVariable Long[] bizIds)
    {
        return toAjax(uavpsTaskService.deleteUavpsTaskByBizIds(bizIds));
    }
}
