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

/**
 * 弹性伸缩服务Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/ElasticScalingServicesController")
public class ElasticScalingServicesController extends BaseController
{
    @Autowired
    private IElasticScalingServicesService elasticScalingServicesService;

    /**
     * 查询弹性伸缩服务列表
     */
    @PreAuthorize("@ss.hasPermi('system:services:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElasticScalingServices elasticScalingServices)
    {
        startPage();
        List<ElasticScalingServices> list = elasticScalingServicesService.selectElasticScalingServicesList(elasticScalingServices);
        return getDataTable(list);
    }

    /**
     * 导出弹性伸缩服务列表
     */
    @PreAuthorize("@ss.hasPermi('system:services:export')")
    @Log(title = "弹性伸缩服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElasticScalingServices elasticScalingServices)
    {
        List<ElasticScalingServices> list = elasticScalingServicesService.selectElasticScalingServicesList(elasticScalingServices);
        ExcelUtil<ElasticScalingServices> util = new ExcelUtil<ElasticScalingServices>(ElasticScalingServices.class);
        util.exportExcel(response, list, "弹性伸缩服务数据");
    }

    /**
     * 获取弹性伸缩服务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:services:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(elasticScalingServicesService.selectElasticScalingServicesById(id));
    }

    /**
     * 新增弹性伸缩服务
     */
    @PreAuthorize("@ss.hasPermi('system:services:add')")
    @Log(title = "弹性伸缩服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElasticScalingServices elasticScalingServices)
    {
        return toAjax(elasticScalingServicesService.insertElasticScalingServices(elasticScalingServices));
    }

    /**
     * 修改弹性伸缩服务
     */
    @PreAuthorize("@ss.hasPermi('system:services:edit')")
    @Log(title = "弹性伸缩服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElasticScalingServices elasticScalingServices)
    {
        return toAjax(elasticScalingServicesService.updateElasticScalingServices(elasticScalingServices));
    }

    /**
     * 删除弹性伸缩服务
     */
    @PreAuthorize("@ss.hasPermi('system:services:remove')")
    @Log(title = "弹性伸缩服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(elasticScalingServicesService.deleteElasticScalingServicesByIds(ids));
    }
}
