From 50c82578604f83a2f050d89b6a4f2d0e148fec58 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 04 八月 2020 14:03:46 +0800
Subject: [PATCH] 优化代码
---
service-front/src/main/java/com/java110/front/smo/wechatGateway/impl/WechatGatewaySMOImpl.java | 47 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/service-front/src/main/java/com/java110/front/smo/wechatGateway/impl/WechatGatewaySMOImpl.java b/service-front/src/main/java/com/java110/front/smo/wechatGateway/impl/WechatGatewaySMOImpl.java
index ab22672..2b51d42 100644
--- a/service-front/src/main/java/com/java110/front/smo/wechatGateway/impl/WechatGatewaySMOImpl.java
+++ b/service-front/src/main/java/com/java110/front/smo/wechatGateway/impl/WechatGatewaySMOImpl.java
@@ -1,20 +1,27 @@
package com.java110.front.smo.wechatGateway.impl;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.base.smo.front.AbstractFrontServiceSMO;
import com.java110.core.context.IPageData;
import com.java110.core.factory.WechatFactory;
import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.smallWeChat.SmallWeChatDto;
+import com.java110.dto.smallWechatAttr.SmallWechatAttrDto;
import com.java110.front.properties.WechatAuthProperties;
import com.java110.front.smo.wechatGateway.IWechatGatewaySMO;
import com.java110.utils.cache.MappingCache;
import com.java110.utils.constant.ServiceCodeConstant;
+import com.java110.utils.constant.ServiceCodeSmallWechatAttrConstant;
+import com.java110.utils.constant.ServiceConstant;
import com.java110.utils.constant.WechatConstant;
import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -44,7 +51,7 @@
public ResponseEntity<String>
gateway(IPageData pd) throws Exception {
- JSONObject paramIn = JSONObject.parseObject(JSONObject.toJSONString(pd.getReqData()));
+ JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
Assert.hasKeyAndValue(paramIn, "fromUserName", "璇锋眰鎶ユ枃涓湭鍖呭惈fromUserName");
Assert.hasKeyAndValue(paramIn, "toUserName", "璇锋眰鎶ユ枃涓湭鍖呭惈toUserName");
@@ -60,7 +67,15 @@
//鍒ゆ柇鐢ㄦ埛鏄惁缁戝畾涓氫富
boolean bindFlag = judgeBindOwner(pd, fromUserName);
if (!bindFlag) {
- responseStr = WechatFactory.formatText(toUserName, fromUserName, WechatConstant.NO_BIND_OWNER_RESPONSE_MESSAGE);
+
+ String noBindOwnerResponseMessage = MappingCache.getRemark(WechatConstant.WECHAT_DOMAIN, WechatConstant.NO_BIND_OWNER);
+
+ if (StringUtil.isEmpty(noBindOwnerResponseMessage)) {
+
+ noBindOwnerResponseMessage = WechatConstant.NO_BIND_OWNER_RESPONSE_MESSAGE;
+ }
+
+ responseStr = WechatFactory.formatText(toUserName, fromUserName, noBindOwnerResponseMessage);
return new ResponseEntity<String>(responseStr, HttpStatus.OK);
}
@@ -74,6 +89,34 @@
return new ResponseEntity<>(responseStr, HttpStatus.OK);
}
+ @Override
+ public SmallWeChatDto getSmallWechat(IPageData pd, SmallWeChatDto smallWeChatDto) {
+
+ //List<SmallWeChatDto> smallWeChatDtos = super.getForApis(pd, smallWeChatDto, ServiceCodeSmallWeChatConstant.LIST_SMALL_WE_CHATS, SmallWeChatDto.class);
+ ResponseEntity<String> responseEntity = this.callCenterService(restTemplate, pd, "",
+ ServiceConstant.SERVICE_API_URL + "/api/smallWeChat.listSmallWeChats?appId="
+ + smallWeChatDto.getAppId() + "&page=1&row=1", HttpMethod.GET);
+
+ if (responseEntity.getStatusCode() != HttpStatus.OK) {
+ return null;
+ }
+ JSONObject smallWechatObj = JSONObject.parseObject(responseEntity.getBody().toString());
+ JSONArray smallWeChats = smallWechatObj.getJSONArray("smallWeChats");
+
+
+ if (smallWeChats == null || smallWeChats.size() < 1) {
+ return null;
+ }
+ smallWeChatDto = BeanConvertUtil.covertBean(smallWeChats.get(0), SmallWeChatDto.class);
+ SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
+ smallWechatAttrDto.setCommunityId(smallWeChatDto.getObjId());
+ smallWechatAttrDto.setWechatId(smallWeChatDto.getWeChatId());
+ List<SmallWechatAttrDto> smallWechatAttrs = super.getForApis(pd, smallWechatAttrDto, ServiceCodeSmallWechatAttrConstant.LIST_SMALLWECHATATTRS, SmallWechatAttrDto.class);
+
+ smallWeChatDto.setSmallWechatAttrs(smallWechatAttrs);
+ return smallWeChatDto;
+ }
+
public RestTemplate getRestTemplate() {
return restTemplate;
--
Gitblit v1.8.0