语雀javaSDK

支持语雀全部api接口,纯java编写,项目已上传至maven中央仓库,可直接maven引用。

源码地址

包引用

1
2
3
4
5
<dependency>
<groupId>com.bumao.models.yuquesdk</groupId>
<artifactId>yuquesdk</artifactId>
<version>0.0.1</version>
</dependency>

使用方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
YuqueClient client = new YuqueClient("yuque-token");

System.out.println("--获取某个用户信息 by Id--");
UserDetailSerializer userDetailSerializer = client.getUserInfoById("1757692");
System.out.println(userDetailSerializer);

System.out.println("--获取某个用户信息 by Login--");
UserDetailSerializer user1 = client.getUserInfoByLogin("zhangxin_ux");
System.out.println(user1);
System.out.println(JSONObject.toJSONString(user1) );

System.out.println("--获取当前用户信息--");
UserDetailSerializer user2 = client.getCurrUserInfo();
System.out.println(user2);

System.out.println("--获取某个用户的加入的组织列表 by Id--");
List<GroupSerializer> groupList = client.listJoinedGroupById("1757692");
System.out.println(groupList);

System.out.println("--获取某个用户的加入的组织列表 by Login--");
List<GroupSerializer> groupList1 = client.listJoinedGroupByLogin("u1486894");
System.out.println(groupList1);

System.out.println("--获取公开组织列表--");
List<GroupSerializer> groupList3 = client.listPublicGroup();
System.out.println(groupList3);
System.out.println(groupList3.size());

List<GroupSerializer> groupList2 = client.listPublicGroup(99);
System.out.println(groupList2);
System.out.println(groupList2.size());

System.out.println("--获取单个组织的详细信息--");
GroupDetailVo groupDetailVo = client.getGroupInfoById("antv");
System.out.println(groupDetailVo.getData());
System.out.println(groupDetailVo.getAbilities());

System.out.println("--创建组织--");
GroupCreatePo createPo = new GroupCreatePo();
createPo.setName("firstGroup1");
createPo.setLogin("firstGroup2");
createPo.setDescription("firstGroup");
try {
GroupSerializer newGroup = client.createGroup(createPo);
System.out.println(newGroup);
}catch (YuqueException e){
System.out.println(e);
System.out.println("创建组织错误:httpCode="+e.getHttpCode()+",code="+e.getOrigCode()+",message="+e.getOrigMsg());
}

System.out.println("--更新组织--");
GroupCreatePo updatePo = new GroupCreatePo();
updatePo.setName("first被更新");
updatePo.setLogin("firstGroup2");
updatePo.setDescription("1234567890");
try {
GroupSerializer newGroup = client.updateGroupById("21807875",updatePo);
System.out.println(newGroup);
}catch (YuqueException e){
System.out.println(e);
if(e.getHttpCode().equals(400)) {
System.out.println("更新组织错误:httpCode=" + e.getHttpCode() + ",code=" + e.getOrigCode() + ",message=" + e.getOrigMsg());
}
}

System.out.println("--删除组织--");
try {
client.deleteGroupById("21807875");
}catch (YuqueException e){
System.out.println(e);
}

System.out.println("--获取组织成员信息--");
List<GroupUserSerializer> groupUserSerializerList = client.listGroupUserById("firstGroup");
System.out.println(groupUserSerializerList);

System.out.println("--增加或更新组织成员--");
GroupUserSerializer UpgroupUserSerializer = client.updateGroupUserbyId("firstGroup","zhangxin_ux",1);
System.out.println(UpgroupUserSerializer);

System.out.println("--删除组织成员--");
GroupUserSerializer DelgroupUserSerializer = client.deleteGroupUserbyId("firstGroup","zhangxin_ux");
System.out.println(DelgroupUserSerializer);

System.out.println("--获取某个用户的知识库列表 by Id--");
List<BookSerializer> bookSerializerList = client.listUserReposById("u1486894","all",0);
System.out.println(bookSerializerList);

System.out.println("--获取某个团队的知识库列表 by Id--");
List<BookSerializer> groupbookSerializerList = client.listGroupReposById("firstgroup","all",0);
System.out.println(groupbookSerializerList);

System.out.println("--往团队创建知识库 by Id--");
RepoCreatePo createPo = new RepoCreatePo();
createPo.setDescription("介绍");
createPo.setName("名称");
createPo.setPublic_id(1);
createPo.setSlug("abc");
createPo.setType("Book");
BookSerializer bookSerializer = client.createGroupRepoById("firstgroup",createPo);
System.out.println(bookSerializer);

System.out.println("--往自己下面创建知识库 by Id--");
RepoCreatePo cPo = new RepoCreatePo();
cPo.setDescription("介绍");
cPo.setName("名称");
cPo.setPublic_id(1);
cPo.setSlug("abc");
cPo.setType("Book");
BookSerializer bookSerializer = client.createUserRepoById("u1486894",cPo);
System.out.println(bookSerializer);

System.out.println("--获取知识库详情 by Id--");
BookDetailVo bookDetailVo = client.getRepoDetailById("20113349");
System.out.println(bookDetailVo.getData());//repo
System.out.println(bookDetailVo.getAbilities());//Abilities

System.out.println("--更新知识库信息 by repoId--");
RepoCreatePo upPo = new RepoCreatePo();
upPo.setDescription("介绍");
upPo.setName("名称");
upPo.setPublic_id(0);
upPo.setSlug("abc");
upPo.setType("Book");
BookSerializer bookSerializerUp = client.updateRepoById("20167466",upPo);
System.out.println(bookSerializerUp);

System.out.println("--删除知识库 by repoId--");
BookSerializer bookSerializerDel = client.deleteRepoById("u1486894/slug");
System.out.println(bookSerializerDel);

System.out.println("--获取某仓库的目录 by nameSpace--");
List<TocSerializer> tocSerializerList = client.listTocByNameSpace("u1486894/nn3k9e");
System.out.println(tocSerializerList);

System.out.println("--获取一个仓库的文档列表 by nameSpace--");
List<DocSerializer> docSerializerList = client.listDocByNameSpace("20113349");
System.out.println(docSerializerList);

System.out.println("--获取单篇文档的详细信息 by slug--");
DocDetailVo docDetailVo = client.getDocDetailBySlug("u1486894/nn3k9e","hgg9lg");
System.out.println(docDetailVo.getData());//文章
System.out.println(docDetailVo.getAbilities());//Abilities

System.out.println("--创建文档 by nameSpace--");
DocCreatePo createPo = new DocCreatePo();
createPo.setTitle("helloword");
createPo.setSlug("helloword1");
createPo.setPublic_id(1);
createPo.setFormat("markdown");
createPo.setBody("#helloword");
DocSerializer docSerializerCreate = client.createDocByNameSpace("u1486894/nn3k9e",createPo);
System.out.println(docSerializerCreate);

System.out.println("--更新文档 by nameSpace--");
DocCreatePo upPo = new DocCreatePo();
upPo.setTitle("helloword");
upPo.setSlug("helloword1");
upPo.setPublic_id(1);
upPo.setFormat("markdown");
upPo.setBody("# helloword11111111");
DocSerializer docSerializerUp = client.updateDocByNameSpace("u1486894/nn3k9e","46939700",upPo);
System.out.println(docSerializerUp);

System.out.println("--删除文档 by repoId--");
DocSerializer docSerializerDel = client.deleteDocByRepoId("20113349","46939326");
System.out.println(docSerializerDel);

System.out.println("--搜索--");
SearchPo searchPo = new SearchPo();
searchPo.setType("doc");
searchPo.setQ("世界上最好的语言");
JSONObject obj = client.listSearch(searchPo);
System.out.println(obj);