tiptap content for notify detail

This commit is contained in:
Timi
2026-08-24 16:50:23 +08:00
parent 81933d4e61
commit 2b11bdf65e
6 changed files with 95 additions and 8 deletions
@@ -60,7 +60,7 @@ public class MailQueueServiceImplement extends AbstractQueueService<MailQueue, N
message.setFrom(queue.getSendFrom());
message.setTo(queue.getSendTo());
message.setSubject(queue.getSubject());
message.setText(queue.getData());
message.setText(queue.getContent());
mailSender.send(message);
log.info("邮件发送成功,目标:{}", queue.getSendTo());
}
@@ -1,10 +1,12 @@
package com.imyeyu.api.modules.common.service.implement;
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
import com.imyeyu.api.modules.common.entity.NotifyDetail;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.entity.Notify;
import com.imyeyu.api.modules.common.entity.NotifyDetail;
import com.imyeyu.api.modules.common.mapper.NotifyDetailMapper;
import com.imyeyu.api.modules.common.mapper.NotifyMapper;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.common.service.NotifyDetailService;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiCode;
@@ -19,6 +21,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
* 通知详情服务实现
@@ -31,6 +34,7 @@ import java.util.List;
public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDetail, String> implements NotifyDetailService {
private final NotifyMapper notifyMapper;
private final AttachmentService attachmentService;
private final NotifyDetailMapper mapper;
@@ -53,6 +57,9 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
TimiException.required(detail.getSendTo(), "未找到站内通知接收用户 ID");
}
detail.setContentType(TimiJava.defaultIfNull(detail.getContentType(), detail.getMsgType() == NotifyDetail.MsgType.INTERNAL
? NotifyDetail.ContentType.TIP_TAP
: NotifyDetail.ContentType.TEXT));
detail.setRetry(TimiJava.defaultIfNull(detail.getRetry(), 1));
detail.setSendAt(TimiJava.defaultIfNull(detail.getSendAt(), Time.now()));
@@ -62,6 +69,9 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
: NotifyDetail.Status.WAITING);
detail.setReadAt(null);
super.create(detail);
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
attachmentService.updateByBizId(Attachment.BizType.NOTIFY_DETAIL, detail.getId(), detail.getAttachmentList());
}
if (detail.getMsgType().isQueue()) {
// 加入外部消息队列
@@ -77,7 +87,9 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
public List<NotifyDetail> listByNotifyId(String notifyId) {
NotifyDetail example = new NotifyDetail();
example.setNotifyId(notifyId);
return mapper.selectAllByExample(example);
List<NotifyDetail> detailList = mapper.selectAllByExample(example);
loadAttachments(detailList);
return detailList;
}
/// 删除通知详情
@@ -135,9 +147,11 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
result.setTotal(unreadOnly
? mapper.countUnreadSiteByUserId(userId)
: mapper.countSiteByUserId(userId));
result.setList(unreadOnly
List<NotifyDetail> 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<NotifyDe
TimiException.required(userId, "未找到用户 ID");
NotifyDetail detail = mapper.selectSiteByIdAndUserId(detailId, userId);
TimiException.required(detail, "未找到站内通知");
loadAttachments(detail);
return detail;
}
/// 回填通知详情的媒体附件
///
/// @param detailList 通知详情列表
private void loadAttachments(List<NotifyDetail> detailList) {
List<String> detailIdList = detailList.stream()
.filter(detail -> detail.getMsgType() == NotifyDetail.MsgType.INTERNAL)
.map(NotifyDetail::getId)
.toList();
if (detailIdList.isEmpty()) {
return;
}
Map<String, List<Attachment>> 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