package com.ruoyi.interfaces.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

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.interfaces.domain.SysMetaTable;
import com.ruoyi.interfaces.service.ISysMetaTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 元数据表Controller
 * 
 * @author 朱得糠
 * @date 2025-08-02
 */
@RestController
@RequestMapping("/meta/table")
public class SysMetaTableController extends BaseController
{
    @Autowired
    private ISysMetaTableService sysMetaTableService;

    /**
     * 查询元数据表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysMetaTable sysMetaTable)
    {
        startPage();
        List<SysMetaTable> list = sysMetaTableService.selectSysMetaTableList(sysMetaTable);
        return getDataTable(list);
    }

    /**
     * 导出元数据表列表
     */
    @Log(title = "元数据表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysMetaTable sysMetaTable)
    {
        List<SysMetaTable> list = sysMetaTableService.selectSysMetaTableList(sysMetaTable);
        ExcelUtil<SysMetaTable> util = new ExcelUtil<SysMetaTable>(SysMetaTable.class);
        util.exportExcel(response, list, "元数据表数据");
    }

    /**
     * 获取元数据表详细信息
     */
    @GetMapping("/allList")
    public AjaxResult getInfo(SysMetaTable sysMetaTable)
    {
        return success(sysMetaTableService.selectSysMetaTableList(sysMetaTable));
    }

    /**
     * 新增元数据表
     */
    @Log(title = "元数据表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysMetaTable sysMetaTable)
    {
        return toAjax(sysMetaTableService.insertSysMetaTable(sysMetaTable));
    }

    /**
     * 修改元数据表
     */
    @Log(title = "元数据表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysMetaTable sysMetaTable)
    {
        return toAjax(sysMetaTableService.updateSysMetaTable(sysMetaTable));
    }

    /**
     * 删除元数据表
     */
    @Log(title = "元数据表", businessType = BusinessType.DELETE)
	@DeleteMapping
    public AjaxResult remove(SysMetaTable sysMetaTable)
    {
        return toAjax(sysMetaTableService.deleteSysMetaTable(sysMetaTable));
    }
}
