31 changed files with 682 additions and 98 deletions
@ -0,0 +1,29 @@ |
|||||
|
package com.ccsensptos.tallsdk.bean.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TallPluginDto { |
||||
|
@Data |
||||
|
@ApiModel("通过业务code和插件名查找插件信息") |
||||
|
public static class BusinessPluginByName { |
||||
|
@ApiModelProperty("业务插件关联id") |
||||
|
private String code; |
||||
|
@ApiModelProperty("业务插件关联id") |
||||
|
private String pluginName; |
||||
|
|
||||
|
public BusinessPluginByName(String code, String pluginName) { |
||||
|
this.code = code; |
||||
|
this.pluginName = pluginName; |
||||
|
} |
||||
|
|
||||
|
public BusinessPluginByName() { |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.ccsensptos.tallsdk.bean.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TallPluginVo { |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("查找插件信息,通过服务code和插件名") |
||||
|
public static class BusinessPluginInfo{ |
||||
|
@ApiModelProperty("插件id") |
||||
|
private Long pluginId; |
||||
|
@ApiModelProperty("业务插件关联id") |
||||
|
private Long businessPluginId; |
||||
|
@ApiModelProperty("插件在业务下的唯一code") |
||||
|
private String code; |
||||
|
@ApiModelProperty("是否是内置组件 0否 1是") |
||||
|
private Byte inner; |
||||
|
} |
||||
|
} |
@ -0,0 +1,61 @@ |
|||||
|
package com.ccsensptos.tallsdk.util; |
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.ccsens.util.RestTemplateUtil; |
||||
|
import com.ccsensptos.tallsdk.bean.dto.TallPluginDto; |
||||
|
import com.ccsensptos.tallsdk.bean.dto.TallTokenDto; |
||||
|
import com.ccsensptos.tallsdk.bean.vo.TallPluginVo; |
||||
|
import com.ccsensptos.tallsdk.bean.vo.TallTokenVo; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Component |
||||
|
@Slf4j |
||||
|
public class PluginUtil { |
||||
|
|
||||
|
/** |
||||
|
* 通过业务code和插件名获取插件信息 |
||||
|
* @return 返回accessToken |
||||
|
*/ |
||||
|
public static TallPluginVo.BusinessPluginInfo getPluginByCodeAndName(String businessCode,String pluginName){ |
||||
|
TallPluginVo.BusinessPluginInfo businessPluginInfo; |
||||
|
TallPluginDto.BusinessPluginByName businessPluginByName = new TallPluginDto.BusinessPluginByName(businessCode,pluginName); |
||||
|
|
||||
|
//发送请求
|
||||
|
String url = Constant.GATEWAY_URL + Constant.OPEN_GET_PLUGIN; |
||||
|
log.info("调用接口:{}--{}", url, businessPluginByName); |
||||
|
String postBody = null; |
||||
|
try{ |
||||
|
postBody = RestTemplateUtil.postBody(url, businessPluginByName); |
||||
|
}catch (Exception e){ |
||||
|
log.error("请求开放品台失败--" + e); |
||||
|
} |
||||
|
if(StrUtil.isBlank(postBody)){ |
||||
|
return null; |
||||
|
} |
||||
|
JSONObject jsonObject = JSONObject.parseObject(postBody); |
||||
|
log.info("接口返回:{}", jsonObject); |
||||
|
//请求正确返回则,否则无操作
|
||||
|
Integer code = jsonObject.getInteger("code"); |
||||
|
if (code == null || code != 200) { |
||||
|
return null; |
||||
|
} |
||||
|
String data = jsonObject.getString("data"); |
||||
|
if(ObjectUtil.isNull(data)){ |
||||
|
return null; |
||||
|
} |
||||
|
try { |
||||
|
businessPluginInfo = JSON.parseObject(data, TallPluginVo.BusinessPluginInfo.class); |
||||
|
}catch (Exception e){ |
||||
|
log.info("返回值转换失败"); |
||||
|
return null; |
||||
|
} |
||||
|
return businessPluginInfo; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue