package com.dcs.hnyz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.ActionConfig;
import com.dcs.hnyz.service.IActionConfigService;
import com.dcs.common.utils.poi.ExcelUtil;
import com.dcs.common.core.page.TableDataInfo;

/**
 * 动作配置管理Controller
 * 
 * @author hmy
 * @date 2025-04-28
 */
@Api(tags = "动作配置管理")
@RestController
@RequestMapping("/hnyz/actionConfig")
public class ActionConfigController extends BaseController
{
    @Autowired
    private IActionConfigService actionConfigService;

    /**
     * 查询动作配置管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionConfig:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询动作配置管理列表", notes = "查询动作配置管理列表")
    public TableDataInfo list(@ApiParam(name = "动作配置相关参数",value = "动作配置对象") ActionConfig actionConfig)
    {
        startPage();
        List<ActionConfig> list = actionConfigService.selectActionConfigList(actionConfig);
        return getDataTable(list);
    }

    /**
     * 导出动作配置管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionConfig:export')")
    @Log(title = "动作配置管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActionConfig actionConfig)
    {
        List<ActionConfig> list = actionConfigService.selectActionConfigList(actionConfig);
        ExcelUtil<ActionConfig> util = new ExcelUtil<ActionConfig>(ActionConfig.class);
        util.exportExcel(response, list, "动作配置管理数据");
    }

    /**
     * 获取动作配置管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionConfig:query')")
    @GetMapping(value = "/{actionId}")
    @ApiOperation(value = "获取动作配置管理详细信息", notes = "获取动作配置管理详细信息")
    public AjaxResult getInfo(@PathVariable("actionId") @ApiParam("动作id") Long actionId)
    {
        return success(actionConfigService.selectActionConfigByActionId(actionId));
    }

    /**
     * 新增动作配置管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionConfig:add')")
    @Log(title = "动作配置管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增动作配置管理", notes = "新增动作配置管理")
    public AjaxResult add(@RequestBody ActionConfig actionConfig)
    {
        return toAjax(actionConfigService.insertActionConfig(actionConfig));
    }

    /**
     * 修改动作配置管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionConfig:edit')")
    @Log(title = "动作配置管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改动作配置管理", notes = "修改动作配置管理")
    public AjaxResult edit(@RequestBody ActionConfig actionConfig)
    {
        return toAjax(actionConfigService.updateActionConfig(actionConfig));
    }

    /**
     * 删除动作配置管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionConfig:remove')")
    @Log(title = "动作配置管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{actionIds}")
    @ApiOperation(value = "删除动作配置管理", notes = "删除动作配置管理")
    public AjaxResult remove(@ApiParam(name = "动作id数组",value = "动作id数组")@PathVariable Long[] actionIds)
    {
        return toAjax(actionConfigService.deleteActionConfigByActionIds(actionIds));
    }

    /**
     * 修改启用状态
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionConfig:edit')")
    @Log(title = "动作配置管理", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(ActionConfig actionConfig){
        return toAjax(actionConfigService.updateActionConfig(actionConfig));
    }
}
