Commit ee40a6e2 by Future

入参加对象包装

parent 5137c283
...@@ -2,6 +2,9 @@ package com.wecloud.im.friend.controller; ...@@ -2,6 +2,9 @@ package com.wecloud.im.friend.controller;
import com.wecloud.im.entity.ImClient; import com.wecloud.im.entity.ImClient;
import com.wecloud.im.enums.FriendStateEnum; import com.wecloud.im.enums.FriendStateEnum;
import com.wecloud.im.friend.param.ImCreateRecommendParam;
import com.wecloud.im.friend.param.ImDeleteFriendParam;
import com.wecloud.im.friend.param.ImDeleteRecommendParam;
import com.wecloud.im.friend.param.ImFriendApplyDto; import com.wecloud.im.friend.param.ImFriendApplyDto;
import com.wecloud.im.friend.param.ImFriendApplyParam; import com.wecloud.im.friend.param.ImFriendApplyParam;
import com.wecloud.im.friend.param.ImFriendApproveParam; import com.wecloud.im.friend.param.ImFriendApproveParam;
...@@ -20,7 +23,6 @@ import io.geekidea.springbootplus.framework.log.annotation.OperationLog; ...@@ -20,7 +23,6 @@ import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType; import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -30,7 +32,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -30,7 +32,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author lixiaozhong * @author lixiaozhong
...@@ -135,13 +136,13 @@ public class ImFriendController extends BaseController { ...@@ -135,13 +136,13 @@ public class ImFriendController extends BaseController {
*/ */
@PostMapping("/batchDelete") @PostMapping("/batchDelete")
@ApiOperation(value = "删除好友") @ApiOperation(value = "删除好友")
public ApiResult<Boolean> batchDeleteFriend(@RequestBody List<String> friendClientIds) { public ApiResult<Boolean> batchDeleteFriend(@RequestBody ImDeleteFriendParam param) {
ImClient currentClient = imClientService.getCurentClient(); ImClient currentClient = imClientService.getCurentClient();
if(currentClient == null) { if(currentClient == null) {
return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null); return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null);
} }
imFriendService.batchDeleteFriend(currentClient, friendClientIds); imFriendService.batchDeleteFriend(currentClient, param.getFriendClientIds());
return ApiResult.ok(); return ApiResult.ok();
} }
...@@ -167,20 +168,20 @@ public class ImFriendController extends BaseController { ...@@ -167,20 +168,20 @@ public class ImFriendController extends BaseController {
@PostMapping("/recommend/batchCreate") @PostMapping("/recommend/batchCreate")
@OperationLog(name = "批量创建好友推荐", type = OperationLogType.PAGE) @OperationLog(name = "批量创建好友推荐", type = OperationLogType.PAGE)
@ApiOperation(value = "批量创建好友推荐") @ApiOperation(value = "批量创建好友推荐")
public ApiResult<Boolean> batchCreateRecommend(@RequestBody List<ImFriendRecommendDto> recommendFriends) { public ApiResult<Boolean> batchCreateRecommend(@RequestBody ImCreateRecommendParam param) {
ImClient currentClient = imClientService.getCurentClient(); ImClient currentClient = imClientService.getCurentClient();
if(currentClient == null) { if(currentClient == null) {
return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null); return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null);
} }
if(CollectionUtils.isEmpty(recommendFriends)) { if(CollectionUtils.isEmpty(param.getRecommendFriends())) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null); return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
} }
for (ImFriendRecommendDto p : recommendFriends) { for (ImFriendRecommendDto p : param.getRecommendFriends()) {
if (BaseEnum.valueOf(FriendStateEnum.class, p.getSource()) == null) { if (BaseEnum.valueOf(FriendStateEnum.class, p.getSource()) == null) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null); return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
} }
} }
imFriendService.batchCreateRecommend(currentClient, recommendFriends); imFriendService.batchCreateRecommend(currentClient, param.getRecommendFriends());
return ApiResult.ok(); return ApiResult.ok();
} }
...@@ -205,12 +206,12 @@ public class ImFriendController extends BaseController { ...@@ -205,12 +206,12 @@ public class ImFriendController extends BaseController {
*/ */
@PostMapping("/recommend/batchDelete") @PostMapping("/recommend/batchDelete")
@ApiOperation(value = "删除好友推荐") @ApiOperation(value = "删除好友推荐")
public ApiResult<Boolean> batchDeleteRecommend(@RequestBody List<String> friendClientIds) { public ApiResult<Boolean> batchDeleteRecommend(@RequestBody ImDeleteRecommendParam param) {
ImClient currentClient = imClientService.getCurentClient(); ImClient currentClient = imClientService.getCurentClient();
if(currentClient == null) { if(currentClient == null) {
return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null); return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null);
} }
imFriendService.batchDeleteRecommend(currentClient, friendClientIds); imFriendService.batchDeleteRecommend(currentClient, param.getFriendClientIds());
return ApiResult.ok(); return ApiResult.ok();
} }
} }
......
package com.wecloud.im.friend.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author wenzhida
* @Date 2022/2/7 16:30
* @Description 批量创建好友推荐入参
*/
@Data
public class ImCreateRecommendParam implements Serializable {
private static final long serialVersionUID = 5228604783548712598L;
@ApiModelProperty("推荐好友列表")
private List<ImFriendRecommendDto> recommendFriends;
}
package com.wecloud.im.friend.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author wenzhida
* @Date 2022/2/7 16:30
* @Description 删除好友入参
*/
@Data
public class ImDeleteFriendParam implements Serializable {
private static final long serialVersionUID = 5228604783548712598L;
@ApiModelProperty("好友的client-id")
private List<String> friendClientIds;
}
package com.wecloud.im.friend.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author wenzhida
* @Date 2022/2/7 16:30
* @Description 批量删除好友推荐入参
*/
@Data
public class ImDeleteRecommendParam implements Serializable {
private static final long serialVersionUID = -2325444195601100874L;
@ApiModelProperty("推荐好友列表")
private List<String> friendClientIds;
}
...@@ -35,7 +35,7 @@ public class ImApplicationServiceImpl extends BaseServiceImpl<ImApplicationMappe ...@@ -35,7 +35,7 @@ public class ImApplicationServiceImpl extends BaseServiceImpl<ImApplicationMappe
private ImApplicationMapper imApplicationMapper; private ImApplicationMapper imApplicationMapper;
@Override @Override
@Cacheable(key = "'id_'+#p0") // @Cacheable(key = "'id_'+#p0")
public ImApplication getCacheById(Long id) { public ImApplication getCacheById(Long id) {
return super.getById(id); return super.getById(id);
} }
......
...@@ -64,12 +64,12 @@ public class ImClientLoginServiceImpl implements ImClientLoginService { ...@@ -64,12 +64,12 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
ImApplication imApplication = imApplicationService.getCacheAppByAppKey(imTokenVerify.getAppKey()); ImApplication imApplication = imApplicationService.getCacheAppByAppKey(imTokenVerify.getAppKey());
if (imApplication == null) { if (imApplication == null) {
log.info("imApplication == null,getAppKey:" + imTokenVerify.getAppKey()); log.error("imApplication == null,getAppKey:" + imTokenVerify.getAppKey());
return ApiResult.result(ApiCode.FAIL, null); return ApiResult.result(ApiCode.FAIL, null);
} }
if (imTokenVerify.getPlatform() == null) { if (imTokenVerify.getPlatform() == null) {
log.info("platform is null , clientId is: {}", imTokenVerify.getClientId()); log.error("platform is null , clientId is: {}", imTokenVerify.getClientId());
return ApiResult.result(ApiCode.FAIL, null); return ApiResult.result(ApiCode.FAIL, null);
} }
...@@ -79,7 +79,7 @@ public class ImClientLoginServiceImpl implements ImClientLoginService { ...@@ -79,7 +79,7 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
// 验证签名 // 验证签名
if (!mySign.equals(imTokenVerify.getSign())) { if (!mySign.equals(imTokenVerify.getSign())) {
log.info("sign不一致" + mySign); log.error("sign不一致,mySign:{},verify sign:{}", mySign, imTokenVerify.getSign());
return ApiResult.result(ApiCode.FAIL, null); return ApiResult.result(ApiCode.FAIL, null);
} }
......
...@@ -68,6 +68,7 @@ public class UserStateCacheManager extends UserStateListener { ...@@ -68,6 +68,7 @@ public class UserStateCacheManager extends UserStateListener {
ClientChannelInfo clientChannelInfo = new ClientChannelInfo(); ClientChannelInfo clientChannelInfo = new ClientChannelInfo();
clientChannelInfo.setPlatform(Integer.valueOf(split[0])); clientChannelInfo.setPlatform(Integer.valueOf(split[0]));
clientChannelInfo.setLanIp(split[1]); clientChannelInfo.setLanIp(split[1]);
clientChannelInfo.setClientId(String.valueOf(clientId));
clientChannelInfos.add(clientChannelInfo); clientChannelInfos.add(clientChannelInfo);
} }
......
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