package com.ruoyi.project.plant.controller;

import java.util.List;
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.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.plant.domain.TMtMessageattention;
import com.ruoyi.project.plant.service.ITMtMessageattentionService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 信息提醒Controller
 *
 * @author ruoyi
 * @date 2021-01-04
 */
@RestController
@RequestMapping("/plant/messageattention")
public class TMtMessageattentionController extends BaseController
{
    @Autowired
    private ITMtMessageattentionService tMtMessageattentionService;

    /**
     * 查询信息提醒列表
     */
    @PreAuthorize("@ss.hasPermi('plant:keymaintenance:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMtMessageattention tMtMessageattention)
    {
        startPage();
        List<TMtMessageattention> list = tMtMessageattentionService.selectTMtMessageattentionList(tMtMessageattention);
        return getDataTable(list);
    }

    /**
     * 导出信息提醒列表
     */
    @PreAuthorize("@ss.hasPermi('plant:keymaintenance:export')")
    @Log(title = "信息提醒", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TMtMessageattention tMtMessageattention)
    {
        List<TMtMessageattention> list = tMtMessageattentionService.selectTMtMessageattentionList(tMtMessageattention);
        ExcelUtil<TMtMessageattention> util = new ExcelUtil<TMtMessageattention>(TMtMessageattention.class);
        return util.exportExcel(list, "messageattention");
    }

    /**
     * 获取信息提醒详细信息
     */
    @PreAuthorize("@ss.hasPermi('plant:keymaintenance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tMtMessageattentionService.selectTMtMessageattentionById(id));
    }

    /**
     * 新增信息提醒
     */
    @PreAuthorize("@ss.hasPermi('plant:keymaintenance:add')")
    @Log(title = "信息提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMtMessageattention tMtMessageattention)
    {
        return toAjax(tMtMessageattentionService.insertTMtMessageattention(tMtMessageattention));
    }

    /**
     * 修改信息提醒
     */
    @PreAuthorize("@ss.hasPermi('plant:keymaintenance:edit')")
    @Log(title = "信息提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMtMessageattention tMtMessageattention)
    {
        return toAjax(tMtMessageattentionService.updateTMtMessageattention(tMtMessageattention));
    }

    /**
     * 删除信息提醒
     */
    @PreAuthorize("@ss.hasPermi('plant:keymaintenance:remove')")
    @Log(title = "信息提醒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMtMessageattentionService.deleteTMtMessageattentionByIds(ids));
    }
}
