package com.cn.fdapfe.biz.controller;

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

import com.cn.fdapfe.biz.domain.ModelDataGen;
import com.cn.fdapfe.biz.service.IModelDataGenService;
import com.cn.fdapfe.common.utils.poi.ExcelUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
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.cn.fdapfe.common.annotation.Log;
import com.cn.fdapfe.common.core.controller.BaseController;
import com.cn.fdapfe.common.core.domain.AjaxResult;
import com.cn.fdapfe.common.enums.BusinessType;
import com.cn.fdapfe.common.core.page.TableDataInfo;

/**
 * 物理模型数据生成管理Controller
 * 
 * @author Allen
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/dataGen")
public class ModelDataGenController extends BaseController
{
    @Autowired
    private IModelDataGenService service;

    /**
     * 查询物理模型数据生成管理列表
     */
    @PreAuthorize("@ss.hasPermi('dataGen:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelDataGen modelDataGen)
    {
        startPage();
        List<ModelDataGen> list = service.selectList(modelDataGen);
        return getDataTable(list);
    }

    /**
     * 导出物理模型数据生成管理列表
     */
    @PreAuthorize("@ss.hasPermi('dataGen:export')")
    @Log(title = "物理模型数据生成管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelDataGen modelDataGen)
    {
        List<ModelDataGen> list = service.selectList(modelDataGen);
        ExcelUtil<ModelDataGen> util = new ExcelUtil<ModelDataGen>(ModelDataGen.class);
        util.exportExcel(response, list, "物理模型数据生成管理数据");
    }

    /**
     * 获取物理模型数据生成管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('dataGen:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(service.selectOne(id));
    }

    /**
     * 新增物理模型数据生成管理
     */
    @PreAuthorize("@ss.hasPermi('dataGen:add')")
    @Log(title = "物理模型数据生成管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelDataGen modelDataGen) throws IOException {
        return toAjax(service.add(modelDataGen));
    }

    /**
     * 修改物理模型数据生成管理
     */
    @PreAuthorize("@ss.hasPermi('dataGen:edit')")
    @Log(title = "物理模型数据生成管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelDataGen modelDataGen)
    {
        return toAjax(service.update(modelDataGen));
    }

    /**
     * 删除物理模型数据生成管理
     */
    @PreAuthorize("@ss.hasPermi('dataGen:remove')")
    @Log(title = "物理模型数据生成管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(service.delete(ids));
    }
}
