package com.ruoyi.zongzhi.controller;

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

import io.swagger.annotations.Api;
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.TcZhongdianWork;
import com.ruoyi.zongzhi.service.ITcZhongdianWorkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 重点工作项目Controller
 * 
 * @author ruoyi
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/zongzhi/work")
@Api(tags = "重点工作项目")
public class TcZhongdianWorkController extends BaseController
{
    @Autowired
    private ITcZhongdianWorkService tcZhongdianWorkService;

    /**
     * 查询重点工作项目列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TcZhongdianWork tcZhongdianWork)
    {
        startPage();
        List<TcZhongdianWork> list = tcZhongdianWorkService.selectTcZhongdianWorkList(tcZhongdianWork);
        return getDataTable(list);
    }

    /**
     * 导出重点工作项目列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, TcZhongdianWork tcZhongdianWork)
    {
        List<TcZhongdianWork> list = tcZhongdianWorkService.selectTcZhongdianWorkList(tcZhongdianWork);
        ExcelUtil<TcZhongdianWork> util = new ExcelUtil<TcZhongdianWork>(TcZhongdianWork.class);
        util.exportExcel(response, list, "重点工作项目数据");
    }

    /**
     * 获取重点工作项目详细信息
     */

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

    /**
     * 新增重点工作项目
     */


    @PostMapping
    public AjaxResult add(@RequestBody TcZhongdianWork tcZhongdianWork)
    {
        tcZhongdianWork.setIsStatus(true);
        return toAjax(tcZhongdianWorkService.insertTcZhongdianWork(tcZhongdianWork));
    }

    /**
     * 修改重点工作项目
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcZhongdianWork tcZhongdianWork)
    {
        return toAjax(tcZhongdianWorkService.updateTcZhongdianWork(tcZhongdianWork));
    }

    /**
     * 删除重点工作项目
     */

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