ソースを参照

:new: #2579【企业微信】增加企业微信OA自建应用-审批流程引擎相关接口

Wong 3 年 前
コミット
56e5d6ff77

+ 29 - 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOaAgentService.java

@@ -0,0 +1,29 @@
+package me.chanjar.weixin.cp.api;
+
+import lombok.NonNull;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.bean.oa.selfagent.WxCpOpenApprovalData;
+
+/**
+ * 企业微信自建应用接口.
+ * https://developer.work.weixin.qq.com/document/path/90269
+ *
+ * @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a>
+ * @date 2022-04-06
+ */
+public interface WxCpOaAgentService {
+
+  /**
+   * 查询第三方应用审批申请当前状态
+   * 开发者也可主动查询审批单的当前审批状态。
+   *
+   * 请求方式: POST(HTTPS)
+   * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/corp/getopenapprovaldata?access_token=ACCESS_TOKEN
+   *
+   * @param thirdNo
+   * @return
+   * @throws WxErrorException
+   */
+  WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException;
+
+}

+ 7 - 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java

@@ -400,6 +400,13 @@ public interface WxCpService extends WxService {
   WxCpLivingService getLivingService();
 
   /**
+   * 获取OA 自建应用相关接口的服务类对象
+   *
+   * @return
+   */
+  WxCpOaAgentService getOaAgentService();
+
+  /**
    * 获取会话存档相关接口的服务类对象
    *
    * @return

+ 6 - 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java

@@ -50,6 +50,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
   private WxCpAgentService agentService = new WxCpAgentServiceImpl(this);
   private WxCpOaService oaService = new WxCpOaServiceImpl(this);
   private WxCpLivingService livingService = new WxCpLivingServiceImpl(this);
+  private WxCpOaAgentService oaAgentService = new WxCpOaAgentServiceImpl(this);
   private WxCpMsgAuditService msgAuditService = new WxCpMsgAuditServiceImpl(this);
   private WxCpTaskCardService taskCardService = new WxCpTaskCardServiceImpl(this);
   private WxCpExternalContactService externalContactService = new WxCpExternalContactServiceImpl(this);
@@ -486,6 +487,11 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
   }
 
   @Override
+  public WxCpOaAgentService getOaAgentService() {
+    return oaAgentService;
+  }
+
+  @Override
   public WxCpMsgAuditService getMsgAuditService() {
     return msgAuditService;
   }

+ 43 - 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOaAgentServiceImpl.java

@@ -0,0 +1,43 @@
+package me.chanjar.weixin.cp.api.impl;
+
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+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.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;
+
+/**
+ * 企业微信自建应用接口实现类.
+ *
+ * @author <a href="https://gitee.com/Wang_Wong/">Wang_Wong</a>
+ * @date 2022-04-06
+ */
+@Slf4j
+@RequiredArgsConstructor
+public class WxCpOaAgentServiceImpl implements WxCpOaAgentService {
+  private final WxCpService cpService;
+
+  @Override
+  public WxCpOpenApprovalData getOpenApprovalData(@NonNull String thirdNo) throws WxErrorException {
+    JsonObject jsonObject = new JsonObject();
+    jsonObject.addProperty("thirdNo", thirdNo);
+    String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_OPEN_APPROVAL_DATA);
+    String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
+    return WxCpGsonBuilder.create()
+      .fromJson(GsonParser.parse(responseContent).get("data"),
+        new TypeToken<WxCpOpenApprovalData>() {
+        }.getType()
+      );
+  }
+
+}

+ 161 - 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/oa/selfagent/WxCpOpenApprovalData.java

@@ -0,0 +1,161 @@
+package me.chanjar.weixin.cp.bean.oa.selfagent;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 审批申请当前状态信息.
+ *
+ * @author Wang_Wong
+ */
+@Data
+public class WxCpOpenApprovalData implements Serializable {
+  private static final long serialVersionUID = -5028321625140879591L;
+
+  @SerializedName("ThirdNo")
+  private String thirdNo;
+
+  @SerializedName("OpenTemplateId")
+  private String openTemplateId;
+
+  @SerializedName("OpenSpName")
+  private String openSpName;
+
+  @SerializedName("OpenSpstatus")
+  private Integer openSpstatus;
+
+  @SerializedName("ApplyTime")
+  private Long applyTime;
+
+  @SerializedName("ApplyUsername")
+  private String applyUserName;
+
+  @SerializedName("ApplyUserParty")
+  private String applyUserParty;
+
+  @SerializedName("ApplyUserImage")
+  private String applyUserImage;
+
+  @SerializedName("ApplyUserId")
+  private String applyUserId;
+
+  @SerializedName("ApprovalNodes")
+  private ApprovalNodes approvalNodes;
+
+  @SerializedName("NotifyNodes")
+  private NotifyNodes notifyNodes;
+
+  @SerializedName("ApproverStep")
+  private Integer approverStep;
+
+  @Getter
+  @Setter
+  public static class ApprovalNodes implements Serializable {
+    private static final long serialVersionUID = -5696099236344075582L;
+
+    @SerializedName("ApprovalNode")
+    private List<ApprovalNode> approvalNode;
+
+  }
+
+  @Getter
+  @Setter
+  public static class ApprovalNode implements Serializable {
+    private static final long serialVersionUID = -5696099236344075582L;
+
+    @SerializedName("NodeStatus")
+    private Integer nodeStatus;
+
+    @SerializedName("NodeAttr")
+    private Integer nodeAttr;
+
+    @SerializedName("NodeType")
+    private Integer nodeType;
+
+    @SerializedName("Items")
+    private Items items;
+
+  }
+
+  @Getter
+  @Setter
+  public static class NotifyNodes implements Serializable {
+    private static final long serialVersionUID = -5696099236344075582L;
+
+    @SerializedName("NotifyNode")
+    private List<NotifyNode> notifyNode;
+
+  }
+
+  @Getter
+  @Setter
+  public static class NotifyNode implements Serializable {
+    private static final long serialVersionUID = -5696099236344075582L;
+
+    @SerializedName("ItemName")
+    private String itemName;
+
+    @SerializedName("ItemParty")
+    private String itemParty;
+
+    @SerializedName("ItemImage")
+    private String itemImage;
+
+    @SerializedName("ItemUserId")
+    private String itemUserId;
+
+  }
+
+  @Getter
+  @Setter
+  public static class Items implements Serializable {
+    private static final long serialVersionUID = -5696099236344075582L;
+
+    @SerializedName("Item")
+    private List<Item> item;
+
+  }
+
+  @Getter
+  @Setter
+  public static class Item implements Serializable {
+    private static final long serialVersionUID = -5696099236344075582L;
+
+    @SerializedName("ItemName")
+    private String itemName;
+
+    @SerializedName("ItemParty")
+    private String itemParty;
+
+    @SerializedName("ItemImage")
+    private String itemImage;
+
+    @SerializedName("ItemUserId")
+    private String itemUserId;
+
+    @SerializedName("ItemSpeech")
+    private String itemSpeech;
+
+    @SerializedName("ItemStatus")
+    private Integer itemStatus;
+
+    @SerializedName("ItemOpTime")
+    private Long itemOpTime;
+
+  }
+
+  public static WxCpOpenApprovalData fromJson(String json) {
+    return WxCpGsonBuilder.create().fromJson(json, WxCpOpenApprovalData.class);
+  }
+
+  public String toJson() {
+    return WxCpGsonBuilder.create().toJson(this);
+  }
+
+}

+ 26 - 3
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

@@ -91,6 +91,10 @@ public interface WxCpApiPathConsts {
   }
 
   interface Oa {
+    /**
+     * 打卡
+     * https://developer.work.weixin.qq.com/document/path/94204
+     */
     String GET_CORP_CHECKIN_OPTION = "/cgi-bin/checkin/getcorpcheckinoption";
     String GET_CHECKIN_DATA = "/cgi-bin/checkin/getcheckindata";
     String GET_CHECKIN_OPTION = "/cgi-bin/checkin/getcheckinoption";
@@ -98,12 +102,27 @@ public interface WxCpApiPathConsts {
     String GET_CHECKIN_MONTH_DATA = "/cgi-bin/checkin/getcheckin_monthdata";
     String GET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/getcheckinschedulist";
     String SET_CHECKIN_SCHEDULE_DATA = "/cgi-bin/checkin/setcheckinschedulist";
+
+    /**
+     * 审批
+     * https://developer.work.weixin.qq.com/document/path/91956
+     */
+    String COPY_TEMPLATE = "/cgi-bin/oa/approval/copytemplate";
+    String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail";
+    String APPLY_EVENT = "/cgi-bin/oa/applyevent";
     String GET_APPROVAL_INFO = "/cgi-bin/oa/getapprovalinfo";
     String GET_APPROVAL_DETAIL = "/cgi-bin/oa/getapprovaldetail";
+
+    /**
+     * 公费电话
+     * https://developer.work.weixin.qq.com/document/path/93662
+     */
     String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record";
-    String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail";
-    String APPLY_EVENT = "/cgi-bin/oa/applyevent";
 
+    /**
+     * 日程
+     * https://developer.work.weixin.qq.com/document/path/93624
+     */
     String CALENDAR_ADD = "/cgi-bin/oa/calendar/add";
     String CALENDAR_UPDATE = "/cgi-bin/oa/calendar/update";
     String CALENDAR_GET = "/cgi-bin/oa/calendar/get";
@@ -115,7 +134,11 @@ public interface WxCpApiPathConsts {
     String SCHEDULE_DEL = "/cgi-bin/oa/schedule/del";
     String SCHEDULE_LIST = "/cgi-bin/oa/schedule/get_by_calendar";
 
-    String COPY_TEMPLATE = "/cgi-bin/oa/approval/copytemplate";
+    /**
+     * 审批流程引擎
+     * https://developer.work.weixin.qq.com/document/path/90269
+     */
+    String GET_OPEN_APPROVAL_DATA = "/cgi-bin/corp/getopenapprovaldata";
   }
 
   interface Living {

ファイルの差分が大きいため隠しています
+ 59 - 0
weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpOaAgentTest.java