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

/**
 * 网络民情责任人Controller
 * 
 * @author ruoyi
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/zongzhi/principal")
@Api(tags = " 网络民情责任人")
public class TcNetworkMqPrincipalController extends BaseController
{
    @Autowired
    private ITcNetworkMqPrincipalService tcNetworkMqPrincipalService;

    /**
     * 查询网络民情责任人列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TcNetworkMqPrincipal tcNetworkMqPrincipal)
    {
        startPage();
        List<TcNetworkMqPrincipal> list = tcNetworkMqPrincipalService.selectTcNetworkMqPrincipalList(tcNetworkMqPrincipal);
        return getDataTable(list);
    }

    /**
     * 导出网络民情责任人列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, TcNetworkMqPrincipal tcNetworkMqPrincipal)
    {
        List<TcNetworkMqPrincipal> list = tcNetworkMqPrincipalService.selectTcNetworkMqPrincipalList(tcNetworkMqPrincipal);
        ExcelUtil<TcNetworkMqPrincipal> util = new ExcelUtil<TcNetworkMqPrincipal>(TcNetworkMqPrincipal.class);
        util.exportExcel(response, list, "网络民情责任人数据");
    }

    /**
     * 获取网络民情责任人详细信息
     */

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

    /**
     * 新增网络民情责任人
     */

    @PostMapping
    public AjaxResult add(@RequestBody TcNetworkMqPrincipal tcNetworkMqPrincipal)
    {
        tcNetworkMqPrincipal.setIsStatus(true);
        return toAjax(tcNetworkMqPrincipalService.insertTcNetworkMqPrincipal(tcNetworkMqPrincipal));
    }

    /**
     * 修改网络民情责任人
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcNetworkMqPrincipal tcNetworkMqPrincipal)
    {
        return toAjax(tcNetworkMqPrincipalService.updateTcNetworkMqPrincipal(tcNetworkMqPrincipal));
    }

    /**
     * 删除网络民情责任人
     */

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