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

/**
 * 模型参数分组Controller
 * 
 * @author 朱得糠
 * @date 2025-08-01
 */
@RestController
@RequestMapping("/model/pargroup")
public class MdModelPargroupController extends BaseController
{
    @Autowired
    private IMdModelPargroupService mdModelPargroupService;

    /**
     * 查询模型参数分组列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MdModelPargroup mdModelPargroup)
    {
        startPage();
        List<MdModelPargroup> list = mdModelPargroupService.selectMdModelPargroupList(mdModelPargroup);
        return getDataTable(list);
    }


    /**
     * 查询模型参数分组列表
     */
    @GetMapping("/allList")
    public AjaxResult allList(MdModelPargroup mdModelPargroup)
    {
        List<MdModelPargroup> list = mdModelPargroupService.selectMdModelPargroupList(mdModelPargroup);
        return AjaxResult.success(list);
    }

    /**
     * 导出模型参数分组列表
     */
    @Log(title = "模型参数分组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdModelPargroup mdModelPargroup)
    {
        List<MdModelPargroup> list = mdModelPargroupService.selectMdModelPargroupList(mdModelPargroup);
        ExcelUtil<MdModelPargroup> util = new ExcelUtil<MdModelPargroup>(MdModelPargroup.class);
        util.exportExcel(response, list, "模型参数分组数据");
    }

    /**
     * 获取模型参数分组详细信息
     */
    @GetMapping(value = "/{mgid}")
    public AjaxResult getInfo(@PathVariable("mgid") Integer mgid)
    {
        return success(mdModelPargroupService.selectMdModelPargroupByMgid(mgid));
    }

    /**
     * 新增模型参数分组
     */
    @Log(title = "模型参数分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MdModelPargroup mdModelPargroup)
    {
        return toAjax(mdModelPargroupService.insertMdModelPargroup(mdModelPargroup));
    }

    /**
     * 修改模型参数分组
     */
    @Log(title = "模型参数分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MdModelPargroup mdModelPargroup)
    {
        return toAjax(mdModelPargroupService.updateMdModelPargroup(mdModelPargroup));
    }

    /**
     * 删除模型参数分组
     */
    @Log(title = "模型参数分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mgids}")
    public AjaxResult remove(@PathVariable Integer[] mgids)
    {
        return toAjax(mdModelPargroupService.deleteMdModelPargroupByMgids(mgids));
    }
}
