Browse Source

优化解决获取通知公告列表界面报错的问题,调整查询语句,测试接口;优化新增通知公告接口,解决跨服务调用传参值为空的问题,优化删除通知公告接口,解决删除报错的问题,测试接口;

james 11 months ago
parent
commit
e37a6a7f8b

+ 5 - 5
service-iot/service-iot-api/src/main/java/com/usky/iot/RemoteMceService.java

@@ -1,22 +1,22 @@
 package com.usky.iot;
 
 import com.usky.common.core.bean.ApiResult;
-import com.usky.iot.factory.RemoteMceFallbackFactory;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 
 /**
  * @author han
  * @date 2024/04/26 14:07
  */
-@FeignClient(contextId = "remoteMceService", value = "service-iot", fallbackFactory =
-        RemoteMceFallbackFactory.class)
+@FeignClient(contextId = "remoteMceService", value = "service-iot")
 public interface RemoteMceService {
     /**
      * 新增消息
      *
      * @return 消息结果
      */
-    @PostMapping("/addMce")
-    ApiResult<Void> addMce(String mceReceive);
+    @RequestMapping(value = "addMce")
+    ApiResult<Void> addMce(@RequestParam(value = "mceReceive",required = false) String mceReceive);
 }

+ 17 - 17
service-iot/service-iot-api/src/main/java/com/usky/iot/factory/RemoteMceFallbackFactory.java

@@ -13,20 +13,20 @@ import org.springframework.stereotype.Component;
  * @author han
  * @date 2024/04/02 15:07
  */
-@Component
-public class RemoteMceFallbackFactory implements FallbackFactory<RemoteMceService> {
-    private static final Logger log = LoggerFactory.getLogger(RemoteMceFallbackFactory.class);
-
-    @Override
-    public RemoteMceService create(Throwable throwable)
-    {
-        log.error("iot服务调用失败:{}", throwable.getMessage());
-        return new RemoteMceService()
-        {
-            @Override
-            public ApiResult<Void> addMce(String mceReceive) {
-                throw new FeignBadRequestException(500,"新增消息异常"+throwable.getMessage());
-            }
-        };
-    }
-}
+//@Component
+//public class RemoteMceFallbackFactory implements FallbackFactory<RemoteMceService> {
+//    private static final Logger log = LoggerFactory.getLogger(RemoteMceFallbackFactory.class);
+//
+//    @Override
+//    public RemoteMceService create(Throwable throwable)
+//    {
+//        log.error("iot服务调用失败:{}", throwable.getMessage());
+//        return new RemoteMceService()
+//        {
+//            @Override
+//            public ApiResult<Void> addMce(String mceReceive) {
+//                throw new FeignBadRequestException(500,"新增消息异常"+throwable.getMessage());
+//            }
+//        };
+//    }
+//}

+ 7 - 0
service-iot/service-iot-biz/pom.xml

@@ -71,6 +71,13 @@
             <artifactId>weixin-java-mp</artifactId>
             <version>4.3.0</version>
         </dependency>
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.2.3</version>
+            <classifier>jdk15</classifier>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 4 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/MceReceiveServiceImpl.java

@@ -1,5 +1,7 @@
 package com.usky.iot.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -223,7 +225,8 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
         mceContent.setInfoType(mceReceiveVO.get("infoType").toString());
         mceContent.setCreateBy(SecurityUtils.getUsername());
         mceContent.setCreateTime(LocalDateTime.now());
-        mceContent.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId().intValue());
+//        mceContent.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId().intValue());
+
         mceContent.setTenantId(SecurityUtils.getTenantId());
         mceContentService.save(mceContent);
         Integer contentId = mceContent.getId();