Skip to content

Commit

Permalink
🆕 #2942【企业微信】增加企业互联相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
1ibo authored Mar 5, 2023
1 parent 3acf55a commit a9b8667
Show file tree
Hide file tree
Showing 26 changed files with 1,927 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package me.chanjar.weixin.cp.api;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.corpgroup.*;

import java.util.List;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.api
* @Description: 企业互联相关接口
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 27/2/2023 9:57 PM
*/
public interface WxCpCorpGroupService {
List<WxCpCorpGroupCorp> listAppShareInfo(Integer agentId,Integer businessType,String corpId,Integer limit,String cursor) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult;
import me.chanjar.weixin.cp.bean.WxCpProviderToken;
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
import me.chanjar.weixin.cp.corpgroup.service.WxCpLinkedCorpService;

/**
* 微信API的Service.
Expand Down Expand Up @@ -569,4 +570,11 @@ public interface WxCpService extends WxService {
* @return the meeting service
*/
WxCpMeetingService getMeetingService();

/**
* 企业互联的服务类对象
*
* @return
*/
WxCpCorpGroupService getCorpGroupService();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult;
import me.chanjar.weixin.cp.bean.WxCpProviderToken;
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
import me.chanjar.weixin.cp.corpgroup.service.WxCpLinkedCorpService;
import me.chanjar.weixin.cp.corpgroup.service.impl.WxCpLinkedCorpServiceImpl;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
Expand Down Expand Up @@ -71,6 +73,7 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
private WxCpExportService exportService = new WxCpExportServiceImpl(this);

private final WxCpMeetingService meetingService = new WxCpMeetingServiceImpl(this);
private final WxCpCorpGroupService corpGroupService = new WxCpCorpGroupServiceImpl(this);

/**
* 全局的是否正在刷新access token的锁.
Expand Down Expand Up @@ -672,4 +675,9 @@ public void setExportService(WxCpExportService exportService) {
public WxCpMeetingService getMeetingService() {
return meetingService;
}

@Override
public WxCpCorpGroupService getCorpGroupService() {
return corpGroupService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package me.chanjar.weixin.cp.api.impl;

import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.json.GsonParser;
import me.chanjar.weixin.cp.api.WxCpCorpGroupService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.corpgroup.*;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.util.List;

import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.CorpGroup.*;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.LinkedCorp.GET_PERM_LIST;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.api.impl
* @Description: 企业互联相关接口实现类
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 27/2/2023 10:02 PM
*/
@RequiredArgsConstructor
public class WxCpCorpGroupServiceImpl implements WxCpCorpGroupService {
private final WxCpService cpService;

@Override
public List<WxCpCorpGroupCorp> listAppShareInfo(Integer agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException {
final String url = this.cpService.getWxCpConfigStorage().getApiUrl(LIST_SHARE_APP_INFO);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("agentid", agentId);
jsonObject.addProperty("corpid", corpId);
jsonObject.addProperty("business_type", businessType);
jsonObject.addProperty("limit", limit);
jsonObject.addProperty("cursor", cursor);
String responseContent = this.cpService.post(url, jsonObject);
JsonObject tmpJson = GsonParser.parse(responseContent);

return WxCpGsonBuilder.create().fromJson(tmpJson.get("corp_list"),
new TypeToken<List<WxCpCorpGroupCorpListAppShareInfoResp>>() {
}.getType()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package me.chanjar.weixin.cp.bean.corpgroup;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.io.Serializable;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.bean.corpgroup
* @Description: 应用类
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 27/2/2023 9:50 PM
*/
@NoArgsConstructor
@Data
public class WxCpCorpGroupCorp implements Serializable {

private static final long serialVersionUID = 6842919838272832415L;
@SerializedName("corpid")
private String corpid;
@SerializedName("corp_name")
private String corpName;
@SerializedName("agentid")
private Integer agentid;

public static WxCpCorpGroupCorp fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpCorpGroupCorp.class);
}

/**
* To json string.
*
* @return the string
*/
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.chanjar.weixin.cp.bean.corpgroup;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.io.Serializable;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.bean.corpgroup
* @Description: 获取下级/下游企业的access_token
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 27/2/2023 9:07 PM
*/
@Data
public class WxCpCorpGroupCorpGetTokenReq implements Serializable {
private static final long serialVersionUID = -1876754768932436524L;
@SerializedName("corpid")
private String corpId;
@SerializedName("business_type")
private int businessType;
@SerializedName("agentid")
private int agentId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package me.chanjar.weixin.cp.bean.corpgroup;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;

import java.io.Serializable;
import java.util.List;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.bean.corpgroup
* @Description: 获取应用共享信息返回类
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 27/2/2023 9:02 PM
*/
@Data
public class WxCpCorpGroupCorpListAppShareInfoResp implements Serializable {
private static final long serialVersionUID = 7165788382879237583L;
@SerializedName("ending")
private int ending;
@SerializedName("corp_list")
private List<WxCpCorpGroupCorp> corpList;
@SerializedName("next_cursor")
private String nextCursor;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package me.chanjar.weixin.cp.bean.corpgroup;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.io.Serializable;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.bean.corpgroup
* @Description: 获取下级/下游企业的access_token返回类
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 27/2/2023 9:07 PM
*/
@Data
public class WxCpCorpGroupCorpToken implements Serializable {
private static final long serialVersionUID = -8139617060677460515L;
@SerializedName("access_token")
private String accessToken;
@SerializedName("expires_in")
private int expiresIn;

public static WxCpCorpGroupCorpToken fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpCorpGroupCorpToken.class);
}

/**
* To json string.
*
* @return the string
*/
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package me.chanjar.weixin.cp.bean.corpgroup;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.bean.WxCpAgent;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.io.Serializable;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.bean.corpgroup
* @Description: 获取下级/下游企业小程序session返回类
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 27/2/2023 9:10 PM
*/
@Data
public class WxCpMaTransferSession implements Serializable {

private static final long serialVersionUID = 4189407986285166516L;
@SerializedName("userid")
private String userId;
@SerializedName("session_key")
private String sessionKey;


/**
* From json WxCpMaTransferSession.
*
* @param json the json
* @return the WxCpMaTransferSession
*/
public static WxCpMaTransferSession fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpMaTransferSession.class);
}

/**
* To json string.
*
* @return the string
*/
public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package me.chanjar.weixin.cp.bean.linkedcorp;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.io.Serializable;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.bean.linkedcorp
* @Description: 获取应用可见范围请求类
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 28/2/2023 6:16 PM
*/
@Data
public class WxCpLinkedCorpAgentPerm implements Serializable {
private static final long serialVersionUID = 6794613362541093845L;
@SerializedName("userids")
private String[] userIdList;
@SerializedName("department_ids")
private String[] departmentIdList;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package me.chanjar.weixin.cp.bean.linkedcorp;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.bean.linkedcorp
* @Description: 获取互联企业部门列表
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 28/2/2023 6:16 PM
*/
@Data
public class WxCpLinkedCorpDepartment implements Serializable {
private static final long serialVersionUID = -210249269343292440L;
@SerializedName("department_id")
private String departmentId;
@SerializedName("department_name")
private String departmentName;
@SerializedName("parentid")
private String parentId;
@SerializedName("order")
private Integer order;
}
Loading

0 comments on commit a9b8667

Please sign in to comment.