package com.ruoyi.web.controller.manage;

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.manage.domain.TaskManage;
import com.ruoyi.manage.service.ITaskManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务管理Controller
 *
 * @author boman
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/manage/taskManage")
public class TaskManageController extends BaseController
{
    @Autowired
    private ITaskManageService taskManageService;

/**
 * 查询任务管理列表
 */
@PreAuthorize("@ss.hasPermi('manage:taskManage:list')")
@GetMapping("/list")
    public TableDataInfo list(TaskManage taskManage)
    {
        startPage();
        List<TaskManage> list = taskManageService.selectTaskManageList(taskManage);
        return getDataTable(list);
    }

    /**
     * 导出任务管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:taskManage:export')")
    @Log(title = "任务管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TaskManage taskManage)
    {
        List<TaskManage> list = taskManageService.selectTaskManageList(taskManage);
        ExcelUtil<TaskManage> util = new ExcelUtil<TaskManage>(TaskManage.class);
        util.exportExcel(response, list, "任务管理数据");
    }

    /**
     * 获取任务管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:taskManage:query')")
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
    {
        return success(taskManageService.selectTaskManageByTaskId(taskId));
    }

    /**
     * 新增任务管理
     */
    @PreAuthorize("@ss.hasPermi('manage:taskManage:add')")
    @Log(title = "任务管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskManage taskManage)
    {
        return toAjax(taskManageService.insertTaskManage(taskManage));
    }

    /**
     * 修改任务管理
     */
    @PreAuthorize("@ss.hasPermi('manage:taskManage:edit')")
    @Log(title = "任务管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody TaskManage taskManage)
    {
        return toAjax(taskManageService.updateTaskManage(taskManage));
    }

    /**
     * 删除任务管理
     */
    @PreAuthorize("@ss.hasPermi('manage:taskManage:remove')")
    @Log(title = "任务管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{taskIds}")
    public AjaxResult remove(@PathVariable Long[] taskIds)
    {
        return toAjax(taskManageService.deleteTaskManageByTaskIds(taskIds));
    }
}
