浏览代码

1.修改发送im消息
2.新增发送短信接口

sss 3 年之前
父节点
当前提交
6e8b684eb3

+ 18 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/messageSendLog/domain/SendMsgParam.java

@@ -0,0 +1,18 @@
+package me.zhengjie.modules.dm.messageSendLog.domain;
+
+import lombok.Data;
+
+@Data
+public class SendMsgParam {
+
+    /*
+     *  手机号
+     */
+    private String phone;
+
+    /*
+     *  发送内容
+     */
+    private String context;
+
+}

+ 16 - 3
eladmin-system/src/main/java/me/zhengjie/modules/dm/messageSendLog/util/SendMessageUtils.java

@@ -5,13 +5,14 @@ import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.base.BaseResponse;
 import me.zhengjie.modules.dm.messageSendLog.domain.DmMessageSendLog;
+import me.zhengjie.modules.dm.messageSendLog.domain.SendMsgParam;
 import me.zhengjie.modules.dm.messageSendLog.service.DmMessageSendLogService;
 import me.zhengjie.utils.StringUtils;
 
 @Slf4j
 public class SendMessageUtils {
 
-    private static String erpapiUrl = "http://10.20.2.231:10088";
+    private static String erpapiUrl = "https://portal.caih.com";
 
     /**
      * 发送
@@ -28,8 +29,6 @@ public class SendMessageUtils {
         bodyJSON.put("messageTo",dmMessageSendLog.getUsernames());
         log.info("bodyJSON:"+bodyJSON.toJSONString());
         String res = HttpRequest.get(erpapiUrl+url)
-                .header("serviceId", "USky")
-                .header("serviceUserId",dmMessageSendLog.getSendUserId())
                 .body(bodyJSON.toJSONString()).execute().body();
         JSONObject json = JSONObject.parseObject(res);
         log.info("json:"+json);
@@ -41,4 +40,18 @@ public class SendMessageUtils {
         }
     }
 
+    /**
+     * 发送
+     */
+    public static Boolean sendMsg(SendMsgParam sendMsgParam){
+        String url = "/api-third-party/otherSystem/sendMsg?authKey=purchasing_platform&phone="+sendMsgParam.getPhone()+"&context="+sendMsgParam.getContext();
+        String res = HttpRequest.get(erpapiUrl+url).execute().body();
+        log.info("res:"+res);
+        if(StringUtils.equals("success",res)){
+            return true;
+        } else {
+            return false;
+        }
+    }
+
 }

+ 14 - 0
eladmin-system/src/main/java/me/zhengjie/modules/thirdparty/v1/MessageSendLogApiController.java

@@ -11,6 +11,7 @@ import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.base.BaseResponse;
 import me.zhengjie.base.QueryPageParams;
 import me.zhengjie.modules.dm.messageSendLog.domain.DmMessageSendLog;
+import me.zhengjie.modules.dm.messageSendLog.domain.SendMsgParam;
 import me.zhengjie.modules.dm.messageSendLog.service.DmMessageSendLogService;
 import me.zhengjie.modules.dm.messageSendLog.util.SendMessageUtils;
 import me.zhengjie.modules.system.service.dto.DeptQueryNoAuthCriteria;
@@ -47,4 +48,17 @@ public class MessageSendLogApiController {
         return new BaseResponse<>("发送成功");
     }
 
+    @Log("发送短信")
+    @ApiOperation("发送短信")
+    @AnonymousPostMapping(value = "/sendMsg")
+    public BaseResponse<Object> sendMsg(@RequestBody QueryPageParams<SendMsgParam> params) {
+        SecurityUtils.CheckApiAuth(params);
+        Boolean isSuccess = SendMessageUtils.sendMsg(params.getQuery());
+        if(isSuccess){
+            return new BaseResponse<>("发送成功");
+        } else {
+            return new BaseResponse<>("发送失败");
+        }
+    }
+
 }