소스 검색

add notice method

Mr.qian 2 주 전
부모
커밋
d0cb19e186

+ 21 - 3
mall-service/src/main/java/com/txz/mall/service/NoticeService.java

@@ -1,6 +1,7 @@
 package com.txz.mall.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.txz.mall.enums.NoticeEnum;
 import com.txz.mall.model.Notice;
 import dto.NoticeDTO;
 
@@ -13,10 +14,27 @@ public interface NoticeService extends IService<Notice> {
     
     /**
      * 添加通知消息
-     *
-     * @param notice 通知数据传输对象,包含通知的详细信息
-     * @param uids   可变长参数,表示接收通知的用户ID列表
      */
     void addNotice(NoticeDTO notice, Long... uids);
     
+    /**
+     * 添加自定义消息
+     */
+    void addOtherNotice(Long otherId, String noticeMessage, String pages, Long... uids);
+    
+    /**
+     * 添加订单通知
+     */
+    void addOrderNotice(NoticeEnum noticeType, String noticeMessage, Long... uids);
+    
+    /**
+     * 添加收益通知
+     */
+    void addRewardNotice(NoticeEnum noticeType, Long... uids);
+    
+    /**
+     * 添加充值/提现通知
+     */
+    void addMoneyNotice(NoticeEnum noticeType, Long... uids);
+    
 }

+ 41 - 0
mall-service/src/main/java/com/txz/mall/service/impl/NoticeServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.txz.mall.dao.NoticeMapper;
+import com.txz.mall.enums.NoticeEnum;
 import com.txz.mall.model.Notice;
 import com.txz.mall.service.NoticeService;
 import dto.NoticeDTO;
@@ -37,4 +38,44 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
         });
         this.saveBatch(saveBatch);
     }
+    
+    @Override
+    public void addOtherNotice(Long otherId, String noticeMessage, String pages, Long... uids) {
+        this.addNotice(NoticeDTO.builder()
+                        .noticeType(NoticeEnum.OTHER)
+                        .otherId(otherId)
+                        .noticeMessage(noticeMessage)
+                        .pages(pages)
+                        .build()
+                , uids
+        );
+    }
+    
+    @Override
+    public void addOrderNotice(NoticeEnum noticeType, String noticeMessage, Long... uids) {
+        this.addNotice(NoticeDTO.builder()
+                        .noticeType(noticeType)
+                        .noticeMessage(noticeMessage)
+                        .build()
+                , uids
+        );
+    }
+    
+    @Override
+    public void addRewardNotice(NoticeEnum noticeType, Long... uids) {
+        this.addNotice(NoticeDTO.builder()
+                        .noticeType(noticeType)
+                        .build()
+                , uids
+        );
+    }
+    
+    @Override
+    public void addMoneyNotice(NoticeEnum noticeType, Long... uids) {
+        this.addNotice(NoticeDTO.builder()
+                        .noticeType(noticeType)
+                        .build()
+                , uids
+        );
+    }
 }

+ 2 - 0
mall-service/src/main/java/dto/NoticeDTO.java

@@ -1,6 +1,7 @@
 package dto;
 
 import com.txz.mall.enums.NoticeEnum;
+import lombok.Builder;
 import lombok.Data;
 
 /**
@@ -8,6 +9,7 @@ import lombok.Data;
  * @date: 2025/8/26
  */
 @Data
+@Builder
 public class NoticeDTO {
     
     /**