Commit 8b908afe90c53a179b65f684bff083c900a528e2
1 parent
6a10ed7d
♻️ refactor(error): 优化错误码常量和消息提示
Showing
3 changed files
with
7 additions
and
22 deletions
yudao-module-im/yudao-module-im-api/src/main/java/cn/iocoder/yudao/module/im/enums/ErrorCodeConstants.java
| ... | ... | @@ -9,21 +9,13 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 9 | 9 | */ |
| 10 | 10 | public interface ErrorCodeConstants { |
| 11 | 11 | |
| 12 | - // ========== 会话 (1-040-100-000) ========== | |
| 13 | - ErrorCode CONVERSATION_NOT_EXISTS = new ErrorCode(1_040_100_000, "会话不存在"); | |
| 14 | - | |
| 15 | - // ========== 收件箱 (1-040-200-000) ========== | |
| 16 | - ErrorCode INBOX_NOT_EXISTS = new ErrorCode(1_040_200_000, "收件箱不存在"); | |
| 17 | - | |
| 18 | 12 | // ========== 消息 (1-040-300-000) ========== |
| 19 | 13 | ErrorCode MESSAGE_NOT_EXISTS = new ErrorCode(1_040_300_000, "消息不存在"); |
| 20 | - ErrorCode MESSAGE_RECEIVER_NOT_EXISTS = new ErrorCode(1_040_300_001, "接收人不存在"); | |
| 21 | 14 | ErrorCode MESSAGE_RECALL_DENIED = new ErrorCode(1_040_300_002, "只能撤回自己发送的消息"); |
| 22 | 15 | ErrorCode MESSAGE_ALREADY_RECALLED = new ErrorCode(1_040_300_003, "消息已撤回"); |
| 23 | - ErrorCode MESSAGE_RECALL_TIMEOUT = new ErrorCode(1_040_300_007, "超过 {} 分钟的消息无法撤回"); | |
| 24 | 16 | ErrorCode MESSAGE_SENSITIVE_WORD_BLOCKED = new ErrorCode(1_040_300_004, "消息包含敏感词,无法发送"); |
| 25 | - ErrorCode MESSAGE_PULL_SIZE_EXCEEDED = new ErrorCode(1_040_300_005, "单次拉取消息数量超出限制"); | |
| 26 | - ErrorCode MESSAGE_CLIENT_ID_DUPLICATE = new ErrorCode(1_040_300_006, "消息已发送,请勿重复提交"); | |
| 17 | + ErrorCode MESSAGE_PULL_SIZE_EXCEEDED = new ErrorCode(1_040_300_005, "单次拉取消息数量不能超过 {} 条"); | |
| 18 | + ErrorCode MESSAGE_RECALL_TIMEOUT = new ErrorCode(1_040_300_007, "超过 {} 分钟的消息无法撤回"); | |
| 27 | 19 | |
| 28 | 20 | // ========== 群 (1-040-400-000) ========== |
| 29 | 21 | ErrorCode GROUP_NOT_EXISTS = new ErrorCode(1_040_400_000, "群不存在"); |
| ... | ... | @@ -32,21 +24,14 @@ public interface ErrorCodeConstants { |
| 32 | 24 | ErrorCode GROUP_NOT_OWNER = new ErrorCode(1_040_400_003, "仅群主可执行该操作"); |
| 33 | 25 | |
| 34 | 26 | // ========== 群成员 (1-040-500-000) ========== |
| 35 | - ErrorCode GROUP_MEMBER_NOT_EXISTS = new ErrorCode(1_040_500_000, "群成员不存在"); | |
| 36 | 27 | ErrorCode GROUP_MEMBER_NOT_IN_GROUP = new ErrorCode(1_040_500_001, "您已不在该群中"); |
| 37 | - ErrorCode GROUP_MEMBER_ALREADY_QUIT = new ErrorCode(1_040_500_002, "您已退出该群"); | |
| 38 | - ErrorCode GROUP_OWNER_CANNOT_QUIT = new ErrorCode(1_040_500_003, "您是群主,不可退出群聊"); | |
| 39 | - ErrorCode GROUP_CANNOT_REMOVE_SELF = new ErrorCode(1_040_500_004, "不能移除自己"); | |
| 40 | - ErrorCode GROUP_MEMBER_EXCEED = new ErrorCode(1_040_500_005, "群聊人数不能超过{}人"); | |
| 28 | + ErrorCode GROUP_OWNER_CANNOT_QUIT = new ErrorCode(1_040_500_003, "群主不能退出群聊,请先转让群主或解散群聊"); | |
| 29 | + ErrorCode GROUP_CANNOT_REMOVE_SELF = new ErrorCode(1_040_500_004, "不能将自己移出群聊"); | |
| 30 | + ErrorCode GROUP_MEMBER_EXCEED = new ErrorCode(1_040_500_005, "群聊人数不能超过 {} 人"); | |
| 41 | 31 | ErrorCode GROUP_INVITE_NOT_FRIEND = new ErrorCode(1_040_500_006, "'{}' 不是您的好友,邀请失败"); |
| 42 | 32 | |
| 43 | 33 | // ========== 好友 (1-040-600-000) ========== |
| 44 | - ErrorCode FRIEND_NOT_EXISTS = new ErrorCode(1_040_600_000, "好友关系不存在"); | |
| 45 | 34 | ErrorCode FRIEND_NOT_FRIEND = new ErrorCode(1_040_600_001, "对方不是您的好友"); |
| 46 | 35 | ErrorCode FRIEND_ADD_SELF = new ErrorCode(1_040_600_002, "不允许添加自己为好友"); |
| 47 | - ErrorCode FRIEND_ALREADY = new ErrorCode(1_040_600_003, "你们已经是好友了"); | |
| 48 | - | |
| 49 | - // ========== 敏感词 (1-040-700-000) ========== | |
| 50 | - ErrorCode SENSITIVE_WORD_NOT_EXISTS = new ErrorCode(1_040_700_000, "敏感词不存在"); | |
| 51 | 36 | |
| 52 | 37 | } | ... | ... |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/message/ImGroupMessageServiceImpl.java
| ... | ... | @@ -104,7 +104,7 @@ public class ImGroupMessageServiceImpl implements ImGroupMessageService { |
| 104 | 104 | @Override |
| 105 | 105 | public List<ImGroupMessageDO> pullGroupMessageList(Long userId, Long minId, Integer size) { |
| 106 | 106 | if (size > MESSAGE_MAX_PULL_SIZE) { |
| 107 | - throw exception(MESSAGE_PULL_SIZE_EXCEEDED); | |
| 107 | + throw exception(MESSAGE_PULL_SIZE_EXCEEDED, MESSAGE_MAX_PULL_SIZE); | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // 0. 拉取时间窗:超过窗口的老消息不再通过离线通道推送 | ... | ... |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/message/ImPrivateMessageServiceImpl.java
| ... | ... | @@ -85,7 +85,7 @@ public class ImPrivateMessageServiceImpl implements ImPrivateMessageService { |
| 85 | 85 | @Override |
| 86 | 86 | public List<ImPrivateMessageDO> pullPrivateMessageList(Long userId, Long minId, Integer size) { |
| 87 | 87 | if (size > MESSAGE_MAX_PULL_SIZE) { |
| 88 | - throw exception(MESSAGE_PULL_SIZE_EXCEEDED); | |
| 88 | + throw exception(MESSAGE_PULL_SIZE_EXCEEDED, MESSAGE_MAX_PULL_SIZE); | |
| 89 | 89 | } |
| 90 | 90 | // 0. 拉取时间窗:超过窗口的老消息不再通过离线通道推送 |
| 91 | 91 | LocalDateTime minSendTime = LocalDateTime.now().minusDays(MESSAGE_PRIVATE_PULL_MAX_DAYS); | ... | ... |