Commit b0c5bc8e by lixiaozhong

将好友相关的接口请求参数全部改成json的方式

parent 6131f748
...@@ -3,7 +3,10 @@ package com.wecloud.im.friend.controller; ...@@ -3,7 +3,10 @@ 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.ImFriendApplyDto; import com.wecloud.im.friend.param.ImFriendApplyDto;
import com.wecloud.im.friend.param.ImFriendApplyParam;
import com.wecloud.im.friend.param.ImFriendApproveParam;
import com.wecloud.im.friend.param.ImFriendBaseDto; import com.wecloud.im.friend.param.ImFriendBaseDto;
import com.wecloud.im.friend.param.ImFriendBaseParam;
import com.wecloud.im.friend.param.ImFriendPageParam; import com.wecloud.im.friend.param.ImFriendPageParam;
import com.wecloud.im.friend.param.ImFriendRecommendDto; import com.wecloud.im.friend.param.ImFriendRecommendDto;
import com.wecloud.im.friend.service.ImFriendService; import com.wecloud.im.friend.service.ImFriendService;
...@@ -50,12 +53,15 @@ public class ImFriendController extends BaseController { ...@@ -50,12 +53,15 @@ public class ImFriendController extends BaseController {
*/ */
@PostMapping("/info") @PostMapping("/info")
@ApiOperation(value = "查询好友信息,只有自己的好友才查得到") @ApiOperation(value = "查询好友信息,只有自己的好友才查得到")
public ApiResult<ImFriendApplyDto> getFriendInfo(@ApiParam("好友的clientId") String friendClientId) { public ApiResult<ImFriendApplyDto> getFriendInfo(@RequestBody ImFriendBaseParam param) {
if(param == null) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
}
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);
} }
ImClient friendClient = imClientService.getCacheImClient(currentClient.getFkAppid(), friendClientId); ImClient friendClient = imClientService.getCacheImClient(currentClient.getFkAppid(), param.getFriendClientId());
if(friendClient == null) { if(friendClient == null) {
return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null); return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null);
} }
...@@ -68,20 +74,22 @@ public class ImFriendController extends BaseController { ...@@ -68,20 +74,22 @@ public class ImFriendController extends BaseController {
*/ */
@PostMapping("/apply") @PostMapping("/apply")
@ApiOperation(value = "申请添加好友") @ApiOperation(value = "申请添加好友")
public ApiResult<Boolean> applyFriend(@ApiParam("好友的clientId") String friendClientId, @ApiParam("备注好友名称") String friendName, public ApiResult<Boolean> applyFriend(@RequestBody ImFriendApplyParam param) {
@ApiParam("请求备注") String requestRemark) { if(param == null) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
}
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);
} }
ImClient friendClient = imClientService.getCacheImClient(currentClient.getFkAppid(), friendClientId); ImClient friendClient = imClientService.getCacheImClient(currentClient.getFkAppid(), param.getFriendClientId());
if(friendClient == null) { if(friendClient == null) {
return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null); return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null);
} }
if(currentClient.getId().equals(friendClient.getId())) { if(currentClient.getId().equals(friendClient.getId())) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null); return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
} }
imFriendService.applyFriend(currentClient, friendClient, friendName, requestRemark); imFriendService.applyFriend(currentClient, friendClient, param.getFriendName(), param.getRequestRemark());
return ApiResult.ok(); return ApiResult.ok();
} }
...@@ -104,20 +112,20 @@ public class ImFriendController extends BaseController { ...@@ -104,20 +112,20 @@ public class ImFriendController extends BaseController {
*/ */
@PostMapping("/approve") @PostMapping("/approve")
@ApiOperation(value = "接受/拒绝好友申请") @ApiOperation(value = "接受/拒绝好友申请")
public ApiResult<Boolean> approveFriend(String friendClientId, Boolean agree, String rejectRemark) { public ApiResult<Boolean> approveFriend(@RequestBody ImFriendApproveParam param) {
if(agree == null) { if(param == null || param.getAgree() == null) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null); return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
} }
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);
} }
ImClient friendClient = imClientService.getCacheImClient(currentClient.getFkAppid(), friendClientId); ImClient friendClient = imClientService.getCacheImClient(currentClient.getFkAppid(), param.getFriendClientId());
if(friendClient == null) { if(friendClient == null) {
return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null); return ApiResult.fail(ApiCode.CLIENT_NOT_FOUNT, null);
} }
imFriendService.approveFriend(currentClient.getId(), friendClient.getId(), agree, rejectRemark); imFriendService.approveFriend(currentClient.getId(), friendClient.getId(), param.getAgree(), param.getRejectRemark());
return ApiResult.ok(); return ApiResult.ok();
} }
......
package com.wecloud.im.friend.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @Description TODO
* @Author lixiaozhong
* @Date 2022/1/13 4:24 下午
*/
@Data
public class ImFriendApplyParam extends ImFriendBaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty("备注好友名称")
private String friendName;
@ApiModelProperty("请求备注")
private String requestRemark;
}
package com.wecloud.im.friend.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Description TODO
* @Author lixiaozhong
* @Date 2022/1/13 4:24 下午
*/
@Data
public class ImFriendApproveParam extends ImFriendBaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty("是否同意接受好友,true同意,false拒绝")
private Boolean agree;
@ApiModelProperty("拒绝理由,如果是同意就不用填啦")
private String rejectRemark;
}
package com.wecloud.im.friend.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @Description TODO
* @Author lixiaozhong
* @Date 2022/1/13 4:24 下午
*/
@Data
public class ImFriendBaseParam implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("好友的client-id")
private String friendClientId;
}
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