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.BareMetalInstances;
import com.zyc.system.service.IBareMetalInstancesService;
import com.zyc.common.utils.poi.ExcelUtil;
import com.zyc.common.core.page.TableDataInfo;

/**
 * 定制裸金属服务Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/BareMetalInstancesController")
public class BareMetalInstancesController extends BaseController
{
    @Autowired
    private IBareMetalInstancesService bareMetalInstancesService;

    /**
     * 查询定制裸金属服务列表
     */
    @PreAuthorize("@ss.hasPermi('system:instances:list')")
    @GetMapping("/list")
    public TableDataInfo list(BareMetalInstances bareMetalInstances)
    {
        startPage();
        List<BareMetalInstances> list = bareMetalInstancesService.selectBareMetalInstancesList(bareMetalInstances);
        return getDataTable(list);
    }

    /**
     * 导出定制裸金属服务列表
     */
    @PreAuthorize("@ss.hasPermi('system:instances:export')")
    @Log(title = "定制裸金属服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BareMetalInstances bareMetalInstances)
    {
        List<BareMetalInstances> list = bareMetalInstancesService.selectBareMetalInstancesList(bareMetalInstances);
        ExcelUtil<BareMetalInstances> util = new ExcelUtil<BareMetalInstances>(BareMetalInstances.class);
        util.exportExcel(response, list, "定制裸金属服务数据");
    }

    /**
     * 获取定制裸金属服务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:instances:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(bareMetalInstancesService.selectBareMetalInstancesById(id));
    }

    /**
     * 新增定制裸金属服务
     */
    @PreAuthorize("@ss.hasPermi('system:instances:add')")
    @Log(title = "定制裸金属服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BareMetalInstances bareMetalInstances)
    {
        return toAjax(bareMetalInstancesService.insertBareMetalInstances(bareMetalInstances));
    }

    /**
     * 修改定制裸金属服务
     */
    @PreAuthorize("@ss.hasPermi('system:instances:edit')")
    @Log(title = "定制裸金属服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BareMetalInstances bareMetalInstances)
    {
        return toAjax(bareMetalInstancesService.updateBareMetalInstances(bareMetalInstances));
    }

    /**
     * 删除定制裸金属服务
     */
    @PreAuthorize("@ss.hasPermi('system:instances:remove')")
    @Log(title = "定制裸金属服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(bareMetalInstancesService.deleteBareMetalInstancesByIds(ids));
    }
}
