k94314517
2024-07-15 83430e4bd60f9a44ec76698fa04ee8d3373a1087
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
@@ -101,6 +105,24 @@
        ZTBaseResponse<List<ZTCatalogInfoResponse>> result = sendHttpRequest(
                ZTConstants.IntegerUrl.CATALOG_LIST_URL,
                ZTConstants.IntegerName.CATALOG_LIST_NAME,
                param.getToken(),
                param.getUserType(),
                JSONObject.toJSONString(param ));
        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 ));
@@ -288,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;
@@ -324,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);