Skip to content

Commit 7992ee0

Browse files
0katekate0binarywang
authored andcommitted
🆕【企业微信】增加获取企业假期管理配置的接口
1 parent 07c3545 commit 7992ee0

File tree

7 files changed

+118
-10
lines changed

7 files changed

+118
-10
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* 企业微信OA相关接口.
1212
*
13-
* @author Element
13+
* @author Element & Wang_Wong
1414
* @date 2019-04-06 10:52
1515
*/
1616
public interface WxCpOaService {
@@ -107,6 +107,7 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime,
107107
*/
108108
WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException;
109109

110+
110111
/**
111112
* <pre>
112113
* 获取审批申请详情
@@ -122,6 +123,21 @@ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime,
122123
*/
123124
WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws WxErrorException;
124125

126+
127+
/**
128+
* 获取企业假期管理配置
129+
* 企业可通过审批应用或自建应用Secret调用本接口,获取可见范围内员工的“假期管理”配置,包括:各个假期的id、名称、请假单位、时长计算方式、发放规则等。
130+
* 第三方应用可获取应用可见范围内员工的“假期管理”配置,包括:各个假期的id、名称、请假单位、时长计算方式、发放规则等。
131+
*
132+
* 请求方式:GET(HTTPS)
133+
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getcorpconf?access_token=ACCESS_TOKEN
134+
*
135+
* @return
136+
* @throws WxErrorException
137+
*/
138+
WxCpCorpConfInfo getCorpConf() throws WxErrorException;
139+
140+
125141
/**
126142
* 获取公费电话拨打记录
127143
*

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public interface WxCpService extends WxService {
386386
WxCpMessageService getMessageService();
387387

388388
/**
389-
* Gets oa service.
389+
* 获取OA相关接口的服务类对象.
390390
*
391391
* @return the oa service
392392
*/

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
import me.chanjar.weixin.common.util.json.GsonParser;
1010
import me.chanjar.weixin.cp.api.WxCpOaAgentService;
1111
import me.chanjar.weixin.cp.api.WxCpService;
12-
import me.chanjar.weixin.cp.bean.living.WxCpLivingInfo;
1312
import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData;
1413
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1514

16-
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Living.GET_USER_ALL_LIVINGID;
1715
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.GET_OPEN_APPROVAL_DATA;
1816

1917
/**

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ public WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws W
165165
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDetailResult.class);
166166
}
167167

168+
@Override
169+
public WxCpCorpConfInfo getCorpConf() throws WxErrorException {
170+
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_CONF);
171+
String responseContent = this.mainService.get(url, null);
172+
return WxCpCorpConfInfo.fromJson(responseContent);
173+
}
174+
168175
@Override
169176
public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit)
170177
throws WxErrorException {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package me.chanjar.weixin.cp.bean.oa;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.Getter;
6+
import lombok.Setter;
7+
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
8+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
9+
10+
import java.io.Serializable;
11+
import java.util.List;
12+
13+
/**
14+
* 企业假期管理配置信息.
15+
*
16+
* @author Wang_Wong
17+
*/
18+
@Data
19+
public class WxCpCorpConfInfo extends WxCpBaseResp implements Serializable {
20+
private static final long serialVersionUID = 7387181805254287157L;
21+
22+
@SerializedName("lists")
23+
private List<CorpConf> lists;
24+
25+
@Getter
26+
@Setter
27+
public static class CorpConf implements Serializable {
28+
private static final long serialVersionUID = -5696099236344075582L;
29+
30+
@SerializedName("id")
31+
private Integer id;
32+
33+
@SerializedName("name")
34+
private String name;
35+
36+
@SerializedName("time_attr")
37+
private Integer timeAttr;
38+
39+
@SerializedName("duration_type")
40+
private Integer durationType;
41+
42+
@SerializedName("quota_attr")
43+
private QuotaAttr quotaAttr;
44+
45+
@SerializedName("perday_duration")
46+
private Integer perdayDuration;
47+
48+
}
49+
50+
@Getter
51+
@Setter
52+
public static class QuotaAttr implements Serializable {
53+
private static final long serialVersionUID = -5696099236344075582L;
54+
55+
@SerializedName("type")
56+
private Integer type;
57+
58+
@SerializedName("autoreset_time")
59+
private Integer autoresetTime;
60+
61+
@SerializedName("autoreset_duration")
62+
private Integer autoresetDuration;
63+
64+
}
65+
66+
public static WxCpCorpConfInfo fromJson(String json) {
67+
return WxCpGsonBuilder.create().fromJson(json, WxCpCorpConfInfo.class);
68+
}
69+
70+
public String toJson() {
71+
return WxCpGsonBuilder.create().toJson(this);
72+
}
73+
74+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ interface Oa {
112112
String APPLY_EVENT = "/cgi-bin/oa/applyevent";
113113
String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo";
114114
String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail";
115+
String GET_APPROVAL_DATA = "/cgi-bin/oa/getapprovaldata";
116+
117+
String GET_CORP_CONF = "/cgi-bin/oa/vacation/getcorpconf";
118+
String GET_USER_VACATION_QUOTA = "/cgi-bin/oa/vacation/getuservacationquota";
119+
String SET_ONE_USER_QUOTA = "/cgi-bin/oa/vacation/setoneuserquota";
115120

116121
/**
117122
* 公费电话

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package me.chanjar.weixin.cp.api.impl;
22

33
import com.google.gson.Gson;
4-
import com.google.gson.JsonObject;
5-
import com.google.gson.reflect.TypeToken;
64
import com.google.inject.Inject;
5+
import lombok.extern.slf4j.Slf4j;
76
import me.chanjar.weixin.common.error.WxErrorException;
8-
import me.chanjar.weixin.common.util.json.GsonParser;
97
import me.chanjar.weixin.cp.api.ApiTestModule;
108
import me.chanjar.weixin.cp.api.WxCpService;
119
import me.chanjar.weixin.cp.bean.oa.*;
12-
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1310
import org.apache.commons.lang3.time.DateFormatUtils;
1411
import org.testng.annotations.Guice;
1512
import org.testng.annotations.Test;
@@ -25,9 +22,9 @@
2522
/**
2623
* 企业微信 OA数据接口 测试用例
2724
*
28-
* @author Element
25+
* @author Element & Wang_Wong
2926
*/
30-
27+
@Slf4j
3128
@Guice(modules = ApiTestModule.class)
3229
public class WxCpOaServiceImplTest {
3330

@@ -171,4 +168,15 @@ public void testGetApprovalData() {
171168
@Test
172169
public void testGetDialRecord() {
173170
}
171+
172+
/**
173+
* https://developer.work.weixin.qq.com/document/path/93375
174+
* @throws WxErrorException
175+
*/
176+
@Test
177+
public void testGetCorpConf() throws WxErrorException{
178+
WxCpCorpConfInfo corpConf = this.wxService.getOaService().getCorpConf();
179+
log.info(corpConf.toJson());
180+
}
181+
174182
}

0 commit comments

Comments
 (0)