|
|
@@ -1,13 +1,22 @@
|
|
|
package com.uas.platform.b2c.common.message.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
+import com.alibaba.fastjson.parser.Feature;
|
|
|
import com.uas.platform.b2c.common.message.service.InternalMessageService;
|
|
|
+import com.uas.platform.b2c.core.config.MessageConf;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.platform.core.model.Status;
|
|
|
+import com.uas.platform.core.util.HttpUtil;
|
|
|
+import com.uas.sso.support.Page;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import com.uas.platform.b2c.common.message.model.MessageModel;
|
|
|
+import java.util.HashMap;
|
|
|
+import com.uas.platform.b2c.core.utils.ContextUtils;
|
|
|
|
|
|
/**
|
|
|
* 站内信接口
|
|
|
@@ -17,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
@RestController
|
|
|
@RequestMapping("/internalmessage-service")
|
|
|
public class InternalMessageController {
|
|
|
+ private static final String MESSAGE_PUBLIC_SERVICE_URL = ContextUtils.getBean(MessageConf.class).getMessagePublicServiceDevUrl();
|
|
|
|
|
|
private final InternalMessageService internalMessageService;
|
|
|
|
|
|
@@ -38,21 +48,62 @@ public class InternalMessageController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
+/* *//**
|
|
|
* 分页获取消息 (用户)
|
|
|
* @param recRole 接收角色
|
|
|
* @param timeSorting 时间排序
|
|
|
* @param classes 消息分类
|
|
|
* @param page 分页参数
|
|
|
* @return
|
|
|
- */
|
|
|
+ *//*
|
|
|
@RequestMapping(value = "/private", method = RequestMethod.GET)
|
|
|
public ModelMap getMessagePagePrivate(@RequestParam(value = "recRole", defaultValue = "BUYER") String recRole, @RequestParam("timeSorting") String timeSorting, @RequestParam("classes") String classes, PageParams page) {
|
|
|
ModelMap map = new ModelMap();
|
|
|
map.put("messages", internalMessageService.getMessagePage(SystemSession.getUser().getUserUU(), (SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu(): null), recRole, timeSorting, classes, page));
|
|
|
return map;
|
|
|
+ }*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取公共消息的方法
|
|
|
+ *
|
|
|
+ * @author dongbw
|
|
|
+ * @param pageParams 分页参数
|
|
|
+ * @param isRead 阅读状态 1已读 0 未读
|
|
|
+
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ @RequestMapping(value = "/private", method = RequestMethod.GET)
|
|
|
+ public static Page<MessageModel> getMessagesPagePrivate(PageParams pageParams, Short isRead) throws Exception {
|
|
|
+
|
|
|
+
|
|
|
+ HashMap<String, Object> params = new HashMap<>();
|
|
|
+ params.put("receiverUu", SystemSession.getUser().getUserUU());
|
|
|
+ params.put("receiverEnuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ params.put("consumerApp", "B2B");
|
|
|
+// params.put("pageParams", FlexJsonUtils.toJsonDeep(pageParams));
|
|
|
+ params.put("page", pageParams.getPage());
|
|
|
+ params.put("count", pageParams.getCount());
|
|
|
+ params.put("sorting", pageParams.getSorting());
|
|
|
+ params.put("isRead", isRead);
|
|
|
+
|
|
|
+ HttpUtil.Response res = HttpUtil.sendGetRequest(MESSAGE_PUBLIC_SERVICE_URL + "/messages", params);
|
|
|
+ if (HttpStatus.OK.value() == res.getStatusCode()) {
|
|
|
+ if (null != res.getResponseText()) {
|
|
|
+ System.out.println(res.getResponseText());
|
|
|
+
|
|
|
+ return (Page) JSONObject.parseObject(res.getResponseText(), new TypeReference<Page<MessageModel>>() {
|
|
|
+ }, new Feature[0]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("获取消息失败");
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 阅读消息
|
|
|
* @param id
|