package com.ruoyi.controller;

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.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.cs.domain.CsUserNetworkInfo;
import com.ruoyi.cs.service.ICsUserNetworkInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户端网络信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-27
 */
@RestController
@RequestMapping("/cs/csUserNetworkInfo")
public class CsUserNetworkInfoController extends BaseController
{
    @Autowired
    private ICsUserNetworkInfoService csUserNetworkInfoService;

    /**
     * 查询用户端网络信息列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserNetworkInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsUserNetworkInfo csUserNetworkInfo)
    {
        startPage();
        List<CsUserNetworkInfo> list = csUserNetworkInfoService.selectCsUserNetworkInfoList(csUserNetworkInfo);
        return getDataTable(list);
    }

    /**
     * 导出用户端网络信息列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserNetworkInfo:export')")
    @Log(title = "用户端网络信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsUserNetworkInfo csUserNetworkInfo)
    {
        List<CsUserNetworkInfo> list = csUserNetworkInfoService.selectCsUserNetworkInfoList(csUserNetworkInfo);
        ExcelUtil<CsUserNetworkInfo> util = new ExcelUtil<CsUserNetworkInfo>(CsUserNetworkInfo.class);
        util.exportExcel(response, list, "用户端网络信息数据");
    }

    /**
     * 获取用户端网络信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserNetworkInfo:query')")
    @GetMapping(value = "/{networkInfoId}")
    public AjaxResult getInfo(@PathVariable("networkInfoId") String networkInfoId)
    {
        return AjaxResult.success(csUserNetworkInfoService.selectCsUserNetworkInfoByNetworkInfoId(networkInfoId));
    }

    /**
     * 新增用户端网络信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserNetworkInfo:add')")
    @Log(title = "用户端网络信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsUserNetworkInfo csUserNetworkInfo)
    {
        return toAjax(csUserNetworkInfoService.insertCsUserNetworkInfo(csUserNetworkInfo));
    }

    /**
     * 修改用户端网络信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserNetworkInfo:edit')")
    @Log(title = "用户端网络信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsUserNetworkInfo csUserNetworkInfo)
    {
        return toAjax(csUserNetworkInfoService.updateCsUserNetworkInfo(csUserNetworkInfo));
    }

    /**
     * 删除用户端网络信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csUserNetworkInfo:remove')")
    @Log(title = "用户端网络信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{networkInfoIds}")
    public AjaxResult remove(@PathVariable String[] networkInfoIds)
    {
        return toAjax(csUserNetworkInfoService.deleteCsUserNetworkInfoByNetworkInfoIds(networkInfoIds));
    }
}
