package com.ruoyi.interfaces.controller;

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

import com.ruoyi.interfaces.domain.MdModelCatetory;
import com.ruoyi.interfaces.service.IMdModelCatetoryService;
import io.swagger.annotations.ApiOperation;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型目录Controller
 * 
 * @author ruoyi
 * @date 2025-07-15
 */
@RestController
@RequestMapping("/model/catetory")
public class MdModelCatetoryController extends BaseController
{
    @Autowired
    private IMdModelCatetoryService mdModelCatetoryService;

    /**
     * 查询模型目录列表
     */
    @ApiOperation("查询模型目录列表")
    @GetMapping("/list")
    public TableDataInfo list(MdModelCatetory mdModelCatetory)
    {
        startPage();
        List<MdModelCatetory> list = mdModelCatetoryService.selectMdModelCatetoryList(mdModelCatetory);
        return getDataTable(list);
    }

    /**
     * 导出模型目录列表
     */
    @ApiOperation("导出模型目录列表")
    @Log(title = "模型目录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdModelCatetory mdModelCatetory)
    {
        List<MdModelCatetory> list = mdModelCatetoryService.selectMdModelCatetoryList(mdModelCatetory);
        ExcelUtil<MdModelCatetory> util = new ExcelUtil<MdModelCatetory>(MdModelCatetory.class);
        util.exportExcel(response, list, "模型目录数据");
    }

    /**
     * 获取模型目录详细信息
     */
    @ApiOperation("获取模型目录详细信息")
    @GetMapping(value = "/{cateid}")
    public AjaxResult getInfo(@PathVariable("cateid") String cateid)
    {
        return success(mdModelCatetoryService.selectMdModelCatetoryByCateid(cateid));
    }

    /**
     * 新增模型目录
     */
    @ApiOperation("新增模型目录")
    @Log(title = "模型目录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MdModelCatetory mdModelCatetory)
    {
        return toAjax(mdModelCatetoryService.insertMdModelCatetory(mdModelCatetory));
    }

    /**
     * 修改模型目录
     */
    @ApiOperation("修改模型目录")
    @Log(title = "模型目录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MdModelCatetory mdModelCatetory)
    {
        return toAjax(mdModelCatetoryService.updateMdModelCatetory(mdModelCatetory));
    }

    /**
     * 删除模型目录
     */
    @ApiOperation("删除模型目录")
    @Log(title = "模型目录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cateids}")
    public AjaxResult remove(@PathVariable String[] cateids)
    {
        return toAjax(mdModelCatetoryService.deleteMdModelCatetoryByCateids(cateids));
    }
}