package com.ruoyi.interfaces.controller;

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

import com.ruoyi.interfaces.service.IMdModelAclService;
import com.ruoyi.interfaces.domain.MdModelAcl;
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/acl")
public class MdModelAclController extends BaseController
{
    @Autowired
    private IMdModelAclService mdModelAclService;

    /**
     * 查询模型访问控制列表
     */
    @ApiOperation("查询模型访问控制列表")
    @GetMapping("/list")
    public TableDataInfo list(MdModelAcl mdModelAcl)
    {
        startPage();
        List<MdModelAcl> list = mdModelAclService.selectMdModelAclList(mdModelAcl);
        return getDataTable(list);
    }

    /**
     * 新增模型访问控制
     */
    @ApiOperation("新增模型访问控制")
    @Log(title = "模型访问控制", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MdModelAcl mdModelAcl)
    {
        return toAjax(mdModelAclService.insertMdModelAcl(mdModelAcl));
    }

    /**
     * 导出模型访问控制列表
     */
    @ApiOperation("导出模型访问控制列表")
    @Log(title = "模型访问控制", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdModelAcl mdModelAcl)
    {
        List<MdModelAcl> list = mdModelAclService.selectMdModelAclList(mdModelAcl);
        ExcelUtil<MdModelAcl> util = new ExcelUtil<MdModelAcl>(MdModelAcl.class);
        util.exportExcel(response, list, "模型访问控制数据");
    }

    /**
     * 获取模型访问控制详细信息
     */
    @ApiOperation("获取模型访问控制详细信息")
    @GetMapping(value = "/{aclid}")
    public AjaxResult getInfo(@PathVariable("aclid") String aclid)
    {
        return success(mdModelAclService.selectMdModelAclByAclid(aclid));
    }

    /**
     * 修改模型访问控制
     */
    @ApiOperation("修改模型访问控制")
    @Log(title = "模型访问控制", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MdModelAcl mdModelAcl)
    {
        return toAjax(mdModelAclService.updateMdModelAcl(mdModelAcl));
    }

    /**
     * 删除模型访问控制
     */
    @ApiOperation("删除模型访问控制")
    @Log(title = "模型访问控制", businessType = BusinessType.DELETE)
	@DeleteMapping("/{aclids}")
    public AjaxResult remove(@PathVariable String[] aclids)
    {
        return toAjax(mdModelAclService.deleteMdModelAclByAclids(aclids));
    }
}