| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | |
| | | public class ZbomZhongTaiServiceImpl implements ZbomZhongTaiService { |
| | | @Autowired |
| | | private InterfaceLogMapper interfaceLogMapper; |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | /** |
| | | * 获取用户登陆token |
| | | * @param param |
| | |
| | | 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 )); |
| | | if(result!=null){ |
| | | return result.getData(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取内容列表分页 |
| | | * @param param |
| | | * @return |
| | |
| | | @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(), |
| | |
| | | Map<String,String> headers = new HashMap<>(); |
| | | headers.put(ZTConstants.HEADER_TOKEN,token); |
| | | headers.put(ZTConstants.HEADER_USERTYPE,userType); |
| | | res = HttpsUtil.postJsonWithHeaders(url,param,headers); |
| | | 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); |