|
|
@@ -1,6 +1,7 @@
|
|
|
package com.uas.platform.b2c.common.message.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.alibaba.fastjson.parser.Feature;
|
|
|
@@ -12,18 +13,23 @@ import com.uas.platform.b2c.core.config.MicroServicesConf;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.ContextUtils;
|
|
|
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
import com.uas.platform.b2c.trade.deprecated.model.BasicMessage;
|
|
|
+import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.platform.core.model.Type;
|
|
|
import com.uas.platform.core.util.HttpUtil;
|
|
|
import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
-import com.uas.sso.support.Page;
|
|
|
+import com.uas.ps.core.util.ObjectUtils;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.collections.map.ListOrderedMap;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.apache.velocity.app.VelocityEngine;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.velocity.VelocityEngineUtils;
|
|
|
@@ -254,11 +260,12 @@ public class InternalMessageServiceImpl implements InternalMessageService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Override
|
|
|
- public void setRead(List<MessageModel> content)throws Exception {
|
|
|
- if (!CollectionUtils.isEmpty(content)) {
|
|
|
+ public void setRead(JSONArray content)throws Exception {
|
|
|
+ if (!ObjectUtils.isEmpty(content)) {
|
|
|
HashMap<String, Object> params = new HashMap<>();
|
|
|
StringBuilder idString = new StringBuilder();
|
|
|
- for(MessageModel m :content) {
|
|
|
+ List<MessageModel> models = FastjsonUtils.fromJsonArray( content.toString(), MessageModel.class);
|
|
|
+ for(MessageModel m :models) {
|
|
|
if (!StringUtils.isEmpty(idString.toString())) {
|
|
|
idString.append(",");
|
|
|
}
|
|
|
@@ -311,7 +318,7 @@ public class InternalMessageServiceImpl implements InternalMessageService {
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
- public Page<MessageModel> getMessagesPagePrivate(PageParams pageParams, Short isRead,String keyword) throws Exception {
|
|
|
+ public JSONObject getMessagesPagePrivate(PageParams pageParams, Short isRead, String keyword) throws Exception {
|
|
|
HashMap<String, Object> params = new HashMap<>();
|
|
|
params.put("receiverUu", SystemSession.getUser().getUserUU());
|
|
|
params.put("receiverEnuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
@@ -325,35 +332,32 @@ public class InternalMessageServiceImpl implements InternalMessageService {
|
|
|
params.put("keyword", keyword);
|
|
|
}
|
|
|
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());
|
|
|
- Page<MessageModel> messageModelPage = JSONObject.parseObject(res.getResponseText(), new TypeReference<Page<MessageModel>>() {
|
|
|
- }, new Feature[0]);
|
|
|
- if (messageModelPage != null) {
|
|
|
- for (MessageModel messageModel : messageModelPage.getContent()) {
|
|
|
- // 拼接公共询价链接
|
|
|
- if (INQUIRY_TYPE_MALL.equals(messageModel.getType()) ) {
|
|
|
- messageModel.setUrl("/user#/seekPurchase" );
|
|
|
- } else if (INQUIRY_DECIDE_TYPE_MALL.equals(messageModel.getType())||INQUIRY_DECIDE_TYPE.equals(messageModel.getType())) {
|
|
|
- messageModel.setUrl("/vendor#/vendorPurchaseOffer" );
|
|
|
- } else if (INQUIRY_TYPE_SELLER_MALL.equals(messageModel.getType())||INQUIRY_TYPE.equals(messageModel.getType())) {
|
|
|
- messageModel.setUrl("/vendor#/seekPurchase" );
|
|
|
+ JSONObject jsonObject = FastjsonUtils.fromJson(res.getResponseText(), JSONObject.class);
|
|
|
+ String content = jsonObject.getString("content");
|
|
|
+ if (!StringUtils.isEmpty(content)) {
|
|
|
+ List<MessageModel> models = FastjsonUtils.fromJsonArray(content, MessageModel.class);
|
|
|
+ if (CollectionUtils.isNotEmpty(models)) {
|
|
|
+ for (MessageModel messageModel : models) {
|
|
|
+ // 拼接公共询价链接
|
|
|
+ if (INQUIRY_TYPE_MALL.equals(messageModel.getType()) ) {
|
|
|
+ messageModel.setUrl("/user#/seekPurchase" );
|
|
|
+ } else if (INQUIRY_DECIDE_TYPE_MALL.equals(messageModel.getType())||INQUIRY_DECIDE_TYPE.equals(messageModel.getType())) {
|
|
|
+ messageModel.setUrl("/vendor#/vendorPurchaseOffer" );
|
|
|
+ } else if (INQUIRY_TYPE_SELLER_MALL.equals(messageModel.getType())||INQUIRY_TYPE.equals(messageModel.getType())) {
|
|
|
+ messageModel.setUrl("/vendor#/seekPurchase" );
|
|
|
+ }
|
|
|
}
|
|
|
+ jsonObject.remove("content");
|
|
|
+ jsonObject.put("content", models);
|
|
|
}
|
|
|
}
|
|
|
- return messageModelPage;
|
|
|
-
|
|
|
- // 拼接访问URL
|
|
|
- /* if(messagePage != null){
|
|
|
- for(MessageModel messageModel : messagePage.getContent()){
|
|
|
- if (INQUIRY_TYPE.equals(messageModel.getType())) {
|
|
|
- messageModel.setUrl("#/DECIDE" );
|
|
|
- } else if (INQUIRY_DECIDE_TYPE_MALL.equals(messageModel.getType())) {
|
|
|
- messageModel.setUrl("#/vendorPurchaseOffer" );
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
+
|
|
|
+ return jsonObject;
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
throw new RuntimeException("获取消息失败");
|