package com.ruoyi.zongzhi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zongzhi.domain.TcSgjTj;
import com.ruoyi.zongzhi.service.ITcSgjTjService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 安全监测受攻击统计Controller
 *
 * @author ruoyi
 * @date 2023-09-13
 */
@RestController
@RequestMapping("/zongzhi/tj")
@Api(tags = " 安全监测受攻击统计")
public class TcSgjTjController extends BaseController {

    @Resource
    private ITcSgjTjService tcSgjTjService;

    /**
     * 查询安全监测受攻击统计列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TcSgjTj tcSgjTj) {
        startPage();
        List<TcSgjTj> list = tcSgjTjService.selectTcSgjTjList(tcSgjTj);
        return getDataTable(list);
    }

    /**
     * 导出安全监测受攻击统计列表
     */
    @Log(title = "安全监测受攻击统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TcSgjTj tcSgjTj) {
        List<TcSgjTj> list = tcSgjTjService.selectTcSgjTjList(tcSgjTj);
        ExcelUtil<TcSgjTj> util = new ExcelUtil<TcSgjTj>(TcSgjTj.class);
        util.exportExcel(response, list, "安全监测受攻击统计数据");
    }

    /**
     * 获取安全监测受攻击统计详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tcSgjTjService.selectTcSgjTjById(id));
    }

    /**
     * 新增安全监测受攻击统计
     */
    @Log(title = "安全监测受攻击统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TcSgjTj tcSgjTj) {
        tcSgjTj.setIsStatus(true);
        return toAjax(tcSgjTjService.insertTcSgjTj(tcSgjTj));
    }

    /**
     * 修改安全监测受攻击统计
     */
    @Log(title = "安全监测受攻击统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TcSgjTj tcSgjTj) {
        return toAjax(tcSgjTjService.updateTcSgjTj(tcSgjTj));
    }

    /**
     * 删除安全监测受攻击统计
     */
    @Log(title = "安全监测受攻击统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tcSgjTjService.deleteTcSgjTjByIds(ids));
    }
}
