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

/**
 * api数据集Controller
 *
 * @author 朱得糠
 * @date 2025-09-02
 */
@RestController
@RequestMapping("/data/set/api")
public class MdDataSetApiController extends BaseController {
    @Autowired
    private IMdDataSetApiService mdDataSetApiService;

    /**
     * 查询api数据集列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MdDataSetApi mdDataSetApi) {
        startPage();
        List<MdDataSetApi> list = mdDataSetApiService.selectMdDataSetApiList(mdDataSetApi);
        return getDataTable(list);
    }


    /**
     * 获取api数据集详细信息
     */
    @GetMapping(value = "/{dcCode}")
    public AjaxResult getInfoBy(@PathVariable("dcCode") String dcCode) {
        return success(mdDataSetApiService.selectMdDataSetApiByDcCode(dcCode));
    }


    /**
     * 新增api数据集
     */
    @Log(title = "api数据集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MdDataSetApi mdDataSetApi) {
        mdDataSetApiService.deleteMdDataSetApiByDcCode(mdDataSetApi.getDcCode());
        return toAjax(mdDataSetApiService.insertMdDataSetApi(mdDataSetApi));
    }


}
