Commit 2804e5ed1009a3118af189180db0f97ae89758d7

Authored by YunaiV
1 parent ba1a85e3

fix(im):好友模块 code review 多项修复(缓存事务时序、agree/refuse 乐观锁、补建表 SQL 与字典 seed);framewor…

…k 开 setTransactionAware 让 @CacheEvict 自动事务感知
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/enums/ErrorCodeConstants.java
... ... @@ -52,7 +52,6 @@ public interface ErrorCodeConstants {
52 52 ErrorCode FRIEND_REQUEST_NOT_EXISTS = new ErrorCode(1_040_610_001, "好友申请不存在");
53 53 ErrorCode FRIEND_REQUEST_HANDLED = new ErrorCode(1_040_610_002, "好友申请已处理");
54 54 ErrorCode FRIEND_REQUEST_NOT_TO_ME = new ErrorCode(1_040_610_003, "不能处理别人的好友申请");
55   - ErrorCode FRIEND_REQUEST_TARGET_INVALID = new ErrorCode(1_040_610_004, "好友申请的对方不存在或已禁用");
56 55 ErrorCode FRIEND_REQUEST_ALREADY_FRIEND = new ErrorCode(1_040_610_005, "您已是 TA 的好友,无需重复添加");
57 56 ErrorCode FRIEND_REQUEST_BLOCKED_BY_PEER = new ErrorCode(1_040_610_006, "您已被对方拉入黑名单,无法添加为好友");
58 57  
... ...
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/enums/friend/ImFriendStateEnum.java
... ... @@ -9,7 +9,7 @@ import java.util.Arrays;
9 9 /**
10 10 * IM 好友关系状态(合并「是否好友」+「是否拉黑」两态)
11 11 * <p>
12   - * 用 state 而非 status:避免和 ImFriendDO 的 statue 物理字段(CommonStatusEnum:ENABLE / DISABLE)混淆。
  12 + * 用 state 而非 status:避免和 ImFriendDO 的 status 物理字段(CommonStatusEnum:ENABLE / DISABLE)混淆。
13 13 * <p>
14 14 * 用于 ImFriendService.getFriendState 返回值与 FRIEND_STATE 缓存值:私聊发送热点路径下,sender 调缓存即可同时判定「能否发」和「是否屏蔽接收方」
15 15 *
... ...
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendService.java
... ... @@ -73,7 +73,7 @@ public interface ImFriendService {
73 73 /**
74 74 * 删除好友(单向软删除)
75 75 * <p>
76   - * 仅删除 userId 视角下的好友关系;对端 friendUserId 的视角不受影响(与 OpenIM 单边删除语义对齐)
  76 + * 仅删除 userId 视角下的好友关系;对端 friendUserId 的视角不受影响(单边删除语义)
77 77 */
78 78 void deleteFriend(Long userId, Long friendUserId);
79 79  
... ...
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendServiceImpl.java
... ... @@ -154,6 +154,7 @@ public class ImFriendServiceImpl implements ImFriendService {
154 154 getSelf().addFriend0(userId, friendUserId, displayName, addSource);
155 155  
156 156 // 2. 仅推 FRIEND_ADD 给 userId 多端(不通知对方,保持「对方一直把我当好友」的错觉)
  157 + // operatorUserId 填 friendUserId(对方):让 userId 多端 UI 呈现「对方加了我」的视觉效果,与 silent 语义对齐
157 158 FriendAddNotification payload = (FriendAddNotification) new FriendAddNotification()
158 159 .setOperatorUserId(friendUserId).setFriendUserId(friendUserId);
159 160 websocketService.sendPrivateMessageAsync(userId, ImPrivateMessageDTO.ofFriendNotification(
... ...