dcs 4 months ago
parent
commit
f7f8549fc7

+ 6 - 2
virgo.api/src/main/java/com/bosshand/virgo/api/controller/ReminderController.java

@@ -73,10 +73,14 @@ public class ReminderController {
     @ApiOperation("system发送消息")
     @RequestMapping(value = "/send", method = RequestMethod.POST)
     public Response send(@RequestBody JSONObject jsonObject) {
-        String userId = jsonObject.getString("userId");
+        String token = reminderService.getToken();
+        String userIds = jsonObject.getString("userId");
         String data = jsonObject.getString("data");
         String type = jsonObject.getString("type");
-        reminderService.send(userId, data, type);
+        String[] ids = userIds.split(",");
+        for (String id : ids) {
+            reminderService.send(token, id, data, type);
+        }
         return Response.ok();
     }
 

+ 2 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/job/JobReminderQuartz.java

@@ -28,7 +28,8 @@ public class JobReminderQuartz extends QuartzJobBean {
         JSONObject json = JSONObject.parseObject(data);
         long userId = json.getLongValue("creator");
         int type = json.getIntValue("type");
-        reminderService.send(String.valueOf(userId), json.toJSONString(), String.valueOf(type));
+        String token = reminderService.getToken();
+        reminderService.send(token, String.valueOf(userId), json.toJSONString(), String.valueOf(type));
     }
 
 }

+ 3 - 3
virgo.api/src/main/java/com/bosshand/virgo/api/service/ReminderService.java

@@ -52,7 +52,7 @@ public class ReminderService {
         return reminderDao.delete(id);
     }
 
-    private String getToken() {
+    public String getToken() {
         JSONObject js = new JSONObject();
         String userId = "system";
         long timestamp = System.currentTimeMillis() + 30000;
@@ -70,7 +70,7 @@ public class ReminderService {
         return null;
     }
 
-    public void send(String userId, String data, String type) {
+    public void send(String token, String userId, String data, String type) {
         long m = System.currentTimeMillis();
         JSONObject js = new JSONObject();
         js.put("conversationId", userId);
@@ -91,7 +91,7 @@ public class ReminderService {
         JSONObject j = new JSONObject();
         j.put("text", type);
         js.put("body", j);
-        String s = WeChatUtil.httpPost("https://www.waywish.com/im/message/save", js, getToken());
+        String s = WeChatUtil.httpPost("https://www.waywish.com/im/message/save", js, token);
         log.info("在" + m + "时间点给userId:" + userId + "发送消息成功.");
     }