Commit 47b8b698 by 罗长华

移动sdk获取用户列表至ImFriendController

parent c24c3494
......@@ -3,7 +3,6 @@ package com.wecloud.im.externalaccess.controller;
import io.geekidea.springbootplus.framework.common.api.ApiCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.shiro.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -11,11 +10,9 @@ import lombok.extern.slf4j.Slf4j;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.wecloud.im.entity.ImClient;
......@@ -72,46 +69,5 @@ public class FriendController extends BaseController {
return ApiResult.ok(applyFriends);
}
/**
* 查询好友信息,只有自己的好友才查得到 sdk
*/
@GetMapping("/sdk/info")
@ApiOperation(value = "查询好友信息,只有自己的好友才查得到")
public ApiResult<FriendDto> getFriendInfoSdk(@RequestBody ImFriendBaseParam param) {
if (param == null) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
}
Long appId = SecurityUtils.getCurrentAppId();
ImClient imClient = imClientService.getCacheImClient(appId, param.getClientId());
return ApiResult.ok(friendService.getFriendInfo(imClient, param));
}
/**
* 全量获取好友列表 sdk使用
* @Author luozh
* @Date 2022年04月22日 11:28:44
* @param
* @Return
*/
@GetMapping("/sdk/getFriends")
@ApiOperation(value = "全量获取好友列表")
public ApiResult<List<FriendDto>> getFriendsSdk(@RequestParam("clientId") String clientId) {
Long appId = SecurityUtils.getCurrentAppId();
ImClient imClient = imClientService.getCacheImClient(appId, clientId);
return ApiResult.ok(friendService.getFriends(imClient));
}
/**
* 好友请求列表,最多只返回1000个 sdk使用
*/
@GetMapping("/sdk/unsureFriends")
@ApiOperation(value = "获取好友请求列表,最多只返回1000个")
public ApiResult<List<FriendDto>> getUnsureFriendsSdk(@RequestParam("clientId") String clientId) {
Long appId = SecurityUtils.getCurrentAppId();
ImClient imClient = imClientService.getCacheImClient(appId, clientId);
List<FriendDto> applyFriends = friendService.getApplyFriends(imClient);
return ApiResult.ok(applyFriends);
}
}
......@@ -130,6 +130,35 @@ public class ImFriendController extends BaseController {
return ApiResult.ok(applyFriends);
}
/**
* 查询好友信息,只有自己的好友才查得到 sdk
*/
@GetMapping("/sdk/info")
@ApiOperation(value = "查询好友信息,只有自己的好友才查得到")
public ApiResult<ImFriendApplyDto> getFriendInfoSdk(@RequestBody ImFriendBaseParam param) {
if (param == null) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
}
Long appId = SecurityUtils.getCurrentAppId();
ImClient imClient = imClientService.getCacheImClient(appId, param.getClientId());
return ApiResult.ok(imFriendService.getFriendInfo(imClient.getClientId(), param.getFriendClientId()));
}
/**
* 全量获取好友列表 sdk使用
* @Author luozh
* @Date 2022年04月22日 11:28:44
* @param
* @Return
*/
@GetMapping("/sdk/getFriends")
@ApiOperation(value = "全量获取好友列表")
public ApiResult<List<ImFriendBaseDto>> getFriendsSdk(@RequestParam("clientId") String clientId) {
Long appId = SecurityUtils.getCurrentAppId();
ImClient imClient = imClientService.getCacheImClient(appId, clientId);
return ApiResult.ok(imFriendService.getFriends(imClient));
}
/**
* 接受/拒绝好友申请
......
package com.wecloud.im.friend.service;
import io.geekidea.springbootplus.framework.common.exception.BusinessException;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
......@@ -66,6 +67,20 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
}
/**
* 全量获取好友列表
*/
public List<ImFriendBaseDto> getFriends(ImClient currentClient) {
if (currentClient == null) {
throw new BusinessException("当前登录用户未找到");
}
ImFriendPageParam pageParam = new ImFriendPageParam();
pageParam.setPageIndex(1L);
pageParam.setPageSize(Long.MAX_VALUE);
Paging<ImFriendBaseDto> pageFriends = getImFriendPageList(currentClient.getClientId(), pageParam);
return pageFriends.getRecords();
}
/**
* 获取待验证的好友列表
* @param currentClient
* @return
......
......@@ -34,7 +34,7 @@ public class ResourcePathConstants {
/**
* 全量获取好友列表
*/
public static final String GET_FRIENDS = "/api/friends/sdk/getFriends";
public static final String GET_FRIENDS = "/api/friend/sdk/getFriends";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment