package com.cpms.project.plant.controller;

import com.cpms.common.annotation.Log;
import com.cpms.common.core.controller.BaseController;
import com.cpms.common.core.domain.AjaxResult;
import com.cpms.common.core.page.TableDataInfo;
import com.cpms.common.enums.BusinessType;
import com.cpms.common.utils.poi.ExcelUtil;
import com.cpms.project.plant.service.ITMtContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 装置空白会议Controller
 *
 * @author ruoyi
 * @date 2023-08-03
 */
@RestController
@RequestMapping("/plant/content")
public class TMtContentController extends BaseController
{
    @Autowired
    private ITMtContentService tMtContentService;

    /**
     * 查询装置空白会议列表
     */
    @PreAuthorize("@ss.hasPermi('plant:content:list')")
    @GetMapping("/list")
    public TableDataInfo list(com.cpms.project.plant.domain.TMtContent tMtContent)
    {
        startPage();
        List<com.cpms.project.plant.domain.TMtContent> list = tMtContentService.selectTMtContentList(tMtContent);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('plant:content:list')")
    @GetMapping("/list2")
    public TableDataInfo list2(com.cpms.project.plant.domain.TMtContent tMtContent)
    {
        startPage();
        List<com.cpms.project.plant.domain.TMtContent> list = tMtContentService.selectContentList(tMtContent);
        return getDataTable(list);
    }

    /**
     * 导出装置空白会议列表
     */
    @PreAuthorize("@ss.hasPermi('plant:content:export')")
    @Log(title = "装置空白会议", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, com.cpms.project.plant.domain.TMtContent tMtContent)
    {
        List<com.cpms.project.plant.domain.TMtContent> list = tMtContentService.selectTMtContentList(tMtContent);
        ExcelUtil<com.cpms.project.plant.domain.TMtContent> util = new ExcelUtil<com.cpms.project.plant.domain.TMtContent>(com.cpms.project.plant.domain.TMtContent.class);
        util.exportExcel(list, "装置空白会议数据");
    }

    /**
     * 获取装置空白会议详细信息
     */
    @PreAuthorize("@ss.hasPermi('plant:content:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tMtContentService.selectTMtContentById(id));
    }

    /**
     * 新增装置空白会议
     */
    @PreAuthorize("@ss.hasPermi('plant:content:add')")
    @Log(title = "装置空白会议", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody com.cpms.project.plant.domain.TMtContent tMtContent)
    {
        return toAjax(tMtContentService.insertTMtContent(tMtContent));
    }

    /**
     * 修改装置空白会议
     */
    @PreAuthorize("@ss.hasPermi('plant:content:edit')")
    @Log(title = "装置空白会议", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody com.cpms.project.plant.domain.TMtContent tMtContent)
    {
        return toAjax(tMtContentService.updateTMtContent(tMtContent));
    }

    /**
     * 删除装置空白会议
     */
    @PreAuthorize("@ss.hasPermi('plant:content:remove')")
    @Log(title = "装置空白会议", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMtContentService.deleteTMtContentByIds(ids));
    }
}
