mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🎨 优化重构OA审批模板相关接口及类定义
This commit is contained in:
parent
baa8a6da37
commit
b7ceeed557
@ -211,7 +211,7 @@ public interface WxCpOaService {
|
||||
* @return . template detail
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException;
|
||||
WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 创建审批模板
|
||||
@ -223,11 +223,11 @@ public interface WxCpOaService {
|
||||
* • 仅『审批』系统应用、自建应用和代开发自建应用可调用。
|
||||
* </pre>
|
||||
*
|
||||
* @param wxCpTemplateCreate wxCpTemplateCreate
|
||||
* @param cpTemplate cpTemplate
|
||||
* @return templateId
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
String createTemplate(WxCpTemplateCreate wxCpTemplateCreate) throws WxErrorException;
|
||||
String createOaApprovalTemplate(WxCpOaApprovalTemplate cpTemplate) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 更新审批模板
|
||||
@ -242,10 +242,10 @@ public interface WxCpOaService {
|
||||
* • 自建应用和代开发自建应用不可通过本接口更新其他应用创建的模板
|
||||
* </pre>
|
||||
*
|
||||
* @param wxCpTemplateUpdate wxCpTemplateUpdate
|
||||
* @param wxCpTemplate wxCpTemplate
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
void updateTemplate(WxCpTemplateUpdate wxCpTemplateUpdate) throws WxErrorException;
|
||||
void updateOaApprovalTemplate(WxCpOaApprovalTemplate wxCpTemplate) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取打卡日报数据
|
||||
|
@ -251,26 +251,26 @@ public class WxCpOaServiceImpl implements WxCpOaService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException {
|
||||
public WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("template_id", templateId);
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL);
|
||||
String responseContent = this.mainService.post(url, jsonObject.toString());
|
||||
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpTemplateResult.class);
|
||||
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpOaApprovalTemplateResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTemplate(WxCpTemplateCreate wxCpTemplateCreate) throws WxErrorException {
|
||||
public String createOaApprovalTemplate(WxCpOaApprovalTemplate cpTemplate) throws WxErrorException {
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CREATE_TEMPLATE);
|
||||
String responseContent = this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpTemplateCreate));
|
||||
String responseContent = this.mainService.post(url, WxCpGsonBuilder.create().toJson(cpTemplate));
|
||||
JsonObject tmpJson = GsonParser.parse(responseContent);
|
||||
return tmpJson.get("template_id").getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTemplate(WxCpTemplateUpdate wxCpTemplateUpdate) throws WxErrorException {
|
||||
public void updateOaApprovalTemplate(WxCpOaApprovalTemplate wxCpTemplate) throws WxErrorException {
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_TEMPLATE);
|
||||
this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpTemplateUpdate));
|
||||
this.mainService.post(url, WxCpGsonBuilder.create().toJson(wxCpTemplate));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 更新审批模板
|
||||
* 新增/更新审批模板的请求对象
|
||||
*
|
||||
* @author yiyingcanfeng
|
||||
*/
|
||||
@ -22,9 +22,12 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WxCpTemplateUpdate implements Serializable {
|
||||
public class WxCpOaApprovalTemplate implements Serializable {
|
||||
private static final long serialVersionUID = 8332120725354015143L;
|
||||
|
||||
/**
|
||||
* 仅更新审批模版时需要提供
|
||||
*/
|
||||
@SerializedName("template_id")
|
||||
private String templateId;
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||
* @author gyv12345 @163.com
|
||||
*/
|
||||
@Data
|
||||
public class WxCpTemplateResult implements Serializable {
|
||||
public class WxCpOaApprovalTemplateResult implements Serializable {
|
||||
private static final long serialVersionUID = 6690547131189343887L;
|
||||
|
||||
@SerializedName("errcode")
|
@ -1,34 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
@ -12,7 +12,6 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class TemplateContent implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5640250983775840865L;
|
||||
|
||||
private List<TemplateControls> controls;
|
||||
|
@ -4,7 +4,7 @@ import lombok.NonNull;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult;
|
||||
import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest;
|
||||
import me.chanjar.weixin.cp.bean.oa.WxCpTemplateResult;
|
||||
import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult;
|
||||
|
||||
/**
|
||||
* 企业微信OA相关接口.
|
||||
@ -38,7 +38,7 @@ public interface WxCpTpOAService {
|
||||
* @return . template detail
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxCpTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException;
|
||||
WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 复制/更新模板到企业
|
||||
|
@ -7,7 +7,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult;
|
||||
import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest;
|
||||
import me.chanjar.weixin.cp.bean.oa.WxCpTemplateResult;
|
||||
import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpOAService;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpService;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
@ -34,13 +34,13 @@ public class WxCpTpOAServiceImpl implements WxCpTpOAService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException {
|
||||
public WxCpOaApprovalTemplateResult getTemplateDetail(@NonNull String templateId, String corpId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("template_id", templateId);
|
||||
String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL) +
|
||||
"?access_token=" + mainService.getWxCpTpConfigStorage().getAccessToken(corpId);
|
||||
String responseContent = this.mainService.post(url, jsonObject.toString());
|
||||
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpTemplateResult.class);
|
||||
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpOaApprovalTemplateResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,6 @@ import org.testng.annotations.Test;
|
||||
import org.testng.collections.Lists;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -213,7 +212,7 @@ public class WxCpOaServiceImplTest {
|
||||
@Test
|
||||
public void testGetTemplateDetail() throws WxErrorException {
|
||||
String templateId = "3TkZjxugodbqpEMk9j7X6h6zKqYkc7MxQrrFmT7H";
|
||||
WxCpTemplateResult result = wxService.getOaService().getTemplateDetail(templateId);
|
||||
WxCpOaApprovalTemplateResult result = wxService.getOaService().getTemplateDetail(templateId);
|
||||
assertThat(result).isNotNull();
|
||||
System.out.println("result ");
|
||||
System.out.println(gson.toJson(result));
|
||||
|
Loading…
Reference in New Issue
Block a user