parent
02ca4bd22a
commit
fc065088fa
@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
//获取联想词汇
|
||||
export function getAssociation(content) {
|
||||
return request({
|
||||
url: '/openapi/association/getAssociation',
|
||||
method: 'get',
|
||||
params: content
|
||||
})
|
||||
}
|
After Width: | Height: | Size: 3.8 KiB |
@ -0,0 +1,24 @@
|
||||
package com.xjs.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* json工具类
|
||||
* @author xiejs
|
||||
* @since 2022-02-24
|
||||
*/
|
||||
public class JsonUtils {
|
||||
|
||||
/**
|
||||
* 解析jsonp
|
||||
* @param jsonp 一种json文本格式
|
||||
* @return JSONObject
|
||||
*/
|
||||
public static JSONObject parseJsonp(String jsonp) {
|
||||
int startIndex = jsonp.indexOf("(");
|
||||
int endIndex = jsonp.lastIndexOf(")");
|
||||
String json = jsonp.substring(startIndex+1, endIndex);
|
||||
return JSON.parseObject(json);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.xjs.common.client.api.sougou;
|
||||
|
||||
import com.xjs.annotation.ApiLog;
|
||||
import com.xjs.common.client.factory.SouGouAssociationFeignFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import static com.xjs.consts.ApiConst.SOUGOU_ASSOCIATION;
|
||||
import static com.xjs.consts.ApiConst.SOUGOU__ASSOCIATION_URL;
|
||||
|
||||
/**
|
||||
* 搜狗语义联想api feign
|
||||
* @author xiejs
|
||||
* @since 2022-02-25
|
||||
*/
|
||||
@FeignClient(name = "souGouAssociation", url = SOUGOU__ASSOCIATION_URL, fallbackFactory = SouGouAssociationFeignFactory.class)
|
||||
public interface SouGouAssociationFeignClient {
|
||||
|
||||
@GetMapping
|
||||
@ApiLog(name = SOUGOU_ASSOCIATION,
|
||||
url = SOUGOU__ASSOCIATION_URL,
|
||||
method = "Get")
|
||||
String associationApi(@RequestParam("key") String key);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.xjs.common.client.factory;
|
||||
|
||||
import com.xjs.common.client.api.sougou.SouGouAssociationFeignClient;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 搜狗语义联想api 降级
|
||||
* @author xiejs
|
||||
* @since 2022-02-25
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class SouGouAssociationFeignFactory implements FallbackFactory<SouGouAssociationFeignClient> {
|
||||
|
||||
@Override
|
||||
public SouGouAssociationFeignClient create(Throwable cause) {
|
||||
log.error("搜狗联想服务调用失败:{},执行降级处理", cause.getMessage());
|
||||
return (wd ->"");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue