Skip to content

Commit 1922aaa

Browse files
authored
🎨 #3751 【企业微信】提交审批申请接口增加process参数以支持新版的审批流程信息
1 parent 3c440ea commit 1922aaa

File tree

2 files changed

+144
-1
lines changed

2 files changed

+144
-1
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequest.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ public class WxCpOaApplyEventRequest implements Serializable {
4444
private Integer chooseDepartment;
4545

4646
/**
47-
* 审批流程信息,用于指定审批申请的审批流程,支持单人审批、多人会签、多人或签,可能有多个审批节点,仅use_template_approver为0时生效。
47+
* 审批流程信息(新版流程列表),用于指定审批申请的审批流程,支持单人审批、多人会签、多人或签,可能有多个审批节点,仅use_template_approver为0时生效。
48+
*/
49+
@SerializedName("process")
50+
private Process process;
51+
52+
/**
53+
* 审批流程信息(旧版),用于指定审批申请的审批流程,支持单人审批、多人会签、多人或签,可能有多个审批节点,仅use_template_approver为0时生效。
4854
*/
4955
@SerializedName("approver")
5056
private List<Approver> approvers;
@@ -118,4 +124,46 @@ public static class ApplyData implements Serializable {
118124
private List<ApplyDataContent> contents;
119125
}
120126

127+
/**
128+
* 审批流程信息(新版).
129+
*/
130+
@Data
131+
@Accessors(chain = true)
132+
public static class Process implements Serializable {
133+
private static final long serialVersionUID = 4758206091546930988L;
134+
135+
/**
136+
* 审批流程节点列表,当use_template_approver为0时必填
137+
*/
138+
@SerializedName("node_list")
139+
private List<ProcessNode> nodeList;
140+
}
141+
142+
/**
143+
* 审批流程节点.
144+
*/
145+
@Data
146+
@Accessors(chain = true)
147+
public static class ProcessNode implements Serializable {
148+
private static final long serialVersionUID = 1758206091546930988L;
149+
150+
/**
151+
* 节点类型:1-审批人,2-抄送人,3-抄送人
152+
*/
153+
@SerializedName("type")
154+
private Integer type;
155+
156+
/**
157+
* 多人审批方式:1-全签,2-或签,3-依次审批
158+
*/
159+
@SerializedName("apv_rel")
160+
private Integer apvRel;
161+
162+
/**
163+
* 审批节点审批人userid列表,若为多人会签、多人或签,需填写每个人的userid
164+
*/
165+
@SerializedName("userid")
166+
private String[] userIds;
167+
}
168+
121169
}

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/WxCpOaApplyEventRequestTest.java

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,99 @@ public void testToJson() {
9595

9696
assertThat(request.toJson()).isEqualTo(GsonParser.parse(json).toString());
9797
}
98+
99+
/**
100+
* Test to json with process.
101+
*/
102+
@Test
103+
public void testToJsonWithProcess() {
104+
String json = "{\n" +
105+
" \"creator_userid\": \"WangXiaoMing\",\n" +
106+
" \"template_id\": \"3Tka1eD6v6JfzhDMqPd3aMkFdxqtJMc2ZRioeFXkaaa\",\n" +
107+
" \"use_template_approver\":0,\n" +
108+
" \"process\": {\n" +
109+
" \"node_list\": [\n" +
110+
" {\n" +
111+
" \"type\": 1,\n" +
112+
" \"apv_rel\": 2,\n" +
113+
" \"userid\": [\"WuJunJie\",\"WangXiaoMing\"]\n" +
114+
" },\n" +
115+
" {\n" +
116+
" \"type\": 1,\n" +
117+
" \"apv_rel\": 1,\n" +
118+
" \"userid\": [\"LiuXiaoGang\"]\n" +
119+
" },\n" +
120+
" {\n" +
121+
" \"type\": 2,\n" +
122+
" \"userid\": [\"ZhangSan\",\"LiSi\"]\n" +
123+
" }\n" +
124+
" ]\n" +
125+
" },\n" +
126+
" \"apply_data\": {\n" +
127+
" \"contents\": [\n" +
128+
" {\n" +
129+
" \"control\": \"Text\",\n" +
130+
" \"id\": \"Text-15111111111\",\n" +
131+
" \"value\": {\n" +
132+
" \"text\": \"文本填写的内容\"\n" +
133+
" }\n" +
134+
" }\n" +
135+
" ]\n" +
136+
" },\n" +
137+
" \"summary_list\": [\n" +
138+
" {\n" +
139+
" \"summary_info\": [{\n" +
140+
" \"text\": \"摘要第1行\",\n" +
141+
" \"lang\": \"zh_CN\"\n" +
142+
" }]\n" +
143+
" },\n" +
144+
" {\n" +
145+
" \"summary_info\": [{\n" +
146+
" \"text\": \"摘要第2行\",\n" +
147+
" \"lang\": \"zh_CN\"\n" +
148+
" }]\n" +
149+
" },\n" +
150+
" {\n" +
151+
" \"summary_info\": [{\n" +
152+
" \"text\": \"摘要第3行\",\n" +
153+
" \"lang\": \"zh_CN\"\n" +
154+
" }]\n" +
155+
" }\n" +
156+
" ]\n" +
157+
"}";
158+
159+
WxCpOaApplyEventRequest request = new WxCpOaApplyEventRequest();
160+
request.setCreatorUserId("WangXiaoMing")
161+
.setTemplateId("3Tka1eD6v6JfzhDMqPd3aMkFdxqtJMc2ZRioeFXkaaa")
162+
.setUseTemplateApprover(0)
163+
.setProcess(new WxCpOaApplyEventRequest.Process()
164+
.setNodeList(Arrays.asList(
165+
new WxCpOaApplyEventRequest.ProcessNode()
166+
.setType(1)
167+
.setApvRel(2)
168+
.setUserIds(new String[]{"WuJunJie", "WangXiaoMing"}),
169+
new WxCpOaApplyEventRequest.ProcessNode()
170+
.setType(1)
171+
.setApvRel(1)
172+
.setUserIds(new String[]{"LiuXiaoGang"}),
173+
new WxCpOaApplyEventRequest.ProcessNode()
174+
.setType(2)
175+
.setUserIds(new String[]{"ZhangSan", "LiSi"})
176+
)))
177+
.setApplyData(new WxCpOaApplyEventRequest.ApplyData()
178+
.setContents(Collections.singletonList(new ApplyDataContent()
179+
.setControl("Text").setId("Text-15111111111").setValue(new ContentValue().setText("文本填写的内容")))))
180+
.setSummaryList(Arrays.asList(new SummaryInfo()
181+
.setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText(
182+
"摘要第1行"))),
183+
new SummaryInfo()
184+
.setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText(
185+
"摘要第2行"))),
186+
new SummaryInfo()
187+
.setSummaryInfoData(Collections.singletonList(new SummaryInfo.SummaryInfoData().setLang("zh_CN").setText(
188+
"摘要第3行")))))
189+
;
190+
191+
assertThat(request.toJson()).isEqualTo(GsonParser.parse(json).toString());
192+
}
98193
}

0 commit comments

Comments
 (0)