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

/**
 * IP地址资源Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/IpAddressResourcesController")
public class IpAddressResourcesController extends BaseController
{
    @Autowired
    private IIpAddressResourcesService ipAddressResourcesService;

    /**
     * 查询IP地址资源列表
     */
    @PreAuthorize("@ss.hasPermi('system:resources:list')")
    @GetMapping("/list")
    public TableDataInfo list(IpAddressResources ipAddressResources)
    {
        startPage();
        List<IpAddressResources> list = ipAddressResourcesService.selectIpAddressResourcesList(ipAddressResources);
        return getDataTable(list);
    }

    /**
     * 导出IP地址资源列表
     */
    @PreAuthorize("@ss.hasPermi('system:resources:export')")
    @Log(title = "IP地址资源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IpAddressResources ipAddressResources)
    {
        List<IpAddressResources> list = ipAddressResourcesService.selectIpAddressResourcesList(ipAddressResources);
        ExcelUtil<IpAddressResources> util = new ExcelUtil<IpAddressResources>(IpAddressResources.class);
        util.exportExcel(response, list, "IP地址资源数据");
    }

    /**
     * 获取IP地址资源详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:resources:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(ipAddressResourcesService.selectIpAddressResourcesById(id));
    }

    /**
     * 新增IP地址资源
     */
    @PreAuthorize("@ss.hasPermi('system:resources:add')")
    @Log(title = "IP地址资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IpAddressResources ipAddressResources)
    {
        return toAjax(ipAddressResourcesService.insertIpAddressResources(ipAddressResources));
    }

    /**
     * 修改IP地址资源
     */
    @PreAuthorize("@ss.hasPermi('system:resources:edit')")
    @Log(title = "IP地址资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IpAddressResources ipAddressResources)
    {
        return toAjax(ipAddressResourcesService.updateIpAddressResources(ipAddressResources));
    }

    /**
     * 删除IP地址资源
     */
    @PreAuthorize("@ss.hasPermi('system:resources:remove')")
    @Log(title = "IP地址资源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(ipAddressResourcesService.deleteIpAddressResourcesByIds(ids));
    }
}
