package com.dcs.hnyz.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.dcs.common.annotation.Log;
import com.dcs.common.core.controller.BaseController;
import com.dcs.common.core.domain.AjaxResult;
import com.dcs.common.enums.BusinessType;
import com.dcs.hnyz.domain.DcsRequestTask;
import com.dcs.hnyz.service.IDcsRequestTaskService;
import com.dcs.common.utils.poi.ExcelUtil;
import com.dcs.common.core.page.TableDataInfo;

/**
 * 请求任务Controller
 *
 * @author wuhb
 * @date 2025-08-02
 */
@RestController
@RequestMapping("/hnyz/requesttask")
public class DcsRequestTaskController extends BaseController
{
    @Autowired
    private IDcsRequestTaskService dcsRequestTaskService;

    /**
     * 查询请求任务列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:requesttask:list')")
    @GetMapping("/list")
    public TableDataInfo list(DcsRequestTask dcsRequestTask)
    {
        startPage();
        List<DcsRequestTask> list = dcsRequestTaskService.selectDcsRequestTaskList(dcsRequestTask);
        return getDataTable(list);
    }

    /**
     * 导出请求任务列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:requesttask:export')")
    @Log(title = "请求任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DcsRequestTask dcsRequestTask)
    {
        List<DcsRequestTask> list = dcsRequestTaskService.selectDcsRequestTaskList(dcsRequestTask);
        ExcelUtil<DcsRequestTask> util = new ExcelUtil<DcsRequestTask>(DcsRequestTask.class);
        util.exportExcel(response, list, "请求任务数据");
    }

    /**
     * 获取请求任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('hnyz:requesttask:query')")
    @GetMapping(value = "/{requestId}")
    public AjaxResult getInfo(@PathVariable("requestId") Long requestId)
    {
        return success(dcsRequestTaskService.selectDcsRequestTaskByRequestId(requestId));
    }

    /**
     * 新增请求任务
     */
    @PreAuthorize("@ss.hasPermi('hnyz:requesttask:add')")
    @Log(title = "请求任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DcsRequestTask dcsRequestTask)
    {
        return toAjax(dcsRequestTaskService.insertDcsRequestTask(dcsRequestTask));
    }

    /**
     * 修改请求任务
     */
    @PreAuthorize("@ss.hasPermi('hnyz:requesttask:edit')")
    @Log(title = "请求任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DcsRequestTask dcsRequestTask)
    {
        return toAjax(dcsRequestTaskService.updateDcsRequestTask(dcsRequestTask));
    }

    /**
     * 删除请求任务
     */
    @PreAuthorize("@ss.hasPermi('hnyz:requesttask:remove')")
    @Log(title = "请求任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{requestIds}")
    public AjaxResult remove(@PathVariable Long[] requestIds)
    {
        return toAjax(dcsRequestTaskService.deleteDcsRequestTaskByRequestIds(requestIds));
    }
}
