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

/**
 * 网络安全支持单位Controller
 * 
 * @author ruoyi
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/zongzhi/supportunit")
@Api(tags = " 网络安全支持单位")
public class TcNetworkSupportUnitController extends BaseController
{
    @Autowired
    private ITcNetworkSupportUnitService tcNetworkSupportUnitService;

    /**
     * 查询网络安全支持单位列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TcNetworkSupportUnit tcNetworkSupportUnit)
    {
        startPage();
        List<TcNetworkSupportUnit> list = tcNetworkSupportUnitService.selectTcNetworkSupportUnitList(tcNetworkSupportUnit);
        return getDataTable(list);
    }

    /**
     * 导出网络安全支持单位列表
     */


    @PostMapping("/export")
    public void export(HttpServletResponse response, TcNetworkSupportUnit tcNetworkSupportUnit)
    {
        List<TcNetworkSupportUnit> list = tcNetworkSupportUnitService.selectTcNetworkSupportUnitList(tcNetworkSupportUnit);
        ExcelUtil<TcNetworkSupportUnit> util = new ExcelUtil<TcNetworkSupportUnit>(TcNetworkSupportUnit.class);
        util.exportExcel(response, list, "网络安全支持单位数据");
    }

    /**
     * 获取网络安全支持单位详细信息
     */

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

    /**
     * 新增网络安全支持单位
     */

    @PostMapping
    public AjaxResult add(@RequestBody TcNetworkSupportUnit tcNetworkSupportUnit)
    {
        tcNetworkSupportUnit.setIsStatus(true);
        return toAjax(tcNetworkSupportUnitService.insertTcNetworkSupportUnit(tcNetworkSupportUnit));
    }

    /**
     * 修改网络安全支持单位
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcNetworkSupportUnit tcNetworkSupportUnit)
    {
        return toAjax(tcNetworkSupportUnitService.updateTcNetworkSupportUnit(tcNetworkSupportUnit));
    }

    /**
     * 删除网络安全支持单位
     */

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