package com.ruoyi.zongzhi.controller;

import java.util.List;
import io.swagger.annotations.Api;
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.zongzhi.domain.TcGovernmentWeb;
import com.ruoyi.zongzhi.service.ITcGovernmentWebService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 政府网站Controller
 * 
 * @author ruoyi
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/zongzhi/web")
@Api(tags = " 政府网站")
public class TcGovernmentWebController extends BaseController
{
    @Autowired
    private ITcGovernmentWebService tcGovernmentWebService;

    /**
     * 查询政府网站列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TcGovernmentWeb tcGovernmentWeb)
    {
        startPage();
        List<TcGovernmentWeb> list = tcGovernmentWebService.selectTcGovernmentWebList(tcGovernmentWeb);
        return getDataTable(list);
    }

    /**
     * 导出政府网站列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, TcGovernmentWeb tcGovernmentWeb)
    {
        List<TcGovernmentWeb> list = tcGovernmentWebService.selectTcGovernmentWebList(tcGovernmentWeb);
        ExcelUtil<TcGovernmentWeb> util = new ExcelUtil<TcGovernmentWeb>(TcGovernmentWeb.class);
        util.exportExcel(response, list, "政府网站数据");
    }

    /**
     * 获取政府网站详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tcGovernmentWebService.selectTcGovernmentWebById(id));
    }

    /**
     * 新增政府网站
     */

    @PostMapping
    public AjaxResult add(@RequestBody TcGovernmentWeb tcGovernmentWeb)
    {
        tcGovernmentWeb.setIsStatus(true);
        return toAjax(tcGovernmentWebService.insertTcGovernmentWeb(tcGovernmentWeb));
    }

    /**
     * 修改政府网站
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcGovernmentWeb tcGovernmentWeb)
    {
        return toAjax(tcGovernmentWebService.updateTcGovernmentWeb(tcGovernmentWeb));
    }

    /**
     * 删除政府网站
     */

	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tcGovernmentWebService.deleteTcGovernmentWebByIds(ids));
    }
}
