mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🆕【企业微信】 新增获取成员假期余额的接口
This commit is contained in:
parent
8bcafdc6b2
commit
b00e938ef7
@ -138,6 +138,21 @@ public interface WxCpOaService {
|
||||
WxCpCorpConfInfo getCorpConf() throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取成员假期余额
|
||||
* 企业可通过审批应用或自建应用Secret调用本接口,获取可见范围内各个员工的假期余额数据。
|
||||
* 第三方应用可获取应用可见范围内各个员工的假期余额数据。
|
||||
*
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getuservacationquota?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpUserVacationQuota getUserVacationQuota(@NonNull String userId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取公费电话拨打记录
|
||||
*
|
||||
|
@ -172,6 +172,15 @@ public class WxCpOaServiceImpl implements WxCpOaService {
|
||||
return WxCpCorpConfInfo.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpUserVacationQuota getUserVacationQuota(@NonNull String userId) throws WxErrorException {
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_VACATION_QUOTA);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("userid", userId);
|
||||
String responseContent = this.mainService.post(url, jsonObject.toString());
|
||||
return WxCpUserVacationQuota.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit)
|
||||
throws WxErrorException {
|
||||
|
@ -29,4 +29,5 @@ public class WxCpBaseResp implements Serializable {
|
||||
public static WxCpBaseResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpBaseResp.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
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 WxCpUserVacationQuota extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = 7387181805254287157L;
|
||||
|
||||
@SerializedName("lists")
|
||||
private List<VacationQuota> lists;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class VacationQuota implements Serializable {
|
||||
private static final long serialVersionUID = -5696099236344075582L;
|
||||
|
||||
@SerializedName("id")
|
||||
private Integer id;
|
||||
|
||||
@SerializedName("assignduration")
|
||||
private Integer assignDuration;
|
||||
|
||||
@SerializedName("usedduration")
|
||||
private Integer usedDuration;
|
||||
|
||||
@SerializedName("leftduration")
|
||||
private Integer leftDuration;
|
||||
|
||||
@SerializedName("vacationname")
|
||||
private String vacationName;
|
||||
|
||||
}
|
||||
|
||||
public static WxCpUserVacationQuota fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUserVacationQuota.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -170,7 +170,9 @@ public class WxCpOaServiceImplTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业假期管理配置
|
||||
* https://developer.work.weixin.qq.com/document/path/93375
|
||||
*
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
@ -179,4 +181,21 @@ public class WxCpOaServiceImplTest {
|
||||
log.info(corpConf.toJson());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员假期余额
|
||||
* https://developer.work.weixin.qq.com/document/path/93376
|
||||
*
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Test
|
||||
public void testGetUserVacationQuota() throws WxErrorException{
|
||||
WxCpUserVacationQuota vacationQuota = this.wxService.getOaService().getUserVacationQuota("WangKai");
|
||||
log.info(vacationQuota.toJson());
|
||||
|
||||
String text = "{\"errcode\":0,\"errmsg\":\"ok\",\"lists\":[{\"id\":1,\"assignduration\":0,\"usedduration\":0,\"leftduration\":604800,\"vacationname\":\"年假\"},{\"id\":2,\"assignduration\":0,\"usedduration\":0,\"leftduration\":1296000,\"vacationname\":\"事假\"},{\"id\":3,\"assignduration\":0,\"usedduration\":0,\"leftduration\":0,\"vacationname\":\"病假\"}]}";
|
||||
WxCpUserVacationQuota json = WxCpUserVacationQuota.fromJson(text);
|
||||
log.info("数据为:{}", json.toJson());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user