package com.ruoyi.web.controller.cp;

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

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
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.system.domain.CpsGlbMsg;
import com.ruoyi.system.service.ICpsGlbMsgService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * cps_glb_msg 全局消息Controller
 *
 * @author ruoyi
 * @date 2024-08-14
 */
@RestController
@CrossOrigin
@Anonymous
@RequestMapping("/cp/msg")
public class CpsGlbMsgController extends BaseController
{
    @Autowired
    private ICpsGlbMsgService cpsGlbMsgService;

    /**
     * 查询cps_glb_msg 全局消息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CpsGlbMsg cpsGlbMsg)
    {
        startPage();
        List<CpsGlbMsg> list = cpsGlbMsgService.selectCpsGlbMsgList(cpsGlbMsg);
        return getDataTable(list);
    }

    /**
     * 导出cps_glb_msg 全局消息列表
     */
    @Log(title = "cps_glb_msg 全局消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CpsGlbMsg cpsGlbMsg)
    {
        List<CpsGlbMsg> list = cpsGlbMsgService.selectCpsGlbMsgList(cpsGlbMsg);
        ExcelUtil<CpsGlbMsg> util = new ExcelUtil<CpsGlbMsg>(CpsGlbMsg.class);
        util.exportExcel(response, list, "cps_glb_msg 全局消息数据");
    }

    /**
     * 获取cps_glb_msg 全局消息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cpsGlbMsgService.selectCpsGlbMsgById(id));
    }

    /**
     * 新增cps_glb_msg 全局消息
     */
    @Log(title = "cps_glb_msg 全局消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CpsGlbMsg cpsGlbMsg)
    {
        return toAjax(cpsGlbMsgService.insertCpsGlbMsg(cpsGlbMsg));
    }

    /**
     * 修改cps_glb_msg 全局消息
     */
    @Log(title = "cps_glb_msg 全局消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CpsGlbMsg cpsGlbMsg)
    {
        return toAjax(cpsGlbMsgService.updateCpsGlbMsg(cpsGlbMsg));
    }

    /**
     * 删除cps_glb_msg 全局消息
     */
    @Log(title = "cps_glb_msg 全局消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cpsGlbMsgService.deleteCpsGlbMsgByIds(ids));
    }
}
