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.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.interfaces.domain.MdDataSetFile;
import com.ruoyi.interfaces.service.IMdDataSetFileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文件数据集Controller
 * 
 * @author 朱得糠
 * @date 2025-09-02
 */
@RestController
@RequestMapping("/data/set/file")
public class MdDataSetFileController extends BaseController
{
    @Autowired
    private IMdDataSetFileService mdDataSetFileService;

    /**
     * 查询文件数据集列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MdDataSetFile mdDataSetFile)
    {
        startPage();
        List<MdDataSetFile> list = mdDataSetFileService.selectMdDataSetFileList(mdDataSetFile);
        return getDataTable(list);
    }

    /**
     * 导出文件数据集列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdDataSetFile mdDataSetFile)
    {
        List<MdDataSetFile> list = mdDataSetFileService.selectMdDataSetFileList(mdDataSetFile);
        ExcelUtil<MdDataSetFile> util = new ExcelUtil<MdDataSetFile>(MdDataSetFile.class);
        util.exportExcel(response, list, "文件数据集数据");
    }

    /**
     * 获取文件数据集详细信息
     */
    @GetMapping(value = "/{dcCode}")
    public AjaxResult getInfo(@PathVariable("dcCode") String dcCode)
    {
        return success(mdDataSetFileService.selectMdDataSetFileByDcCode(dcCode));
    }

    /**
     * 新增文件数据集
     */
    @PostMapping
    public AjaxResult add(@RequestBody MdDataSetFile mdDataSetFile)
    {
        mdDataSetFileService.deleteMdDataSetFileByDcCode(mdDataSetFile.getDcCode());
        return toAjax(mdDataSetFileService.insertMdDataSetFile(mdDataSetFile));
    }

    /**
     * 修改文件数据集
     */
    @PutMapping
    public AjaxResult edit(@RequestBody MdDataSetFile mdDataSetFile)
    {
        return toAjax(mdDataSetFileService.updateMdDataSetFile(mdDataSetFile));
    }

    /**
     * 删除文件数据集
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mdDataSetFileService.deleteMdDataSetFileByIds(ids));
    }
}
