diff --git a/src/main/java/com/imyeyu/api/modules/common/entity/Attachment.java b/src/main/java/com/imyeyu/api/modules/common/entity/Attachment.java index 8b829bb..6b45bbf 100644 --- a/src/main/java/com/imyeyu/api/modules/common/entity/Attachment.java +++ b/src/main/java/com/imyeyu/api/modules/common/entity/Attachment.java @@ -32,6 +32,8 @@ public class Attachment extends UUIDEntity { ARTICLE, + NOTIFY_DETAIL, + USER, GAO_CUSTOMER, diff --git a/src/main/java/com/imyeyu/api/modules/common/entity/BaseQueueEntity.java b/src/main/java/com/imyeyu/api/modules/common/entity/BaseQueueEntity.java index 2b8a32f..2dccd25 100644 --- a/src/main/java/com/imyeyu/api/modules/common/entity/BaseQueueEntity.java +++ b/src/main/java/com/imyeyu/api/modules/common/entity/BaseQueueEntity.java @@ -26,7 +26,7 @@ public class BaseQueueEntity implements IDEntity, Creatable, Destroyable protected String notifyDetailId; /** 内容 */ - protected String data; + protected String content; /** 参数 */ protected JsonNode args; @@ -51,7 +51,7 @@ public class BaseQueueEntity implements IDEntity, Creatable, Destroyable /// @param detail 通知详情 public BaseQueueEntity(NotifyDetail detail) { notifyDetailId = detail.getId(); - data = detail.getData(); + content = detail.getContent(); args = detail.getArgs(); sendTo = detail.getSendTo(); sendAt = detail.getSendAt(); diff --git a/src/main/java/com/imyeyu/api/modules/common/entity/NotifyDetail.java b/src/main/java/com/imyeyu/api/modules/common/entity/NotifyDetail.java index 7087cb0..ac1fdce 100644 --- a/src/main/java/com/imyeyu/api/modules/common/entity/NotifyDetail.java +++ b/src/main/java/com/imyeyu/api/modules/common/entity/NotifyDetail.java @@ -16,6 +16,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + /** * 通知详情 * @@ -82,6 +84,19 @@ public class NotifyDetail extends UUIDEntity { FAIL } + /// 内容类型 + /// + /// @author 夜雨 + /// @since 2026-08-24 + public enum ContentType { + + /** 纯文本 */ + TEXT, + + /** TipTap 富文本 */ + TIP_TAP + } + /** 所属通知 ID */ @JsonView(ResponseView.Public.class) private String notifyId; @@ -100,7 +115,11 @@ public class NotifyDetail extends UUIDEntity { /** 内容 */ @JsonView(ResponseView.Public.class) - private String data; + private String content; + + /// 内容类型 + @JsonView(ResponseView.Public.class) + private ContentType contentType; /** 参数 */ @JsonView(ResponseView.Public.class) @@ -146,4 +165,9 @@ public class NotifyDetail extends UUIDEntity { @Transient protected User toUser; + + /// 媒体附件列表 + @JsonView(ResponseView.Public.class) + @Transient + protected List attachmentList; } diff --git a/src/main/java/com/imyeyu/api/modules/common/service/implement/MailQueueServiceImplement.java b/src/main/java/com/imyeyu/api/modules/common/service/implement/MailQueueServiceImplement.java index ac23345..b0d06a7 100644 --- a/src/main/java/com/imyeyu/api/modules/common/service/implement/MailQueueServiceImplement.java +++ b/src/main/java/com/imyeyu/api/modules/common/service/implement/MailQueueServiceImplement.java @@ -60,7 +60,7 @@ public class MailQueueServiceImplement extends AbstractQueueService implements NotifyDetailService { private final NotifyMapper notifyMapper; + private final AttachmentService attachmentService; private final NotifyDetailMapper mapper; @@ -53,6 +57,9 @@ public class NotifyDetailServiceImplement extends AbstractEntityService listByNotifyId(String notifyId) { NotifyDetail example = new NotifyDetail(); example.setNotifyId(notifyId); - return mapper.selectAllByExample(example); + List detailList = mapper.selectAllByExample(example); + loadAttachments(detailList); + return detailList; } /// 删除通知详情 @@ -135,9 +147,11 @@ public class NotifyDetailServiceImplement extends AbstractEntityService detailList = unreadOnly ? mapper.selectUnreadSiteByUserId(userId, validPage.getOffset(), validPage.getLimit()) - : mapper.selectSiteByUserId(userId, validPage.getOffset(), validPage.getLimit())); + : mapper.selectSiteByUserId(userId, validPage.getOffset(), validPage.getLimit()); + loadAttachments(detailList); + result.setList(detailList); return result; } @@ -152,9 +166,41 @@ public class NotifyDetailServiceImplement extends AbstractEntityService detailList) { + List detailIdList = detailList.stream() + .filter(detail -> detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) + .map(NotifyDetail::getId) + .toList(); + if (detailIdList.isEmpty()) { + return; + } + Map> attachmentMap = attachmentService.mapByBizIdList( + Attachment.BizType.NOTIFY_DETAIL, + detailIdList + ); + for (NotifyDetail detail : detailList) { + if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) { + detail.setAttachmentList(attachmentMap.getOrDefault(detail.getId(), List.of())); + } + } + } + + /// 回填通知详情的媒体附件 + /// + /// @param detail 通知详情 + private void loadAttachments(NotifyDetail detail) { + if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) { + detail.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.NOTIFY_DETAIL, detail.getId())); + } + } + /// 删除当前用户拥有的站内通知详情 /// /// @param detailId 通知详情 ID diff --git a/src/main/resources/db/migration/timiserver/V40__add_notify_detail_content_type.sql b/src/main/resources/db/migration/timiserver/V40__add_notify_detail_content_type.sql new file mode 100644 index 0000000..30b000c --- /dev/null +++ b/src/main/resources/db/migration/timiserver/V40__add_notify_detail_content_type.sql @@ -0,0 +1,15 @@ +ALTER TABLE `notify_detail` + CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容', + ADD COLUMN `content_type` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容类型' AFTER `content`; + +ALTER TABLE `sms_queue` + CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容'; + +ALTER TABLE `mail_queue` + CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容'; + +ALTER TABLE `http_queue` + CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容'; + +ALTER TABLE `wechat_queue` + CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容';