From 3b61f8f6dd0cdb6ae3d9736c6e7770843ef49c92 Mon Sep 17 00:00:00 2001 From: "heavyrain.lee" Date: Mon, 6 Jan 2020 14:53:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A2=91=E9=81=93=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=87=AA=E5=B7=B1=E4=BF=A1=E6=81=AF=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/wildfirechat/common/APIPath.java | 1 + .../pojos/OutputGetChannelInfo.java | 106 ++++++++++++++++++ .../wildfirechat/sdk/ChannelServiceApi.java | 5 + .../main/java/cn/wildfirechat/sdk/Main.java | 42 ++++--- 4 files changed, 137 insertions(+), 17 deletions(-) create mode 100755 common/src/main/java/cn/wildfirechat/pojos/OutputGetChannelInfo.java diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index 6f8ee82f..37a4cb75 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -50,6 +50,7 @@ public interface APIPath { String Channel_User_Info = "/channel/user_info"; String Channel_Update_Profile = "/channel/update_profile"; + String Channel_Get_Profile = "/channel/get_profile"; String Channel_Message_Send = "/channel/message/send"; String Channel_Subscribe = "/channel/subscribe"; String Channel_Subscriber_List = "/channel/subscriber_list"; diff --git a/common/src/main/java/cn/wildfirechat/pojos/OutputGetChannelInfo.java b/common/src/main/java/cn/wildfirechat/pojos/OutputGetChannelInfo.java new file mode 100755 index 00000000..84cb045a --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/OutputGetChannelInfo.java @@ -0,0 +1,106 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + + +import cn.wildfirechat.proto.WFCMessage; + +public class OutputGetChannelInfo { + private String channelId; + private String name; + private String desc; + private String portrait; + private String extra; + private String owner; + private int status; + private long updateDt; + private String callback; + private int automatic; + + + public String getChannelId() { + return channelId; + } + + public void setChannelId(String channelId) { + this.channelId = channelId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getPortrait() { + return portrait; + } + + public void setPortrait(String portrait) { + this.portrait = portrait; + } + + public String getExtra() { + return extra; + } + + public void setExtra(String extra) { + this.extra = extra; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public long getUpdateDt() { + return updateDt; + } + + public void setUpdateDt(long updateDt) { + this.updateDt = updateDt; + } + + public String getCallback() { + return callback; + } + + public void setCallback(String callback) { + this.callback = callback; + } + + public int getAutomatic() { + return automatic; + } + + public void setAutomatic(int automatic) { + this.automatic = automatic; + } +} diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java b/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java index 1f6270df..a05fbd0f 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java @@ -32,6 +32,11 @@ public class ChannelServiceApi { return httpUtils.httpJsonPost(path, modifyChannelInfo, Void.class); } + public IMResult getChannelInfo() throws Exception { + String path = APIPath.Channel_Get_Profile; + return httpUtils.httpJsonPost(path, null, OutputGetChannelInfo.class); + } + public IMResult sendMessage(int line, List targets, MessagePayload payload) throws Exception { String path = APIPath.Channel_Message_Send; SendChannelMessageData messageData = new SendChannelMessageData(); diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index ad609016..912b9606 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -494,13 +494,13 @@ public class Main { } //测试频道API功能,仅专业版支持 - //1. 先创建频道 + //1. 先使用admin api创建频道 inputCreateChannel = new InputCreateChannel(); inputCreateChannel.setName("testChannel"); inputCreateChannel.setOwner("user1"); resultCreateChannel = GeneralAdmin.createChannel(inputCreateChannel); if (resultCreateChannel != null && resultCreateChannel.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { - System.out.println("success"); + System.out.println("create channel success"); } else { System.out.println("create channel failure"); System.exit(-1); @@ -512,41 +512,41 @@ public class Main { //3. 测试channel api功能 resultVoid = channelServiceApi.subscribe("user2"); if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { - System.out.println("block user done"); + System.out.println("subscribe success"); } else { - System.out.println("block user failure"); + System.out.println("subscribe failure"); System.exit(-1); } resultVoid = channelServiceApi.subscribe("user3"); if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { - System.out.println("block user done"); + System.out.println("subscribe done"); } else { - System.out.println("block user failure"); + System.out.println("subscribe failure"); System.exit(-1); } IMResult resultStringList = channelServiceApi.getSubscriberList(); if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("user2") && resultStringList.getResult().getList().contains("user3")) { - System.out.println("block user done"); + System.out.println("get subscriber done"); } else { - System.out.println("block user failure"); + System.out.println("get subscriber failure"); System.exit(-1); } resultVoid = channelServiceApi.unsubscribe("user2"); if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { - System.out.println("block user done"); + System.out.println("unsubscriber done"); } else { - System.out.println("block user failure"); + System.out.println("unsubscriber failure"); System.exit(-1); } resultStringList = channelServiceApi.getSubscriberList(); if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("user3") && !resultStringList.getResult().getList().contains("user2")) { - System.out.println("block user done"); + System.out.println("get subscriber done"); } else { - System.out.println("block user failure"); + System.out.println("get subscriber failure"); System.exit(-1); } @@ -554,7 +554,7 @@ public class Main { if (resultGetUserInfo1 != null && resultGetUserInfo1.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { System.out.println("get user info success"); } else { - System.out.println("get user info by name failure"); + System.out.println("get user info failure"); System.exit(-1); } @@ -565,9 +565,9 @@ public class Main { resultSendMessage = channelServiceApi.sendMessage(0, null,payload); if (resultSendMessage != null && resultSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { - System.out.println("send message success"); + System.out.println("send message to all the subscriber success"); } else { - System.out.println("send message failure"); + System.out.println("send message to all the subscriber failure"); System.exit(-1); } @@ -575,14 +575,22 @@ public class Main { resultSendMessage = channelServiceApi.sendMessage(0, Arrays.asList("user2"),payload); if (resultSendMessage != null && resultSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { - System.out.println("send message success"); + System.out.println("send message to user2 success"); } else { - System.out.println("send message failure"); + System.out.println("send message to user2 failure"); System.exit(-1); } voidIMResult = channelServiceApi.modifyChannelInfo(ProtoConstants.ModifyChannelInfoType.Modify_Channel_Desc, "this is a test channel, update at:" + new Date().toString()); if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("modify channel profile success"); + } else { + System.out.println("modify channel profile failure"); + System.exit(-1); + } + + IMResult outputGetChannelInfoIMResult = channelServiceApi.getChannelInfo(); + if (outputGetChannelInfoIMResult != null && outputGetChannelInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { System.out.println("destroy user success"); } else { System.out.println("destroy user failure");