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.TcWorkDongtai;
import com.ruoyi.zongzhi.service.ITcWorkDongtaiService;
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-10
 */
@RestController
@RequestMapping("/zongzhi/dongtai")
@Api(tags = "工作动态")
public class TcWorkDongtaiController extends BaseController
{
    @Autowired
    private ITcWorkDongtaiService tcWorkDongtaiService;

    /**
     * 查询工作动态列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TcWorkDongtai tcWorkDongtai)
    {
        startPage();
        List<TcWorkDongtai> list = tcWorkDongtaiService.selectTcWorkDongtaiList(tcWorkDongtai);
        return getDataTable(list);
    }

    /**
     * 导出工作动态列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, TcWorkDongtai tcWorkDongtai)
    {
        List<TcWorkDongtai> list = tcWorkDongtaiService.selectTcWorkDongtaiList(tcWorkDongtai);
        ExcelUtil<TcWorkDongtai> util = new ExcelUtil<TcWorkDongtai>(TcWorkDongtai.class);
        util.exportExcel(response, list, "工作动态数据");
    }

    /**
     * 获取工作动态详细信息
     */

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

    /**
     * 新增工作动态
     */

    @PostMapping
    public AjaxResult add(@RequestBody TcWorkDongtai tcWorkDongtai)
    {
        tcWorkDongtai.setIsStatus(true);
        return toAjax(tcWorkDongtaiService.insertTcWorkDongtai(tcWorkDongtai));
    }

    /**
     * 修改工作动态
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcWorkDongtai tcWorkDongtai)
    {
        return toAjax(tcWorkDongtaiService.updateTcWorkDongtai(tcWorkDongtai));
    }

    /**
     * 删除工作动态
     */

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




}
