修正sdk好友和频道接口错误
This commit is contained in:
@@ -44,7 +44,8 @@ public class CreateChannelAction extends AdminAction {
|
|||||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||||
InputCreateChannel inputCreateChannel = getRequestBody(request.getNettyRequest(), InputCreateChannel.class);
|
InputCreateChannel inputCreateChannel = getRequestBody(request.getNettyRequest(), InputCreateChannel.class);
|
||||||
if (inputCreateChannel != null
|
if (inputCreateChannel != null
|
||||||
&& !StringUtil.isNullOrEmpty(inputCreateChannel.getName())) {
|
&& !StringUtil.isNullOrEmpty(inputCreateChannel.getName())
|
||||||
|
&& !StringUtil.isNullOrEmpty(inputCreateChannel.getOwner())) {
|
||||||
|
|
||||||
|
|
||||||
if(StringUtil.isNullOrEmpty(inputCreateChannel.getTargetId())) {
|
if(StringUtil.isNullOrEmpty(inputCreateChannel.getTargetId())) {
|
||||||
|
|||||||
+2
-1
@@ -9,6 +9,7 @@
|
|||||||
package com.xiaoleilu.loServer.action.admin;
|
package com.xiaoleilu.loServer.action.admin;
|
||||||
|
|
||||||
import cn.wildfirechat.common.APIPath;
|
import cn.wildfirechat.common.APIPath;
|
||||||
|
import cn.wildfirechat.pojos.OutputStringList;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.xiaoleilu.loServer.RestResult;
|
import com.xiaoleilu.loServer.RestResult;
|
||||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||||
@@ -44,7 +45,7 @@ public class FriendRelationGetAction extends AdminAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.setStatus(HttpResponseStatus.OK);
|
response.setStatus(HttpResponseStatus.OK);
|
||||||
RestResult result = RestResult.ok(list);
|
RestResult result = RestResult.ok(new OutputStringList(list));
|
||||||
response.setContent(new Gson().toJson(result));
|
response.setContent(new Gson().toJson(result));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
|||||||
this.doAction(ctx, request, response);
|
this.doAction(ctx, request, response);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
Action errorAction = ServerSetting.getErrorAction(ServerSetting.MAPPING_ERROR);
|
Action errorAction = ServerSetting.getErrorAction(ServerSetting.MAPPING_ERROR);
|
||||||
request.putParam(UnknownErrorAction.ERROR_PARAM_NAME, e);
|
request.putParam(UnknownErrorAction.ERROR_PARAM_NAME, e);
|
||||||
response.setContent(e.toString());
|
response.setContent(e.toString());
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OutputStringList {
|
||||||
|
private List<String> list;
|
||||||
|
|
||||||
|
public OutputStringList() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutputStringList(List<String> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<String> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,12 +15,12 @@ public class FriendAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IMResult<Void> getFriendStatusList(String userId, int status) throws Exception {
|
public static IMResult<OutputStringList> getFriendStatusList(String userId, int status) throws Exception {
|
||||||
String path = APIPath.Friend_Get_List;
|
String path = APIPath.Friend_Get_List;
|
||||||
InputGetFriendList input = new InputGetFriendList();
|
InputGetFriendList input = new InputGetFriendList();
|
||||||
input.setUserId(userId);
|
input.setUserId(userId);
|
||||||
input.setStatus(status);
|
input.setStatus(status);
|
||||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, input, OutputStringList.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,6 +369,7 @@ public class Main {
|
|||||||
|
|
||||||
InputCreateChannel inputCreateChannel = new InputCreateChannel();
|
InputCreateChannel inputCreateChannel = new InputCreateChannel();
|
||||||
inputCreateChannel.setName("MyChannel");
|
inputCreateChannel.setName("MyChannel");
|
||||||
|
inputCreateChannel.setOwner("user1");
|
||||||
IMResult<OutputCreateChannel> resultCreateChannel = GeneralAdmin.createChannel(inputCreateChannel);
|
IMResult<OutputCreateChannel> resultCreateChannel = GeneralAdmin.createChannel(inputCreateChannel);
|
||||||
if (resultCreateChannel != null && resultCreateChannel.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (resultCreateChannel != null && resultCreateChannel.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("success");
|
System.out.println("success");
|
||||||
@@ -377,6 +378,56 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//***********************************************
|
||||||
|
//**** 好友相关功能
|
||||||
|
//***********************************************
|
||||||
|
//先创建2个用户
|
||||||
|
userInfo = new InputOutputUserInfo();
|
||||||
|
userInfo.setUserId("ff1");
|
||||||
|
userInfo.setName("ff1");
|
||||||
|
userInfo.setMobile("13800000000");
|
||||||
|
userInfo.setDisplayName("ff1");
|
||||||
|
|
||||||
|
resultCreateUser = UserAdmin.createUser(userInfo);
|
||||||
|
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||||
|
} else {
|
||||||
|
System.out.println("Create user failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
userInfo = new InputOutputUserInfo();
|
||||||
|
userInfo.setUserId("ff2");
|
||||||
|
userInfo.setName("ff2");
|
||||||
|
userInfo.setMobile("13800000001");
|
||||||
|
userInfo.setDisplayName("ff2");
|
||||||
|
|
||||||
|
resultCreateUser = UserAdmin.createUser(userInfo);
|
||||||
|
if (resultCreateUser != null && resultCreateUser.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("Create user " + resultCreateUser.getResult().getName() + " success");
|
||||||
|
} else {
|
||||||
|
System.out.println("Create user failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
IMResult<Void> updateFriendStatusResult = FriendAdmin.updateFriendStatus("ff1", "ff2", 1);
|
||||||
|
if (updateFriendStatusResult != null && updateFriendStatusResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("update friend status success");
|
||||||
|
} else {
|
||||||
|
System.out.println("update friend status failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
IMResult<OutputStringList> resultGetFriendList = FriendAdmin.getFriendStatusList("ff1", 1);
|
||||||
|
if (resultGetFriendList != null && resultGetFriendList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultGetFriendList.getResult().getList().contains("ff2")) {
|
||||||
|
System.out.println("get friend status success");
|
||||||
|
} else {
|
||||||
|
System.out.println("get friend status failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//初始化机器人API
|
//初始化机器人API
|
||||||
RobotHttpUtils.init("http://localhost", "robot1", "123456");
|
RobotHttpUtils.init("http://localhost", "robot1", "123456");
|
||||||
//***********************************************
|
//***********************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user