🎨 #2461 【小程序】自定义交易组件上传接口支持图片链接

This commit is contained in:
linlinjava
2021-12-27 15:03:02 +08:00
committed by GitHub
parent 31984c130f
commit c66ecbfd4d
7 changed files with 88 additions and 21 deletions

View File

@ -29,4 +29,14 @@ public interface WxMaShopImgService {
* @throws WxErrorException
*/
WxMinishopImageUploadCustomizeResult uploadImg(File file, String respType) throws WxErrorException;
/**
* 上传图片链接,带respType参数
*
* @param imgUrl
* @param respType
* @return WxMinishopImageUploadCustomizeResult
* @throws WxErrorException
*/
WxMinishopImageUploadCustomizeResult uploadImg(String imgUrl, String respType) throws WxErrorException;
}

View File

@ -23,14 +23,21 @@ public class WxMaShopImgServiceImpl implements WxMaShopImgService {
@Override
public WxMinishopImageUploadCustomizeResult uploadImg(File file) throws WxErrorException {
WxMinishopImageUploadCustomizeResult result = this.service.execute(
MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), "0"), IMG_UPLOAD, file);
MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), "0", null), IMG_UPLOAD, file);
return result;
}
@Override
public WxMinishopImageUploadCustomizeResult uploadImg(File file, String respType) throws WxErrorException {
WxMinishopImageUploadCustomizeResult result = this.service.execute(
MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), respType), IMG_UPLOAD, file);
MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), respType, null), IMG_UPLOAD, file);
return result;
}
@Override
public WxMinishopImageUploadCustomizeResult uploadImg(String imgUrl, String respType) throws WxErrorException {
WxMinishopImageUploadCustomizeResult result = this.service.execute(
MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp(), respType, imgUrl), IMG_UPLOAD, null);
return result;
}
}

View File

@ -35,4 +35,11 @@ public class WxMaShopImgServiceImplTest {
WxMinishopImageUploadCustomizeResult result = wxService.getShopImgService().uploadImg(file, "1");
assertThat(result).isNotNull();
}
@Test
public void testUploadImg3() throws WxErrorException {
String imgUrl = "https://www.example.com/demo.jpg";
WxMinishopImageUploadCustomizeResult result = wxService.getShopImgService().uploadImg(imgUrl, "1");
assertThat(result).isNotNull();
}
}