Skip to content

Commit a9b8667

Browse files
authored
🆕 #2942【企业微信】增加企业互联相关接口
1 parent 3acf55a commit a9b8667

26 files changed

+1927
-12
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
import me.chanjar.weixin.common.error.WxErrorException;
4+
import me.chanjar.weixin.cp.bean.corpgroup.*;
5+
6+
import java.util.List;
7+
8+
/**
9+
* @Project: WxJava
10+
* @Package: me.chanjar.weixin.cp.api
11+
* @Description: 企业互联相关接口
12+
* @Author: libo
13+
* @Email: 422423229@qq.com
14+
* @Date: 27/2/2023 9:57 PM
15+
*/
16+
public interface WxCpCorpGroupService {
17+
List<WxCpCorpGroupCorp> listAppShareInfo(Integer agentId,Integer businessType,String corpId,Integer limit,String cursor) throws WxErrorException;
18+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult;
1313
import me.chanjar.weixin.cp.bean.WxCpProviderToken;
1414
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
15+
import me.chanjar.weixin.cp.corpgroup.service.WxCpLinkedCorpService;
1516

1617
/**
1718
* 微信API的Service.
@@ -569,4 +570,11 @@ public interface WxCpService extends WxService {
569570
* @return the meeting service
570571
*/
571572
WxCpMeetingService getMeetingService();
573+
574+
/**
575+
* 企业互联的服务类对象
576+
*
577+
* @return
578+
*/
579+
WxCpCorpGroupService getCorpGroupService();
572580
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult;
2525
import me.chanjar.weixin.cp.bean.WxCpProviderToken;
2626
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
27+
import me.chanjar.weixin.cp.corpgroup.service.WxCpLinkedCorpService;
28+
import me.chanjar.weixin.cp.corpgroup.service.impl.WxCpLinkedCorpServiceImpl;
2729
import org.apache.commons.lang3.StringUtils;
2830

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

7375
private final WxCpMeetingService meetingService = new WxCpMeetingServiceImpl(this);
76+
private final WxCpCorpGroupService corpGroupService = new WxCpCorpGroupServiceImpl(this);
7477

7578
/**
7679
* 全局的是否正在刷新access token的锁.
@@ -672,4 +675,9 @@ public void setExportService(WxCpExportService exportService) {
672675
public WxCpMeetingService getMeetingService() {
673676
return meetingService;
674677
}
678+
679+
@Override
680+
public WxCpCorpGroupService getCorpGroupService() {
681+
return corpGroupService;
682+
}
675683
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package me.chanjar.weixin.cp.api.impl;
2+
3+
import com.google.gson.JsonObject;
4+
import com.google.gson.reflect.TypeToken;
5+
import lombok.RequiredArgsConstructor;
6+
import me.chanjar.weixin.common.error.WxErrorException;
7+
import me.chanjar.weixin.common.util.json.GsonParser;
8+
import me.chanjar.weixin.cp.api.WxCpCorpGroupService;
9+
import me.chanjar.weixin.cp.api.WxCpService;
10+
import me.chanjar.weixin.cp.bean.corpgroup.*;
11+
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
12+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
13+
14+
import java.util.List;
15+
16+
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.CorpGroup.*;
17+
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.LinkedCorp.GET_PERM_LIST;
18+
19+
/**
20+
* @Project: WxJava
21+
* @Package: me.chanjar.weixin.cp.api.impl
22+
* @Description: 企业互联相关接口实现类
23+
* @Author: libo
24+
* @Email: 422423229@qq.com
25+
* @Date: 27/2/2023 10:02 PM
26+
*/
27+
@RequiredArgsConstructor
28+
public class WxCpCorpGroupServiceImpl implements WxCpCorpGroupService {
29+
private final WxCpService cpService;
30+
31+
@Override
32+
public List<WxCpCorpGroupCorp> listAppShareInfo(Integer agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException {
33+
final String url = this.cpService.getWxCpConfigStorage().getApiUrl(LIST_SHARE_APP_INFO);
34+
JsonObject jsonObject = new JsonObject();
35+
jsonObject.addProperty("agentid", agentId);
36+
jsonObject.addProperty("corpid", corpId);
37+
jsonObject.addProperty("business_type", businessType);
38+
jsonObject.addProperty("limit", limit);
39+
jsonObject.addProperty("cursor", cursor);
40+
String responseContent = this.cpService.post(url, jsonObject);
41+
JsonObject tmpJson = GsonParser.parse(responseContent);
42+
43+
return WxCpGsonBuilder.create().fromJson(tmpJson.get("corp_list"),
44+
new TypeToken<List<WxCpCorpGroupCorpListAppShareInfoResp>>() {
45+
}.getType()
46+
);
47+
}
48+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package me.chanjar.weixin.cp.bean.corpgroup;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* @Project: WxJava
12+
* @Package: me.chanjar.weixin.cp.bean.corpgroup
13+
* @Description: 应用类
14+
* @Author: libo
15+
* @Email: 422423229@qq.com
16+
* @Date: 27/2/2023 9:50 PM
17+
*/
18+
@NoArgsConstructor
19+
@Data
20+
public class WxCpCorpGroupCorp implements Serializable {
21+
22+
private static final long serialVersionUID = 6842919838272832415L;
23+
@SerializedName("corpid")
24+
private String corpid;
25+
@SerializedName("corp_name")
26+
private String corpName;
27+
@SerializedName("agentid")
28+
private Integer agentid;
29+
30+
public static WxCpCorpGroupCorp fromJson(String json) {
31+
return WxCpGsonBuilder.create().fromJson(json, WxCpCorpGroupCorp.class);
32+
}
33+
34+
/**
35+
* To json string.
36+
*
37+
* @return the string
38+
*/
39+
public String toJson() {
40+
return WxCpGsonBuilder.create().toJson(this);
41+
}
42+
43+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package me.chanjar.weixin.cp.bean.corpgroup;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @Project: WxJava
10+
* @Package: me.chanjar.weixin.cp.bean.corpgroup
11+
* @Description: 获取下级/下游企业的access_token
12+
* @Author: libo
13+
* @Email: 422423229@qq.com
14+
* @Date: 27/2/2023 9:07 PM
15+
*/
16+
@Data
17+
public class WxCpCorpGroupCorpGetTokenReq implements Serializable {
18+
private static final long serialVersionUID = -1876754768932436524L;
19+
@SerializedName("corpid")
20+
private String corpId;
21+
@SerializedName("business_type")
22+
private int businessType;
23+
@SerializedName("agentid")
24+
private int agentId;
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package me.chanjar.weixin.cp.bean.corpgroup;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
6+
7+
import java.io.Serializable;
8+
import java.util.List;
9+
10+
/**
11+
* @Project: WxJava
12+
* @Package: me.chanjar.weixin.cp.bean.corpgroup
13+
* @Description: 获取应用共享信息返回类
14+
* @Author: libo
15+
* @Email: 422423229@qq.com
16+
* @Date: 27/2/2023 9:02 PM
17+
*/
18+
@Data
19+
public class WxCpCorpGroupCorpListAppShareInfoResp implements Serializable {
20+
private static final long serialVersionUID = 7165788382879237583L;
21+
@SerializedName("ending")
22+
private int ending;
23+
@SerializedName("corp_list")
24+
private List<WxCpCorpGroupCorp> corpList;
25+
@SerializedName("next_cursor")
26+
private String nextCursor;
27+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package me.chanjar.weixin.cp.bean.corpgroup;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
6+
7+
import java.io.Serializable;
8+
9+
/**
10+
* @Project: WxJava
11+
* @Package: me.chanjar.weixin.cp.bean.corpgroup
12+
* @Description: 获取下级/下游企业的access_token返回类
13+
* @Author: libo
14+
* @Email: 422423229@qq.com
15+
* @Date: 27/2/2023 9:07 PM
16+
*/
17+
@Data
18+
public class WxCpCorpGroupCorpToken implements Serializable {
19+
private static final long serialVersionUID = -8139617060677460515L;
20+
@SerializedName("access_token")
21+
private String accessToken;
22+
@SerializedName("expires_in")
23+
private int expiresIn;
24+
25+
public static WxCpCorpGroupCorpToken fromJson(String json) {
26+
return WxCpGsonBuilder.create().fromJson(json, WxCpCorpGroupCorpToken.class);
27+
}
28+
29+
/**
30+
* To json string.
31+
*
32+
* @return the string
33+
*/
34+
public String toJson() {
35+
return WxCpGsonBuilder.create().toJson(this);
36+
}
37+
38+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package me.chanjar.weixin.cp.bean.corpgroup;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import me.chanjar.weixin.cp.bean.WxCpAgent;
6+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* @Project: WxJava
12+
* @Package: me.chanjar.weixin.cp.bean.corpgroup
13+
* @Description: 获取下级/下游企业小程序session返回类
14+
* @Author: libo
15+
* @Email: 422423229@qq.com
16+
* @Date: 27/2/2023 9:10 PM
17+
*/
18+
@Data
19+
public class WxCpMaTransferSession implements Serializable {
20+
21+
private static final long serialVersionUID = 4189407986285166516L;
22+
@SerializedName("userid")
23+
private String userId;
24+
@SerializedName("session_key")
25+
private String sessionKey;
26+
27+
28+
/**
29+
* From json WxCpMaTransferSession.
30+
*
31+
* @param json the json
32+
* @return the WxCpMaTransferSession
33+
*/
34+
public static WxCpMaTransferSession fromJson(String json) {
35+
return WxCpGsonBuilder.create().fromJson(json, WxCpMaTransferSession.class);
36+
}
37+
38+
/**
39+
* To json string.
40+
*
41+
* @return the string
42+
*/
43+
public String toJson() {
44+
return WxCpGsonBuilder.create().toJson(this);
45+
}
46+
47+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package me.chanjar.weixin.cp.bean.linkedcorp;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @Project: WxJava
10+
* @Package: me.chanjar.weixin.cp.bean.linkedcorp
11+
* @Description: 获取应用可见范围请求类
12+
* @Author: libo
13+
* @Email: 422423229@qq.com
14+
* @Date: 28/2/2023 6:16 PM
15+
*/
16+
@Data
17+
public class WxCpLinkedCorpAgentPerm implements Serializable {
18+
private static final long serialVersionUID = 6794613362541093845L;
19+
@SerializedName("userids")
20+
private String[] userIdList;
21+
@SerializedName("department_ids")
22+
private String[] departmentIdList;
23+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package me.chanjar.weixin.cp.bean.linkedcorp;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
import lombok.experimental.Accessors;
9+
10+
import java.io.Serializable;
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
14+
/**
15+
* @Project: WxJava
16+
* @Package: me.chanjar.weixin.cp.bean.linkedcorp
17+
* @Description: 获取互联企业部门列表
18+
* @Author: libo
19+
* @Email: 422423229@qq.com
20+
* @Date: 28/2/2023 6:16 PM
21+
*/
22+
@Data
23+
public class WxCpLinkedCorpDepartment implements Serializable {
24+
private static final long serialVersionUID = -210249269343292440L;
25+
@SerializedName("department_id")
26+
private String departmentId;
27+
@SerializedName("department_name")
28+
private String departmentName;
29+
@SerializedName("parentid")
30+
private String parentId;
31+
@SerializedName("order")
32+
private Integer order;
33+
}

0 commit comments

Comments
 (0)