diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java index 7eb986dbb..bbbcb6095 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaService.java @@ -10,7 +10,7 @@ import java.util.List; /** * 企业微信OA相关接口. * - * @author Element + * @author Element & Wang_Wong * @date 2019-04-06 10:52 */ public interface WxCpOaService { @@ -107,6 +107,7 @@ public interface WxCpOaService { */ WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException; + /** *
* 获取审批申请详情 @@ -122,6 +123,21 @@ public interface WxCpOaService { */ WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws WxErrorException; + + /** + * 获取企业假期管理配置 + * 企业可通过审批应用或自建应用Secret调用本接口,获取可见范围内员工的“假期管理”配置,包括:各个假期的id、名称、请假单位、时长计算方式、发放规则等。 + * 第三方应用可获取应用可见范围内员工的“假期管理”配置,包括:各个假期的id、名称、请假单位、时长计算方式、发放规则等。 + * + * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getcorpconf?access_token=ACCESS_TOKEN + * + * @return + * @throws WxErrorException + */ + WxCpCorpConfInfo getCorpConf() throws WxErrorException; + + /** * 获取公费电话拨打记录 * diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java index 529e6f06e..ddb3968c2 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java @@ -386,7 +386,7 @@ public interface WxCpService extends WxService { WxCpMessageService getMessageService(); /** - * Gets oa service. + * 获取OA相关接口的服务类对象. * * @return the oa service */ diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java index 9f3d3f167..5acdf0cf0 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java @@ -9,11 +9,9 @@ import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.WxCpOaAgentService; import me.chanjar.weixin.cp.api.WxCpService; -import me.chanjar.weixin.cp.bean.living.WxCpLivingInfo; import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; -import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Living.GET_USER_ALL_LIVINGID; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.GET_OPEN_APPROVAL_DATA; /** diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java index 3e8277a85..afee242fe 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImpl.java @@ -165,6 +165,13 @@ public class WxCpOaServiceImpl implements WxCpOaService { return WxCpGsonBuilder.create().fromJson(responseContent, WxCpApprovalDetailResult.class); } + @Override + public WxCpCorpConfInfo getCorpConf() throws WxErrorException { + final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_CONF); + String responseContent = this.mainService.get(url, null); + return WxCpCorpConfInfo.fromJson(responseContent); + } + @Override public ListgetDialRecord(Date startTime, Date endTime, Integer offset, Integer limit) throws WxErrorException { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCorpConfInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCorpConfInfo.java new file mode 100644 index 000000000..514cb421f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/WxCpCorpConfInfo.java @@ -0,0 +1,74 @@ +package me.chanjar.weixin.cp.bean.oa; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 企业假期管理配置信息. + * + * @author Wang_Wong + */ +@Data +public class WxCpCorpConfInfo extends WxCpBaseResp implements Serializable { + private static final long serialVersionUID = 7387181805254287157L; + + @SerializedName("lists") + private List lists; + + @Getter + @Setter + public static class CorpConf implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("id") + private Integer id; + + @SerializedName("name") + private String name; + + @SerializedName("time_attr") + private Integer timeAttr; + + @SerializedName("duration_type") + private Integer durationType; + + @SerializedName("quota_attr") + private QuotaAttr quotaAttr; + + @SerializedName("perday_duration") + private Integer perdayDuration; + + } + + @Getter + @Setter + public static class QuotaAttr implements Serializable { + private static final long serialVersionUID = -5696099236344075582L; + + @SerializedName("type") + private Integer type; + + @SerializedName("autoreset_time") + private Integer autoresetTime; + + @SerializedName("autoreset_duration") + private Integer autoresetDuration; + + } + + public static WxCpCorpConfInfo fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCorpConfInfo.class); + } + + public String toJson() { + return WxCpGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index e80a93263..b3773eeab 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -112,6 +112,11 @@ public interface WxCpApiPathConsts { String APPLY_EVENT = "/cgi-bin/oa/applyevent"; String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo"; String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail"; + String GET_APPROVAL_DATA = "/cgi-bin/oa/getapprovaldata"; + + String GET_CORP_CONF = "/cgi-bin/oa/vacation/getcorpconf"; + String GET_USER_VACATION_QUOTA = "/cgi-bin/oa/vacation/getuservacationquota"; + String SET_ONE_USER_QUOTA = "/cgi-bin/oa/vacation/setoneuserquota"; /** * 公费电话 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 4370bb3d8..d3f52561a 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 @@ -1,15 +1,12 @@ package me.chanjar.weixin.cp.api.impl; import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; import com.google.inject.Inject; +import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.WxCpService; 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; @@ -25,9 +22,9 @@ import static org.assertj.core.api.Assertions.assertThat; /** * 企业微信 OA数据接口 测试用例 * - * @author Element + * @author Element & Wang_Wong */ - +@Slf4j @Guice(modules = ApiTestModule.class) public class WxCpOaServiceImplTest { @@ -171,4 +168,15 @@ public class WxCpOaServiceImplTest { @Test public void testGetDialRecord() { } + + /** + * https://developer.work.weixin.qq.com/document/path/93375 + * @throws WxErrorException + */ + @Test + public void testGetCorpConf() throws WxErrorException{ + WxCpCorpConfInfo corpConf = this.wxService.getOaService().getCorpConf(); + log.info(corpConf.toJson()); + } + }