Skip to content

Add support for ot_info_v2 structure in WeChat Work attendance rules API #3658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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表示不限制
*/
Expand Down Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down