Skip to content

Commit 584f346

Browse files
committed
node api feature
1 parent 79876b6 commit 584f346

File tree

7 files changed

+394
-0
lines changed

7 files changed

+394
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2021 vikadata, https://vika.cn <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
package cn.vika.client.api;
24+
25+
import java.util.List;
26+
27+
import cn.vika.client.api.http.AbstractApi;
28+
import cn.vika.client.api.http.ApiHttpClient;
29+
import cn.vika.client.api.model.GetNodeResult;
30+
import cn.vika.client.api.model.HttpResult;
31+
import cn.vika.client.api.model.Node;
32+
import cn.vika.client.api.model.NodeDetail;
33+
import cn.vika.client.api.model.NodeTree;
34+
import cn.vika.core.http.GenericTypeReference;
35+
import cn.vika.core.http.HttpHeader;
36+
37+
38+
/**
39+
* the api for operate workbench nodes
40+
*
41+
* @author Zoe Zheng
42+
* @date 2020/12/15 5:14 下午
43+
*/
44+
public class NodeApi extends AbstractApi {
45+
46+
private static final String GET_NODES = "/spaces/%s/nodes";
47+
48+
private static final String GET_NODE = "/spaces/%s/nodes/%s";
49+
50+
public NodeApi(ApiHttpClient apiHttpClient) {
51+
super(apiHttpClient);
52+
}
53+
54+
public List<Node> getNodes(String spaceId) {
55+
GenericTypeReference<HttpResult<GetNodeResult>> reference = new GenericTypeReference<HttpResult<GetNodeResult>>() {};
56+
HttpResult<GetNodeResult> result = getDefaultHttpClient().get(String.format(GET_NODES, spaceId),
57+
new HttpHeader(), reference);
58+
return result.getData().getNodes();
59+
}
60+
61+
public NodeDetail getNode(String spaceId, String nodeId) {
62+
GenericTypeReference<HttpResult<NodeDetail>> reference = new GenericTypeReference<HttpResult<NodeDetail>>() {};
63+
HttpResult<NodeDetail> result = getDefaultHttpClient().get(String.format(GET_NODE, spaceId, nodeId),
64+
new HttpHeader(), reference);
65+
return result.getData();
66+
}
67+
68+
public NodeTree getNodeTree(String spaceId, String nodeId) {
69+
return new NodeTree(this, spaceId, nodeId);
70+
}
71+
72+
}

client/src/main/java/cn/vika/client/api/VikaApiClient.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class VikaApiClient {
4747

4848
private AttachmentApi attachmentApi;
4949

50+
private NodeApi nodeApi;
51+
5052
public VikaApiClient(ApiCredential credential) {
5153
this(ApiVersion.V1, DEFAULT_HOST, credential);
5254
}
@@ -146,4 +148,15 @@ public AttachmentApi getAttachmentApi() {
146148
}
147149
return this.attachmentApi;
148150
}
151+
152+
public NodeApi getNodeApi() {
153+
if (this.nodeApi == null) {
154+
synchronized (this) {
155+
if (this.nodeApi == null) {
156+
this.nodeApi = new NodeApi(this.apiHttpClient);
157+
}
158+
}
159+
}
160+
return this.nodeApi;
161+
}
149162
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2021 vikadata, https://vika.cn <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
package cn.vika.client.api.model;
24+
25+
import java.util.List;
26+
27+
/**
28+
* get node api result data
29+
* @author Shawn Deng
30+
* @date 2021-07-09 14:04:09
31+
*/
32+
public class GetNodeResult {
33+
34+
private List<Node> nodes;
35+
36+
public List<Node> getNodes() {
37+
return nodes;
38+
}
39+
40+
public void setNodes(List<Node> nodes) {
41+
this.nodes = nodes;
42+
}
43+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2021 vikadata, https://vika.cn <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
package cn.vika.client.api.model;
24+
25+
/**
26+
* node object
27+
* @author Shawn Deng
28+
* @date 2021-07-09 13:51:04
29+
*/
30+
public class Node {
31+
32+
private String id;
33+
34+
private String name;
35+
36+
private String type;
37+
38+
private String icon;
39+
40+
private boolean isFav;
41+
42+
public String getId() {
43+
return id;
44+
}
45+
46+
public void setId(String id) {
47+
this.id = id;
48+
}
49+
50+
public String getName() {
51+
return name;
52+
}
53+
54+
public void setName(String name) {
55+
this.name = name;
56+
}
57+
58+
public String getType() {
59+
return type;
60+
}
61+
62+
public void setType(String type) {
63+
this.type = type;
64+
}
65+
66+
public String getIcon() {
67+
return icon;
68+
}
69+
70+
public void setIcon(String icon) {
71+
this.icon = icon;
72+
}
73+
74+
public boolean isFav() {
75+
return isFav;
76+
}
77+
78+
public void setFav(boolean fav) {
79+
isFav = fav;
80+
}
81+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (c) 2021 vikadata, https://vika.cn <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
package cn.vika.client.api.model;
24+
25+
import java.util.List;
26+
27+
/**
28+
*
29+
* @author Shawn Deng
30+
* @date 2021-07-09 14:07:26
31+
*/
32+
public class NodeDetail {
33+
34+
private String id;
35+
36+
private String name;
37+
38+
private String type;
39+
40+
private String icon;
41+
42+
private boolean isFav;
43+
44+
private List<NodeDetail> children;
45+
46+
public String getId() {
47+
return id;
48+
}
49+
50+
public void setId(String id) {
51+
this.id = id;
52+
}
53+
54+
public String getName() {
55+
return name;
56+
}
57+
58+
public void setName(String name) {
59+
this.name = name;
60+
}
61+
62+
public String getType() {
63+
return type;
64+
}
65+
66+
public void setType(String type) {
67+
this.type = type;
68+
}
69+
70+
public String getIcon() {
71+
return icon;
72+
}
73+
74+
public void setIcon(String icon) {
75+
this.icon = icon;
76+
}
77+
78+
public boolean isFav() {
79+
return isFav;
80+
}
81+
82+
public void setFav(boolean fav) {
83+
isFav = fav;
84+
}
85+
86+
public List<NodeDetail> getChildren() {
87+
return children;
88+
}
89+
90+
public void setChildren(List<NodeDetail> children) {
91+
this.children = children;
92+
}
93+
}

0 commit comments

Comments
 (0)