mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🆕 #2579【企业微信】增加企业微信OA自建应用-审批流程引擎相关接口
This commit is contained in:
parent
4f2360c9b2
commit
56e5d6ff77
@ -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 {
|
||||
|
||||
/**
|
||||
* 查询第三方应用审批申请当前状态
|
||||
* 开发者也可主动查询审批单的当前审批状态。
|
||||
*
|
||||
* 请求方式: POST(HTTPS)
|
||||
* 请求地址: 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;
|
||||
|
||||
}
|
@ -399,6 +399,13 @@ public interface WxCpService extends WxService {
|
||||
*/
|
||||
WxCpLivingService getLivingService();
|
||||
|
||||
/**
|
||||
* 获取OA 自建应用相关接口的服务类对象
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxCpOaAgentService getOaAgentService();
|
||||
|
||||
/**
|
||||
* 获取会话存档相关接口的服务类对象
|
||||
*
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package me.chanjar.weixin.cp.bean.oa.selfagent;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 审批申请当前状态信息.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
*/
|
||||
@Data
|
||||
public class WxCpOpenApprovalData implements Serializable {
|
||||
private static final long serialVersionUID = -5028321625140879591L;
|
||||
|
||||
@SerializedName("ThirdNo")
|
||||
private String thirdNo;
|
||||
|
||||
@SerializedName("OpenTemplateId")
|
||||
private String openTemplateId;
|
||||
|
||||
@SerializedName("OpenSpName")
|
||||
private String openSpName;
|
||||
|
||||
@SerializedName("OpenSpstatus")
|
||||
private Integer openSpstatus;
|
||||
|
||||
@SerializedName("ApplyTime")
|
||||
private Long applyTime;
|
||||
|
||||
@SerializedName("ApplyUsername")
|
||||
private String applyUserName;
|
||||
|
||||
@SerializedName("ApplyUserParty")
|
||||
private String applyUserParty;
|
||||
|
||||
@SerializedName("ApplyUserImage")
|
||||
private String applyUserImage;
|
||||
|
||||
@SerializedName("ApplyUserId")
|
||||
private String applyUserId;
|
||||
|
||||
@SerializedName("ApprovalNodes")
|
||||
private ApprovalNodes approvalNodes;
|
||||
|
||||
@SerializedName("NotifyNodes")
|
||||
private NotifyNodes notifyNodes;
|
||||
|
||||
@SerializedName("ApproverStep")
|
||||
private Integer approverStep;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ApprovalNodes implements Serializable {
|
||||
private static final long serialVersionUID = -5696099236344075582L;
|
||||
|
||||
@SerializedName("ApprovalNode")
|
||||
private List<ApprovalNode> approvalNode;
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ApprovalNode implements Serializable {
|
||||
private static final long serialVersionUID = -5696099236344075582L;
|
||||
|
||||
@SerializedName("NodeStatus")
|
||||
private Integer nodeStatus;
|
||||
|
||||
@SerializedName("NodeAttr")
|
||||
private Integer nodeAttr;
|
||||
|
||||
@SerializedName("NodeType")
|
||||
private Integer nodeType;
|
||||
|
||||
@SerializedName("Items")
|
||||
private Items items;
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class NotifyNodes implements Serializable {
|
||||
private static final long serialVersionUID = -5696099236344075582L;
|
||||
|
||||
@SerializedName("NotifyNode")
|
||||
private List<NotifyNode> notifyNode;
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class NotifyNode implements Serializable {
|
||||
private static final long serialVersionUID = -5696099236344075582L;
|
||||
|
||||
@SerializedName("ItemName")
|
||||
private String itemName;
|
||||
|
||||
@SerializedName("ItemParty")
|
||||
private String itemParty;
|
||||
|
||||
@SerializedName("ItemImage")
|
||||
private String itemImage;
|
||||
|
||||
@SerializedName("ItemUserId")
|
||||
private String itemUserId;
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Items implements Serializable {
|
||||
private static final long serialVersionUID = -5696099236344075582L;
|
||||
|
||||
@SerializedName("Item")
|
||||
private List<Item> item;
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Item implements Serializable {
|
||||
private static final long serialVersionUID = -5696099236344075582L;
|
||||
|
||||
@SerializedName("ItemName")
|
||||
private String itemName;
|
||||
|
||||
@SerializedName("ItemParty")
|
||||
private String itemParty;
|
||||
|
||||
@SerializedName("ItemImage")
|
||||
private String itemImage;
|
||||
|
||||
@SerializedName("ItemUserId")
|
||||
private String itemUserId;
|
||||
|
||||
@SerializedName("ItemSpeech")
|
||||
private String itemSpeech;
|
||||
|
||||
@SerializedName("ItemStatus")
|
||||
private Integer itemStatus;
|
||||
|
||||
@SerializedName("ItemOpTime")
|
||||
private Long itemOpTime;
|
||||
|
||||
}
|
||||
|
||||
public static WxCpOpenApprovalData fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpOpenApprovalData.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -91,6 +91,10 @@ public interface WxCpApiPathConsts {
|
||||
}
|
||||
|
||||
interface Oa {
|
||||
/**
|
||||
* 打卡
|
||||
* https://developer.work.weixin.qq.com/document/path/94204
|
||||
*/
|
||||
String GET_CORP_CHECKIN_OPTION = "/cgi-bin/checkin/getcorpcheckinoption";
|
||||
String GET_CHECKIN_DATA = "/cgi-bin/checkin/getcheckindata";
|
||||
String GET_CHECKIN_OPTION = "/cgi-bin/checkin/getcheckinoption";
|
||||
@ -98,12 +102,27 @@ public interface WxCpApiPathConsts {
|
||||
String GET_CHECKIN_MONTH_DATA = "/cgi-bin/checkin/getcheckin_monthdata";
|
||||
String GET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/getcheckinschedulist";
|
||||
String SET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/setcheckinschedulist";
|
||||
String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo";
|
||||
String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail";
|
||||
String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record";
|
||||
|
||||
/**
|
||||
* 审批
|
||||
* https://developer.work.weixin.qq.com/document/path/91956
|
||||
*/
|
||||
String COPY_TEMPLATE = "/cgi-bin/oa/approval/copytemplate";
|
||||
String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail";
|
||||
String APPLY_EVENT = "/cgi-bin/oa/applyevent";
|
||||
String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo";
|
||||
String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail";
|
||||
|
||||
/**
|
||||
* 公费电话
|
||||
* https://developer.work.weixin.qq.com/document/path/93662
|
||||
*/
|
||||
String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record";
|
||||
|
||||
/**
|
||||
* 日程
|
||||
* https://developer.work.weixin.qq.com/document/path/93624
|
||||
*/
|
||||
String CALENDAR_ADD = "/cgi-bin/oa/calendar/add";
|
||||
String CALENDAR_UPDATE = "/cgi-bin/oa/calendar/update";
|
||||
String CALENDAR_GET = "/cgi-bin/oa/calendar/get";
|
||||
@ -115,7 +134,11 @@ public interface WxCpApiPathConsts {
|
||||
String SCHEDULE_DEL = "/cgi-bin/oa/schedule/del";
|
||||
String SCHEDULE_LIST = "/cgi-bin/oa/schedule/get_by_calendar";
|
||||
|
||||
String COPY_TEMPLATE = "/cgi-bin/oa/approval/copytemplate";
|
||||
/**
|
||||
* 审批流程引擎
|
||||
* https://developer.work.weixin.qq.com/document/path/90269
|
||||
*/
|
||||
String GET_OPEN_APPROVAL_DATA = "/cgi-bin/corp/getopenapprovaldata";
|
||||
}
|
||||
|
||||
interface Living {
|
||||
|
@ -0,0 +1,59 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
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.impl.WxCpServiceImpl;
|
||||
import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData;
|
||||
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
|
||||
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 企业微信自建应用接口测试类.
|
||||
* https://developer.work.weixin.qq.com/document/path/90269
|
||||
*
|
||||
* @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a>
|
||||
* @date 2022-04-06
|
||||
*/
|
||||
@Slf4j
|
||||
public class WxCpOaAgentTest {
|
||||
|
||||
// extends WxCpBaseResp
|
||||
private static WxCpConfigStorage wxCpConfigStorage;
|
||||
private static WxCpService cpService;
|
||||
|
||||
@Test
|
||||
public void test() throws WxErrorException {
|
||||
|
||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("test-config.xml");
|
||||
WxCpDemoInMemoryConfigStorage config = WxCpDemoInMemoryConfigStorage.fromXml(inputStream);
|
||||
|
||||
wxCpConfigStorage = config;
|
||||
cpService = new WxCpServiceImpl();
|
||||
cpService.setWxCpConfigStorage(config);
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
String test = "{\"errcode\":0,\"errmsg\":\"ok\",\"data\":{\"ThirdNo\":\"thirdNoxxx\",\"OpenTemplateId\":\"1234567111\",\"OpenSpName\":\"付款\",\"OpenSpstatus\":1,\"ApplyTime\":1527837645,\"ApplyUsername\":\"jackiejjwu\",\"ApplyUserParty\":\"产品部\",\"ApplyUserImage\":\"http://www.qq.com/xxx.png\",\"ApplyUserId\":\"WuJunJie\",\"ApprovalNodes\":{\"ApprovalNode\":[{\"NodeStatus\":1,\"NodeAttr\":1,\"NodeType\":1,\"Items\":{\"Item\":[{\"ItemName\":\"chauvetxiao\",\"ItemParty\":\"产品部\",\"ItemImage\":\"http://www.qq.com/xxx.png\",\"ItemUserId\":\"XiaoWen\",\"ItemStatus\":1,\"ItemSpeech\":\"\",\"ItemOpTime\":0}]}}]},\"NotifyNodes\":{\"NotifyNode\":[{\"ItemName\":\"jinhuiguo\",\"ItemParty\":\"行政部\",\"ItemImage\":\"http://www.qq.com/xxx.png\",\"ItemUserId\":\"GuoJinHui\"}]},\"ApproverStep\":0}}";
|
||||
|
||||
final WxCpOpenApprovalData data = WxCpGsonBuilder.create()
|
||||
.fromJson(GsonParser.parse(test).get("data"),
|
||||
new TypeToken<WxCpOpenApprovalData>() {
|
||||
}.getType()
|
||||
);
|
||||
|
||||
log.info(data.toJson());
|
||||
|
||||
|
||||
WxCpOpenApprovalData openApprovalData = cpService.getOaAgentService().getOpenApprovalData("943225459735269376");
|
||||
log.info(openApprovalData.toJson());
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user