package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageDomain;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.EpsBusinessScript;
import com.ruoyi.system.service.IEpsBusinessScriptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 业务脚本管理Controller
 * 
 * @author gyt
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/businessScript")
public class EpsBusinessScriptController extends BaseController
{
    @Autowired
    private IEpsBusinessScriptService epsBusinessScriptService;

    /**
     * 查询业务脚本管理列表
     */
    @RequiresPermissions("system:businessScript:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody EpsBusinessScript epsBusinessScript)
    {
        PageDomain pageDomain = new PageDomain();
        pageDomain.setPageNum(epsBusinessScript.getPageNum());
        pageDomain.setPageSize(epsBusinessScript.getPageSize());
        startPage(pageDomain);
        List<EpsBusinessScript> list = epsBusinessScriptService.selectEpsBusinessScriptList(epsBusinessScript);
        return getDataTable(list);
    }


    /**
     * 获取业务脚本管理详细信息
     */
    @RequiresPermissions("system:businessScript:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(epsBusinessScriptService.selectEpsBusinessScriptById(id));
    }

    /**
     * 新增业务脚本管理
     */
    @RequiresPermissions("system:businessScript:add")
    @Log(title = "业务脚本管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EpsBusinessScript epsBusinessScript)
    {
        return toAjax(epsBusinessScriptService.insertEpsBusinessScript(epsBusinessScript));
    }

    /**
     * 修改业务脚本管理
     */
    @RequiresPermissions("system:businessScript:edit")
    @Log(title = "业务脚本管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EpsBusinessScript epsBusinessScript)
    {
        return toAjax(epsBusinessScriptService.updateEpsBusinessScript(epsBusinessScript));
    }

    /**
     * 删除业务脚本管理
     */
    @RequiresPermissions("system:businessScript:remove")
    @Log(title = "业务脚本管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(epsBusinessScriptService.deleteEpsBusinessScriptByIds(ids));
    }

    /**
     * 获取所有业务脚本名称
     * @return
     */
    @RequiresPermissions("system:businessScript:list")
    @GetMapping("/getAllScriptName")
    public AjaxResult getAllScriptName(){
        List<EpsBusinessScript> list = epsBusinessScriptService.selectEpsBusinessScriptList(new EpsBusinessScript());
        return success(list);
    }
}
