add chatroom api
This commit is contained in:
@@ -90,6 +90,12 @@
|
|||||||
<map name="user_chatroom">
|
<map name="user_chatroom">
|
||||||
</map>
|
</map>
|
||||||
|
|
||||||
|
<multimap name="chatroom_black">
|
||||||
|
</multimap>
|
||||||
|
|
||||||
|
<multimap name="chatroom_manager">
|
||||||
|
</multimap>
|
||||||
|
|
||||||
<map name="robots">
|
<map name="robots">
|
||||||
<!-- 7 days -->
|
<!-- 7 days -->
|
||||||
<time-to-live-seconds>604800</time-to-live-seconds>
|
<time-to-live-seconds>604800</time-to-live-seconds>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_chatroom_blacklist`;
|
||||||
|
CREATE TABLE `t_chatroom_blacklist` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_cid` varchar(64) NOT NULL,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_state` tinyint NOT NULL DEFAULT 0,
|
||||||
|
`_expired_time` bigint(20) NOT NULL,
|
||||||
|
`_dt` bigint(20) NOT NULL,
|
||||||
|
UNIQUE INDEX `cr_bl_uid_index` (`_cid`,_uid)
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_chatroom_manager`;
|
||||||
|
CREATE TABLE `t_chatroom_manager` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_cid` varchar(64) NOT NULL,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_state` tinyint NOT NULL DEFAULT 0,
|
||||||
|
`_dt` bigint(20) NOT NULL,
|
||||||
|
UNIQUE INDEX `cr_man_uid_index` (`_cid`,_uid)
|
||||||
|
);
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_chatroom_blacklist`;
|
||||||
|
CREATE TABLE `t_chatroom_blacklist` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_cid` varchar(64) NOT NULL,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_state` tinyint NOT NULL DEFAULT 0,
|
||||||
|
`_expired_time` bigint(20) NOT NULL,
|
||||||
|
`_dt` bigint(20) NOT NULL,
|
||||||
|
UNIQUE INDEX `cr_bl_uid_index` (`_cid`,_uid)
|
||||||
|
)
|
||||||
|
ENGINE = InnoDB
|
||||||
|
DEFAULT CHARACTER SET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_chatroom_manager`;
|
||||||
|
CREATE TABLE `t_chatroom_manager` (
|
||||||
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`_cid` varchar(64) NOT NULL,
|
||||||
|
`_uid` varchar(64) NOT NULL,
|
||||||
|
`_state` tinyint NOT NULL DEFAULT 0,
|
||||||
|
`_dt` bigint(20) NOT NULL,
|
||||||
|
UNIQUE INDEX `cr_man_uid_index` (`_cid`,_uid)
|
||||||
|
)
|
||||||
|
ENGINE = InnoDB
|
||||||
|
DEFAULT CHARACTER SET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -5,6 +5,11 @@ public interface APIPath {
|
|||||||
String Chatroom_Destroy = "/admin/chatroom/del";
|
String Chatroom_Destroy = "/admin/chatroom/del";
|
||||||
String Chatroom_Info = "/admin/chatroom/info";
|
String Chatroom_Info = "/admin/chatroom/info";
|
||||||
String Chatroom_GetMembers = "/admin/chatroom/members";
|
String Chatroom_GetMembers = "/admin/chatroom/members";
|
||||||
|
String Chatroom_SetBlacklist = "/admin/chatroom/set_black_status";
|
||||||
|
String Chatroom_GetBlacklist = "/admin/chatroom/get_black_status";
|
||||||
|
String Chatroom_SetManager = "/admin/chatroom/set_manager";
|
||||||
|
String Chatroom_GetManagerList = "/admin/chatroom/get_manager_list";
|
||||||
|
String Chatroom_MuteAll = "/admin/chatroom/mute_all";
|
||||||
|
|
||||||
|
|
||||||
String Sensitive_Add = "/admin/sensitive/add";
|
String Sensitive_Add = "/admin/sensitive/add";
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
public class InputChatroomId {
|
||||||
|
public String chatroomId;
|
||||||
|
|
||||||
|
public InputChatroomId() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputChatroomId(String chatroomId) {
|
||||||
|
this.chatroomId = chatroomId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
|
||||||
|
public class InputChatroomMute {
|
||||||
|
private String chatroomId;
|
||||||
|
private int status;
|
||||||
|
|
||||||
|
public InputChatroomMute(String chatroomId, int status) {
|
||||||
|
this.chatroomId = chatroomId;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChatroomId() {
|
||||||
|
return chatroomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChatroomId(String chatroomId) {
|
||||||
|
this.chatroomId = chatroomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
public class InputSetChatroomBlacklist {
|
||||||
|
private String chatroomId;
|
||||||
|
private String userId;
|
||||||
|
private int status;
|
||||||
|
private long expiredTime;
|
||||||
|
|
||||||
|
public InputSetChatroomBlacklist() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputSetChatroomBlacklist(String chatroomId, String userId, int status, long expiredTime) {
|
||||||
|
this.chatroomId = chatroomId;
|
||||||
|
this.userId = userId;
|
||||||
|
this.status = status;
|
||||||
|
this.expiredTime = expiredTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChatroomId() {
|
||||||
|
return chatroomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChatroomId(String chatroomId) {
|
||||||
|
this.chatroomId = chatroomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpiredTime() {
|
||||||
|
return expiredTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiredTime(long expiredTime) {
|
||||||
|
this.expiredTime = expiredTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
public class InputSetChatroomManager {
|
||||||
|
private String chatroomId;
|
||||||
|
private String userId;
|
||||||
|
private int status;
|
||||||
|
|
||||||
|
public InputSetChatroomManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputSetChatroomManager(String chatroomId, String userId, int status) {
|
||||||
|
this.chatroomId = chatroomId;
|
||||||
|
this.userId = userId;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChatroomId() {
|
||||||
|
return chatroomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChatroomId(String chatroomId) {
|
||||||
|
this.chatroomId = chatroomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OutputChatroomBlackInfos {
|
||||||
|
public static class OutputChatroomBlackInfo {
|
||||||
|
public String userId;
|
||||||
|
public int state;
|
||||||
|
public long expiredTime;
|
||||||
|
|
||||||
|
public OutputChatroomBlackInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutputChatroomBlackInfo(String userId, int state, long expiredTime) {
|
||||||
|
this.userId = userId;
|
||||||
|
this.state = state;
|
||||||
|
this.expiredTime = expiredTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<OutputChatroomBlackInfo> infos = new ArrayList<>();
|
||||||
|
public void addBlackInfo(String userId, int state, long expiredTime) {
|
||||||
|
infos.add(new OutputChatroomBlackInfo(userId, state, expiredTime));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,6 +84,12 @@
|
|||||||
<map name="user_chatroom">
|
<map name="user_chatroom">
|
||||||
</map>
|
</map>
|
||||||
|
|
||||||
|
<multimap name="chatroom_black">
|
||||||
|
</multimap>
|
||||||
|
|
||||||
|
<multimap name="chatroom_manager">
|
||||||
|
</multimap>
|
||||||
|
|
||||||
<map name="robots">
|
<map name="robots">
|
||||||
<!-- 7 days -->
|
<!-- 7 days -->
|
||||||
<time-to-live-seconds>604800</time-to-live-seconds>
|
<time-to-live-seconds>604800</time-to-live-seconds>
|
||||||
|
|||||||
@@ -37,6 +37,37 @@ public class ChatroomAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, input, OutputStringList.class);
|
return AdminHttpUtils.httpJsonPost(path, input, OutputStringList.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//仅专业版支持
|
||||||
|
//status:0,正常;1,禁言;2,禁止加入
|
||||||
|
public static IMResult<Void> setChatroomBlacklist(String chatroomId, String userId, int status) throws Exception {
|
||||||
|
String path = APIPath.Chatroom_SetBlacklist;
|
||||||
|
InputSetChatroomBlacklist input = new InputSetChatroomBlacklist(chatroomId, userId, status, 0);
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMResult<OutputChatroomBlackInfos> getChatroomBlacklist(String chatroomId) throws Exception {
|
||||||
|
String path = APIPath.Chatroom_GetBlacklist;
|
||||||
|
InputChatroomId input = new InputChatroomId(chatroomId);
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, input, OutputChatroomBlackInfos.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
//status: 1 set; 0 unset
|
||||||
|
public static IMResult<Void> setChatroomManager(String chatroomId, String userId, int status) throws Exception {
|
||||||
|
String path = APIPath.Chatroom_SetManager;
|
||||||
|
InputSetChatroomManager input = new InputSetChatroomManager(chatroomId, userId, status);
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMResult<OutputStringList> getChatroomManagerList(String chatroomId) throws Exception {
|
||||||
|
String path = APIPath.Chatroom_GetManagerList;
|
||||||
|
InputChatroomId input = new InputChatroomId(chatroomId);
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, input, OutputStringList.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMResult<Void> setChatroomMute(String chatroomId, boolean mute) throws Exception {
|
||||||
|
String path = APIPath.Chatroom_MuteAll;
|
||||||
|
InputChatroomMute input = new InputChatroomMute(chatroomId, mute ? 1 : 0);
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -575,6 +575,105 @@ public class Main {
|
|||||||
System.out.println("chatroom not destroyed!");
|
System.out.println("chatroom not destroyed!");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//下面仅专业版支持
|
||||||
|
/*
|
||||||
|
//设置用户聊天室黑名单。0正常;1禁言;2禁止加入。
|
||||||
|
IMResult<Void> voidIMResult1 = ChatroomAdmin.setChatroomBlacklist("chatroom1", "oto9o9__", 1);
|
||||||
|
if (voidIMResult1 != null && voidIMResult1.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("add chatroom black success");
|
||||||
|
} else {
|
||||||
|
System.out.println("add chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取聊天室黑名单
|
||||||
|
IMResult<OutputChatroomBlackInfos> blackInfos = ChatroomAdmin.getChatroomBlacklist("chatroom1");
|
||||||
|
if (blackInfos != null && blackInfos.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && !blackInfos.getResult().infos.isEmpty()) {
|
||||||
|
boolean success = false;
|
||||||
|
for (OutputChatroomBlackInfos.OutputChatroomBlackInfo info : blackInfos.getResult().infos) {
|
||||||
|
if (info.userId.equals("oto9o9__")) {
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
|
System.out.println("add chatroom black success");
|
||||||
|
} else {
|
||||||
|
System.out.println("add chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("add chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//取消用户聊天室黑名单。0正常;1禁言;2禁止加入。
|
||||||
|
voidIMResult1 = ChatroomAdmin.setChatroomBlacklist("chatroom1", "oto9o9__", 0);
|
||||||
|
if (voidIMResult1 != null && voidIMResult1.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("remove chatroom black success");
|
||||||
|
} else {
|
||||||
|
System.out.println("remove chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取聊天室黑名单
|
||||||
|
blackInfos = ChatroomAdmin.getChatroomBlacklist("chatroom1");
|
||||||
|
if (blackInfos != null && blackInfos.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
boolean success = true;
|
||||||
|
for (OutputChatroomBlackInfos.OutputChatroomBlackInfo info : blackInfos.getResult().infos) {
|
||||||
|
if (info.userId.equals("oto9o9__")) {
|
||||||
|
success = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
|
System.out.println("remove chatroom black success");
|
||||||
|
} else {
|
||||||
|
System.out.println("remove chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("remove chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置聊天室管理员
|
||||||
|
IMResult<Void> voidIMResult2 = ChatroomAdmin.setChatroomManager("chatroom1", "UserId1", 1);
|
||||||
|
if (voidIMResult2 != null && voidIMResult2.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("add chatroom manager success");
|
||||||
|
} else {
|
||||||
|
System.out.println("add chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取聊天室管理员
|
||||||
|
IMResult<OutputStringList> managers = ChatroomAdmin.getChatroomManagerList("chatroom1");
|
||||||
|
if (managers != null && managers.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && !managers.getResult().getList().isEmpty() && managers.getResult().getList().contains("UserId1")) {
|
||||||
|
System.out.println("add chatroom black success");
|
||||||
|
} else {
|
||||||
|
System.out.println("add chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//取消聊天室管理员
|
||||||
|
IMResult<Void> voidIMResult3 = ChatroomAdmin.setChatroomManager("chatroom1", "UserId1", 0);
|
||||||
|
if (voidIMResult3 != null && voidIMResult3.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("add chatroom manager success");
|
||||||
|
} else {
|
||||||
|
System.out.println("add chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取聊天室管理员
|
||||||
|
IMResult<OutputStringList> managers2 = ChatroomAdmin.getChatroomManagerList("chatroom1");
|
||||||
|
if (managers2 != null && managers2.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && !managers2.getResult().getList().contains("UserId1")) {
|
||||||
|
System.out.println("add chatroom black success");
|
||||||
|
} else {
|
||||||
|
System.out.println("add chatroom black failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testRobot() throws Exception {
|
static void testRobot() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user