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

/**
 * 地区受攻击Controller
 * 
 * @author ruoyi
 * @date 2023-08-21
 */
@RestController
@RequestMapping("/zongzhi/attack")
@Api(tags = " 地区受攻击")
public class TcAttackController extends BaseController
{
    @Autowired
    private ITcAttackService tcAttackService;

    /**
     * 查询地区受攻击列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TcAttack tcAttack)
    {
        startPage();
        List<TcAttack> list = tcAttackService.selectTcAttackList(tcAttack);
        return getDataTable(list);
    }

    /**
     * 导出地区受攻击列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, TcAttack tcAttack)
    {
        List<TcAttack> list = tcAttackService.selectTcAttackList(tcAttack);
        ExcelUtil<TcAttack> util = new ExcelUtil<TcAttack>(TcAttack.class);
        util.exportExcel(response, list, "地区受攻击数据");
    }

    /**
     * 获取地区受攻击详细信息
     */

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

    /**
     * 新增地区受攻击
     */


    @PostMapping
    public AjaxResult add(@RequestBody TcAttack tcAttack)
    {
        tcAttack.setIsStatus(true);
        return toAjax(tcAttackService.insertTcAttack(tcAttack));
    }

    /**
     * 修改地区受攻击
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcAttack tcAttack)
    {
        return toAjax(tcAttackService.updateTcAttack(tcAttack));
    }

    /**
     * 删除地区受攻击
     */

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