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.DcsGroupTask;
import com.dcs.hnyz.service.IDcsGroupTaskService;
import com.dcs.common.utils.poi.ExcelUtil;
import com.dcs.common.core.page.TableDataInfo;

/**
 * 任务动作组Controller
 *
 * @author wuhb
 * @date 2025-08-04
 */
@RestController
@RequestMapping("/hnyz/groupTask")
public class DcsGroupTaskController extends BaseController
{
    @Autowired
    private IDcsGroupTaskService dcsGroupTaskService;

    /**
     * 查询任务动作组列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:groupTask:list')")
    @GetMapping("/list")
    public TableDataInfo list(DcsGroupTask dcsGroupTask)
    {
        startPage();
        List<DcsGroupTask> list = dcsGroupTaskService.selectDcsGroupTaskList(dcsGroupTask);
        return getDataTable(list);
    }

    /**
     * 导出任务动作组列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:groupTask:export')")
    @Log(title = "任务动作组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DcsGroupTask dcsGroupTask)
    {
        List<DcsGroupTask> list = dcsGroupTaskService.selectDcsGroupTaskList(dcsGroupTask);
        ExcelUtil<DcsGroupTask> util = new ExcelUtil<DcsGroupTask>(DcsGroupTask.class);
        util.exportExcel(response, list, "任务动作组数据");
    }

    /**
     * 获取任务动作组详细信息
     */
    @PreAuthorize("@ss.hasPermi('hnyz:groupTask:query')")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
    {
        return success(dcsGroupTaskService.selectDcsGroupTaskByGroupId(groupId));
    }

    /**
     * 新增任务动作组
     */
    @PreAuthorize("@ss.hasPermi('hnyz:groupTask:add')")
    @Log(title = "任务动作组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DcsGroupTask dcsGroupTask)
    {
        dcsGroupTask.setCreateBy(getUsername());
        return toAjax(dcsGroupTaskService.insertDcsGroupTask(dcsGroupTask));
    }

    /**
     * 修改任务动作组
     */
    @PreAuthorize("@ss.hasPermi('hnyz:groupTask:edit')")
    @Log(title = "任务动作组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DcsGroupTask dcsGroupTask)
    {
        dcsGroupTask.setUpdateBy(getUsername());
        return toAjax(dcsGroupTaskService.updateDcsGroupTask(dcsGroupTask));
    }

    /**
     * 删除任务动作组
     */
    @PreAuthorize("@ss.hasPermi('hnyz:groupTask:remove')")
    @Log(title = "任务动作组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable Long[] groupIds)
    {
        return toAjax(dcsGroupTaskService.deleteDcsGroupTaskByGroupIds(groupIds));
    }
}
