package com.dgtly.wxportal.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.dgtly.common.annotation.Log;
import com.dgtly.common.enums.BusinessType;
import com.dgtly.wxportal.domain.WxSendMessage;
import com.dgtly.wxportal.service.IWxSendMessageService;
import com.dgtly.common.core.controller.BaseController;
import com.dgtly.common.core.domain.AjaxResult;
import com.dgtly.common.utils.poi.ExcelUtil;
import com.dgtly.common.core.page.TableDataInfo;

/**
 * 企业微信发送消息历史记录Controller
 * 
 * @author qxp
 * @date 2020-09-02
 */
@Controller
@RequestMapping("/wxmessage")
public class WxSendMessageController extends BaseController
{
    private String prefix = "wxportal/wxmessage";

    @Autowired
    private IWxSendMessageService wxSendMessageService;

    @RequiresPermissions("wxportal")
    @GetMapping()
    public String wxmessage()
    {
        return prefix + "/wxmessage";
    }

    /**
     * 查询企业微信发送消息历史记录列表
     */
    @RequiresPermissions("wxportal:wxmessage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WxSendMessage wxSendMessage)
    {
        startPage();
        List<WxSendMessage> list = wxSendMessageService.selectWxSendMessageList(wxSendMessage);
        return getDataTable(list);
    }

    /**
     * 导出企业微信发送消息历史记录列表
     */
    @RequiresPermissions("wxportal:wxmessage:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WxSendMessage wxSendMessage)
    {
        List<WxSendMessage> list = wxSendMessageService.selectWxSendMessageList(wxSendMessage);
        ExcelUtil<WxSendMessage> util = new ExcelUtil<WxSendMessage>(WxSendMessage.class);
        return util.exportExcel(list, "wxmessage");
    }

    /**
     * 新增企业微信发送消息历史记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }



    /**
     * 修改企业微信发送消息历史记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WxSendMessage wxSendMessage = wxSendMessageService.selectWxSendMessageById(id);
        mmap.put("wxSendMessage", wxSendMessage);
        return prefix + "/edit";
    }



}
