package com.solution.web.controller.behaviour;

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.solution.common.annotation.Log;
import com.solution.common.core.controller.BaseController;
import com.solution.common.core.domain.AjaxResult;
import com.solution.common.enums.BusinessType;
import com.solution.system.domain.Treenodeinstance;
import com.solution.system.service.ITreenodeinstanceService;
import com.solution.common.utils.poi.ExcelUtil;
import com.solution.common.core.page.TableDataInfo;

/**
 * 行为树实例节点Controller
 * 
 * @author ruoyi
 * @date 2026-02-05
 */
@RestController
@RequestMapping("/system/treenodeinstance")
public class TreenodeinstanceController extends BaseController
{
    @Autowired
    private ITreenodeinstanceService treenodeinstanceService;

    /**
     * 查询行为树实例节点列表
     */
    @PreAuthorize("@ss.hasPermi('system:treenodeinstance:list')")
    @GetMapping("/list")
    public TableDataInfo list(Treenodeinstance treenodeinstance)
    {
        startPage();
        List<Treenodeinstance> list = treenodeinstanceService.selectTreenodeinstanceList(treenodeinstance);
        return getDataTable(list);
    }

    /**
     * 导出行为树实例节点列表
     */
    @PreAuthorize("@ss.hasPermi('system:treenodeinstance:export')")
    @Log(title = "行为树实例节点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Treenodeinstance treenodeinstance)
    {
        List<Treenodeinstance> list = treenodeinstanceService.selectTreenodeinstanceList(treenodeinstance);
        ExcelUtil<Treenodeinstance> util = new ExcelUtil<Treenodeinstance>(Treenodeinstance.class);
        util.exportExcel(response, list, "行为树实例节点数据");
    }

    /**
     * 获取行为树实例节点详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:treenodeinstance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(treenodeinstanceService.selectTreenodeinstanceById(id));
    }

    /**
     * 新增行为树实例节点
     */
    @PreAuthorize("@ss.hasPermi('system:treenodeinstance:add')")
    @Log(title = "行为树实例节点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Treenodeinstance treenodeinstance)
    {
        return toAjax(treenodeinstanceService.insertTreenodeinstance(treenodeinstance));
    }

    /**
     * 修改行为树实例节点
     */
    @PreAuthorize("@ss.hasPermi('system:treenodeinstance:edit')")
    @Log(title = "行为树实例节点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Treenodeinstance treenodeinstance)
    {
        return toAjax(treenodeinstanceService.updateTreenodeinstance(treenodeinstance));
    }

    /**
     * 删除行为树实例节点
     */
    @PreAuthorize("@ss.hasPermi('system:treenodeinstance:remove')")
    @Log(title = "行为树实例节点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(treenodeinstanceService.deleteTreenodeinstanceByIds(ids));
    }
}
