package com.keao.edu.im.controller;

import com.keao.edu.im.service.MessageService;
import io.rong.models.message.BroadcastMessage;
import io.rong.models.message.SystemMessage;
import io.rong.models.message.TemplateMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by weiqinxiao on 2019/2/25.
 */
@RestController
@RequestMapping("/system")
public class SystemController {

    @Autowired
    MessageService messageService;

    @RequestMapping(value = "/send", method = RequestMethod.POST)
    public Object send(@RequestBody SystemMessage systemMessage) throws Exception {
        return messageService.systemSend(systemMessage);
    }

    @RequestMapping(value = "/broadcast", method = RequestMethod.POST)
    public Object broadcast(@RequestBody BroadcastMessage broadcastMessage) throws Exception {
        return messageService.systemBroadcast(broadcastMessage);
    }

    @RequestMapping(value = "/sendTemplate", method = RequestMethod.POST)
    public Object sendTemplate(@RequestBody TemplateMessage templateMessage) throws Exception {
        return messageService.systemSendTemplate(templateMessage);
    }
}
