Commit 79be419067c39b73f1a49dcfd1c1d656c64ba24b
1 parent
ee9362a2
✨ feat(im): 继续优化频道的各种代码(v4)优化卡片样式
Showing
3 changed files
with
15 additions
and
3 deletions
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/dal/dataobject/message/ImChannelMessageDO.java
| ... | ... | @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.im.dal.dataobject.message; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; |
| 5 | +import cn.iocoder.yudao.module.im.dal.dataobject.channel.ImChannelDO; | |
| 6 | +import cn.iocoder.yudao.module.im.dal.dataobject.channel.ImChannelMaterialDO; | |
| 5 | 7 | import cn.iocoder.yudao.module.im.enums.message.ImMessageTypeEnum; |
| 6 | 8 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 7 | 9 | import com.baomidou.mybatisplus.annotation.TableField; | ... | ... |
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/message/ImChannelMessageServiceImpl.java
| ... | ... | @@ -56,8 +56,9 @@ public class ImChannelMessageServiceImpl implements ImChannelMessageService { |
| 56 | 56 | // 1. 校验素材存在 |
| 57 | 57 | ImChannelMaterialDO material = channelMaterialService.validateMaterialExists(reqVO.getMaterialId()); |
| 58 | 58 | |
| 59 | - // 2.1 组装 payload(不带富文本正文);字段同名直接 BeanUtils 拷贝 | |
| 60 | - String payloadJson = JsonUtils.toJsonString(BeanUtils.toBean(material, MaterialMessage.class)); | |
| 59 | + // 2.1 组装 payload(不带富文本正文);字段同名直接 BeanUtils 拷贝,materialId 单独 set 以兼容转发场景 | |
| 60 | + MaterialMessage payload = BeanUtils.toBean(material, MaterialMessage.class).setMaterialId(material.getId()); | |
| 61 | + String payloadJson = JsonUtils.toJsonString(payload); | |
| 61 | 62 | // 2.2 落库 1 行 message;reqVO 同名字段(materialId / receiverUserIds)自动拷贝,剩余字段补 set |
| 62 | 63 | ImChannelMessageDO message = BeanUtils.toBean(reqVO, ImChannelMessageDO.class).setChannelId(material.getChannelId()) |
| 63 | 64 | .setType(ImMessageTypeEnum.MATERIAL.getType()).setContent(payloadJson).setSendTime(LocalDateTime.now()); | ... | ... |
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/websocket/dto/message/MaterialMessage.java
| ... | ... | @@ -15,13 +15,22 @@ import lombok.experimental.Accessors; |
| 15 | 15 | public class MaterialMessage { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | + * 素材编号 | |
| 19 | + */ | |
| 20 | + private Long materialId; | |
| 21 | + /** | |
| 22 | + * 频道编号 | |
| 23 | + * <p> | |
| 24 | + * 冗余到 payload 内;转发到私聊 / 群聊后客户端用本字段定位频道,渲染卡片底部的频道头像 + 名称 | |
| 25 | + */ | |
| 26 | + private Long channelId; | |
| 27 | + /** | |
| 18 | 28 | * 素材内容类型 |
| 19 | 29 | * <p> |
| 20 | 30 | * 枚举 {@link cn.iocoder.yudao.module.im.enums.channel.ImChannelMaterialTypeEnum} |
| 21 | 31 | * 客户端按本字段判定点击行为:CONTENT 走站内详情页拉富文本;LINK 跳 url |
| 22 | 32 | */ |
| 23 | 33 | private Integer type; |
| 24 | - | |
| 25 | 34 | /** |
| 26 | 35 | * 标题 |
| 27 | 36 | */ | ... | ... |