package com.evobms.project.ota.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.evobms.framework.aspectj.lang.annotation.Log;
import com.evobms.framework.aspectj.lang.enums.BusinessType;
import com.evobms.project.ota.domain.OtaTasks;
import com.evobms.project.ota.service.IOtaTasksService;
import com.evobms.framework.web.controller.BaseController;
import com.evobms.framework.web.domain.AjaxResult;
import com.evobms.common.utils.poi.ExcelUtil;
import com.evobms.framework.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * OTA任务Controller
 *
 * @author ruoyi
 * @date 2025-10-14
 */
@RestController
@RequestMapping("/ota/tasks")
@Api(tags = "OTA任务管理")
public class OtaTasksController extends BaseController
{
    @Autowired
    private IOtaTasksService otaTasksService;

    /**
     * 查询OTA任务列表
     */
    //@PreAuthorize("@ss.hasPermi('OTA:tasks:list')")
    @GetMapping("/list")
    @ApiOperation("查询OTA任务列表")
    public TableDataInfo list(OtaTasks otaTasks)
    {
        startPage();
        List<OtaTasks> list = otaTasksService.selectOtaTasksList(otaTasks);
        return getDataTable(list);
    }

    /**
     * 导出OTA任务列表
     */
    //@PreAuthorize("@ss.hasPermi('OTA:tasks:export')")
    @Log(title = "OTA任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出OTA任务列表")
    public void export(HttpServletResponse response, OtaTasks otaTasks)
    {
        List<OtaTasks> list = otaTasksService.selectOtaTasksList(otaTasks);
        ExcelUtil<OtaTasks> util = new ExcelUtil<OtaTasks>(OtaTasks.class);
        util.exportExcel(response, list, "OTA任务数据");
    }

    /**
     * 获取OTA任务详细信息
     */
    //@PreAuthorize("@ss.hasPermi('OTA:tasks:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取OTA任务详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(otaTasksService.selectOtaTasksById(id));
    }

    /**
     * 新增OTA任务
     */
    //@PreAuthorize("@ss.hasPermi('OTA:tasks:add')")
    @Log(title = "OTA任务", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增OTA任务")
    public AjaxResult add(@RequestBody OtaTasks otaTasks)
    {
        return toAjax(otaTasksService.insertOtaTasks(otaTasks));
    }

    /**
     * 修改OTA任务
     */
    //@PreAuthorize("@ss.hasPermi('OTA:tasks:edit')")
    @Log(title = "OTA任务", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改OTA任务")
    public AjaxResult edit(@RequestBody OtaTasks otaTasks)
    {
        return toAjax(otaTasksService.updateOtaTasks(otaTasks));
    }

    /**
     * 删除OTA任务
     */
    @Log(title = "OTA任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除OTA任务")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(otaTasksService.deleteOtaTasksByIds(ids));
    }
}
