浏览代码

消息中心代码改造

fuyuchuan 2 周之前
父节点
当前提交
7361cd2c61

+ 17 - 4
base-modules/service-system/service-system-api/src/main/java/com/usky/system/RemoteMceService.java

@@ -2,6 +2,8 @@ package com.usky.system;
 
 
 import com.usky.common.core.bean.ApiResult;
+
+import com.usky.system.domain.MceRequestVO;
 import com.usky.system.factory.RemoteMceFallbackFactory;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
@@ -11,19 +13,30 @@ import org.springframework.web.bind.annotation.RequestBody;
 
 /**
  * 消息服务
- * 
+ *
  * @author ruoyi
  */
 @FeignClient(contextId = "remoteMceService", value = "usky-system", fallbackFactory = RemoteMceFallbackFactory.class)
-public interface RemoteMceService
-{
+public interface RemoteMceService {
     /**
      * 新增消息推送
      *
      * @param mceInfo 消息信息
      * @return 结果
      */
-    @PostMapping(value = "/addMce",produces= MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = "application/json;" +
+    @PostMapping(value = "/addMce", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = "application/json;" +
             "charset=UTF-8")
     public ApiResult<Void> addMce(@RequestBody String mceInfo);
+
+    /**
+     * @description: 消息推送-新
+     * @author: fyc
+     * @email yuchuan.fu@chinausky.com
+     * @date: 2025/3/14 14:58
+     * @param: [mceInfo]
+     * @return: com.usky.common.core.bean.ApiResult<java.lang.Void>
+     **/
+    @PostMapping(value = "/addMceReceive")
+    ApiResult<Void> addMceReceive(MceRequestVO mceInfo);
+
 }

+ 62 - 0
base-modules/service-system/service-system-api/src/main/java/com/usky/system/domain/MceRequestVO.java

@@ -0,0 +1,62 @@
+package com.usky.system.domain;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.usky.common.core.bean.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ *
+ * @author fyc
+ * @email yuchuan.fu@chinausky.com
+ * @date 2025/3/13
+ */
+@EqualsAndHashCode(callSuper = true)
+@Slf4j
+@Data
+public class MceRequestVO  extends BaseEntity {
+
+    /** 字典标签  */
+    private String infoTypeName;
+
+    /** 消息类型  */
+    @NotBlank(message = "消息类型 infoType 不能为空!")
+    private String infoType;
+
+    /** 消息标题  */
+    @NotBlank(message = "消息标题 infoTitle 不能为空!")
+    private String infoTitle;
+
+    /** 消息内容  */
+    @NotBlank(message = "消息内容 infoContent 不能为空!")
+    private String infoContent;
+
+    /** 消息发布人  */
+    @NotBlank(message = "消息发布人 userName 不能为空!")
+    private String userName;
+
+    /** 消息详情id  */
+    @NotNull(message = "消息详情 id 不能为空!")
+    private Integer id;
+
+    /** 消息接收人userId集合  */
+    @NotNull(message = "消息接收人 userIds 不能为空!")
+    private List<Long> userIds;
+
+    @Override
+    public String toString() {
+        ObjectMapper objectMapper = new ObjectMapper();
+        try {
+            return objectMapper.writeValueAsString(this);
+        } catch (JsonProcessingException e) {
+            log.error("MceRequestVO toString error: {}", e.getMessage());
+            return "{}";
+        }
+    }
+}

+ 12 - 10
base-modules/service-system/service-system-api/src/main/java/com/usky/system/factory/RemoteMceFallbackFactory.java

@@ -3,6 +3,7 @@ package com.usky.system.factory;
 
 import com.usky.common.core.bean.ApiResult;
 import com.usky.system.RemoteMceService;
+import com.usky.system.domain.MceRequestVO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.cloud.openfeign.FallbackFactory;
@@ -10,24 +11,25 @@ import org.springframework.stereotype.Component;
 
 /**
  * 消息服务降级处理
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class RemoteMceFallbackFactory implements FallbackFactory<RemoteMceService>
-{
+public class RemoteMceFallbackFactory implements FallbackFactory<RemoteMceService> {
     private static final Logger log = LoggerFactory.getLogger(RemoteMceFallbackFactory.class);
 
     @Override
-    public RemoteMceService create(Throwable throwable)
-    {
+    public RemoteMceService create(Throwable throwable) {
         log.error("用户服务调用失败:{}", throwable.getMessage());
-        return new RemoteMceService()
-        {
+        return new RemoteMceService() {
             @Override
-            public ApiResult<Void> addMce(String mceInfo)
-            {
-                return ApiResult.error("500","新增消息失败:" + throwable.getMessage());
+            public ApiResult<Void> addMce(String mceInfo) {
+                return ApiResult.error("500", "新增消息失败:" + throwable.getMessage());
+            }
+
+            @Override
+            public ApiResult<Void> addMceReceive(MceRequestVO mceInfo) {
+                return ApiResult.error("500", "新增消息失败:" + throwable.getMessage());
             }
         };
     }