-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
974ecf2
commit dd6452d
Showing
34 changed files
with
2,632 additions
and
2 deletions.
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaPromotionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package cn.binarywang.wx.miniapp.api; | ||
|
||
import cn.binarywang.wx.miniapp.bean.promoter.request.*; | ||
import cn.binarywang.wx.miniapp.bean.promoter.response.*; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
|
||
/** | ||
* 小程序推广员 | ||
* | ||
* @author zhuangzibin | ||
*/ | ||
public interface WxMaPromotionService { | ||
|
||
/** | ||
* 管理角色接口-新增角色 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionAddRoleResponse | ||
*/ | ||
WxMaPromotionAddRoleResponse addRole(WxMaPromotionAddRoleRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 管理角色接口-查询角色 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionGetRoleResponse | ||
*/ | ||
WxMaPromotionGetRoleResponse getRole(WxMaPromotionGetRoleRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 管理角色接口-修改角色 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionUpdateRoleResponse | ||
*/ | ||
WxMaPromotionUpdateRoleResponse updateRole(WxMaPromoterUpdateRoleRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 管理推广员接口-声明推广员身份 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionAddPromoterResponse | ||
*/ | ||
WxMaPromotionAddPromoterResponse addPromoter(WxMaPromotionAddPromoterRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 管理推广员接口-查询推广员身份 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionGetPromoterResponse | ||
*/ | ||
WxMaPromotionGetPromoterResponse getPromoter(WxMaPromotionGetPromoterRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 管理推广员接口-修改推广员身份 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionUpdatePromoterResponse | ||
*/ | ||
WxMaPromotionUpdatePromoterResponse updatePromoter(WxMaPromotionUpdatePromoterRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 邀请推广员-获取推广员邀请素材 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionGetInvitationMaterialResponse | ||
*/ | ||
WxMaPromotionGetInvitationMaterialResponse getInvitationMaterial(WxMaPromotionGetInvitationMaterialRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 推广员消息管理接口-群发消息 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionSendMsgResponse | ||
*/ | ||
WxMaPromotionSendMsgResponse sendMsg(WxMaPromotionSendMsgRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 推广员消息管理接口-单发消息 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionSingleSendMsgResponse | ||
*/ | ||
WxMaPromotionSingleSendMsgResponse singleSendMsg(WxMaPromotionSingleSendMsgRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 推广员消息管理接口-查询送达结果 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionGetMsgResponse | ||
*/ | ||
WxMaPromotionGetMsgResponse getMsg(WxMaPromotionGetMsgRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 推广员消息管理接口-分析点击效果 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionGetMsgClickDataResponse | ||
*/ | ||
WxMaPromotionGetMsgClickDataResponse getMsgClickData(WxMaPromotionGetMsgClickDataRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 推广数据接口-生成推广素材 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionGetShareMaterialResponse | ||
*/ | ||
WxMaPromotionGetShareMaterialResponse getShareMaterial(WxMaPromotionGetShareMaterialRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 推广数据接口-分析触达效果 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionGetRelationResponse | ||
*/ | ||
WxMaPromotionGetRelationResponse getRelation(WxMaPromotionGetRelationRequest request) throws WxErrorException; | ||
|
||
/** | ||
* 推广数据接口-查询推广订单 | ||
* | ||
* @param request 请求参数 | ||
* @return WxMaPromotionGetOrderResponse | ||
*/ | ||
WxMaPromotionGetOrderResponse getOrder(WxMaPromotionGetOrderRequest request) throws WxErrorException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
...ava-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaPromotionServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
package cn.binarywang.wx.miniapp.api.impl; | ||
|
||
import cn.binarywang.wx.miniapp.api.WxMaPromotionService; | ||
import cn.binarywang.wx.miniapp.api.WxMaService; | ||
import cn.binarywang.wx.miniapp.bean.promoter.request.*; | ||
import cn.binarywang.wx.miniapp.bean.promoter.response.*; | ||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; | ||
import com.google.gson.JsonObject; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import me.chanjar.weixin.common.enums.WxType; | ||
import me.chanjar.weixin.common.error.WxError; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
import me.chanjar.weixin.common.util.json.GsonParser; | ||
|
||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Promotion.*; | ||
import static me.chanjar.weixin.common.api.WxConsts.ERR_CODE; | ||
|
||
/** | ||
* @author zhuangzibin | ||
*/ | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class WxMaPromotionServiceImpl implements WxMaPromotionService { | ||
|
||
private final WxMaService wxMaService; | ||
|
||
private final static Integer ERR_CODE_OF_EMPTY_LIST = 103006; | ||
|
||
@Override | ||
public WxMaPromotionAddRoleResponse addRole(WxMaPromotionAddRoleRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_ADD_ROLE, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionAddRoleResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionGetRoleResponse getRole(WxMaPromotionGetRoleRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_GET_ROLE, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionGetRoleResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionUpdateRoleResponse updateRole(WxMaPromoterUpdateRoleRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_UPDATE_ROLE, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionUpdateRoleResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionAddPromoterResponse addPromoter(WxMaPromotionAddPromoterRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_ADD_PROMOTER, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionAddPromoterResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionGetPromoterResponse getPromoter(WxMaPromotionGetPromoterRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_GET_PROMOTER, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0 || jsonObject.get(ERR_CODE).getAsInt() != ERR_CODE_OF_EMPTY_LIST) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionGetPromoterResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionUpdatePromoterResponse updatePromoter(WxMaPromotionUpdatePromoterRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_UPDATE_PROMOTER, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionUpdatePromoterResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionGetInvitationMaterialResponse getInvitationMaterial(WxMaPromotionGetInvitationMaterialRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_GET_INVITATION_MATERIAL, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionGetInvitationMaterialResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionSendMsgResponse sendMsg(WxMaPromotionSendMsgRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_SEND_MSG, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionSendMsgResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionSingleSendMsgResponse singleSendMsg(WxMaPromotionSingleSendMsgRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_SINGLE_SEND_MSG, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionSingleSendMsgResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionGetMsgResponse getMsg(WxMaPromotionGetMsgRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_GET_MSG, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionGetMsgResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionGetMsgClickDataResponse getMsgClickData(WxMaPromotionGetMsgClickDataRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_GET_MSG_CLICK_DATA, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionGetMsgClickDataResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionGetShareMaterialResponse getShareMaterial(WxMaPromotionGetShareMaterialRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_GET_SHARE_MATERIAL, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionGetShareMaterialResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionGetRelationResponse getRelation(WxMaPromotionGetRelationRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_GET_RELATION, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0 || jsonObject.get(ERR_CODE).getAsInt() != ERR_CODE_OF_EMPTY_LIST) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionGetRelationResponse.class); | ||
} | ||
|
||
@Override | ||
public WxMaPromotionGetOrderResponse getOrder(WxMaPromotionGetOrderRequest request) throws WxErrorException { | ||
String responseContent = this.wxMaService.post(PROMOTION_GET_ORDER, request); | ||
JsonObject jsonObject = GsonParser.parse(responseContent); | ||
|
||
if (jsonObject.get(ERR_CODE).getAsInt() != 0 || jsonObject.get(ERR_CODE).getAsInt() != ERR_CODE_OF_EMPTY_LIST) { | ||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); | ||
} | ||
|
||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaPromotionGetOrderResponse.class); | ||
} | ||
} |
Oops, something went wrong.