🆕 #2579【企业微信】增加企业微信OA自建应用-审批流程引擎相关接口

This commit is contained in:
Wong
2022-04-07 02:51:51 +00:00
committed by binarywang
parent 4f2360c9b2
commit 56e5d6ff77
7 changed files with 332 additions and 4 deletions

View File

@@ -0,0 +1,29 @@
package me.chanjar.weixin.cp.api;
import lombok.NonNull;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData;
/**
* 企业微信自建应用接口.
* https://developer.work.weixin.qq.com/document/path/90269
*
* @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a>
* @date 2022-04-06
*/
public interface WxCpOaAgentService {
/**
* 查询第三方应用审批申请当前状态
* 开发者也可主动查询审批单的当前审批状态。
*
* 请求方式: POSTHTTPS
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/corp/getopenapprovaldata?access_token=ACCESS_TOKEN
*
* @param thirdNo
* @return
* @throws WxErrorException
*/
WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException;
}

View File

@@ -399,6 +399,13 @@ public interface WxCpService extends WxService {
*/
WxCpLivingService getLivingService();
/**
* 获取OA 自建应用相关接口的服务类对象
*
* @return
*/
WxCpOaAgentService getOaAgentService();
/**
* 获取会话存档相关接口的服务类对象
*

View File

@@ -50,6 +50,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
private WxCpAgentService agentService = new WxCpAgentServiceImpl(this);
private WxCpOaService oaService = new WxCpOaServiceImpl(this);
private WxCpLivingService livingService = new WxCpLivingServiceImpl(this);
private WxCpOaAgentService oaAgentService = new WxCpOaAgentServiceImpl(this);
private WxCpMsgAuditService msgAuditService = new WxCpMsgAuditServiceImpl(this);
private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this);
private WxCpExternalContactService externalContactService = new WxCpExternalContactServiceImpl(this);
@@ -485,6 +486,11 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
return livingService;
}
@Override
public WxCpOaAgentService getOaAgentService() {
return oaAgentService;
}
@Override
public WxCpMsgAuditService getMsgAuditService() {
return msgAuditService;

View File

@@ -0,0 +1,43 @@
package me.chanjar.weixin.cp.api.impl;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.json.GsonParser;
import me.chanjar.weixin.cp.api.WxCpOaAgentService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.living.WxCpLivingInfo;
import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Living.GET_USER_ALL_LIVINGID;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.GET_OPEN_APPROVAL_DATA;
/**
* 企业微信自建应用接口实现类.
*
* @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a>
* @date 2022-04-06
*/
@Slf4j
@RequiredArgsConstructor
public class WxCpOaAgentServiceImpl implements WxCpOaAgentService {
private final WxCpService cpService;
@Override
public WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("thirdNo", thirdNo);
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_OPEN_APPROVAL_DATA);
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
return WxCpGsonBuilder.create()
.fromJson(GsonParser.parse(responseContent).get("data"),
new TypeToken<WxCpOpenApprovalData>() {
}.getType()
);
}
}