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

/**
 * 网评员Controller
 * 
 * @author ruoyi
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/zongzhi/commentator")
@Api(tags = " 网评员")
public class TcCommentatorController extends BaseController
{
    @Autowired
    private ITcCommentatorService tcCommentatorService;

    /**
     * 查询网评员列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TcCommentator tcCommentator)
    {
        startPage();
        List<TcCommentator> list = tcCommentatorService.selectTcCommentatorList(tcCommentator);
        return getDataTable(list);
    }

    /**
     * 导出网评员列表
     */


    @PostMapping("/export")
    public void export(HttpServletResponse response, TcCommentator tcCommentator)
    {
        List<TcCommentator> list = tcCommentatorService.selectTcCommentatorList(tcCommentator);
        ExcelUtil<TcCommentator> util = new ExcelUtil<TcCommentator>(TcCommentator.class);
        util.exportExcel(response, list, "网评员数据");
    }

    /**
     * 获取网评员详细信息
     */

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

    /**
     * 新增网评员
     */


    @PostMapping
    public AjaxResult add(@RequestBody TcCommentator tcCommentator)
    {
        tcCommentator.setIsStatus(true);
        return toAjax(tcCommentatorService.insertTcCommentator(tcCommentator));
    }

    /**
     * 修改网评员
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcCommentator tcCommentator)
    {
        return toAjax(tcCommentatorService.updateTcCommentator(tcCommentator));
    }

    /**
     * 删除网评员
     */

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