package com.ruoyi.zongzhi.controller;

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.utils.poi.ExcelUtil;
import com.ruoyi.zongzhi.domain.TcWpyrwwcl;
import com.ruoyi.zongzhi.service.ITcWpyrwwclService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 网评员任务完成率心Controller
 *
 * @author ruoyi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/zongzhi/wpyrwwcl")
@Api(tags = " 网评员任务完成率心")
public class TcWpyrwwclController extends BaseController {
    @Autowired
    private ITcWpyrwwclService tcWpyrwwclService;

    /**
     * 查询网评员任务完成率心列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TcWpyrwwcl tcWpyrwwcl) {
        startPage();
        List<TcWpyrwwcl> list = tcWpyrwwclService.selectTcWpyrwwclList(tcWpyrwwcl);
        return getDataTable(list);
    }

    /**
     * 导出网评员任务完成率心列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, TcWpyrwwcl tcWpyrwwcl) {
        List<TcWpyrwwcl> list = tcWpyrwwclService.selectTcWpyrwwclList(tcWpyrwwcl);
        ExcelUtil<TcWpyrwwcl> util = new ExcelUtil<TcWpyrwwcl>(TcWpyrwwcl.class);
        util.exportExcel(response, list, "网评员任务完成率心数据");
    }

    /**
     * 获取网评员任务完成率心详细信息
     */

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

    /**
     * 新增网评员任务完成率心
     */

    @PostMapping
    public AjaxResult add(@RequestBody TcWpyrwwcl tcWpyrwwcl) {
        tcWpyrwwcl.setIsStatus(true);
        return toAjax(tcWpyrwwclService.insertTcWpyrwwcl(tcWpyrwwcl));
    }

    /**
     * 修改网评员任务完成率心
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcWpyrwwcl tcWpyrwwcl) {
        return toAjax(tcWpyrwwclService.updateTcWpyrwwcl(tcWpyrwwcl));
    }

    /**
     * 删除网评员任务完成率心
     */

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