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.TcNetworkReport;
import com.ruoyi.zongzhi.service.ITcNetworkReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网络举报Controller
 * 
 * @author ruoyi
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/zongzhi/report")
@Api(tags = " 网络举报")
public class TcNetworkReportController extends BaseController
{
    @Autowired
    private ITcNetworkReportService tcNetworkReportService;

    /**
     * 查询网络举报列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TcNetworkReport tcNetworkReport)
    {
        startPage();
        List<TcNetworkReport> list = tcNetworkReportService.selectTcNetworkReportList(tcNetworkReport);
        return getDataTable(list);
    }

    /**
     * 导出网络举报列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, TcNetworkReport tcNetworkReport)
    {
        List<TcNetworkReport> list = tcNetworkReportService.selectTcNetworkReportList(tcNetworkReport);
        ExcelUtil<TcNetworkReport> util = new ExcelUtil<TcNetworkReport>(TcNetworkReport.class);
        util.exportExcel(response, list, "网络举报数据");
    }

    /**
     * 获取网络举报详细信息
     */

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

    /**
     * 新增网络举报
     */
    @PostMapping
    public AjaxResult add(@RequestBody TcNetworkReport tcNetworkReport)
    {
        tcNetworkReport.setIsStatus(true);
        return toAjax(tcNetworkReportService.insertTcNetworkReport(tcNetworkReport));
    }

    /**
     * 修改网络举报
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcNetworkReport tcNetworkReport)
    {
        return toAjax(tcNetworkReportService.updateTcNetworkReport(tcNetworkReport));
    }

    /**
     * 删除网络举报
     */

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