🆕 #2905【企业微信】增加OA模块创建审批模板、更新审批模板的接口

This commit is contained in:
yiyingcanfeng 2022-12-17 15:10:00 +08:00 committed by GitHub
parent 901fceba27
commit baa8a6da37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 126 additions and 0 deletions

View File

@ -213,6 +213,39 @@ public interface WxCpOaService {
*/
WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException;
/**
* 创建审批模板
* <br>
* 可以调用此接口创建审批模板创建新模板后管理后台及审批应用内将生成对应模板并生效默认流程和规则配置
* <pre>
* 文档地址: <a href="https://developer.work.weixin.qq.com/document/path/97437">https://developer.work.weixin.qq.com/document/path/97437</a>
* 权限说明
* 审批系统应用自建应用和代开发自建应用可调用
* </pre>
*
* @param wxCpTemplateCreate wxCpTemplateCreate
* @return templateId
* @throws WxErrorException .
*/
String createTemplate(WxCpTemplateCreate wxCpTemplateCreate) throws WxErrorException;
/**
* 更新审批模板
* <br>
* 可调用本接口更新审批模板更新模板后管理后台及审批应用内将更新原模板的内容已配置的审批流程和规则不变
* <pre>
* 文档地址: <a href="https://developer.work.weixin.qq.com/document/path/97438">https://developer.work.weixin.qq.com/document/path/97438</a>
* 权限说明
* 审批系统应用自建应用和代开发自建应用可调用
* 所有应用都可以通过本接口更新自己的模板
* 审批系统应用可以修改管理员手动创建的模板
* 自建应用和代开发自建应用不可通过本接口更新其他应用创建的模板
* </pre>
*
* @param wxCpTemplateUpdate wxCpTemplateUpdate
* @throws WxErrorException .
*/
void updateTemplate(WxCpTemplateUpdate wxCpTemplateUpdate) throws WxErrorException;
/**
* 获取打卡日报数据

View File

@ -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<WxCpCheckinDayData> getCheckinDayData(@NonNull Date startTime, @NonNull Date endTime,
List<String> userIdList)

View File

@ -0,0 +1,34 @@
package me.chanjar.weixin.cp.bean.oa;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateContent;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateTitle;
import java.io.Serializable;
import java.util.List;
/**
* 创建审批模板
*
* @author yiyingcanfeng
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class WxCpTemplateCreate implements Serializable {
private static final long serialVersionUID = 4918111784546859769L;
@SerializedName("template_name")
private List<TemplateTitle> templateName;
@SerializedName("template_content")
private TemplateContent templateContent;
}

View File

@ -0,0 +1,37 @@
package me.chanjar.weixin.cp.bean.oa;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateContent;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateTitle;
import java.io.Serializable;
import java.util.List;
/**
* 更新审批模板
*
* @author yiyingcanfeng
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class WxCpTemplateUpdate implements Serializable {
private static final long serialVersionUID = 8332120725354015143L;
@SerializedName("template_id")
private String templateId;
@SerializedName("template_name")
private List<TemplateTitle> templateName;
@SerializedName("template_content")
private TemplateContent templateContent;
}

View File

@ -289,6 +289,14 @@ public interface WxCpApiPathConsts {
* The constant GET_TEMPLATE_DETAIL.
*/
String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail";
/**
* The constant CREATE_TEMPLATE.
*/
String CREATE_TEMPLATE = "/cgi-bin/oa/approval/create_template";
/**
* The constant CREATE_TEMPLATE.
*/
String UPDATE_TEMPLATE = "/cgi-bin/oa/approval/update_template";
/**
* The constant APPLY_EVENT.
*/