Compare commits

...

2 Commits

Author SHA1 Message Date
Binary Wang
8bb4a21598 🎨 #3662 【企业微信】修复获取审批模板详情接口异常的问题:Expected BEGIN_OBJECT but was BEGIN_ARRAY
Some checks failed
Publish to Maven Central / build-and-publish (push) Has been cancelled
2025-07-30 23:29:59 +08:00
Copilot
a881de59a5
🎨 #3567 【企业微信】获取企业所有打卡规则接口调整 2025-07-30 23:10:30 +08:00
5 changed files with 533 additions and 8 deletions

View File

@ -53,6 +53,12 @@ public class WxCpCropCheckinOption extends WxCpCheckinGroupBase implements Seria
@SerializedName("ot_info")
private OtInfo otInfo;
/**
* 加班信息V2新版API返回的加班信息结构
*/
@SerializedName("ot_info_v2")
private OtInfoV2 otInfoV2;
/**
* 每月最多补卡次数默认-1表示不限制
*/
@ -418,4 +424,94 @@ public class WxCpCropCheckinOption extends WxCpCheckinGroupBase implements Seria
private Integer otNonworkingDaySpanDayTime;
}
/**
* 加班信息V2新版API返回的加班信息结构
*/
@Data
public static class OtInfoV2 implements Serializable {
private static final long serialVersionUID = 1610150484871066200L;
/**
* 工作日加班配置
*/
@SerializedName("workdayconf")
private WorkdayConf workdayConf;
/**
* 非工作日加班配置
*/
@SerializedName("restdayconf")
private RestdayConf restdayConf;
/**
* 节假日加班配置
*/
@SerializedName("holidayconf")
private HolidayConf holidayConf;
/**
* 工作日加班配置
*/
@Data
public static class WorkdayConf implements Serializable {
private static final long serialVersionUID = 1610150484871066201L;
/**
* 是否允许工作日加班true为允许false为不允许
*/
@SerializedName("allow_ot")
private Boolean allowOt;
/**
* 加班类型
* 0以加班申请核算打卡记录根据打卡记录和加班申请核算,
* 1以打卡时间为准根据打卡时间计算
* 2: 以加班申请审批为准只根据加班申请计算
*/
@SerializedName("type")
private Integer type;
}
/**
* 非工作日加班配置
*/
@Data
public static class RestdayConf implements Serializable {
private static final long serialVersionUID = 1610150484871066202L;
/**
* 是否允许非工作日加班true为允许false为不允许
*/
@SerializedName("allow_ot")
private Boolean allowOt;
/**
* 加班类型
*/
@SerializedName("type")
private Integer type;
}
/**
* 节假日加班配置
*/
@Data
public static class HolidayConf implements Serializable {
private static final long serialVersionUID = 1610150484871066203L;
/**
* 是否允许节假日加班true为允许false为不允许
*/
@SerializedName("allow_ot")
private Boolean allowOt;
/**
* 加班类型
*/
@SerializedName("type")
private Integer type;
}
}
}

View File

@ -17,7 +17,7 @@ import java.util.List;
/**
* 审批模板详情
*
* @author gyv12345 @163.com / Wang_Wong
* @author gyv12345@163.com / Wang_Wong
*/
@Data
@Builder
@ -121,7 +121,7 @@ public class WxCpOaApprovalTemplateResult implements Serializable {
/**
* 获取审批模板详情value为list类型
* https://developer.work.weixin.qq.com/document/path/91982
* <a href="https://developer.work.weixin.qq.com/document/path/91982">文档链接</a>
*/
@SerializedName("value")
private List<TemplateTitle> value;

View File

@ -3,6 +3,7 @@ package me.chanjar.weixin.cp.bean.oa.templatedata;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* The type Template options.
@ -17,11 +18,8 @@ public class TemplateOptions implements Serializable {
private String key;
/**
* 创建审批模板value为对象类型
* https://developer.work.weixin.qq.com/document/path/97437#%E9%99%845-%E5%8D%95%E9%80%89%E5%A4%9A%E9%80%89%E6%8E%A7%E4%BB%B6%EF%BC%88control%E5%8F%82%E6%95%B0%E4%B8%BAselector%EF%BC%89
*
* 获取审批模板详情value为list类型
* https://developer.work.weixin.qq.com/document/path/91982
* <a href="https://developer.work.weixin.qq.com/document/path/97437#%E9%99%845-%E5%8D%95%E9%80%89%E5%A4%9A%E9%80%89%E6%8E%A7%E4%BB%B6%EF%BC%88control%E5%8F%82%E6%95%B0%E4%B8%BAselector%EF%BC%89">创建审批模板value为对象类型</a>
* <a href="https://developer.work.weixin.qq.com/document/path/91982">获取审批模板详情value为list类型</a>
**/
private TemplateTitle value;
private List<TemplateTitle> value;
}

View File

@ -8,6 +8,7 @@ import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.oa.*;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
@ -168,6 +169,46 @@ public class WxCpOaServiceImplTest {
System.out.println(gson.toJson(results));
}
/**
* Test new ot_info_v2 structure deserialization.
*/
@Test
public void testOtInfoV2Deserialization() {
// Test JSON with ot_info_v2 structure based on the new API response format
String jsonWithOtInfoV2 = "{\n" +
" \"groupid\": 1,\n" +
" \"groupname\": \"test group\",\n" +
" \"grouptype\": 0,\n" +
" \"ot_info_v2\": {\n" +
" \"workdayconf\": {\n" +
" \"allow_ot\": true,\n" +
" \"type\": 1\n" +
" },\n" +
" \"restdayconf\": {\n" +
" \"allow_ot\": false,\n" +
" \"type\": 0\n" +
" },\n" +
" \"holidayconf\": {\n" +
" \"allow_ot\": true,\n" +
" \"type\": 2\n" +
" }\n" +
" }\n" +
"}";
WxCpCropCheckinOption option = WxCpGsonBuilder.create().fromJson(jsonWithOtInfoV2, WxCpCropCheckinOption.class);
assertThat(option).isNotNull();
assertThat(option.getOtInfoV2()).isNotNull();
assertThat(option.getOtInfoV2().getWorkdayConf()).isNotNull();
assertThat(option.getOtInfoV2().getWorkdayConf().getAllowOt()).isTrue();
assertThat(option.getOtInfoV2().getWorkdayConf().getType()).isEqualTo(1);
assertThat(option.getOtInfoV2().getRestdayConf()).isNotNull();
assertThat(option.getOtInfoV2().getRestdayConf().getAllowOt()).isFalse();
assertThat(option.getOtInfoV2().getHolidayConf().getAllowOt()).isTrue();
System.out.println("Parsed ot_info_v2 structure:");
System.out.println(gson.toJson(option.getOtInfoV2()));
}
/**
* Test get approval info.
*

View File

@ -0,0 +1,390 @@
package me.chanjar.weixin.cp.bean.oa;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
public class WxCpOaApprovalTemplateResultTest {
@Test
public void testFromJson() {
String json = "{\n"
+ " \"errcode\": 0,\n"
+ " \"errmsg\": \"ok\",\n"
+ " \"template_names\": [\n"
+ " {\n"
+ " \"text\": \"智能印章\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Company Seal\",\n"
+ " \"lang\": \"en\"\n"
+ " }\n"
+ " ],\n"
+ " \"template_content\": {\n"
+ " \"controls\": [\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Text\",\n"
+ " \"id\": \"Text-1747127819114\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"用印事由\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 1,\n"
+ " \"un_print\": 0,\n"
+ " \"inner_id\": \"\",\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Selector\",\n"
+ " \"id\": \"Selector-1747123508806\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"用印类型\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 1,\n"
+ " \"un_print\": 0,\n"
+ " \"inner_id\": \"\",\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " },\n"
+ " \"config\": {\n"
+ " \"selector\": {\n"
+ " \"type\": \"single\",\n"
+ " \"options\": [\n"
+ " {\n"
+ " \"key\": \"option-1747123508806\",\n"
+ " \"value\": [\n"
+ " {\n"
+ " \"text\": \"一般事务性用印\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " {\n"
+ " \"key\": \"option-1747123508807\",\n"
+ " \"value\": [\n"
+ " {\n"
+ " \"text\": \"对外事务性用印\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " {\n"
+ " \"key\": \"option-1747123530814\",\n"
+ " \"value\": [\n"
+ " {\n"
+ " \"text\": \"重大事务性用印\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ],\n"
+ " \"op_relations\": [],\n"
+ " \"external_option\": {\n"
+ " \"use_external_option\": false,\n"
+ " \"external_url\": \"\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Tips\",\n"
+ " \"id\": \"Tips-1747123397470\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"说明\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [],\n"
+ " \"require\": 0,\n"
+ " \"un_print\": 0,\n"
+ " \"inner_id\": \"\",\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " },\n"
+ " \"config\": {\n"
+ " \"tips\": {\n"
+ " \"tips_content\": [\n"
+ " {\n"
+ " \"text\": {\n"
+ " \"sub_text\": [\n"
+ " {\n"
+ " \"type\": 1,\n"
+ " \"content\": {\n"
+ " \"plain_text\": {\n"
+ " \"content\": \"用印类型说明1. 一般事务性用印:内部日常材料流转、常规业务报表报送、非对外承诺性质的证明文件,用印文件内容不得涉及经济、法律责任条款 \"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Table\",\n"
+ " \"id\": \"Table-1746005041962\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"印章明细\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 0,\n"
+ " \"un_print\": 0,\n"
+ " \"inner_id\": \"\",\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " },\n"
+ " \"config\": {\n"
+ " \"table\": {\n"
+ " \"children\": [\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Text\",\n"
+ " \"id\": \"Text-1747127691499\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"印章名称\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"请输入“公章”\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 1,\n"
+ " \"un_print\": 0,\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Number\",\n"
+ " \"id\": \"Number-1746006598992\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"普通用印\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"请填写正文用印次数\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 1,\n"
+ " \"un_print\": 0,\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Number\",\n"
+ " \"id\": \"Number-1746006601002\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"骑缝用印\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"请填写骑缝用印次数\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 1,\n"
+ " \"un_print\": 0,\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Selector\",\n"
+ " \"id\": \"Selector-1746005136537\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"是否外借\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 0,\n"
+ " \"un_print\": 0,\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " },\n"
+ " \"config\": {\n"
+ " \"selector\": {\n"
+ " \"type\": \"single\",\n"
+ " \"exp_type\": 0,\n"
+ " \"options\": [\n"
+ " {\n"
+ " \"key\": \"option-1746005136537\",\n"
+ " \"value\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " {\n"
+ " \"key\": \"option-1746005136538\",\n"
+ " \"value\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ],\n"
+ " \"op_relations\": [],\n"
+ " \"external_option\": {\n"
+ " \"use_external_option\": false,\n"
+ " \"external_url\": \"\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Date\",\n"
+ " \"id\": \"Date-1746005165574\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"外借开始时间\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 0,\n"
+ " \"un_print\": 0,\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " },\n"
+ " \"config\": {\n"
+ " \"date\": {\n"
+ " \"type\": \"day\"\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"Date\",\n"
+ " \"id\": \"Date-1746005173386\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"外借结束时间\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 0,\n"
+ " \"un_print\": 0,\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " },\n"
+ " \"config\": {\n"
+ " \"date\": {\n"
+ " \"type\": \"day\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " ],\n"
+ " \"stat_field\": [],\n"
+ " \"sum_field\": [],\n"
+ " \"print_format\": 0\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"property\": {\n"
+ " \"control\": \"File\",\n"
+ " \"id\": \"item-1494250388062\",\n"
+ " \"title\": [\n"
+ " {\n"
+ " \"text\": \"用印文件\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " },\n"
+ " {\n"
+ " \"text\": \"Attachment\",\n"
+ " \"lang\": \"en\"\n"
+ " }\n"
+ " ],\n"
+ " \"placeholder\": [\n"
+ " {\n"
+ " \"text\": \"\",\n"
+ " \"lang\": \"zh_CN\"\n"
+ " }\n"
+ " ],\n"
+ " \"require\": 1,\n"
+ " \"un_print\": 0,\n"
+ " \"inner_id\": \"\",\n"
+ " \"un_replace\": 0,\n"
+ " \"display\": 1\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
WxCpOaApprovalTemplateResult templateDetail = WxCpGsonBuilder.create().fromJson(json, WxCpOaApprovalTemplateResult.class);
System.out.println(templateDetail);
}
}