|
@@ -40,9 +40,12 @@ public class EasemobComtroller {
|
|
|
private final String DELETE_GROUP_URL = "http://a1.easemob.com/%s/%s/chatgroups/%s";//删除群组
|
|
|
private final String QUERY_GROUP_PAGE_URL = "http://a1.easemob.com/%s/%s/chatgroups";//分页查询群组
|
|
|
private final String QUERY_GROUP_DETAILS_URL = "http://a1.easemob.com/%s/%s/chatgroups/%s";//查询群组详情
|
|
|
+ private final String QUERY_GROUP_USER_URL = "http://a1.easemob.com/%s/%s/chatgroups/%s/users";//查询群组内所有成员
|
|
|
private final String ADD_GROUP_USER_URL = "http://a1.easemob.com/%s/%s/chatgroups/%s/users";//批量添加群组成员
|
|
|
+ private final String DELETE_GROUP_USER_URL = "http://a1.easemob.com/%s/%s/chatgroups/%s/users/%s";//批量移除群组成员
|
|
|
private final String SET_USER_ATTRIBUTE_URL = "http://a1.easemob.com/%s/%s/metadata/user/%s";//设置环信用户属性
|
|
|
private final String GET_USER_ATTRIBUTE_URL = "http://a1.easemob.com/%s/%s/metadata/user/%s";//获取环信用户属性
|
|
|
+ private final String GET_USER_ATTRIBUTE_BATH_URL = "http://a1.easemob.com/%s/%s/metadata/user/get";//获取环信用户属性批量
|
|
|
|
|
|
@PostMapping("/getToken")
|
|
|
@ApiOperation("获取环信token接口")
|
|
@@ -63,7 +66,7 @@ public class EasemobComtroller {
|
|
|
//获取响应参数
|
|
|
String result = HttpRequest.post(tokenUrl)
|
|
|
.header("Accept", "application/json")
|
|
|
- .body(JSONUtil.parse(params).toString(),"application/json")
|
|
|
+ .body(JSONUtil.parse(params).toString(), "application/json")
|
|
|
.execute()
|
|
|
.body();
|
|
|
JSONObject resultJsonObj = JSONUtil.parseObj(result);
|
|
@@ -90,35 +93,13 @@ public class EasemobComtroller {
|
|
|
String result = HttpRequest.post(url)
|
|
|
.header("Accept", "application/json")
|
|
|
.header("Authorization", "Bearer " + easemobTokenStr)
|
|
|
- .body(JSONUtil.parse(params).toString(),"application/json")
|
|
|
+ .body(JSONUtil.parse(params).toString(), "application/json")
|
|
|
.execute()
|
|
|
.body();
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
return R.success(jsonObject);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/queryUserPage")
|
|
|
- @ApiOperation("分页查询环信用户")
|
|
|
- public R queryUserPage(QueryPageDto queryPageDto) {
|
|
|
- //获取环信token
|
|
|
- String easemobTokenStr = this.getToken().getData().toString();
|
|
|
- //拼接请求路径
|
|
|
- String url = String.format(QUERY_USER_PAGE_URL, ORG_NAME, APP_NAME);
|
|
|
- //封装请求参数
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- new MapBuilder<>(params)
|
|
|
- .put("limit", queryPageDto.getLimit())
|
|
|
- .put("cursor", queryPageDto.getCursor())
|
|
|
- .map();
|
|
|
- String result = HttpRequest.get(url)
|
|
|
- .header("Authorization", "Bearer " + easemobTokenStr)
|
|
|
- .form(params)
|
|
|
- .execute()
|
|
|
- .body();
|
|
|
- JSONObject resultJsonObj = JSONUtil.parseObj(result);
|
|
|
- return R.success(resultJsonObj);
|
|
|
- }
|
|
|
-
|
|
|
@GetMapping("/queryGroupPage")
|
|
|
@ApiOperation("分页查询环信应用内的群组")
|
|
|
public R queryGroupPage(QueryPageDto queryPageDto) {
|
|
@@ -236,13 +217,43 @@ public class EasemobComtroller {
|
|
|
String result = HttpRequest.post(url)
|
|
|
.header("Accept", "application/json")
|
|
|
.header("Authorization", "Bearer " + easemobTokenStr)
|
|
|
- .body(JSONUtil.parse(params).toString(),"application/json")
|
|
|
+ .body(JSONUtil.parse(params).toString(), "application/json")
|
|
|
.execute()
|
|
|
.body();
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
return R.success(jsonObject);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/queryGroupUser")
|
|
|
+ @ApiOperation("查询群组内所有的用户")
|
|
|
+ public R queryGroupUser(String groupId) {
|
|
|
+ //获取环信token
|
|
|
+ String easemobTokenStr = this.getToken().getData().toString();
|
|
|
+ //拼接请求路径
|
|
|
+ String url = String.format(QUERY_GROUP_USER_URL, ORG_NAME, APP_NAME, groupId);
|
|
|
+ String result = HttpRequest.get(url)
|
|
|
+ .header("Authorization", "Bearer " + easemobTokenStr)
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ JSONObject resultJsonObj = JSONUtil.parseObj(result);
|
|
|
+ return R.success(resultJsonObj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/removeGroupUser/{groupId}")
|
|
|
+ @ApiOperation("批量删除群组内的用户")
|
|
|
+ public R removeGroupUser(@PathVariable("groupId") String groupId, String usernames) {
|
|
|
+ //获取环信token
|
|
|
+ String easemobTokenStr = this.getToken().getData().toString();
|
|
|
+ //拼接请求路径
|
|
|
+ String url = String.format(DELETE_GROUP_USER_URL, ORG_NAME, APP_NAME, groupId, usernames);
|
|
|
+ String result = HttpRequest.delete(url)
|
|
|
+ .header("Authorization", "Bearer " + easemobTokenStr)
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ JSONObject resultJsonObj = JSONUtil.parseObj(result);
|
|
|
+ return R.success(resultJsonObj);
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/setUpUserAttribute")
|
|
|
@ApiOperation("设置环信用户属性")
|
|
|
public R setUpUserAttribute(@RequestBody SetUserAttributeDto setUserAttributeDto) {
|
|
@@ -286,4 +297,47 @@ public class EasemobComtroller {
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
return R.success(jsonObject);
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/getUpUserAttributeBath")
|
|
|
+ @ApiOperation("获取环信用户属性(批量)")
|
|
|
+ public R getUpUserAttributeBath(@RequestBody GetUpUserAttributeBathDto getUpUserAttributeBathDto) {
|
|
|
+ //获取环信token
|
|
|
+ String easemobTokenStr = this.getToken().getData().toString();
|
|
|
+ //拼接请求路径
|
|
|
+ String url = String.format(GET_USER_ATTRIBUTE_BATH_URL, ORG_NAME, APP_NAME);
|
|
|
+ //封装请求参数
|
|
|
+ Map<Object, Object> params = MapUtil.builder()
|
|
|
+ .put("properties", getUpUserAttributeBathDto.getProperties())
|
|
|
+ .put("targets", getUpUserAttributeBathDto.getTargets())
|
|
|
+ .map();
|
|
|
+ String result = HttpRequest.get(url)
|
|
|
+ .header("Authorization", "Bearer " + easemobTokenStr)
|
|
|
+ .body(JSONUtil.parse(params).toString(), "application/json")
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
+ return R.success(jsonObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/queryUserPage")
|
|
|
+ @ApiOperation("分页查询环信用户")
|
|
|
+ public R queryUserPage(QueryPageDto queryPageDto) {
|
|
|
+ //获取环信token
|
|
|
+ String easemobTokenStr = this.getToken().getData().toString();
|
|
|
+ //拼接请求路径
|
|
|
+ String url = String.format(QUERY_USER_PAGE_URL, ORG_NAME, APP_NAME);
|
|
|
+ //封装请求参数
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ new MapBuilder<>(params)
|
|
|
+ .put("limit", queryPageDto.getLimit())
|
|
|
+ .put("cursor", queryPageDto.getCursor())
|
|
|
+ .map();
|
|
|
+ String result = HttpRequest.get(url)
|
|
|
+ .header("Authorization", "Bearer " + easemobTokenStr)
|
|
|
+ .form(params)
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ JSONObject resultJsonObj = JSONUtil.parseObj(result);
|
|
|
+ return R.success(resultJsonObj);
|
|
|
+ }
|
|
|
}
|