v1.0.26 #36
@@ -32,6 +32,8 @@ public class Attachment extends UUIDEntity {
|
|||||||
|
|
||||||
ARTICLE,
|
ARTICLE,
|
||||||
|
|
||||||
|
NOTIFY_DETAIL,
|
||||||
|
|
||||||
USER,
|
USER,
|
||||||
|
|
||||||
GAO_CUSTOMER,
|
GAO_CUSTOMER,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class BaseQueueEntity implements IDEntity<String>, Creatable, Destroyable
|
|||||||
protected String notifyDetailId;
|
protected String notifyDetailId;
|
||||||
|
|
||||||
/** 内容 */
|
/** 内容 */
|
||||||
protected String data;
|
protected String content;
|
||||||
|
|
||||||
/** 参数 */
|
/** 参数 */
|
||||||
protected JsonNode args;
|
protected JsonNode args;
|
||||||
@@ -51,7 +51,7 @@ public class BaseQueueEntity implements IDEntity<String>, Creatable, Destroyable
|
|||||||
/// @param detail 通知详情
|
/// @param detail 通知详情
|
||||||
public BaseQueueEntity(NotifyDetail detail) {
|
public BaseQueueEntity(NotifyDetail detail) {
|
||||||
notifyDetailId = detail.getId();
|
notifyDetailId = detail.getId();
|
||||||
data = detail.getData();
|
content = detail.getContent();
|
||||||
args = detail.getArgs();
|
args = detail.getArgs();
|
||||||
sendTo = detail.getSendTo();
|
sendTo = detail.getSendTo();
|
||||||
sendAt = detail.getSendAt();
|
sendAt = detail.getSendAt();
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知详情
|
* 通知详情
|
||||||
*
|
*
|
||||||
@@ -82,6 +84,19 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
FAIL
|
FAIL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 内容类型
|
||||||
|
///
|
||||||
|
/// @author 夜雨
|
||||||
|
/// @since 2026-08-24
|
||||||
|
public enum ContentType {
|
||||||
|
|
||||||
|
/** 纯文本 */
|
||||||
|
TEXT,
|
||||||
|
|
||||||
|
/** TipTap 富文本 */
|
||||||
|
TIP_TAP
|
||||||
|
}
|
||||||
|
|
||||||
/** 所属通知 ID */
|
/** 所属通知 ID */
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
private String notifyId;
|
private String notifyId;
|
||||||
@@ -100,7 +115,11 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
|
|
||||||
/** 内容 */
|
/** 内容 */
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
private String data;
|
private String content;
|
||||||
|
|
||||||
|
/// 内容类型
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
private ContentType contentType;
|
||||||
|
|
||||||
/** 参数 */
|
/** 参数 */
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
@@ -146,4 +165,9 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
protected User toUser;
|
protected User toUser;
|
||||||
|
|
||||||
|
/// 媒体附件列表
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
@Transient
|
||||||
|
protected List<Attachment> attachmentList;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ public class MailQueueServiceImplement extends AbstractQueueService<MailQueue, N
|
|||||||
message.setFrom(queue.getSendFrom());
|
message.setFrom(queue.getSendFrom());
|
||||||
message.setTo(queue.getSendTo());
|
message.setTo(queue.getSendTo());
|
||||||
message.setSubject(queue.getSubject());
|
message.setSubject(queue.getSubject());
|
||||||
message.setText(queue.getData());
|
message.setText(queue.getContent());
|
||||||
mailSender.send(message);
|
mailSender.send(message);
|
||||||
log.info("邮件发送成功,目标:{}", queue.getSendTo());
|
log.info("邮件发送成功,目标:{}", queue.getSendTo());
|
||||||
}
|
}
|
||||||
|
|||||||
+50
-4
@@ -1,10 +1,12 @@
|
|||||||
package com.imyeyu.api.modules.common.service.implement;
|
package com.imyeyu.api.modules.common.service.implement;
|
||||||
|
|
||||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
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.Notify;
|
||||||
|
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||||
import com.imyeyu.api.modules.common.mapper.NotifyDetailMapper;
|
import com.imyeyu.api.modules.common.mapper.NotifyDetailMapper;
|
||||||
import com.imyeyu.api.modules.common.mapper.NotifyMapper;
|
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.api.modules.common.service.NotifyDetailService;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.java.bean.timi.TimiCode;
|
import com.imyeyu.java.bean.timi.TimiCode;
|
||||||
@@ -19,6 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
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 {
|
public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDetail, String> implements NotifyDetailService {
|
||||||
|
|
||||||
private final NotifyMapper notifyMapper;
|
private final NotifyMapper notifyMapper;
|
||||||
|
private final AttachmentService attachmentService;
|
||||||
|
|
||||||
private final NotifyDetailMapper mapper;
|
private final NotifyDetailMapper mapper;
|
||||||
|
|
||||||
@@ -53,6 +57,9 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
|
|||||||
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
||||||
TimiException.required(detail.getSendTo(), "未找到站内通知接收用户 ID");
|
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.setRetry(TimiJava.defaultIfNull(detail.getRetry(), 1));
|
||||||
detail.setSendAt(TimiJava.defaultIfNull(detail.getSendAt(), Time.now()));
|
detail.setSendAt(TimiJava.defaultIfNull(detail.getSendAt(), Time.now()));
|
||||||
@@ -62,6 +69,9 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
|
|||||||
: NotifyDetail.Status.WAITING);
|
: NotifyDetail.Status.WAITING);
|
||||||
detail.setReadAt(null);
|
detail.setReadAt(null);
|
||||||
super.create(detail);
|
super.create(detail);
|
||||||
|
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
||||||
|
attachmentService.updateByBizId(Attachment.BizType.NOTIFY_DETAIL, detail.getId(), detail.getAttachmentList());
|
||||||
|
}
|
||||||
|
|
||||||
if (detail.getMsgType().isQueue()) {
|
if (detail.getMsgType().isQueue()) {
|
||||||
// 加入外部消息队列
|
// 加入外部消息队列
|
||||||
@@ -77,7 +87,9 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
|
|||||||
public List<NotifyDetail> listByNotifyId(String notifyId) {
|
public List<NotifyDetail> listByNotifyId(String notifyId) {
|
||||||
NotifyDetail example = new NotifyDetail();
|
NotifyDetail example = new NotifyDetail();
|
||||||
example.setNotifyId(notifyId);
|
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
|
result.setTotal(unreadOnly
|
||||||
? mapper.countUnreadSiteByUserId(userId)
|
? mapper.countUnreadSiteByUserId(userId)
|
||||||
: mapper.countSiteByUserId(userId));
|
: mapper.countSiteByUserId(userId));
|
||||||
result.setList(unreadOnly
|
List<NotifyDetail> detailList = unreadOnly
|
||||||
? mapper.selectUnreadSiteByUserId(userId, validPage.getOffset(), validPage.getLimit())
|
? 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,9 +166,41 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
|
|||||||
TimiException.required(userId, "未找到用户 ID");
|
TimiException.required(userId, "未找到用户 ID");
|
||||||
NotifyDetail detail = mapper.selectSiteByIdAndUserId(detailId, userId);
|
NotifyDetail detail = mapper.selectSiteByIdAndUserId(detailId, userId);
|
||||||
TimiException.required(detail, "未找到站内通知");
|
TimiException.required(detail, "未找到站内通知");
|
||||||
|
loadAttachments(detail);
|
||||||
return 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
|
/// @param detailId 通知详情 ID
|
||||||
|
|||||||
@@ -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 '内容';
|
||||||
Reference in New Issue
Block a user