package com.zyc.web.controller.api;

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.zyc.common.annotation.Log;
import com.zyc.common.core.controller.BaseController;
import com.zyc.common.core.domain.AjaxResult;
import com.zyc.common.enums.BusinessType;
import com.zyc.system.domain.VirtualPrivateCloudServices;
import com.zyc.system.service.IVirtualPrivateCloudServicesService;
import com.zyc.common.utils.poi.ExcelUtil;
import com.zyc.common.core.page.TableDataInfo;

/**
 * 虚拟私有云服务Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/VirtualPrivateCloudServicesController")
public class VirtualPrivateCloudServicesController extends BaseController
{
    @Autowired
    private IVirtualPrivateCloudServicesService virtualPrivateCloudServicesService;

    /**
     * 查询虚拟私有云服务列表
     */
    @PreAuthorize("@ss.hasPermi('system:services:list')")
    @GetMapping("/list")
    public TableDataInfo list(VirtualPrivateCloudServices virtualPrivateCloudServices)
    {
        startPage();
        List<VirtualPrivateCloudServices> list = virtualPrivateCloudServicesService.selectVirtualPrivateCloudServicesList(virtualPrivateCloudServices);
        return getDataTable(list);
    }

    /**
     * 导出虚拟私有云服务列表
     */
    @PreAuthorize("@ss.hasPermi('system:services:export')")
    @Log(title = "虚拟私有云服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VirtualPrivateCloudServices virtualPrivateCloudServices)
    {
        List<VirtualPrivateCloudServices> list = virtualPrivateCloudServicesService.selectVirtualPrivateCloudServicesList(virtualPrivateCloudServices);
        ExcelUtil<VirtualPrivateCloudServices> util = new ExcelUtil<VirtualPrivateCloudServices>(VirtualPrivateCloudServices.class);
        util.exportExcel(response, list, "虚拟私有云服务数据");
    }

    /**
     * 获取虚拟私有云服务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:services:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(virtualPrivateCloudServicesService.selectVirtualPrivateCloudServicesById(id));
    }

    /**
     * 新增虚拟私有云服务
     */
    @PreAuthorize("@ss.hasPermi('system:services:add')")
    @Log(title = "虚拟私有云服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VirtualPrivateCloudServices virtualPrivateCloudServices)
    {
        return toAjax(virtualPrivateCloudServicesService.insertVirtualPrivateCloudServices(virtualPrivateCloudServices));
    }

    /**
     * 修改虚拟私有云服务
     */
    @PreAuthorize("@ss.hasPermi('system:services:edit')")
    @Log(title = "虚拟私有云服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VirtualPrivateCloudServices virtualPrivateCloudServices)
    {
        return toAjax(virtualPrivateCloudServicesService.updateVirtualPrivateCloudServices(virtualPrivateCloudServices));
    }

    /**
     * 删除虚拟私有云服务
     */
    @PreAuthorize("@ss.hasPermi('system:services:remove')")
    @Log(title = "虚拟私有云服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(virtualPrivateCloudServicesService.deleteVirtualPrivateCloudServicesByIds(ids));
    }
}
