Commit 1269e626cac290050db7eff3956b2c0eaf839e08
1 parent
0ac1f0cc
📝 refactor(controller): 移除不必要的导入和注解,优化会话和群成员响应对象
Showing
3 changed files
with
0 additions
and
175 deletions
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/dataobject/message/ImMessageDO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.dal.dataobject.message; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | -import cn.iocoder.yudao.module.im.enums.conversation.ImConversationTypeEnum; | ||
| 5 | -import cn.iocoder.yudao.module.im.enums.message.ImMessageContentTypeEnum; | ||
| 6 | -import cn.iocoder.yudao.module.im.enums.message.ImMessageSourceEnum; | ||
| 7 | -import cn.iocoder.yudao.module.im.enums.message.ImMessageStatusEnum; | ||
| 8 | -import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 9 | -import com.baomidou.mybatisplus.annotation.TableId; | ||
| 10 | -import com.baomidou.mybatisplus.annotation.TableName; | ||
| 11 | -import lombok.*; | ||
| 12 | - | ||
| 13 | -import java.time.LocalDateTime; | ||
| 14 | - | ||
| 15 | -/** | ||
| 16 | - * IM 消息 DO | ||
| 17 | - * | ||
| 18 | - * @author 芋道源码 | ||
| 19 | - */ | ||
| 20 | -@TableName("im_message") | ||
| 21 | -@KeySequence("im_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 22 | -@Data | ||
| 23 | -@EqualsAndHashCode(callSuper = true) | ||
| 24 | -@ToString(callSuper = true) | ||
| 25 | -@Builder | ||
| 26 | -@NoArgsConstructor | ||
| 27 | -@AllArgsConstructor | ||
| 28 | -public class ImMessageDO extends BaseDO { | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | - * 编号 | ||
| 32 | - */ | ||
| 33 | - @TableId | ||
| 34 | - private Long id; | ||
| 35 | - /** | ||
| 36 | - * 客户端消息编号 uuid,用于排重 | ||
| 37 | - */ | ||
| 38 | - private String clientMessageId; | ||
| 39 | - /** | ||
| 40 | - * 发送人编号 存储的是用户编号 | ||
| 41 | - */ | ||
| 42 | - private Long senderId; | ||
| 43 | - /** | ||
| 44 | - * 接收人编号 | ||
| 45 | - * <p> | ||
| 46 | - * 1. 单聊时,用户编号;群聊时,群编号 | ||
| 47 | - */ | ||
| 48 | - private Long receiverId; | ||
| 49 | - /** | ||
| 50 | - * 消息发送者昵称 | ||
| 51 | - * <p> | ||
| 52 | - * 冗余 AdminUserDO 的 nickname 字段 | ||
| 53 | - */ | ||
| 54 | - private String senderNickname; | ||
| 55 | - /** | ||
| 56 | - * 消息发送者头像 | ||
| 57 | - * <p> | ||
| 58 | - * 冗余 AdminUserDO 的 avatar 字段 | ||
| 59 | - */ | ||
| 60 | - private String senderAvatar; | ||
| 61 | - /** | ||
| 62 | - * 会话类型 枚举 {@link ImConversationTypeEnum} | ||
| 63 | - */ | ||
| 64 | - private Integer conversationType; | ||
| 65 | - /** | ||
| 66 | - * 会话标志 | ||
| 67 | - * <p> | ||
| 68 | - * 生成规则:{@link ImConversationTypeEnum#generateConversationNo(Long, Long, Integer)} 方法 | ||
| 69 | - */ | ||
| 70 | - private String conversationNo; | ||
| 71 | - /** | ||
| 72 | - * 消息类型 | ||
| 73 | - * <p> | ||
| 74 | - * 枚举 {@link ImMessageContentTypeEnum} | ||
| 75 | - */ | ||
| 76 | - private Integer contentType; | ||
| 77 | - /** | ||
| 78 | - * 消息内容 | ||
| 79 | - * <p> | ||
| 80 | - * JSON 格式 对应 dal/dataobject/message/content 包 | ||
| 81 | - */ | ||
| 82 | - private String content; | ||
| 83 | - /** | ||
| 84 | - * 发送时间 | ||
| 85 | - */ | ||
| 86 | - private LocalDateTime sendTime; | ||
| 87 | - /** | ||
| 88 | - * 消息来源 | ||
| 89 | - * <p> | ||
| 90 | - * 枚举 {@link ImMessageSourceEnum} | ||
| 91 | - */ | ||
| 92 | - private Integer sendFrom; | ||
| 93 | - /** | ||
| 94 | - * 消息状态 | ||
| 95 | - * <p> | ||
| 96 | - * 枚举 {@link ImMessageStatusEnum} | ||
| 97 | - */ | ||
| 98 | - private Integer messageStatus; | ||
| 99 | - | ||
| 100 | -} | ||
| 101 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/redis/inbox/InboxLockRedisDAO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.dal.redis.inbox; | ||
| 2 | - | ||
| 3 | -import jakarta.annotation.Resource; | ||
| 4 | -import org.redisson.api.RLock; | ||
| 5 | -import org.redisson.api.RedissonClient; | ||
| 6 | -import org.springframework.stereotype.Repository; | ||
| 7 | - | ||
| 8 | -import java.util.concurrent.TimeUnit; | ||
| 9 | - | ||
| 10 | -import static cn.iocoder.yudao.module.im.dal.redis.RedisKeyConstants.INBOX_LOCK; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 收件箱的锁 Redis DAO | ||
| 14 | - * | ||
| 15 | - * @author 芋道源码 | ||
| 16 | - */ | ||
| 17 | -@Repository | ||
| 18 | -public class InboxLockRedisDAO { | ||
| 19 | - | ||
| 20 | - @Resource | ||
| 21 | - private RedissonClient redissonClient; | ||
| 22 | - | ||
| 23 | - private static String formatKey(Long id) { | ||
| 24 | - return String.format(INBOX_LOCK, id); | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - public void lock(Long id, Long timeoutMillis, Runnable runnable) { | ||
| 28 | - String lockKey = formatKey(id); | ||
| 29 | - RLock lock = redissonClient.getLock(lockKey); | ||
| 30 | - try { | ||
| 31 | - lock.lock(timeoutMillis, TimeUnit.MILLISECONDS); | ||
| 32 | - // 执行逻辑 | ||
| 33 | - runnable.run(); | ||
| 34 | - } finally { | ||
| 35 | - lock.unlock(); | ||
| 36 | - } | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | -} |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/redis/inbox/SequenceRedisDAO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.dal.redis.inbox; | ||
| 2 | - | ||
| 3 | -import jakarta.annotation.Resource; | ||
| 4 | -import org.springframework.data.redis.core.RedisTemplate; | ||
| 5 | -import org.springframework.stereotype.Repository; | ||
| 6 | - | ||
| 7 | -import static cn.iocoder.yudao.module.im.dal.redis.RedisKeyConstants.INBOX_SEQUENCE; | ||
| 8 | - | ||
| 9 | -// TODO @芋艿:这个名字,需要在考虑下;至少先搞个 IM 前缀 | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * 序号生成器 Redis DAO | ||
| 13 | - * | ||
| 14 | - * @author anhaohao | ||
| 15 | - */ | ||
| 16 | -@Repository | ||
| 17 | -public class SequenceRedisDAO { | ||
| 18 | - | ||
| 19 | - @Resource | ||
| 20 | - private RedisTemplate<String, Long> redisTemplate; | ||
| 21 | - | ||
| 22 | - private static String formatKey(Long userId) { | ||
| 23 | - return String.format(INBOX_SEQUENCE, userId); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * 生成序号 | ||
| 28 | - * | ||
| 29 | - * @param userId 用户编号 | ||
| 30 | - * @return 序号 | ||
| 31 | - */ | ||
| 32 | - public Long generateSequence(Long userId) { | ||
| 33 | - return redisTemplate.opsForValue().increment(formatKey(userId), 1); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | -} |