master
parent
4ddc978edf
commit
31a3989517
Binary file not shown.
Binary file not shown.
@ -0,0 +1,46 @@ |
|||||||
|
package com.hfkj.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.common.exception.ErrorCode; |
||||||
|
import com.hfkj.common.exception.ErrorHelp; |
||||||
|
import com.hfkj.common.exception.SysCode; |
||||||
|
|
||||||
|
import com.hfkj.common.utils.ResponseMsgUtil; |
||||||
|
import com.hfkj.model.ResponseData; |
||||||
|
|
||||||
|
import com.hfkj.service.pdd.PddService; |
||||||
|
import com.hfkj.service.taobao.TaoBaoService; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value="/test") |
||||||
|
@Api(value="测试") |
||||||
|
public class TestController { |
||||||
|
private static Logger log = LoggerFactory.getLogger(TestController.class); |
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value="/syncInvoke",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "生成商城-频道推广链接") |
||||||
|
public ResponseData syncInvoke() { |
||||||
|
try { |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(TaoBaoService.execute()); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("error!",e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,79 @@ |
|||||||
|
package com.hfkj.service.pdd; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.pdd.pop.sdk.common.util.JsonUtil; |
||||||
|
import com.pdd.pop.sdk.http.PopClient; |
||||||
|
import com.pdd.pop.sdk.http.PopHttpClient; |
||||||
|
import com.pdd.pop.sdk.http.api.pop.request.PddDdkGoodsSearchRequest; |
||||||
|
import com.pdd.pop.sdk.http.api.pop.response.PddDdkGoodsSearchResponse; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class PddService { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(PddService.class); |
||||||
|
|
||||||
|
public static String syncInvoke() throws Exception { |
||||||
|
|
||||||
|
log.info("============ 淘宝请求-START ============="); |
||||||
|
String clientId = "71a050c5d93d4169a237539af44c7c33"; |
||||||
|
String clientSecret = "b96def667dd28660d09f19ba2e9e9f23d810d563"; |
||||||
|
PopClient client = new PopHttpClient(clientId, clientSecret); |
||||||
|
PddDdkGoodsSearchRequest request = new PddDdkGoodsSearchRequest(); |
||||||
|
List<Integer> activityTags = new ArrayList<Integer>(); |
||||||
|
activityTags.add(0); |
||||||
|
request.setActivityTags(activityTags); |
||||||
|
List<Integer> blockCatPackages = new ArrayList<Integer>(); |
||||||
|
blockCatPackages.add(0); |
||||||
|
request.setBlockCatPackages(blockCatPackages); |
||||||
|
List<Integer> blockCats = new ArrayList<Integer>(); |
||||||
|
blockCats.add(0); |
||||||
|
request.setBlockCats(blockCats); |
||||||
|
request.setCatId(49L); |
||||||
|
request.setCustomParameters("str"); |
||||||
|
request.setGoodsImgType(1); |
||||||
|
List<String> goodsSignList = new ArrayList<String>(); |
||||||
|
goodsSignList.add("str"); |
||||||
|
request.setGoodsSignList(goodsSignList); |
||||||
|
request.setIsBrandGoods(true); |
||||||
|
request.setKeyword("str"); |
||||||
|
request.setListId("str"); |
||||||
|
request.setMerchantType(1); |
||||||
|
List<Integer> merchantTypeList = new ArrayList<Integer>(); |
||||||
|
merchantTypeList.add(0); |
||||||
|
request.setMerchantTypeList(merchantTypeList); |
||||||
|
request.setOptId(49L); |
||||||
|
request.setPage(1); |
||||||
|
request.setPageSize(100); |
||||||
|
request.setPid("str"); |
||||||
|
List<PddDdkGoodsSearchRequest.RangeListItem> rangeList = new ArrayList<>(); |
||||||
|
|
||||||
|
PddDdkGoodsSearchRequest.RangeListItem item = new PddDdkGoodsSearchRequest.RangeListItem(); |
||||||
|
item.setRangeFrom(0L); |
||||||
|
item.setRangeId(0); |
||||||
|
item.setRangeTo(0L); |
||||||
|
rangeList.add(item); |
||||||
|
request.setRangeList(rangeList); |
||||||
|
request.setSortType(0); |
||||||
|
request.setUseCustomized(true); |
||||||
|
request.setWithCoupon(true); |
||||||
|
Map<String, String> riskParams = new HashMap<>(); |
||||||
|
riskParams.put("", "str"); |
||||||
|
request.setRiskParams(riskParams); |
||||||
|
PddDdkGoodsSearchResponse response = client.syncInvoke(request); |
||||||
|
|
||||||
|
log.info("请求接口:" + "syncInvoke"); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(request)); |
||||||
|
|
||||||
|
|
||||||
|
log.info("响应参数:" + JsonUtil.transferToJson(response)); |
||||||
|
log.info("============ 淘宝请求-END =============="); |
||||||
|
return JsonUtil.transferToJson(response); |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
package com.hfkj.service.taobao; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import com.taobao.top.DefaultTopApiClient; |
||||||
|
import com.taobao.top.TopApiClient; |
||||||
|
import com.taobao.top.ability371.Ability371; |
||||||
|
import com.taobao.top.ability371.request.TaobaoTbkItemInfoGetRequest; |
||||||
|
import com.taobao.top.ability371.response.TaobaoTbkItemInfoGetResponse; |
||||||
|
import com.taobao.top.defaultability.Defaultability; |
||||||
|
import com.taobao.top.defaultability.domain.TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery; |
||||||
|
import com.taobao.top.defaultability.request.TaobaoTbkDgMaterialRecommendRequest; |
||||||
|
import com.taobao.top.defaultability.request.TaobaoTbkOptimusTouMaterialIdsGetRequest; |
||||||
|
import com.taobao.top.defaultability.response.TaobaoTbkOptimusTouMaterialIdsGetResponse; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
|
||||||
|
public class TaoBaoService { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(TaoBaoService.class); |
||||||
|
|
||||||
|
|
||||||
|
public static JSONObject execute() throws Exception { |
||||||
|
|
||||||
|
log.info("============ 淘宝请求-START ============="); |
||||||
|
String appkey = "34807616"; |
||||||
|
String appsecret = "f04baedca9cd794665dfa04a2fcbfd86"; |
||||||
|
String url = "http://gw.api.taobao.com/router/rest"; |
||||||
|
TopApiClient client = new DefaultTopApiClient(appkey,appsecret,url); |
||||||
|
Defaultability apiPackage = new Defaultability(client); |
||||||
|
// create domain
|
||||||
|
TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery taobaoTbkOptimusTouMaterialIdsGetMaterialQuery = new TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery(); |
||||||
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setPageNo(1L); |
||||||
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setSubject(1L); |
||||||
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setMaterialType(1L); |
||||||
|
taobaoTbkOptimusTouMaterialIdsGetMaterialQuery.setPageSize(20L); |
||||||
|
|
||||||
|
// create request
|
||||||
|
TaobaoTbkOptimusTouMaterialIdsGetRequest request = new TaobaoTbkOptimusTouMaterialIdsGetRequest(); |
||||||
|
request.setMaterialQuery(taobaoTbkOptimusTouMaterialIdsGetMaterialQuery); |
||||||
|
|
||||||
|
TaobaoTbkOptimusTouMaterialIdsGetResponse response = apiPackage.taobaoTbkOptimusTouMaterialIdsGet(request); |
||||||
|
if(!response.isSuccess()){ |
||||||
|
System.out.println(response.getSubMsg()); |
||||||
|
} |
||||||
|
System.out.println(JSON.toJSONString(response)); |
||||||
|
|
||||||
|
log.info("============ 淘宝请求-END =============="); |
||||||
|
return JSONObject.parseObject(JSON.toJSONString(response)); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
|
||||||
|
taoBaoPostUrl = https://eco.taobao.com/router/rest |
||||||
|
taoBaoAppKey = 34807616 |
||||||
|
taoBaoAppSecret = f04baedca9cd794665dfa04a2fcbfd86 |
Loading…
Reference in new issue