package com.ruoyi.web.controller.jarvis;

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

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.jarvis.domain.XbMessageItem;
import com.ruoyi.jarvis.service.IXbMessageItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线报消息项Controller
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/jarvis/xbmessageitem")
public class XbMessageItemController extends BaseController
{
    @Autowired
    private IXbMessageItemService xbMessageItemService;

    /**
     * 查询线报消息项列表
     */
    @GetMapping("/list")
    public TableDataInfo list(XbMessageItem xbMessageItem)
    {
        startPage();
        List<XbMessageItem> list = xbMessageItemService.selectXbMessageItemList(xbMessageItem);
        TableDataInfo data = getDataTable(list);
        return data;
    }

    /**
     * 导出线报消息项列表
     */
    @Log(title = "线报消息项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XbMessageItem xbMessageItem)
    {
        List<XbMessageItem> list = xbMessageItemService.selectXbMessageItemList(xbMessageItem);
        ExcelUtil<XbMessageItem> util = new ExcelUtil<XbMessageItem>(XbMessageItem.class);
        util.exportExcel(response, list, "线报消息项数据");
    }

    /**
     * 获取线报消息项详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(xbMessageItemService.selectXbMessageItemById(id));
    }

    /**
     * 新增线报消息项
     */
    @Log(title = "线报消息项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XbMessageItem xbMessageItem)
    {
        return toAjax(xbMessageItemService.insertXbMessageItem(xbMessageItem));
    }

    /**
     * 修改线报消息项
     */
    @Log(title = "线报消息项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XbMessageItem xbMessageItem)
    {
        return toAjax(xbMessageItemService.updateXbMessageItem(xbMessageItem));
    }

    /**
     * 删除线报消息项
     */
    @Log(title = "线报消息项", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(xbMessageItemService.deleteXbMessageItemByIds(ids));
    }
}
