| | |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.model.CrmInterfaceLog; |
| | | import com.doumee.dao.business.model.InterfaceLog; |
| | | import com.doumee.dao.web.response.ZSZXCatalogResponse; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | ZTConstants.IntegerName.USER_GET_TOKEN_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<ZTUserGetTokenResponse>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 获取用户登陆token |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ZSZXCatalogResponse getZSZXCatalogs(){ |
| | | ZSZXCatalogResponse response = new ZSZXCatalogResponse(); |
| | | ZTCatalogListRequest param = new ZTCatalogListRequest(); |
| | | param.setCatalogCode(ZTConstants.CatalogCode.ZHISHUO_ZHUANGXIU); |
| | | List<ZTCatalogInfoResponse> cataList = getCatalogList(param); |
| | | if(cataList!=null ){ |
| | | for(ZTCatalogInfoResponse data : cataList){ |
| | | if(StringUtils.equals(data.getCode(), ZTConstants.CatalogCode.JIADE_ID)){ |
| | | response.setJdId(data); |
| | | }else if(StringUtils.equals(data.getCode(), ZTConstants.CatalogCode.CHUFANGSHEJI)){ |
| | | response.setCfsj(data); |
| | | }else if(StringUtils.equals(data.getCode(), ZTConstants.CatalogCode.QW_SHEJI)){ |
| | | response.setQwsj(data); |
| | | }else if(StringUtils.equals(data.getCode(), ZTConstants.CatalogCode.SHOUNASHEJI)){ |
| | | response.setSnsj(data); |
| | | } |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | /** |
| | | * 用户信息同步 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ZTUserGetTokenResponse userUpdateInfo(ZTUserInfoUpdateRequest param){ |
| | | public ZTBaseResponse userUpdateInfo(ZTUserInfoUpdateRequest param){ |
| | | ZTBaseResponse<ZTUserGetTokenResponse> result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.USER_UPDATE_URL, |
| | | ZTConstants.IntegerName.USER_UPDATE_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | | return null; |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<ZTUserGetTokenResponse>>(){}); |
| | | // if(result!=null){ |
| | | // return result.getData(); |
| | | // } |
| | | return result; |
| | | } |
| | | /** |
| | | * 注销用户 |
| | |
| | | ZTConstants.IntegerName.USER_LOGOUT_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<Object>>(){}); |
| | | if(result!=null ){ |
| | | return true; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public List<ZTCatalogInfoResponse> getCatalogList(ZTCatalogListRequest param){ |
| | | ZTBaseResponse<List<ZTCatalogInfoResponse>> result = sendHttpRequest( |
| | | |
| | | ZTBaseResponse<List<ZTCatalogInfoResponse>> result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.CATALOG_LIST_URL, |
| | | ZTConstants.IntegerName.CATALOG_LIST_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<List<ZTCatalogInfoResponse>>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 获取分类和分类下的标签 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ZTTagInfoResponse> getTagList(ZTCatalogListRequest param){ |
| | | ZTBaseResponse<List<ZTTagInfoResponse>> result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.TAG_LIST_URL, |
| | | ZTConstants.IntegerName.TAG_LIST_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<List<ZTTagInfoResponse>>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | |
| | | ZTConstants.IntegerName.CONTENT_LIST_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<ZTBasePageResponse<ZTContentListResponse>>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | |
| | | @Override |
| | | public ZTContentInfoResponse getContentInfo(ZTContentInfoRequest param){ |
| | | ZTBaseResponse<ZTContentInfoResponse> result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.CONTENT_INFO_URL+ param.getArticleId(), |
| | | ZTConstants.IntegerUrl.CONTENT_INFO_URL+ param.getId(), |
| | | ZTConstants.IntegerName.CONTENT_INFO_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<ZTContentInfoResponse>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean collectDo(ZTActionDoRequest param){ |
| | | public ZTBaseResponse collectDo(ZTActionDoRequest param){ |
| | | ZTBaseResponse result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.COLLECT_DO_URL, |
| | | ZTConstants.IntegerName.COLLECT_DO_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | if(result!=null ){ |
| | | return true; |
| | | } |
| | | return false; |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<Object>>(){}); |
| | | |
| | | return result; |
| | | } |
| | | /** |
| | | * 内容喜欢 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean likeDo(ZTActionBatchDoRequest param){ |
| | | public ZTBaseResponse likeDo(ZTActionBatchDoRequest param){ |
| | | ZTBaseResponse result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.LIKE_DO_URL, |
| | | ZTConstants.IntegerName.LIKE_DO_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | if(result!=null ){ |
| | | return true; |
| | | } |
| | | return false; |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<Object>>(){}); |
| | | |
| | | return result; |
| | | } |
| | | /** |
| | | * 内容分享 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean shareDo(ZTActionDoRequest param){ |
| | | public ZTBaseResponse shareDo(ZTActionDoRequest param){ |
| | | ZTBaseResponse result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.SHARE_DO_URL, |
| | | ZTConstants.IntegerName.SHARE_DO_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | if(result!=null ){ |
| | | return true; |
| | | } |
| | | return false; |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<Object>>(){}); |
| | | return result; |
| | | } |
| | | /** |
| | | * 内容浏览 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean viewDo(ZTActionDoRequest param){ |
| | | public ZTBaseResponse viewDo(ZTActionDoRequest param){ |
| | | ZTBaseResponse result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.VIEW_DO_URL, |
| | | ZTConstants.IntegerName.VIEW_DO_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<Object>>(){}); |
| | | return result; |
| | | } |
| | | /** |
| | | * 用户绑定客户喜欢清单,可绑定多个内容 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean bindCustomerFavorites(ZTBindCusFavoriteDoRequest param){ |
| | | ZTBaseResponse result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.BIND_CUSTOMER_FAVORITES_URL, |
| | | ZTConstants.IntegerName.BIND_CUSTOMER_FAVORITES_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<Object>>(){}); |
| | | if(result!=null ){ |
| | | return true; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ZTBasePageResponse<ZTContentListResponse> pageCollectList(ZTContentListRequest param){ |
| | | ZTBaseResponse< ZTBasePageResponse<ZTContentListResponse>> result = sendHttpRequest( |
| | | public ZTBasePageResponse<ZTCollectInfoResponse> pageCollectList(ZTContentListRequest param){ |
| | | ZTBaseResponse< ZTBasePageResponse<ZTCollectInfoResponse>> result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.COLLECT_LIST_URL, |
| | | ZTConstants.IntegerName.COLLECT_LIST_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<ZTBasePageResponse<ZTCollectInfoResponse>>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 获取我的收藏列表分页 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ZTBasePageResponse<ZTBehaviorInfoResponse> pageBehavoirList(ZTContentListRequest param){ |
| | | ZTBaseResponse< ZTBasePageResponse<ZTBehaviorInfoResponse>> result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.BEHAVIOR_LIST_URL, |
| | | ZTConstants.IntegerName.BEHAVIOR_LIST_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<ZTBasePageResponse<ZTBehaviorInfoResponse>>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 获取客户喜欢 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ZTBasePageResponse<ZTCusFavoritesInfoResponse> pageCusFavoriteList(ZTContentListRequest param){ |
| | | ZTBaseResponse< ZTBasePageResponse<ZTCusFavoritesInfoResponse>> result = sendHttpRequest( |
| | | ZTConstants.IntegerUrl.CUSTOMER_FAVORITES_LIST_URL, |
| | | ZTConstants.IntegerName.CUSTOMER_FAVORITES_LIST_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<ZTBasePageResponse<ZTCusFavoritesInfoResponse>>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | |
| | | ZTConstants.IntegerName.LIKE_LIST_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<ZTBasePageResponse<ZTContentListResponse>>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | |
| | | ZTConstants.IntegerName.AREA_LIST_NAME, |
| | | param.getToken(), |
| | | param.getUserType(), |
| | | JSONObject.toJSONString(param )); |
| | | JSONObject.toJSONString(param ), |
| | | new TypeReference<ZTBaseResponse<List<ZTAreaInfoResponse>>>(){}); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public <T> ZTBaseResponse<T> sendHttpRequest(String url,String name,String token,String userType,String param){ |
| | | public <T> ZTBaseResponse<T> sendHttpRequest(String url,String name,String token,String userType,String param,TypeReference<ZTBaseResponse<T>> typeReference){ |
| | | log.info("【"+name+"】================开始===="+ JSONObject.toJSONString(param)); |
| | | String res = null; |
| | | int success = 0; |
| | | try { |
| | | |
| | | Map<String,String> headers = new HashMap<>(); |
| | | headers.put(ZTConstants.HEADER_TOKEN,token); |
| | | headers.put(ZTConstants.HEADER_USERTYPE,userType); |
| | | String index = (String) redisTemplate.opsForValue().get(Constants.RedisKeys.ZBOM_ZHONGTAI_API_URL); |
| | | res = HttpsUtil.postJsonWithHeaders(index+url,param,headers); |
| | | TypeReference typeReference = |
| | | new TypeReference<ZTBaseResponse<T>>(){}; |
| | | ZTBaseResponse<T> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,name); |
| | | if(StringUtils.equals(result.getCode(),ZTConstants.CODE_SUCCESS)){ |
| | | if(Constants.equalsInteger(result.getCode(),ZTConstants.CODE_SUCCESS)){ |
| | | return result; |
| | | }else{ |
| | | success =1; |
| | |
| | | interfaceLogMapper.insert(log); |
| | | } |
| | | private static void logResult(ZTBaseResponse res,String name) { |
| | | if(StringUtils.equals(res.getCode(), ZTConstants.CODE_SUCCESS)){ |
| | | if(Constants.equalsInteger(res.getCode(),ZTConstants.CODE_SUCCESS)){ |
| | | log.info("【中台接口:"+name+"】================成功====\n"+res); |
| | | }else{ |
| | | log.error("【中台接口:"+name+"】================失败====:\n"+ res); |