mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🆕 #2252 【小程序】增加自定义组件之图片上传接口
This commit is contained in:
@@ -426,6 +426,13 @@ public interface WxMaService extends WxService {
|
||||
*/
|
||||
WxMaShopCatService getShopCatService();
|
||||
|
||||
/**
|
||||
* 小程序交易组件-接入商品前必需接口-上传图片
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaShopImgService getShopImgService();
|
||||
|
||||
/**
|
||||
* 获取小程序 URL Link服务接口
|
||||
*
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadCustomizeResult;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 小程序交易组件-接入商品前必需接口
|
||||
*
|
||||
* @author liming1019
|
||||
*/
|
||||
public interface WxMaShopImgService {
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @return WxMinishopImageUploadCustomizeResult
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMinishopImageUploadCustomizeResult uploadImg(File file) throws WxErrorException;
|
||||
}
|
||||
@@ -68,6 +68,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
private final WxMaShopRegisterService shopRegisterService = new WxMaShopRegisterServiceImpl(this);
|
||||
private final WxMaShopAccountService shopAccountService = new WxMaShopAccountServiceImpl(this);
|
||||
private final WxMaShopCatService shopCatService = new WxMaShopCatServiceImpl(this);
|
||||
private final WxMaShopImgService shopImgService = new WxMaShopImgServiceImpl(this);
|
||||
private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
|
||||
private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
|
||||
private Map<String, WxMaConfig> configMap;
|
||||
@@ -534,6 +535,11 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
return this.shopCatService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopImgService getShopImgService() {
|
||||
return this.shopImgService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaLinkService getLinkService() {
|
||||
return this.linkService;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShopImgService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadCustomizeResult;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.MinishopUploadRequestCustomizeExecutor;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Img.IMG_UPLOAD;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaShopImgServiceImpl implements WxMaShopImgService {
|
||||
private final WxMaService service;
|
||||
|
||||
@Override
|
||||
public WxMinishopImageUploadCustomizeResult uploadImg(File file) throws WxErrorException {
|
||||
WxMinishopImageUploadCustomizeResult result = this.service.execute(
|
||||
MinishopUploadRequestCustomizeExecutor.create(this.service.getRequestHttp()), IMG_UPLOAD, file);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -337,6 +337,10 @@ public class WxMaApiUrlConstants {
|
||||
interface Cat {
|
||||
String GET_CAT = "https://api.weixin.qq.com/shop/cat/get";
|
||||
}
|
||||
|
||||
interface Img {
|
||||
String IMG_UPLOAD = "https://api.weixin.qq.com/shop/img/upload";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user