Authored by unknown

分享图片资源位替换

... ... @@ -58,6 +58,10 @@
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rabbitmq</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.service.model</groupId>
<artifactId>resource-service-model</artifactId>
</dependency>
</dependencies>
<build>
... ...
... ... @@ -16,6 +16,9 @@ import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.core.rest.exception.ServiceNotAvaibleException;
import com.yoho.core.rest.exception.ServiceNotFoundException;
import com.yoho.service.model.request.AreaReqBO;
import com.yoho.service.model.resource.ResourcesBO;
import com.yoho.service.model.resource.ResourcesServices;
import com.yoho.service.model.resource.request.ResourcesRequestBody;
import com.yoho.service.model.response.AreaRspBo;
import com.yoho.service.model.union.bo.*;
import com.yoho.service.model.union.request.*;
... ... @@ -28,6 +31,7 @@ import com.yoho.unions.helper.SendMessageHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Maps;
import org.omg.CORBA.OBJ_ADAPTER;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
... ... @@ -1138,7 +1142,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
//设置返回文案
bo.setShareId(configReader.getString(UNION_SHAREID, ""));//列表分享的活动id
bo.setInviteShareId(configReader.getString(UNION_INVITE_SHAREID, ""));//列表分享的活动id
bo.setImageUrl(configReader.getString(UNION_CPS_IMAGEURL, ""));//分享banner
//调用接口返回
ResourcesBO resourcesBO=getResourcesBO();
// bo.setImageUrl(configReader.getString(UNION_CPS_IMAGEURL, ""));//分享banner
bo.setImageUrl(getCpsImgUrl(resourcesBO));
bo.setApplyImageUrl(configReader.getString(UNION_CPS_APPLY_IMAGEURL, ""));//申请banner
logger.info("queryUnionTypeByUid,uid is {},result is {}",uid,bo);
//设置缓存
... ... @@ -1146,6 +1153,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return bo;
}
@Override
public UnionShareCountBo queryShareTotal(int uid) {
//先从缓存获取
... ... @@ -4338,4 +4348,46 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
}
private ResourcesBO getResourcesBO() {
ResourcesBO bo;//find by service call
ResourcesRequestBody request = new ResourcesRequestBody();
request.setContentCode("b8ce2b9c4b3baf75551d4d7888306e40");
request.setUid(0);
request.setUdid("0");
logger.debug("UnionShareServiceImpl request is{}",JSON.toJSONString(request));
//调用ResourcesServices.home
bo = serviceCaller.call(ResourcesServices.getResourcesPrimaryHome, request, ResourcesBO.class);
logger.debug("UnionShareServiceImpl ResourcesBO bo{}",JSON.toJSONString(bo));
return bo;
}
/**
* 从返回结果中解析得到图片地址src
* @param resourcesBO
* @return
*/
private String getCpsImgUrl(ResourcesBO resourcesBO) {
List<Object> objs= resourcesBO.getList();
JSONObject json;
if(CollectionUtils.isNotEmpty(objs)){
Object o=objs.get(0);
if(o instanceof JSONObject){
json=(JSONObject) JSONObject.toJSON(o);
Object object= json.get("data");
if(object instanceof JSONObject){
Object object2= json.get("data");
json=(JSONObject) JSONObject.toJSON(object2);
return String.valueOf(json.get("src"));
}
}
}
return null;
}
public static void main(String[] args) {
System.out.println( DateUtil.getCurrentTimeSecond());
}
}
... ...