|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.rongwe.scentity.vo.PushMessageToAppRequestVo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -23,15 +24,17 @@ public class AppPushMessageController {
|
|
|
* @param message
|
|
|
*/
|
|
|
@PostMapping("/old/pushToApp")
|
|
|
- public void pushToWeb(@RequestParam String message){
|
|
|
+ public R pushToWeb(@RequestParam String message){
|
|
|
try {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(message);
|
|
|
String title = jsonObject.getString("title");
|
|
|
String content = jsonObject.getString("content");
|
|
|
List<String> userIdList = JSON.parseArray(jsonObject.getJSONArray("userIds").toJSONString(), String.class);
|
|
|
Lists.partition(userIdList, 10).forEach(userIds -> CXCommonUtils.pushApp(title, content, userIds));
|
|
|
+ return R.ok("发送app通知成功");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
+ return R.error("发送app通知失败");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -40,14 +43,16 @@ public class AppPushMessageController {
|
|
|
* 新版可用此方式,post实体类传参
|
|
|
*/
|
|
|
@PostMapping("/new/pushToApp")
|
|
|
- public void pushToWeb(@RequestBody PushMessageToAppRequestVo model){
|
|
|
+ public R pushToWeb(@RequestBody PushMessageToAppRequestVo model){
|
|
|
try {
|
|
|
String title = model.getTitle();
|
|
|
String content = model.getContent();
|
|
|
List<String> userIdList = model.getUserIds();
|
|
|
Lists.partition(userIdList, 10).forEach(userIds -> CXCommonUtils.pushApp(title, content, userIds));
|
|
|
+ return R.ok("发送app通知成功");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
+ return R.error("发送app通知失败");
|
|
|
}
|
|
|
}
|
|
|
|