Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a881de5

Browse files
authored
🎨 #3567 【企业微信】获取企业所有打卡规则接口调整
1 parent 14f8c8e commit a881de5

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

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

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public class WxCpCropCheckinOption extends WxCpCheckinGroupBase implements Seria
5353
@SerializedName("ot_info")
5454
private OtInfo otInfo;
5555

56+
/**
57+
* 加班信息V2,新版API返回的加班信息结构
58+
*/
59+
@SerializedName("ot_info_v2")
60+
private OtInfoV2 otInfoV2;
61+
5662
/**
5763
* 每月最多补卡次数,默认-1表示不限制
5864
*/
@@ -418,4 +424,94 @@ public static class OtApplyInfo implements Serializable {
418424
private Integer otNonworkingDaySpanDayTime;
419425

420426
}
427+
428+
/**
429+
* 加班信息V2,新版API返回的加班信息结构
430+
*/
431+
@Data
432+
public static class OtInfoV2 implements Serializable {
433+
434+
private static final long serialVersionUID = 1610150484871066200L;
435+
436+
/**
437+
* 工作日加班配置
438+
*/
439+
@SerializedName("workdayconf")
440+
private WorkdayConf workdayConf;
441+
442+
/**
443+
* 非工作日加班配置
444+
*/
445+
@SerializedName("restdayconf")
446+
private RestdayConf restdayConf;
447+
448+
/**
449+
* 节假日加班配置
450+
*/
451+
@SerializedName("holidayconf")
452+
private HolidayConf holidayConf;
453+
454+
/**
455+
* 工作日加班配置
456+
*/
457+
@Data
458+
public static class WorkdayConf implements Serializable {
459+
private static final long serialVersionUID = 1610150484871066201L;
460+
461+
/**
462+
* 是否允许工作日加班,true为允许,false为不允许
463+
*/
464+
@SerializedName("allow_ot")
465+
private Boolean allowOt;
466+
467+
/**
468+
* 加班类型
469+
* 0:以加班申请核算打卡记录(根据打卡记录和加班申请核算),
470+
* 1:以打卡时间为准(根据打卡时间计算),
471+
* 2: 以加班申请审批为准(只根据加班申请计算)
472+
*/
473+
@SerializedName("type")
474+
private Integer type;
475+
}
476+
477+
/**
478+
* 非工作日加班配置
479+
*/
480+
@Data
481+
public static class RestdayConf implements Serializable {
482+
private static final long serialVersionUID = 1610150484871066202L;
483+
484+
/**
485+
* 是否允许非工作日加班,true为允许,false为不允许
486+
*/
487+
@SerializedName("allow_ot")
488+
private Boolean allowOt;
489+
490+
/**
491+
* 加班类型
492+
*/
493+
@SerializedName("type")
494+
private Integer type;
495+
}
496+
497+
/**
498+
* 节假日加班配置
499+
*/
500+
@Data
501+
public static class HolidayConf implements Serializable {
502+
private static final long serialVersionUID = 1610150484871066203L;
503+
504+
/**
505+
* 是否允许节假日加班,true为允许,false为不允许
506+
*/
507+
@SerializedName("allow_ot")
508+
private Boolean allowOt;
509+
510+
/**
511+
* 加班类型
512+
*/
513+
@SerializedName("type")
514+
private Integer type;
515+
}
516+
}
421517
}

‎weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import me.chanjar.weixin.cp.api.WxCpService;
99
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
1010
import me.chanjar.weixin.cp.bean.oa.*;
11+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1112
import org.apache.commons.lang3.time.DateFormatUtils;
1213
import org.testng.annotations.Guice;
1314
import org.testng.annotations.Test;
@@ -168,6 +169,46 @@ public void testGetCropCheckinOption() throws WxErrorException {
168169
System.out.println(gson.toJson(results));
169170
}
170171

172+
/**
173+
* Test new ot_info_v2 structure deserialization.
174+
*/
175+
@Test
176+
public void testOtInfoV2Deserialization() {
177+
// Test JSON with ot_info_v2 structure based on the new API response format
178+
String jsonWithOtInfoV2 = "{\n" +
179+
" \"groupid\": 1,\n" +
180+
" \"groupname\": \"test group\",\n" +
181+
" \"grouptype\": 0,\n" +
182+
" \"ot_info_v2\": {\n" +
183+
" \"workdayconf\": {\n" +
184+
" \"allow_ot\": true,\n" +
185+
" \"type\": 1\n" +
186+
" },\n" +
187+
" \"restdayconf\": {\n" +
188+
" \"allow_ot\": false,\n" +
189+
" \"type\": 0\n" +
190+
" },\n" +
191+
" \"holidayconf\": {\n" +
192+
" \"allow_ot\": true,\n" +
193+
" \"type\": 2\n" +
194+
" }\n" +
195+
" }\n" +
196+
"}";
197+
198+
WxCpCropCheckinOption option = WxCpGsonBuilder.create().fromJson(jsonWithOtInfoV2, WxCpCropCheckinOption.class);
199+
assertThat(option).isNotNull();
200+
assertThat(option.getOtInfoV2()).isNotNull();
201+
assertThat(option.getOtInfoV2().getWorkdayConf()).isNotNull();
202+
assertThat(option.getOtInfoV2().getWorkdayConf().getAllowOt()).isTrue();
203+
assertThat(option.getOtInfoV2().getWorkdayConf().getType()).isEqualTo(1);
204+
assertThat(option.getOtInfoV2().getRestdayConf()).isNotNull();
205+
assertThat(option.getOtInfoV2().getRestdayConf().getAllowOt()).isFalse();
206+
assertThat(option.getOtInfoV2().getHolidayConf().getAllowOt()).isTrue();
207+
208+
System.out.println("Parsed ot_info_v2 structure:");
209+
System.out.println(gson.toJson(option.getOtInfoV2()));
210+
}
211+
171212
/**
172213
* Test get approval info.
173214
*

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /