🎨 #3567 【企业微信】获取企业所有打卡规则接口调整

This commit is contained in:
Copilot 2025-07-30 23:10:30 +08:00 committed by GitHub
parent 14f8c8ebc2
commit a881de59a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 137 additions and 0 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

@ -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.
*