Skip to content

Commit 0af608f

Browse files
authored
🆕 #1947 【企业微信】第三方应用增加用户管理、OA、外部联系人、部门、通讯录搜索等相关接口的实现
* 修复getSuiteJsApiTicket和getAuthCorpJsApiTicket方法代码错误 * 增加企业微信第三方应用用户管理、oa、外部联系人、部门、通讯录搜索相关接口实现
1 parent e946ce0 commit 0af608f

21 files changed

+1423
-27
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package me.chanjar.weixin.cp.bean;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.experimental.Accessors;
6+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
7+
8+
/**
9+
* @author uianz
10+
* @description
11+
* @since 2020/12/23 下午 02:43
12+
*/
13+
@Data
14+
@Accessors(chain = true)
15+
public class WxCpTpContactSearch {
16+
17+
/**
18+
* 查询的企业corpid
19+
*/
20+
@SerializedName("auth_corpid")
21+
private String authCorpId;
22+
23+
/**
24+
* 搜索关键词。当查询用户时应为用户名称、名称拼音或者英文名;当查询部门时应为部门名称或者部门名称拼音
25+
*/
26+
@SerializedName("query_word")
27+
private String queryWord;
28+
29+
/**
30+
* 查询类型 1:查询用户,返回用户userid列表 2:查询部门,返回部门id列表。 不填该字段或者填0代表同时查询部门跟用户
31+
*/
32+
@SerializedName("query_type")
33+
private Integer type;
34+
35+
/**
36+
* 应用id,若非0则只返回应用可见范围内的用户或者部门信息
37+
*/
38+
@SerializedName("agentid")
39+
private Integer agentId;
40+
41+
/**
42+
* 查询的偏移量,每次调用的offset在上一次offset基础上加上limit
43+
*/
44+
@SerializedName("offset")
45+
private Integer offset;
46+
47+
/**
48+
* 查询返回的最大数量,默认为50,最多为200,查询返回的数量可能小于limit指定的值
49+
*/
50+
@SerializedName("limit")
51+
private Integer limit;
52+
53+
/**
54+
* 如果需要精确匹配用户名称或者部门名称或者英文名,不填则默认为模糊匹配;1:匹配用户名称或者部门名称 2:匹配用户英文名
55+
*/
56+
@SerializedName("full_match_field")
57+
private Integer fullMatchField;
58+
59+
public String toJson() {
60+
return WxCpGsonBuilder.create().toJson(this);
61+
}
62+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package me.chanjar.weixin.cp.bean;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
7+
8+
import java.util.List;
9+
10+
/**
11+
* @author uianz
12+
* @description
13+
* @since 2020/12/23 下午 02:55
14+
*/
15+
@EqualsAndHashCode(callSuper = true)
16+
@Data
17+
public class WxCpTpContactSearchResp extends WxCpBaseResp {
18+
19+
@SerializedName("is_last")
20+
private Boolean isLast;
21+
22+
@SerializedName("query_result")
23+
private QueryResult queryResult;
24+
25+
@Data
26+
public static class QueryResult {
27+
28+
@SerializedName("user")
29+
private User user;
30+
@SerializedName("party")
31+
private Party party;
32+
33+
@Data
34+
public static class User {
35+
@SerializedName("userid")
36+
private List<String> userid;
37+
@SerializedName("open_userid")
38+
private List<String> openUserId;
39+
}
40+
41+
@Data
42+
public static class Party {
43+
@SerializedName("department_id")
44+
private List<Integer> departmentId;
45+
}
46+
47+
}
48+
49+
public static WxCpTpContactSearchResp fromJson(String json) {
50+
return WxCpGsonBuilder.create().fromJson(json, WxCpTpContactSearchResp.class);
51+
}
52+
53+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package me.chanjar.weixin.cp.bean;
2+
3+
import lombok.Data;
4+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* 企业微信的部门.
10+
*
11+
* @author Daniel Qian
12+
*/
13+
@Data
14+
public class WxCpTpDepart implements Serializable {
15+
private static final long serialVersionUID = -5028321625140879571L;
16+
17+
private Integer id;
18+
private String name;
19+
private String enName;
20+
private Integer parentid;
21+
private Integer order;
22+
23+
public static WxCpTpDepart fromJson(String json) {
24+
return WxCpGsonBuilder.create().fromJson(json, WxCpTpDepart.class);
25+
}
26+
27+
public String toJson() {
28+
return WxCpGsonBuilder.create().toJson(this);
29+
}
30+
31+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
package me.chanjar.weixin.cp.bean;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.*;
5+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
6+
7+
import java.util.List;
8+
9+
/**
10+
* <pre>
11+
* 外部联系人详情
12+
* Created by Binary Wang on 2018/9/16.
13+
* 参考文档:https://work.weixin.qq.com/api/doc#13878
14+
* </pre>
15+
*
16+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
17+
*/
18+
@Getter
19+
@Setter
20+
public class WxCpUserExternalContactInfo {
21+
@SerializedName("external_contact")
22+
private ExternalContact externalContact;
23+
24+
@SerializedName("follow_user")
25+
private List<FollowedUser> followedUsers;
26+
27+
@Getter
28+
@Setter
29+
public static class ExternalContact {
30+
@SerializedName("external_userid")
31+
private String externalUserId;
32+
33+
@SerializedName("position")
34+
private String position;
35+
36+
@SerializedName("name")
37+
private String name;
38+
39+
@SerializedName("avatar")
40+
private String avatar;
41+
42+
@SerializedName("corp_name")
43+
private String corpName;
44+
45+
@SerializedName("corp_full_name")
46+
private String corpFullName;
47+
48+
@SerializedName("type")
49+
private Integer type;
50+
51+
@SerializedName("gender")
52+
private Integer gender;
53+
54+
@SerializedName("unionid")
55+
private String unionId;
56+
57+
@SerializedName("external_profile")
58+
private ExternalProfile externalProfile;
59+
}
60+
61+
@Setter
62+
@Getter
63+
public static class ExternalProfile {
64+
@SerializedName("external_attr")
65+
private List<ExternalAttribute> externalAttrs;
66+
}
67+
68+
@Data
69+
@Builder
70+
@NoArgsConstructor
71+
@AllArgsConstructor
72+
public static class ExternalAttribute {
73+
@Setter
74+
@Getter
75+
public static class Text {
76+
private String value;
77+
}
78+
79+
@Setter
80+
@Getter
81+
public static class Web {
82+
private String title;
83+
private String url;
84+
}
85+
86+
@Setter
87+
@Getter
88+
public static class MiniProgram {
89+
@SerializedName("pagepath")
90+
private String pagePath;
91+
private String appid;
92+
private String title;
93+
}
94+
95+
private int type;
96+
97+
private String name;
98+
99+
private Text text;
100+
101+
private Web web;
102+
103+
@SerializedName("miniprogram")
104+
private MiniProgram miniProgram;
105+
}
106+
107+
@Setter
108+
@Getter
109+
public static class FollowedUser {
110+
@SerializedName("userid")
111+
private String userId;
112+
private String remark;
113+
private String description;
114+
@SerializedName("createtime")
115+
private Long createTime;
116+
private String state;
117+
@SerializedName("remark_company")
118+
private String remarkCompany;
119+
@SerializedName("remark_mobiles")
120+
private String[] remarkMobiles;
121+
private Tag[] tags;
122+
@SerializedName("add_way")
123+
private Integer addWay;
124+
@SerializedName("oper_userid")
125+
private String operUserid;
126+
127+
}
128+
129+
public static WxCpUserExternalContactInfo fromJson(String json) {
130+
return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalContactInfo.class);
131+
}
132+
133+
@Setter
134+
@Getter
135+
public static class Tag {
136+
@SerializedName("group_name")
137+
private String groupName;
138+
@SerializedName("tag_name")
139+
private String tagName;
140+
private int type;
141+
}
142+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package me.chanjar.weixin.cp.bean;
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.util.List;
8+
9+
/**
10+
* @description: 登录信息
11+
* @author: Jamie.shi
12+
* @create: 2020-08-03 17:18
13+
**/
14+
@Data
15+
public class WxTpLoginInfo extends WxCpBaseResp {
16+
@SerializedName("usertype")
17+
private Integer userType;
18+
@SerializedName("user_info")
19+
private UserInfo userInfo;
20+
@SerializedName("corp_info")
21+
private CorpInfoBean corpInfo;
22+
@SerializedName("auth_info")
23+
private AuthInfo authInfo;
24+
private List<Agent> agent;
25+
26+
@Data
27+
public static class UserInfo {
28+
@SerializedName("userid")
29+
private String userId;
30+
@SerializedName("open_userid")
31+
private String openUserId;
32+
private String name;
33+
private String avatar;
34+
}
35+
36+
@Data
37+
public static class CorpInfoBean {
38+
@SerializedName("corpid")
39+
private String corpId;
40+
}
41+
42+
@Data
43+
public static class AuthInfo {
44+
private List<Department> department;
45+
46+
@Data
47+
public static class Department {
48+
49+
private int id;
50+
private boolean writable;
51+
}
52+
}
53+
54+
@Data
55+
public static class Agent {
56+
@SerializedName("agentid")
57+
private int agentId;
58+
@SerializedName("auth_type")
59+
private int authType;
60+
}
61+
62+
public static WxTpLoginInfo fromJson(String json) {
63+
return WxCpGsonBuilder.create().fromJson(json, WxTpLoginInfo.class);
64+
}
65+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpTpConfigStorage.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public interface WxCpTpConfigStorage {
6262
String getCorpId();
6363
String getCorpSecret();
6464

65+
/**
66+
* 服务商secret
67+
*/
68+
String getProviderSecret();
69+
6570
/**
6671
* 授权企业的access token相关
6772
*/
@@ -83,6 +88,11 @@ public interface WxCpTpConfigStorage {
8388
boolean isAuthSuiteJsApiTicketExpired(String authCorpId);
8489
void updateAuthSuiteJsApiTicket(String authCorpId, String jsApiTicket, int expiredInSeconds);;
8590

91+
boolean isProviderTokenExpired();
92+
void updateProviderToken(String providerToken, int expiredInSeconds);
93+
94+
String getProviderToken();
95+
8696
/**
8797
* 网络代理相关
8898
*/

0 commit comments

Comments
 (0)