123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package com.ym.service.Impl;
- import com.ym.service.MessageService;
- import io.rong.methods.message._private.Private;
- import io.rong.methods.message.chatroom.Chatroom;
- import io.rong.methods.message.group.Group;
- import io.rong.methods.message.history.History;
- import io.rong.methods.message.system.MsgSystem;
- import io.rong.methods.push.Push;
- import io.rong.models.Result;
- import io.rong.models.message.*;
- import io.rong.models.push.BroadcastModel;
- import io.rong.models.push.PushModel;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- @Slf4j
- @Service
- public class MessageServiceImpl implements MessageService {
- @Value("${cn.rongcloud.im.appkey}")
- private String appKey;
- @Value("${cn.rongcloud.im.secret}")
- private String appSecret;
- private Private getPrivate(){
- return new Private(appKey,appSecret);
- }
- private Group getGroup(){
- return new Group(appKey,appSecret);
- }
- private Chatroom getChatroom(){
- return new Chatroom(appKey,appSecret);
- }
- private MsgSystem getMsgSystem(){
- return new MsgSystem(appKey,appSecret);
- }
- private History getHistory(){
- return new History(appKey,appSecret);
- }
- private Push getPush(){
- return new Push(appKey,appSecret);
- }
- @Override
- public Result privateSend(PrivateMessage privateMessage) throws Exception {
- return getPrivate().send(privateMessage);
- }
- @Override
- public Result privateRecall(RecallMessage recallMessage) throws Exception {
- return getPrivate().recall(recallMessage);
- }
- @Override
- public Result privateSendTemplate(TemplateMessage templateMessage) throws Exception {
- return getPrivate().sendTemplate(templateMessage);
- }
- @Override
- public Result groupSend(GroupMessage groupMessage) throws Exception {
- return getGroup().send(groupMessage);
- }
- @Override
- public Result groupSendDirection(GroupMessage groupMessage) throws Exception {
- return getGroup().sendDirection(groupMessage);
- }
- @Override
- public Result groupSendMention(MentionMessage mentionMessage) throws Exception {
- return getGroup().sendMention(mentionMessage);
- }
- @Override
- public Result groupRecall(RecallMessage recallMessage) throws Exception {
- return getGroup().recall(recallMessage);
- }
- @Override
- public Result chatroomSend(ChatroomMessage chatroomMessage) throws Exception {
- return getChatroom().send(chatroomMessage);
- }
- @Override
- public Result chatroomBroadcast(ChatroomMessage chatroomMessage) throws Exception {
- return getChatroom().broadcast(chatroomMessage);
- }
- @Override
- public Result systemSend(SystemMessage systemMessage) throws Exception {
- return getMsgSystem().send(systemMessage);
- }
- @Override
- public Result systemBroadcast(BroadcastMessage broadcastMessage) throws Exception {
- return getMsgSystem().broadcast(broadcastMessage);
- }
- @Override
- public Result systemSendTemplate(TemplateMessage templateMessage) throws Exception {
- return getMsgSystem().sendTemplate(templateMessage);
- }
- @Override
- public Result historyGet(String date) throws Exception {
- return getHistory().get(date);
- }
- @Override
- public Result historyRemove(String date) throws Exception {
- return getHistory().remove(date);
- }
- @Override
- public Result pushPush(PushModel pushModel) throws Exception {
- return getPush().push(pushModel);
- }
- @Override
- public Result pushMessage(BroadcastModel broadcastModel) throws Exception {
- return getPush().message(broadcastModel);
- }
- }
|