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.ActionBinding;
import com.dcs.hnyz.service.IActionBindingService;
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/actionBinding")
public class ActionBindingController extends BaseController
{
    @Autowired
    private IActionBindingService actionBindingService;

    /**
     * 查询动作关联管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionBinding:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询动作关联管理列表")
    public TableDataInfo list(@ApiParam(name = "动作关联对象",value = "动作关联对象") ActionBinding actionBinding)
    {
        startPage();
        List<ActionBinding> list = actionBindingService.selectActionBindingList(actionBinding);
        return getDataTable(list);
    }

    /**
     * 导出动作关联管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionBinding:export')")
    @Log(title = "动作关联管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出动作关联管理列表")
    public void export(HttpServletResponse response, ActionBinding actionBinding)
    {
        List<ActionBinding> list = actionBindingService.selectActionBindingList(actionBinding);
        ExcelUtil<ActionBinding> util = new ExcelUtil<ActionBinding>(ActionBinding.class);
        util.exportExcel(response, list, "动作关联管理数据");
    }

    /**
     * 获取动作关联管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionBinding:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取动作关联管理详细信息")
    public AjaxResult getInfo(@PathVariable("id") @ApiParam("动作关联id") Long id)
    {
        return success(actionBindingService.selectActionBindingById(id));
    }

    /**
     * 新增动作关联管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionBinding:add')")
    @Log(title = "动作关联管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增动作关联管理")
    public AjaxResult add(@RequestBody ActionBinding actionBinding)
    {
        return toAjax(actionBindingService.insertActionBinding(actionBinding));
    }

    /**
     * 修改动作关联管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionBinding:edit')")
    @Log(title = "动作关联管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改动作关联管理")
    public AjaxResult edit(@RequestBody ActionBinding actionBinding)
    {
        return toAjax(actionBindingService.updateActionBinding(actionBinding));
    }

    /**
     * 删除动作关联管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionBinding:remove')")
    @Log(title = "动作关联管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除动作关联管理")
    public AjaxResult remove(@ApiParam("id数组,中间用英文逗号隔开") @PathVariable Long[] ids)
    {
        return toAjax(actionBindingService.deleteActionBindingByIds(ids));
    }

    /**
     * 修改启用状态
     */
    @PreAuthorize("@ss.hasPermi('hnyz:actionBinding:edit')")
    @Log(title = "动作关联管理", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody ActionBinding actionBinding){
        return toAjax(actionBindingService.changeStatus(actionBinding));
    }
}
