k94314517
2024-07-15 11fcbd5a74edcc48466e27f2e7d22ea2b169810d
server/service/src/main/java/com/doumee/biz/zbom/impl/ZbomZhongTaiServiceImpl.java
@@ -19,6 +19,7 @@
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;
@@ -36,6 +37,9 @@
public class ZbomZhongTaiServiceImpl implements ZbomZhongTaiService {
    @Autowired
    private InterfaceLogMapper interfaceLogMapper;
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    /**
     * 获取用户登陆token
     * @param param
@@ -110,6 +114,25 @@
        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
@@ -135,7 +158,7 @@
    @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(),
@@ -287,12 +310,13 @@
            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;
@@ -323,7 +347,7 @@
        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);