mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	🎨 #2461 【小程序】自定义交易组件上传接口支持图片链接
This commit is contained in:
		| @ -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; | ||||
| } | ||||
|  | ||||
| @ -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; | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -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(); | ||||
|   } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 linlinjava
					linlinjava