From 206b64f9ed9e550fa0fcd5f7654e74031fdd6976 Mon Sep 17 00:00:00 2001 From: wangkai Date: Wed, 6 Apr 2022 17:35:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E3=80=91=E5=A2=9E=E5=8A=A0=E5=AE=A1=E6=89=B9=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=BC=95=E6=93=8E=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/constant/WxCpApiPathConsts.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index 2155b4c61..ddda08bf9 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -91,6 +91,11 @@ 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 +103,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"; + + /** + * 审批 + * 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"; - String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail"; - String APPLY_EVENT = "/cgi-bin/oa/applyevent"; + /** + * 日程 + * 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 +135,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 getOpenApprovalData = "/cgi-bin/corp/getopenapprovaldata"; } interface Living { -- Gitee From 69ebbe0acf734e2fb48137f9996d914d26e839d6 Mon Sep 17 00:00:00 2001 From: wangkai Date: Wed, 6 Apr 2022 19:52:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E3=80=91=20=E5=A2=9E=E5=8A=A0=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1OA=E8=87=AA=E5=BB=BA=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/api/WxCpOaAgentService.java | 29 ++++ .../me/chanjar/weixin/cp/api/WxCpService.java | 7 + .../cp/api/impl/BaseWxCpServiceImpl.java | 6 + .../cp/api/impl/WxCpOaAgentServiceImpl.java | 31 ++++ .../oa/selfagent/WxCpOpenApprovalData.java | 132 ++++++++++++++++++ .../weixin/cp/constant/WxCpApiPathConsts.java | 1 - .../weixin/cp/api/WxCpOaAgentTest.java | 46 ++++++ 7 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java create mode 100644 weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java new file mode 100644 index 000000000..6f4fae85d --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java @@ -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 Wang_Wong + * @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; + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java index 473fb3dfc..529e6f06e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java @@ -399,6 +399,13 @@ public interface WxCpService extends WxService { */ WxCpLivingService getLivingService(); + /** + * 获取OA 自建应用相关接口的服务类对象 + * + * @return + */ + WxCpOaAgentService getOaAgentService(); + /** * 获取会话存档相关接口的服务类对象 * diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java index cccbe8648..55ddcf9e2 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java @@ -50,6 +50,7 @@ public abstract class BaseWxCpServiceImpl 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 implements WxCpService, RequestH return livingService; } + @Override + public WxCpOaAgentService getOaAgentService() { + return oaAgentService; + } + @Override public WxCpMsgAuditService getMsgAuditService() { return msgAuditService; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java new file mode 100644 index 000000000..dd3f7a07f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java @@ -0,0 +1,31 @@ +package me.chanjar.weixin.cp.api.impl; + +import com.google.gson.JsonObject; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.cp.api.WxCpOaAgentService; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData; + +/** + * 企业微信自建应用接口实现类. + * + * @author Wang_Wong + * @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 result = cpService.post("https://qyapi.weixin.qq.com/cgi-bin/corp/getopenapprovaldata", jsonObject); + return WxCpOpenApprovalData.fromJson(result); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java new file mode 100644 index 000000000..9315740c0 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java @@ -0,0 +1,132 @@ +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.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 审批申请当前状态信息. + * + * @author Wang_Wong + */ +@Data +public class WxCpOpenApprovalData extends WxCpBaseResp 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 ApprovalNode approvalNodes; + + @SerializedName("NotifyNodes") + private NotifyNode notifyNodes; + + @SerializedName("approverstep") + private Integer approverStep; + + @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 List items; + + } + + @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 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); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index ddda08bf9..bfe59bc17 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -91,7 +91,6 @@ public interface WxCpApiPathConsts { } interface Oa { - /** * 打卡 * https://developer.work.weixin.qq.com/document/path/94204 diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java new file mode 100644 index 000000000..87c4be739 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java @@ -0,0 +1,46 @@ +package me.chanjar.weixin.cp.api; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.error.WxErrorException; +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 org.testng.annotations.Test; + +import java.io.InputStream; + +/** + * 企业微信自建应用接口测试类. + * https://developer.work.weixin.qq.com/document/path/90269 + * + * @author Wang_Wong + * @date 2022-04-06 + */ +@Slf4j +public class WxCpOaAgentTest { + + 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); + + WxCpOpenApprovalData openApprovalData = cpService.getOaAgentService().getOpenApprovalData("943225459735269376"); + log.info(openApprovalData.toJson()); + + // 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}}"; + WxCpOpenApprovalData json = WxCpOpenApprovalData.fromJson(test); + log.info(json.toJson()); + + } + +} -- Gitee From 8c24a9475fd4e8ed34526d8afeedc0e3ce687317 Mon Sep 17 00:00:00 2001 From: 0katekate0 <1960779692@qq.com> Date: Wed, 6 Apr 2022 23:10:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E3=80=91=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=BB=BA=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E6=9F=A5=E8=AF=A2=E5=AE=A1=E6=89=B9=E5=8D=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cp/api/impl/WxCpOaAgentServiceImpl.java | 16 +++++++- .../oa/selfagent/WxCpOpenApprovalData.java | 41 ++++++++++++++++--- .../weixin/cp/constant/WxCpApiPathConsts.java | 2 +- .../weixin/cp/api/WxCpOaAgentTest.java | 23 ++++++++--- 4 files changed, 68 insertions(+), 14 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java index dd3f7a07f..9f3d3f167 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java @@ -1,13 +1,20 @@ 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; /** * 企业微信自建应用接口实现类. @@ -24,8 +31,13 @@ public class WxCpOaAgentServiceImpl implements WxCpOaAgentService { public WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("thirdNo", thirdNo); - String result = cpService.post("https://qyapi.weixin.qq.com/cgi-bin/corp/getopenapprovaldata", jsonObject); - return WxCpOpenApprovalData.fromJson(result); + 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() { + }.getType() + ); } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java index 9315740c0..261a0f8de 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java @@ -4,7 +4,6 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.Getter; import lombok.Setter; -import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.io.Serializable; @@ -16,7 +15,7 @@ import java.util.List; * @author Wang_Wong */ @Data -public class WxCpOpenApprovalData extends WxCpBaseResp implements Serializable { +public class WxCpOpenApprovalData implements Serializable { private static final long serialVersionUID = -5028321625140879591L; @SerializedName("ThirdNo") @@ -47,14 +46,24 @@ public class WxCpOpenApprovalData extends WxCpBaseResp implements Serializable { private String applyUserId; @SerializedName("ApprovalNodes") - private ApprovalNode approvalNodes; + private ApprovalNodes approvalNodes; @SerializedName("NotifyNodes") - private NotifyNode notifyNodes; + private NotifyNodes notifyNodes; - @SerializedName("approverstep") + @SerializedName("ApproverStep") private Integer approverStep; + @Getter + @Setter + public static class ApprovalNodes implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("ApprovalNode") + private List approvalNode; + + } + @Getter @Setter public static class ApprovalNode implements Serializable { @@ -70,7 +79,17 @@ public class WxCpOpenApprovalData extends WxCpBaseResp implements Serializable { private Integer nodeType; @SerializedName("Items") - private List items; + private Items items; + + } + + @Getter + @Setter + public static class NotifyNodes implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("NotifyNode") + private List notifyNode; } @@ -93,6 +112,16 @@ public class WxCpOpenApprovalData extends WxCpBaseResp implements Serializable { } + @Getter + @Setter + public static class Items implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("Item") + private List item; + + } + @Getter @Setter public static class Item implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index bfe59bc17..e80a93263 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -138,7 +138,7 @@ public interface WxCpApiPathConsts { * 审批流程引擎 * https://developer.work.weixin.qq.com/document/path/90269 */ - String getOpenApprovalData = "/cgi-bin/corp/getopenapprovaldata"; + String GET_OPEN_APPROVAL_DATA = "/cgi-bin/corp/getopenapprovaldata"; } interface Living { diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java index 87c4be739..88d990e4f 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java @@ -1,11 +1,14 @@ 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; @@ -20,6 +23,7 @@ import java.io.InputStream; @Slf4j public class WxCpOaAgentTest { + // extends WxCpBaseResp private static WxCpConfigStorage wxCpConfigStorage; private static WxCpService cpService; @@ -33,14 +37,23 @@ public class WxCpOaAgentTest { 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() { + }.getType() + ); + + log.info(data.toJson()); + + WxCpOpenApprovalData openApprovalData = cpService.getOaAgentService().getOpenApprovalData("943225459735269376"); log.info(openApprovalData.toJson()); - // 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}}"; - WxCpOpenApprovalData json = WxCpOpenApprovalData.fromJson(test); - log.info(json.toJson()); - } } -- Gitee