mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-07 22:27:47 +08:00
🆕【企业微信】新增修改成员假期余额的接口
This commit is contained in:
parent
6f776bdda0
commit
7229bb4e40
@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.api;
|
|||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
|
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||||
import me.chanjar.weixin.cp.bean.oa.*;
|
import me.chanjar.weixin.cp.bean.oa.*;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -146,13 +147,32 @@ public interface WxCpOaService {
|
|||||||
* 请求方式:POST(HTTPS)
|
* 请求方式:POST(HTTPS)
|
||||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getuservacationquota?access_token=ACCESS_TOKEN
|
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getuservacationquota?access_token=ACCESS_TOKEN
|
||||||
*
|
*
|
||||||
* @param userId
|
* @param userId 需要获取假期余额的成员的userid
|
||||||
* @return
|
* @return
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
WxCpUserVacationQuota getUserVacationQuota(@NonNull String userId) throws WxErrorException;
|
WxCpUserVacationQuota getUserVacationQuota(@NonNull String userId) throws WxErrorException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改成员假期余额
|
||||||
|
* 企业可通过审批应用或自建应用Secret调用本接口,修改可见范围内员工的“假期余额”。
|
||||||
|
* 第三方应用可通过应本接口修改应用可见范围内指定员工的“假期余额”。
|
||||||
|
*
|
||||||
|
* 请求方式:POST(HTTPS)
|
||||||
|
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/setoneuserquota?access_token=ACCESS_TOKEN
|
||||||
|
*
|
||||||
|
* @param userId 需要修改假期余额的成员的userid
|
||||||
|
* @param vacationId 假期id
|
||||||
|
* @param leftDuration 设置的假期余额,单位为秒,不能大于1000天或24000小时,当假期时间刻度为按小时请假时,必须为360整倍数,即0.1小时整倍数,按天请假时,必须为8640整倍数,即0.1天整倍数
|
||||||
|
* @param timeAttr 假期时间刻度:0-按天请假;1-按小时请假
|
||||||
|
* @param remarks 修改备注,用于显示在假期余额的修改记录当中,可对修改行为作说明,不超过200字符
|
||||||
|
* @return
|
||||||
|
* @throws WxErrorException
|
||||||
|
*/
|
||||||
|
WxCpBaseResp setOneUserQuota(@NonNull String userId, @NonNull Integer vacationId, @NonNull Integer leftDuration, @NonNull Integer timeAttr, String remarks) throws WxErrorException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取公费电话拨打记录
|
* 获取公费电话拨打记录
|
||||||
*
|
*
|
||||||
|
@ -11,8 +11,10 @@ import me.chanjar.weixin.common.error.WxRuntimeException;
|
|||||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||||
import me.chanjar.weixin.cp.api.WxCpOaService;
|
import me.chanjar.weixin.cp.api.WxCpOaService;
|
||||||
import me.chanjar.weixin.cp.api.WxCpService;
|
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.bean.oa.*;
|
||||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -181,6 +183,21 @@ public class WxCpOaServiceImpl implements WxCpOaService {
|
|||||||
return WxCpUserVacationQuota.fromJson(responseContent);
|
return WxCpUserVacationQuota.fromJson(responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxCpBaseResp setOneUserQuota(@NonNull String userId, @NonNull Integer vacationId, @NonNull Integer leftDuration, @NonNull Integer timeAttr, String remarks) throws WxErrorException {
|
||||||
|
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SET_ONE_USER_QUOTA);
|
||||||
|
JsonObject jsonObject = new JsonObject();
|
||||||
|
jsonObject.addProperty("userid", userId);
|
||||||
|
jsonObject.addProperty("vacation_id", vacationId);
|
||||||
|
jsonObject.addProperty("leftduration", leftDuration);
|
||||||
|
jsonObject.addProperty("time_attr", timeAttr);
|
||||||
|
if (StringUtils.isNotEmpty(remarks)) {
|
||||||
|
jsonObject.addProperty("remarks", remarks);
|
||||||
|
}
|
||||||
|
String responseContent = this.mainService.post(url, jsonObject.toString());
|
||||||
|
return WxCpBaseResp.fromJson(responseContent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit)
|
public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit)
|
||||||
throws WxErrorException {
|
throws WxErrorException {
|
||||||
|
@ -8,7 +8,9 @@ import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yqx
|
* 返回结果
|
||||||
|
*
|
||||||
|
* @author yqx & WangWong
|
||||||
* @date 2020/3/16
|
* @date 2020/3/16
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@ -30,4 +32,8 @@ public class WxCpBaseResp implements Serializable {
|
|||||||
return WxCpGsonBuilder.create().fromJson(json, WxCpBaseResp.class);
|
return WxCpGsonBuilder.create().fromJson(json, WxCpBaseResp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toJson() {
|
||||||
|
return WxCpGsonBuilder.create().toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
import me.chanjar.weixin.cp.api.ApiTestModule;
|
import me.chanjar.weixin.cp.api.ApiTestModule;
|
||||||
import me.chanjar.weixin.cp.api.WxCpService;
|
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.bean.oa.*;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
import org.testng.annotations.Guice;
|
import org.testng.annotations.Guice;
|
||||||
@ -176,7 +177,7 @@ public class WxCpOaServiceImplTest {
|
|||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetCorpConf() throws WxErrorException{
|
public void testGetCorpConf() throws WxErrorException {
|
||||||
WxCpCorpConfInfo corpConf = this.wxService.getOaService().getCorpConf();
|
WxCpCorpConfInfo corpConf = this.wxService.getOaService().getCorpConf();
|
||||||
log.info(corpConf.toJson());
|
log.info(corpConf.toJson());
|
||||||
}
|
}
|
||||||
@ -188,7 +189,7 @@ public class WxCpOaServiceImplTest {
|
|||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetUserVacationQuota() throws WxErrorException{
|
public void testGetUserVacationQuota() throws WxErrorException {
|
||||||
WxCpUserVacationQuota vacationQuota = this.wxService.getOaService().getUserVacationQuota("WangKai");
|
WxCpUserVacationQuota vacationQuota = this.wxService.getOaService().getUserVacationQuota("WangKai");
|
||||||
log.info(vacationQuota.toJson());
|
log.info(vacationQuota.toJson());
|
||||||
|
|
||||||
@ -198,4 +199,21 @@ public class WxCpOaServiceImplTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改成员假期余额
|
||||||
|
* https://developer.work.weixin.qq.com/document/path/93377
|
||||||
|
*
|
||||||
|
* @throws WxErrorException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testSetOneUserQuota() throws WxErrorException {
|
||||||
|
|
||||||
|
String text = "{\"errcode\":0,\"errmsg\":\"ok\"}";
|
||||||
|
WxCpBaseResp resp = WxCpBaseResp.fromJson(text);
|
||||||
|
log.info("返回结果为:{}", resp.toJson());
|
||||||
|
|
||||||
|
// WxCpBaseResp wxCpBaseResp = this.wxService.getOaService().setOneUserQuota(, , , , );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user