package com.ruoyi.base.controller;

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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BasePlcParam;
import com.ruoyi.base.service.IBasePlcParamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * PLC参数信息Controller
 * 
 * @author zangch
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/base/basePlcParam")
public class BasePlcParamController extends BaseController
{
    @Autowired
    private IBasePlcParamService basePlcParamService;

    /**
     * 查询PLC参数信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:basePlcParam:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasePlcParam basePlcParam)
    {
        startPage();
        List<BasePlcParam> list = basePlcParamService.selectBasePlcParamList(basePlcParam);
        return getDataTable(list);
    }

    /**
     * 导出PLC参数信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:basePlcParam:export')")
    @Log(title = "PLC参数信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasePlcParam basePlcParam)
    {
        List<BasePlcParam> list = basePlcParamService.selectBasePlcParamList(basePlcParam);
        ExcelUtil<BasePlcParam> util = new ExcelUtil<BasePlcParam>(BasePlcParam.class);
        util.exportExcel(response, list, "PLC参数信息数据");
    }

    /**
     * 获取PLC参数信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:basePlcParam:query')")
    @GetMapping(value = "/{objId}")
    public AjaxResult getInfo(@PathVariable("objId") Long objId)
    {
        return success(basePlcParamService.selectBasePlcParamByObjId(objId));
    }

    /**
     * 新增PLC参数信息
     */
    @PreAuthorize("@ss.hasPermi('base:basePlcParam:add')")
    @Log(title = "PLC参数信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasePlcParam basePlcParam)
    {
        return toAjax(basePlcParamService.insertBasePlcParam(basePlcParam));
    }

    /**
     * 修改PLC参数信息
     */
    @PreAuthorize("@ss.hasPermi('base:basePlcParam:edit')")
    @Log(title = "PLC参数信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasePlcParam basePlcParam)
    {
        return toAjax(basePlcParamService.updateBasePlcParam(basePlcParam));
    }

    /**
     * 删除PLC参数信息
     */
    @PreAuthorize("@ss.hasPermi('base:basePlcParam:remove')")
    @Log(title = "PLC参数信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objIds}")
    public AjaxResult remove(@PathVariable Long[] objIds)
    {
        return toAjax(basePlcParamService.deleteBasePlcParamByObjIds(objIds));
    }
}
