diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCropCheckinOption.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCropCheckinOption.java index bda77447fe..8cdccd9953 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCropCheckinOption.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCropCheckinOption.java @@ -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 static class OtApplyInfo implements Serializable { 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; + } + } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java index 0cb1e8e5e6..59c7a5cddf 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java @@ -8,6 +8,7 @@ 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 void testGetCropCheckinOption() throws WxErrorException { 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. *