🆕【企业微信】新增修改成员假期余额的接口

This commit is contained in:
Wong 2022-04-14 08:51:03 +00:00 committed by binarywang
parent 6f776bdda0
commit 7229bb4e40
4 changed files with 65 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.api;
import lombok.NonNull;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.oa.*;
import java.util.Date;
@ -146,13 +147,32 @@ public interface WxCpOaService {
* 请求方式POST(HTTPS)
* 请求地址https://qyapi.weixin.qq.com/cgi-bin/oa/vacation/getuservacationquota?access_token=ACCESS_TOKEN
*
* @param userId
* @param userId 需要获取假期余额的成员的userid
* @return
* @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;
/**
* 获取公费电话拨打记录
*

View File

@ -11,8 +11,10 @@ import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.json.GsonParser;
import me.chanjar.weixin.cp.api.WxCpOaService;
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.StringUtils;
import java.util.Date;
import java.util.List;
@ -181,6 +183,21 @@ public class WxCpOaServiceImpl implements WxCpOaService {
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
public List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, Integer limit)
throws WxErrorException {

View File

@ -8,7 +8,9 @@ import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable;
/**
* @author yqx
* 返回结果
*
* @author yqx & WangWong
* @date 2020/3/16
*/
@Getter
@ -30,4 +32,8 @@ public class WxCpBaseResp implements Serializable {
return WxCpGsonBuilder.create().fromJson(json, WxCpBaseResp.class);
}
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}

View File

@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.oa.*;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.testng.annotations.Guice;
@ -176,7 +177,7 @@ public class WxCpOaServiceImplTest {
* @throws WxErrorException
*/
@Test
public void testGetCorpConf() throws WxErrorException{
public void testGetCorpConf() throws WxErrorException {
WxCpCorpConfInfo corpConf = this.wxService.getOaService().getCorpConf();
log.info(corpConf.toJson());
}
@ -188,7 +189,7 @@ public class WxCpOaServiceImplTest {
* @throws WxErrorException
*/
@Test
public void testGetUserVacationQuota() throws WxErrorException{
public void testGetUserVacationQuota() throws WxErrorException {
WxCpUserVacationQuota vacationQuota = this.wxService.getOaService().getUserVacationQuota("WangKai");
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(, , , , );
}
}