From baa8a6da370e522a84e05aceca3493b4675d17d4 Mon Sep 17 00:00:00 2001
From: yiyingcanfeng <39869232+yiyingcanfeng@users.noreply.github.com>
Date: Sat, 17 Dec 2022 15:10:00 +0800
Subject: [PATCH] =?UTF-8?q?:new:=20#2905=E3=80=90=E4=BC=81=E4=B8=9A?=
=?UTF-8?q?=E5=BE=AE=E4=BF=A1=E3=80=91=E5=A2=9E=E5=8A=A0OA=E6=A8=A1?=
=?UTF-8?q?=E5=9D=97=E5=88=9B=E5=BB=BA=E5=AE=A1=E6=89=B9=E6=A8=A1=E6=9D=BF?=
=?UTF-8?q?=E3=80=81=E6=9B=B4=E6=96=B0=E5=AE=A1=E6=89=B9=E6=A8=A1=E6=9D=BF?=
=?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../chanjar/weixin/cp/api/WxCpOaService.java | 33 +++++++++++++++++
.../weixin/cp/api/impl/WxCpOaServiceImpl.java | 14 +++++++
.../weixin/cp/bean/oa/WxCpTemplateCreate.java | 34 +++++++++++++++++
.../weixin/cp/bean/oa/WxCpTemplateUpdate.java | 37 +++++++++++++++++++
.../weixin/cp/constant/WxCpApiPathConsts.java | 8 ++++
5 files changed, 126 insertions(+)
create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpTemplateCreate.java
create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpTemplateUpdate.java
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java
index ff60b352d..68cbc3950 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java
@@ -213,6 +213,39 @@ public interface WxCpOaService {
*/
WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException;
+ /**
+ * 创建审批模板
+ *
+ * 可以调用此接口创建审批模板。创建新模板后,管理后台及审批应用内将生成对应模板,并生效默认流程和规则配置。
+ *
+ * 文档地址: https://developer.work.weixin.qq.com/document/path/97437 + * 权限说明 + * • 仅『审批』系统应用、自建应用和代开发自建应用可调用。 + *+ * + * @param wxCpTemplateCreate wxCpTemplateCreate + * @return templateId + * @throws WxErrorException . + */ + String createTemplate(WxCpTemplateCreate wxCpTemplateCreate) throws WxErrorException; + + /** + * 更新审批模板 + *
+ * 文档地址: https://developer.work.weixin.qq.com/document/path/97438 + * 权限说明 + * • 仅『审批』系统应用,自建应用和代开发自建应用可调用 + * • 所有应用都可以通过本接口更新自己的模板 + * • 『审批』系统应用可以修改管理员手动创建的模板 + * • 自建应用和代开发自建应用不可通过本接口更新其他应用创建的模板 + *+ * + * @param wxCpTemplateUpdate wxCpTemplateUpdate + * @throws WxErrorException . + */ + void updateTemplate(WxCpTemplateUpdate wxCpTemplateUpdate) throws WxErrorException; /** * 获取打卡日报数据 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java index 289968757..6fc618661 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java @@ -259,6 +259,20 @@ public class WxCpOaServiceImpl implements WxCpOaService { return WxCpGsonBuilder.create().fromJson(responseContent, WxCpTemplateResult.class); } + @Override + public String createTemplate(WxCpTemplateCreate wxCpTemplateCreate) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CREATE_TEMPLATE); + String responseContent = this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpTemplateCreate)); + JsonObject tmpJson = GsonParser.parse(responseContent); + return tmpJson.get("template_id").getAsString(); + } + + @Override + public void updateTemplate(WxCpTemplateUpdate wxCpTemplateUpdate) throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE); + this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpTemplateUpdate)); + } + @Override public List