mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🆕 #1641 企业微信增加OA提交审批申请的接口
This commit is contained in:
@@ -15,6 +15,22 @@ import java.util.List;
|
||||
*/
|
||||
public interface WxCpOaService {
|
||||
|
||||
/**
|
||||
* <pre>提交审批申请
|
||||
* 调试工具
|
||||
* 企业可通过审批应用或自建应用Secret调用本接口,代应用可见范围内员工在企业微信“审批应用”内提交指定类型的审批申请。
|
||||
*
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/oa/applyevent?access_token=ACCESS_TOKEN
|
||||
* 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/91853
|
||||
* </pre>
|
||||
*
|
||||
* @param request 请求
|
||||
* @return 表单提交成功后,返回的表单编号
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
String apply(WxCpOaApplyEventRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取打卡数据
|
||||
@@ -40,7 +56,7 @@ public interface WxCpOaService {
|
||||
* @param datetime 需要获取规则的当天日期
|
||||
* @param userIdList 需要获取打卡规则的用户列表
|
||||
* @return 打卡规则列表
|
||||
* @throws WxErrorException
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
List<WxCpCheckinOption> getCheckinOption(Date datetime, List<String> userIdList) throws WxErrorException;
|
||||
|
||||
@@ -63,7 +79,7 @@ public interface WxCpOaService {
|
||||
* @param size 一次请求拉取审批单数量,默认值为100,上限值为100
|
||||
* @param filters 筛选条件,可对批量拉取的审批申请设置约束条件,支持设置多个条件,nullable
|
||||
* @return WxCpApprovalInfo
|
||||
* @throws WxErrorException
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime, Integer cursor, Integer size,
|
||||
List<WxCpApprovalInfoQueryFilter> filters) throws WxErrorException;
|
||||
@@ -74,7 +90,7 @@ public interface WxCpOaService {
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return WxCpApprovalInfo
|
||||
* @throws WxErrorException
|
||||
* @throws WxErrorException .
|
||||
* @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo
|
||||
*/
|
||||
WxCpApprovalInfo getApprovalInfo(@NonNull Date startTime, @NonNull Date endTime) throws WxErrorException;
|
||||
@@ -90,7 +106,7 @@ public interface WxCpOaService {
|
||||
*
|
||||
* @param spNo 审批单编号。
|
||||
* @return WxCpApprovaldetail
|
||||
* @throws WxErrorException
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxCpApprovalDetailResult getApprovalDetail(@NonNull String spNo) throws WxErrorException;
|
||||
|
||||
@@ -104,7 +120,7 @@ public interface WxCpOaService {
|
||||
* @param startTime 获取审批记录的开始时间
|
||||
* @param endTime 获取审批记录的结束时间
|
||||
* @param nextSpnum 第一个拉取的审批单号,不填从该时间段的第一个审批单拉取
|
||||
* @throws WxErrorException
|
||||
* @throws WxErrorException .
|
||||
* @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalInfo
|
||||
* @see me.chanjar.weixin.cp.api.WxCpOaService#getApprovalDetail
|
||||
*/
|
||||
@@ -118,18 +134,19 @@ public interface WxCpOaService {
|
||||
* @param endTime 查询的结束时间戳
|
||||
* @param offset 分页查询的偏移量
|
||||
* @param limit 分页查询的每页大小,默认为100条,如该参数大于100则按100处理
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
* @return .
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset,
|
||||
Integer limit) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取审批模板详情
|
||||
*
|
||||
* @param templateId 模板ID
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
* @return .
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxCpTemplateResult getTemplateDetail(@NonNull String templateId)throws WxErrorException;
|
||||
WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,13 @@ public class WxCpOaServiceImpl implements WxCpOaService {
|
||||
private static final int MONTH_SECONDS = 30 * 24 * 60 * 60;
|
||||
private static final int USER_IDS_LIMIT = 100;
|
||||
|
||||
@Override
|
||||
public String apply(WxCpOaApplyEventRequest request) throws WxErrorException {
|
||||
String responseContent = this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(APPLY_EVENT),
|
||||
request.toJson());
|
||||
return GsonParser.parse(responseContent).get("sp_no").getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WxCpCheckinData> getCheckinData(Integer openCheckinDataType, Date startTime, Date endTime,
|
||||
List<String> userIdList) throws WxErrorException {
|
||||
@@ -42,10 +49,10 @@ public class WxCpOaServiceImpl implements WxCpOaService {
|
||||
throw new RuntimeException("用户列表不能为空,不超过 " + USER_IDS_LIMIT + " 个,若用户超过 " + USER_IDS_LIMIT + " 个,请分批获取");
|
||||
}
|
||||
|
||||
long endtimestamp = endTime.getTime() / 1000L;
|
||||
long starttimestamp = startTime.getTime() / 1000L;
|
||||
long endTimestamp = endTime.getTime() / 1000L;
|
||||
long startTimestamp = startTime.getTime() / 1000L;
|
||||
|
||||
if (endtimestamp - starttimestamp < 0 || endtimestamp - starttimestamp >= MONTH_SECONDS) {
|
||||
if (endTimestamp - startTimestamp < 0 || endTimestamp - startTimestamp >= MONTH_SECONDS) {
|
||||
throw new RuntimeException("获取记录时间跨度不超过一个月");
|
||||
}
|
||||
|
||||
@@ -53,8 +60,8 @@ public class WxCpOaServiceImpl implements WxCpOaService {
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
|
||||
jsonObject.addProperty("opencheckindatatype", openCheckinDataType);
|
||||
jsonObject.addProperty("starttime", starttimestamp);
|
||||
jsonObject.addProperty("endtime", endtimestamp);
|
||||
jsonObject.addProperty("starttime", startTimestamp);
|
||||
jsonObject.addProperty("endtime", endTimestamp);
|
||||
|
||||
for (String userid : userIdList) {
|
||||
jsonArray.add(userid);
|
||||
@@ -213,9 +220,9 @@ public class WxCpOaServiceImpl implements WxCpOaService {
|
||||
@Override
|
||||
public WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("template_id",templateId);
|
||||
jsonObject.addProperty("template_id", templateId);
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL);
|
||||
String responseContent = this.mainService.post(url, jsonObject.toString());
|
||||
return WxCpGsonBuilder.create().fromJson(responseContent,WxCpTemplateResult.class);
|
||||
return WxCpGsonBuilder.create().fromJson(responseContent, WxCpTemplateResult.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user