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

/**
 * 政务外网接入Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/GovernmentExtranetAccessController")
public class GovernmentExtranetAccessController extends BaseController
{
    @Autowired
    private IGovernmentExtranetAccessService governmentExtranetAccessService;

    /**
     * 查询政务外网接入列表
     */
    @PreAuthorize("@ss.hasPermi('system:access:list')")
    @GetMapping("/list")
    public TableDataInfo list(GovernmentExtranetAccess governmentExtranetAccess)
    {
        startPage();
        List<GovernmentExtranetAccess> list = governmentExtranetAccessService.selectGovernmentExtranetAccessList(governmentExtranetAccess);
        return getDataTable(list);
    }

    /**
     * 导出政务外网接入列表
     */
    @PreAuthorize("@ss.hasPermi('system:access:export')")
    @Log(title = "政务外网接入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GovernmentExtranetAccess governmentExtranetAccess)
    {
        List<GovernmentExtranetAccess> list = governmentExtranetAccessService.selectGovernmentExtranetAccessList(governmentExtranetAccess);
        ExcelUtil<GovernmentExtranetAccess> util = new ExcelUtil<GovernmentExtranetAccess>(GovernmentExtranetAccess.class);
        util.exportExcel(response, list, "政务外网接入数据");
    }

    /**
     * 获取政务外网接入详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:access:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(governmentExtranetAccessService.selectGovernmentExtranetAccessById(id));
    }

    /**
     * 新增政务外网接入
     */
    @PreAuthorize("@ss.hasPermi('system:access:add')")
    @Log(title = "政务外网接入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GovernmentExtranetAccess governmentExtranetAccess)
    {
        return toAjax(governmentExtranetAccessService.insertGovernmentExtranetAccess(governmentExtranetAccess));
    }

    /**
     * 修改政务外网接入
     */
    @PreAuthorize("@ss.hasPermi('system:access:edit')")
    @Log(title = "政务外网接入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GovernmentExtranetAccess governmentExtranetAccess)
    {
        return toAjax(governmentExtranetAccessService.updateGovernmentExtranetAccess(governmentExtranetAccess));
    }

    /**
     * 删除政务外网接入
     */
    @PreAuthorize("@ss.hasPermi('system:access:remove')")
    @Log(title = "政务外网接入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(governmentExtranetAccessService.deleteGovernmentExtranetAccessByIds(ids));
    }
}
