bug修改
This commit is contained in:
1 parent
1d7f665550
commit
17d293ec0a
10 files changed
+190
-18
No files matched your search
+5
@@ -29,6 +29,11 @@ public interface ChatApi {
|
||||
*/
|
||||
boolean createOrUpdate(@Valid ChatCreateOrUpdateUserReqVO dto);
|
||||
|
||||
/**
|
||||
* 封禁聊天用户并推送下线
|
||||
*/
|
||||
boolean banUser(Long userId, String reason);
|
||||
|
||||
/**
|
||||
* 根据userId查询用户详情
|
||||
*/
|
||||
|
||||
+30
@@ -121,6 +121,36 @@ public class ChatApiImpl implements ChatApi {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 封禁聊天用户并推送下线
|
||||
*/
|
||||
@Override
|
||||
public boolean banUser(Long userId, String reason) {
|
||||
if (userId == null) {
|
||||
return false;
|
||||
}
|
||||
ChatApiTool.API api = setApiConfig(ChatApiTool.USER_BAN);
|
||||
try {
|
||||
ChatBanUserReqVO dto = new ChatBanUserReqVO(userId, reason);
|
||||
String body = JSONUtil.toJsonStr(dto);
|
||||
String res = HttpRequest.post(api.getFullPath()).header(apiCountersign(body)).body(body).execute().body();
|
||||
log.debug("封禁聊天用户,res:{}", res);
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
log.error("封禁聊天用户,res为空");
|
||||
return false;
|
||||
}
|
||||
ChatBaseRespVO baseRes = JSONUtil.toBean(res, ChatBaseRespVO.class);
|
||||
if (ObjectUtil.isEmpty(baseRes) || !baseRes.isSuccess()) {
|
||||
log.error("封禁聊天用户,返回错误,res:{}", res);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("封禁聊天用户,意外的错误,userId={}", userId, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据userId查询用户详情
|
||||
*/
|
||||
|
||||
+1
@@ -21,6 +21,7 @@ public class ChatApiTool {
|
||||
public static final API USER_LOGIN = API.builder().summary("用户登录").url("/third/user/login").method(HttpMethod.POST).build();
|
||||
public static final API USER_GET = API.builder().summary("根据userId查询用户详情").url("/third/user/getUserByUserId").method(HttpMethod.POST).build();
|
||||
public static final API USER_SAVE_OR_UPDATE = API.builder().summary("创建或者更新用户").url("/third/user/createOrUpdate").method(HttpMethod.POST).build();
|
||||
public static final API USER_BAN = API.builder().summary("封禁用户并踢下线").url("/third/user/ban").method(HttpMethod.POST).build();
|
||||
public static final API GET_USER_ONLINE_STATUS_BY_ID = API.builder().summary("查询用户在线状态").url("/third/user/getUserOnlineStatusById").method(HttpMethod.POST).build();
|
||||
|
||||
// 朋友圈
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.member.client.vo.chat.user;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "封禁聊天用户")
|
||||
public class ChatBanUserReqVO {
|
||||
|
||||
@NotNull(message = "用户id不可为空")
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "封禁原因")
|
||||
private String reason;
|
||||
}
|
||||
+11
-3
@@ -478,7 +478,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理会员全部 OAuth2 access + refresh,App 下次请求会 401 并退出登录。
|
||||
* 清理会员全部 OAuth2 access + refresh,并通知 IM 立刻踢下线。
|
||||
*/
|
||||
private void kickMemberLogin(Long userId) {
|
||||
try {
|
||||
@@ -487,6 +487,11 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
log.warn("踢出会员登录态失败, userId={}", userId, e);
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
chatApi.banUser(userId, "账号已被禁用");
|
||||
} catch (Exception e) {
|
||||
log.warn("通知聊天服务封禁用户失败, userId={}", userId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -577,12 +582,15 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
|
||||
/**
|
||||
* 获取用户的微信信息
|
||||
* 有微信号即可解锁;二维码为可选展示字段。
|
||||
*/
|
||||
@Override
|
||||
public MemberWechatBO getMemberWechat(Long memberId) {
|
||||
MemberUserDO detail = memberUserMapper.selectById(memberId);
|
||||
if (ObjectUtil.isEmpty(detail)) return null;
|
||||
if (ObjectUtil.isEmpty(detail.getWechatNum()) || ObjectUtil.isEmpty(detail.getWechatQrCode())) {
|
||||
if (ObjectUtil.isEmpty(detail)) {
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(detail.getWechatNum())) {
|
||||
return null;
|
||||
}
|
||||
MemberWechatBO result = new MemberWechatBO();
|
||||
|
||||
Reference in new issue
Block a user