Authored by unknown

分享图片资源位替换

@@ -58,6 +58,10 @@ @@ -58,6 +58,10 @@
58 <groupId>com.yoho.core</groupId> 58 <groupId>com.yoho.core</groupId>
59 <artifactId>yoho-core-rabbitmq</artifactId> 59 <artifactId>yoho-core-rabbitmq</artifactId>
60 </dependency> 60 </dependency>
  61 + <dependency>
  62 + <groupId>com.yoho.service.model</groupId>
  63 + <artifactId>resource-service-model</artifactId>
  64 + </dependency>
61 </dependencies> 65 </dependencies>
62 66
63 <build> 67 <build>
@@ -16,6 +16,9 @@ import com.yoho.core.rest.client.ServiceCaller; @@ -16,6 +16,9 @@ import com.yoho.core.rest.client.ServiceCaller;
16 import com.yoho.core.rest.exception.ServiceNotAvaibleException; 16 import com.yoho.core.rest.exception.ServiceNotAvaibleException;
17 import com.yoho.core.rest.exception.ServiceNotFoundException; 17 import com.yoho.core.rest.exception.ServiceNotFoundException;
18 import com.yoho.service.model.request.AreaReqBO; 18 import com.yoho.service.model.request.AreaReqBO;
  19 +import com.yoho.service.model.resource.ResourcesBO;
  20 +import com.yoho.service.model.resource.ResourcesServices;
  21 +import com.yoho.service.model.resource.request.ResourcesRequestBody;
19 import com.yoho.service.model.response.AreaRspBo; 22 import com.yoho.service.model.response.AreaRspBo;
20 import com.yoho.service.model.union.bo.*; 23 import com.yoho.service.model.union.bo.*;
21 import com.yoho.service.model.union.request.*; 24 import com.yoho.service.model.union.request.*;
@@ -28,6 +31,7 @@ import com.yoho.unions.helper.SendMessageHelper; @@ -28,6 +31,7 @@ import com.yoho.unions.helper.SendMessageHelper;
28 import org.apache.commons.collections.CollectionUtils; 31 import org.apache.commons.collections.CollectionUtils;
29 import org.apache.commons.lang3.StringUtils; 32 import org.apache.commons.lang3.StringUtils;
30 import org.elasticsearch.common.collect.Maps; 33 import org.elasticsearch.common.collect.Maps;
  34 +import org.omg.CORBA.OBJ_ADAPTER;
31 import org.slf4j.Logger; 35 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory; 36 import org.slf4j.LoggerFactory;
33 import org.springframework.beans.BeanUtils; 37 import org.springframework.beans.BeanUtils;
@@ -1138,7 +1142,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -1138,7 +1142,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
1138 //设置返回文案 1142 //设置返回文案
1139 bo.setShareId(configReader.getString(UNION_SHAREID, ""));//列表分享的活动id 1143 bo.setShareId(configReader.getString(UNION_SHAREID, ""));//列表分享的活动id
1140 bo.setInviteShareId(configReader.getString(UNION_INVITE_SHAREID, ""));//列表分享的活动id 1144 bo.setInviteShareId(configReader.getString(UNION_INVITE_SHAREID, ""));//列表分享的活动id
1141 - bo.setImageUrl(configReader.getString(UNION_CPS_IMAGEURL, ""));//分享banner 1145 + //调用接口返回
  1146 + ResourcesBO resourcesBO=getResourcesBO();
  1147 + // bo.setImageUrl(configReader.getString(UNION_CPS_IMAGEURL, ""));//分享banner
  1148 + bo.setImageUrl(getCpsImgUrl(resourcesBO));
1142 bo.setApplyImageUrl(configReader.getString(UNION_CPS_APPLY_IMAGEURL, ""));//申请banner 1149 bo.setApplyImageUrl(configReader.getString(UNION_CPS_APPLY_IMAGEURL, ""));//申请banner
1143 logger.info("queryUnionTypeByUid,uid is {},result is {}",uid,bo); 1150 logger.info("queryUnionTypeByUid,uid is {},result is {}",uid,bo);
1144 //设置缓存 1151 //设置缓存
@@ -1146,6 +1153,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -1146,6 +1153,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
1146 return bo; 1153 return bo;
1147 } 1154 }
1148 1155
  1156 +
  1157 +
  1158 +
1149 @Override 1159 @Override
1150 public UnionShareCountBo queryShareTotal(int uid) { 1160 public UnionShareCountBo queryShareTotal(int uid) {
1151 //先从缓存获取 1161 //先从缓存获取
@@ -4338,4 +4348,46 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -4338,4 +4348,46 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
4338 } 4348 }
4339 } 4349 }
4340 4350
  4351 + private ResourcesBO getResourcesBO() {
  4352 + ResourcesBO bo;//find by service call
  4353 + ResourcesRequestBody request = new ResourcesRequestBody();
  4354 + request.setContentCode("b8ce2b9c4b3baf75551d4d7888306e40");
  4355 + request.setUid(0);
  4356 + request.setUdid("0");
  4357 + logger.debug("UnionShareServiceImpl request is{}",JSON.toJSONString(request));
  4358 + //调用ResourcesServices.home
  4359 + bo = serviceCaller.call(ResourcesServices.getResourcesPrimaryHome, request, ResourcesBO.class);
  4360 + logger.debug("UnionShareServiceImpl ResourcesBO bo{}",JSON.toJSONString(bo));
  4361 + return bo;
  4362 +
  4363 + }
  4364 +
  4365 + /**
  4366 + * 从返回结果中解析得到图片地址src
  4367 + * @param resourcesBO
  4368 + * @return
  4369 + */
  4370 + private String getCpsImgUrl(ResourcesBO resourcesBO) {
  4371 + List<Object> objs= resourcesBO.getList();
  4372 + JSONObject json;
  4373 + if(CollectionUtils.isNotEmpty(objs)){
  4374 + Object o=objs.get(0);
  4375 + if(o instanceof JSONObject){
  4376 + json=(JSONObject) JSONObject.toJSON(o);
  4377 + Object object= json.get("data");
  4378 + if(object instanceof JSONObject){
  4379 + Object object2= json.get("data");
  4380 + json=(JSONObject) JSONObject.toJSON(object2);
  4381 + return String.valueOf(json.get("src"));
  4382 + }
  4383 + }
  4384 + }
  4385 + return null;
  4386 + }
  4387 +
  4388 + public static void main(String[] args) {
  4389 + System.out.println( DateUtil.getCurrentTimeSecond());
  4390 + }
  4391 +
  4392 +
4341 } 4393 }