소스 검색

添加-对接素描通图片服务演示测试方法。

dev
부모
커밋
8dc70e1329
4개의 변경된 파일214개의 추가작업 그리고 1개의 파일을 삭제
  1. BIN
      001.jpg
  2. +9
    -1
      README.md
  3. +50
    -0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/AliexpressDemoController.java
  4. +155
    -0
      ruoyi-admin/src/test/java/com/ruoyi/ap/AliexpressTest.java

BIN
001.jpg 파일 보기

Before After
Width: 1000  |  Height: 1000  |  Size: 26KB

+ 9
- 1
README.md 파일 보기

@@ -18,4 +18,12 @@
## 对接接口整理,以及工期评估
https://shimo.im/sheets/wV3VM9r189Sxb0Ay/MODOC
### 协作链接
https://shimo.im/file-invite/6bxRUFBtaBLwA9cq66ZuyEPQp9wl6/ +8618750905359 邀请您协作《对接速卖通接口API》,点击链接开始编辑
https://shimo.im/file-invite/6bxRUFBtaBLwA9cq66ZuyEPQp9wl6/ +8618750905359 邀请您协作《对接速卖通接口API》,点击链接开始编辑

## 速卖通 卖家账号
zyjwish21@163.com
vogocm2019
厦门旺嘉创亿电子商务有限公司

## 速卖通开发信息
https://www.yuque.com/xiaoxuesheng-4pior/cioqum/ngy0836sxw13f6ag?singleDoc# 《速卖通接口对接》

+ 50
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/aliexpress/AliexpressDemoController.java 파일 보기

@@ -0,0 +1,50 @@
package com.ruoyi.web.controller.aliexpress;

import com.global.iop.api.IopClient;
import com.global.iop.api.IopClientImpl;
import com.global.iop.api.IopRequest;
import com.global.iop.api.IopResponse;
import com.global.iop.domain.Protocol;
import com.global.iop.util.ApiException;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* 用户信息
*
* @author ruoyi
*/
@RestController
@Api("对接速卖通图片演示")
@RequestMapping("/aliexpress/img")
public class AliexpressDemoController extends BaseController
{

/**
* 获取图片银行分页查询
*/
@Log(title = "查询图片", businessType = BusinessType.SELECT)
@ApiOperation("获取用户列表")
@GetMapping("/list")
public String list(SysUser user) throws ApiException {
IopClient iopClient = new IopClientImpl("https://api-sg.aliexpress.com", "500516", "5KD1nXaPxADnXUxISAImi1gcgPqbKMN4");;
IopRequest request = new IopRequest();
request.setApiName("aliexpress.photobank.redefining.listimagepagination");
request.addApiParameter("aeop_image_pagination_request", "{\"group_id\":\"0\", \"current_page\":\"1\",\"location_type\":\"0\",\"page_size\":\"10\"}");
IopResponse response = iopClient.execute(request, "50000100810eAzdp7j9nwt11e7586aQDBYn1hnSitvhdCbyemVxjhEPKZHhuGq44F3KQ", Protocol.TOP);
System.out.println("list:" + response.getGopResponseBody());
return response.getGopResponseBody();
}
}

+ 155
- 0
ruoyi-admin/src/test/java/com/ruoyi/ap/AliexpressTest.java 파일 보기

@@ -0,0 +1,155 @@
package com.ruoyi.ap;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.global.iop.api.IopClient;
import com.global.iop.api.IopClientImpl;
import com.global.iop.api.IopRequest;
import com.global.iop.api.IopResponse;
import com.global.iop.domain.Protocol;
import com.global.iop.util.ApiException;
import com.global.iop.util.Constants;
import com.global.iop.util.FileItem;

/**
* @ClassName AliexpressTest
* @Description TODO
* @Author xxs
* @Date 2024/2/22 15:32
* @Version 1.0
**/
public class AliexpressTest {
private static IopClient iopClient = new IopClientImpl("https://api-sg.aliexpress.com", "500516", "5KD1nXaPxADnXUxISAImi1gcgPqbKMN4");;
private static String token;

public static void init() throws ApiException {
iopClient = new IopClientImpl("https://api-sg.aliexpress.com", "500516", "5KD1nXaPxADnXUxISAImi1gcgPqbKMN4");
IopRequest request = new IopRequest();
request.setApiName("/auth/token/create");
request.addApiParameter("code", "0_2DL4DV3jcU1UOT7WGI1A4rY91");
request.addApiParameter("uuid", "uuid");
IopResponse response = iopClient.execute(request, Protocol.GOP);
token = response.getGopResponseBody();
}

// 4.换取access_token 调用: /auth/token/create 获取access_token。
public static void authToke() throws ApiException {
// iopClient = new IopClientImpl("https://api-sg.aliexpress.com", "500516", "5KD1nXaPxADnXUxISAImi1gcgPqbKMN4");
IopRequest request = new IopRequest();
request.setApiName("/auth/token/create");
request.addApiParameter("code", "3_500516_dfXuvcFlRyBdEptp8jE2f4xx6122");
// request.addApiParameter("uuid", "uuid");
IopResponse response = iopClient.execute(request, Protocol.GOP);
System.out.println("response:" + response);
String responseBody = response.getGopResponseBody();
JSONObject entries = JSONUtil.parseObj(responseBody);
System.out.println("token:" + token);
token = entries.get("access_token").toString();
System.out.println("accessToken:" + token);
}


public static void getProductList() throws ApiException {
IopRequest request = new IopRequest();
request.setApiName("aliexpress.solution.product.list.get");
request.addApiParameter("aeop_a_e_product_list_query", "{\"gmt_modified_start\":\"2012-01-01 12:13:14\",\"gmt_modified_end\":\"2012-01-01 12:13:14\",\"off_line_time\":\"7\",\"gmt_create_start\":\"2012-01-01 12:13:14\",\"subject\":\"knew odd\",\"have_national_quote\":\"n\",\"ws_display\":\"expire_offline\",\"product_status_type\":\"onSelling\",\"owner_member_id\":\"aliqatest01\",\"gmt_create_end\":\"2012-01-01 12:13:14\",\"group_id\":\"1234\",\"product_id\":\"123\",\"excepted_product_ids\":[\"[32962333569,32813963253]\",\"[32962333569,32813963253]\"],\"sku_code\":\"123ABC\",\"current_page\":\"2\",\"page_size\":\"30\"}");
IopResponse response = iopClient.execute(request, "50000101922g2UZqpeWbbweOUTkniPJ4fx18c3d40fxGDxHPqENvxQrQZZvqiUibKx01", Protocol.TOP);
System.out.println(response.getGopResponseBody());
}

public static void main(String[] args) throws Exception {
// authToke();

token = "50000100810eAzdp7j9nwt11e7586aQDBYn1hnSitvhdCbyemVxjhEPKZHhuGq44F3KQ";
// testUpload();
// testQuery();
// group();
updateImg();
imgList();
// getPhotoInfo();
}

public static void updateImg() throws ApiException {
IopRequest request = new IopRequest();
request.setApiName("aliexpress.photobank.redefining.uploadimage");
request.addApiParameter("file_name", "001.jpg");
request.addApiParameter("group_id", "0");
request.addFileParameter("image_bytes",new FileItem("E:\\工作资料\\图片素材\\001.jpg"));
IopResponse response = iopClient.execute(request, token, Protocol.TOP);
System.out.println(response.getGopResponseBody());
}

public static void testQuery() throws Exception {
// IopRequest iopRequest = new IopRequest("aliexpress.photobank.redefining.queryphotobankimagebypaths");
// iopRequest.setHttpMethod(Constants.METHOD_POST);
// iopRequest.addApiParameter("paths", "001.jpg");
// //tip:请注意simplify为请求公共参数,在设置该参数时请作为一级参数单独设置,不要作为任意子参数放到业务参数下(即单独使用下面一行代码)
//// iopRequest.addApiParameter("simplify", "true");
// IopResponse rsp = iopClient.execute(iopRequest, token, Protocol.TOP);
// System.out.println("testQuery:" + JSONUtil.toJsonStr(rsp));

IopRequest request = new IopRequest();
request.setApiName("aliexpress.photobank.redefining.queryphotobankimagebypaths");
request.addApiParameter("paths", "001.jpg");
IopResponse response = iopClient.execute(request, token, Protocol.TOP);
System.out.println("testQuery:" + JSONUtil.toJsonStr(response.getGopResponseBody()));
}

public static void imgList() throws ApiException {
IopRequest request = new IopRequest();
request.setApiName("aliexpress.photobank.redefining.listimagepagination");
request.addApiParameter("aeop_image_pagination_request", "{\"group_id\":\"0\", \"current_page\":\"1\",\"location_type\":\"0\",\"page_size\":\"10\"}");
IopResponse response = iopClient.execute(request, token, Protocol.TOP);
System.out.println("list:" + response.getGopResponseBody());
}

public static void group() throws ApiException {
IopRequest request = new IopRequest();
request.setApiName("aliexpress.photobank.redefining.listgroup");
// request.addApiParameter("group_id", "8401");
IopResponse response = iopClient.execute(request, token, Protocol.TOP);
System.out.println(response.getGopResponseBody());
}

public static void getPhotoInfo() throws ApiException {
IopRequest request = new IopRequest();
request.setApiName("aliexpress.photobank.redefining.getphotobankinfo");
IopResponse response = iopClient.execute(request, token, Protocol.TOP);
System.out.println(response.getGopResponseBody());
}

public static void testUpload() throws Exception {
IopRequest iopRequest = new IopRequest("aliexpress.image.redefining.uploadtempimage");
iopRequest.setHttpMethod(Constants.METHOD_POST);
iopRequest.addFileParameter("file_data", new FileItem("E:\\工作资料\\图片素材\\001.jpg"));
iopRequest.addApiParameter("src_file_name", "001.jpg");
iopRequest.addApiParameter("simplify", "true");
// 如果是TOP协议下的老api 则选择top协议,apiName以'.'为分隔符的是TOP协议 比如aliexpress.image.redefining.uploadtempimage
// 如果是在新开放平台(GOP)配置的api,则选择GOP协议,apiName以'/'为分隔符
// 具体某个API属于哪一种协议请参考每个API页面的sample code
IopResponse rsp = iopClient.execute(iopRequest, token, Protocol.TOP);
System.out.println("testUpload:" + JSONUtil.toJsonStr(rsp));
}


public void testGopTraditionalApi() throws Exception {
IopRequest iopRequest = new IopRequest("/globalopen/api/get/a");
iopRequest.setHttpMethod(Constants.METHOD_GET);
iopRequest.addApiParameter("apiId", "1");
iopRequest.addApiParameter("simplify", "true");
IopResponse rsp = iopClient.execute(iopRequest, Protocol.GOP);
System.out.println(JSONUtil.toJsonStr(rsp));
}

public void testGopRestfulApi() throws Exception {
// path参数
IopRequest iopRequest = new IopRequest("/globalopen/api/getApiDsl/{region}/{env}/{apiId}");
iopRequest.setHttpMethod(Constants.METHOD_PUT);
iopRequest.addApiParameter("region", "global");
iopRequest.addApiParameter("env", "PRE");
iopRequest.addApiParameter("apiId", "1");
iopRequest.addApiParameter("simplify", "true");
IopResponse rsp = iopClient.execute(iopRequest, token, Protocol.REST_VND_2);
System.out.println(JSONUtil.toJsonStr(rsp));
}
}

불러오는 중...
취소
저장