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

/**
 * 电子政务网Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/EGovernmentNetworkController")
public class EGovernmentNetworkController extends BaseController
{
    @Autowired
    private IEGovernmentNetworkService eGovernmentNetworkService;

    /**
     * 查询电子政务网列表
     */
    @PreAuthorize("@ss.hasPermi('system:network:list')")
    @GetMapping("/list")
    public TableDataInfo list(EGovernmentNetwork eGovernmentNetwork)
    {
        startPage();
        List<EGovernmentNetwork> list = eGovernmentNetworkService.selectEGovernmentNetworkList(eGovernmentNetwork);
        return getDataTable(list);
    }

    /**
     * 导出电子政务网列表
     */
    @PreAuthorize("@ss.hasPermi('system:network:export')")
    @Log(title = "电子政务网", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EGovernmentNetwork eGovernmentNetwork)
    {
        List<EGovernmentNetwork> list = eGovernmentNetworkService.selectEGovernmentNetworkList(eGovernmentNetwork);
        ExcelUtil<EGovernmentNetwork> util = new ExcelUtil<EGovernmentNetwork>(EGovernmentNetwork.class);
        util.exportExcel(response, list, "电子政务网数据");
    }

    /**
     * 获取电子政务网详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:network:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(eGovernmentNetworkService.selectEGovernmentNetworkById(id));
    }

    /**
     * 新增电子政务网
     */
    @PreAuthorize("@ss.hasPermi('system:network:add')")
    @Log(title = "电子政务网", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EGovernmentNetwork eGovernmentNetwork)
    {
        return toAjax(eGovernmentNetworkService.insertEGovernmentNetwork(eGovernmentNetwork));
    }

    /**
     * 修改电子政务网
     */
    @PreAuthorize("@ss.hasPermi('system:network:edit')")
    @Log(title = "电子政务网", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EGovernmentNetwork eGovernmentNetwork)
    {
        return toAjax(eGovernmentNetworkService.updateEGovernmentNetwork(eGovernmentNetwork));
    }

    /**
     * 删除电子政务网
     */
    @PreAuthorize("@ss.hasPermi('system:network:remove')")
    @Log(title = "电子政务网", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(eGovernmentNetworkService.deleteEGovernmentNetworkByIds(ids));
    }
}
