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

/**
 * 节点模板Controller
 * 
 * @author ruoyi
 * @date 2026-02-05
 */
@RestController
@RequestMapping("/system/nodetemplate")
public class NodetemplateController extends BaseController
{
    @Autowired
    private INodetemplateService nodetemplateService;

    /**
     * 查询节点模板列表
     */
    @PreAuthorize("@ss.hasPermi('system:nodetemplate:list')")
    @GetMapping("/list")
    public TableDataInfo list(Nodetemplate nodetemplate)
    {
        startPage();
        List<Nodetemplate> list = nodetemplateService.selectNodetemplateList(nodetemplate);
        return getDataTable(list);
    }

    /**
     * 导出节点模板列表
     */
    @PreAuthorize("@ss.hasPermi('system:nodetemplate:export')")
    @Log(title = "节点模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Nodetemplate nodetemplate)
    {
        List<Nodetemplate> list = nodetemplateService.selectNodetemplateList(nodetemplate);
        ExcelUtil<Nodetemplate> util = new ExcelUtil<Nodetemplate>(Nodetemplate.class);
        util.exportExcel(response, list, "节点模板数据");
    }

    /**
     * 获取节点模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:nodetemplate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(nodetemplateService.selectNodetemplateById(id));
    }

    /**
     * 新增节点模板
     */
    @PreAuthorize("@ss.hasPermi('system:nodetemplate:add')")
    @Log(title = "节点模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Nodetemplate nodetemplate)
    {
        return toAjax(nodetemplateService.insertNodetemplate(nodetemplate));
    }

    /**
     * 修改节点模板
     */
    @PreAuthorize("@ss.hasPermi('system:nodetemplate:edit')")
    @Log(title = "节点模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Nodetemplate nodetemplate)
    {
        return toAjax(nodetemplateService.updateNodetemplate(nodetemplate));
    }

    /**
     * 删除节点模板
     */
    @PreAuthorize("@ss.hasPermi('system:nodetemplate:remove')")
    @Log(title = "节点模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(nodetemplateService.deleteNodetemplateByIds(ids));
    }
}
