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

/**
 * 模板参数定义Controller
 * 
 * @author ruoyi
 * @date 2026-02-05
 */
@RestController
@RequestMapping("/system/templateparameterdef")
public class TemplateparameterdefController extends BaseController
{
    @Autowired
    private ITemplateparameterdefService templateparameterdefService;

    /**
     * 查询模板参数定义列表
     */
    @PreAuthorize("@ss.hasPermi('system:templateparameterdef:list')")
    @GetMapping("/list")
    public TableDataInfo list(Templateparameterdef templateparameterdef)
    {
        startPage();
        List<Templateparameterdef> list = templateparameterdefService.selectTemplateparameterdefList(templateparameterdef);
        return getDataTable(list);
    }

    /**
     * 导出模板参数定义列表
     */
    @PreAuthorize("@ss.hasPermi('system:templateparameterdef:export')")
    @Log(title = "模板参数定义", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Templateparameterdef templateparameterdef)
    {
        List<Templateparameterdef> list = templateparameterdefService.selectTemplateparameterdefList(templateparameterdef);
        ExcelUtil<Templateparameterdef> util = new ExcelUtil<Templateparameterdef>(Templateparameterdef.class);
        util.exportExcel(response, list, "模板参数定义数据");
    }

    /**
     * 获取模板参数定义详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:templateparameterdef:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(templateparameterdefService.selectTemplateparameterdefById(id));
    }

    /**
     * 新增模板参数定义
     */
    @PreAuthorize("@ss.hasPermi('system:templateparameterdef:add')")
    @Log(title = "模板参数定义", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Templateparameterdef templateparameterdef)
    {
        return toAjax(templateparameterdefService.insertTemplateparameterdef(templateparameterdef));
    }

    /**
     * 修改模板参数定义
     */
    @PreAuthorize("@ss.hasPermi('system:templateparameterdef:edit')")
    @Log(title = "模板参数定义", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Templateparameterdef templateparameterdef)
    {
        return toAjax(templateparameterdefService.updateTemplateparameterdef(templateparameterdef));
    }

    /**
     * 删除模板参数定义
     */
    @PreAuthorize("@ss.hasPermi('system:templateparameterdef:remove')")
    @Log(title = "模板参数定义", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(templateparameterdefService.deleteTemplateparameterdefByIds(ids));
    }
}
