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.Behaviortree;
import com.solution.system.service.IBehaviortreeService;
import com.solution.common.utils.poi.ExcelUtil;
import com.solution.common.core.page.TableDataInfo;

/**
 * 行为树主Controller
 * 
 * @author ruoyi
 * @date 2026-02-05
 */
@RestController
@RequestMapping("/system/behaviortree")
public class BehaviortreeController extends BaseController
{
    @Autowired
    private IBehaviortreeService behaviortreeService;

    /**
     * 查询行为树主列表
     */
    @PreAuthorize("@ss.hasPermi('system:behaviortree:list')")
    @GetMapping("/list")
    public TableDataInfo list(Behaviortree behaviortree)
    {
        startPage();
        List<Behaviortree> list = behaviortreeService.selectBehaviortreeList(behaviortree);
        return getDataTable(list);
    }

    /**
     * 导出行为树主列表
     */
    @PreAuthorize("@ss.hasPermi('system:behaviortree:export')")
    @Log(title = "行为树主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Behaviortree behaviortree)
    {
        List<Behaviortree> list = behaviortreeService.selectBehaviortreeList(behaviortree);
        ExcelUtil<Behaviortree> util = new ExcelUtil<Behaviortree>(Behaviortree.class);
        util.exportExcel(response, list, "行为树主数据");
    }

    /**
     * 获取行为树主详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:behaviortree:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(behaviortreeService.selectBehaviortreeById(id));
    }

    /**
     * 新增行为树主
     */
    @PreAuthorize("@ss.hasPermi('system:behaviortree:add')")
    @Log(title = "行为树主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Behaviortree behaviortree)
    {
        return toAjax(behaviortreeService.insertBehaviortree(behaviortree));
    }

    /**
     * 修改行为树主
     */
    @PreAuthorize("@ss.hasPermi('system:behaviortree:edit')")
    @Log(title = "行为树主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Behaviortree behaviortree)
    {
        return toAjax(behaviortreeService.updateBehaviortree(behaviortree));
    }

    /**
     * 删除行为树主
     */
    @PreAuthorize("@ss.hasPermi('system:behaviortree:remove')")
    @Log(title = "行为树主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(behaviortreeService.deleteBehaviortreeByIds(ids));
    }
}
