-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
314 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app-stream-api/src/main/java/com/dingtalk/open/app/api/callback/DingTalkStreamTopics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.dingtalk.open.app.api.callback; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class DingTalkStreamTopics { | ||
/** | ||
* 机器人回调topic | ||
*/ | ||
public static final String BOT_MESSAGE_TOPIC = "/v1.0/im/bot/messages/get"; | ||
/** | ||
* 卡片回调topic | ||
*/ | ||
public static final String CARD_CALLBACK_TOPIC = "/v1.0/card/instances/callback"; | ||
/** | ||
* 卡片数据源topic | ||
*/ | ||
public static final String CARD_DYNAMIC_TOPIC = "/v1.0/card/dynamicData/get"; | ||
/** | ||
* graph接口回调 | ||
*/ | ||
public static final String GRAPH_API_TOPIC = "/v1.0/graph/api/invoke"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app-stream-api/src/main/java/com/dingtalk/open/app/api/graph/GraphAPIMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.dingtalk.open.app.api.graph; | ||
|
||
import com.alibaba.fastjson.annotation.JSONField; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
class GraphAPIMessage { | ||
private Map<String, String> headers; | ||
private String body; | ||
|
||
public Map<String, String> getHeaders() { | ||
return headers; | ||
} | ||
|
||
public void setHeaders(Map<String, String> headers) { | ||
this.headers = headers; | ||
} | ||
|
||
public String getBody() { | ||
return body; | ||
} | ||
|
||
public void setBody(String body) { | ||
this.body = body; | ||
} | ||
|
||
@JSONField(serialize = false) | ||
public String getHeader(String name) { | ||
if (name == null || headers == null || headers.isEmpty()) { | ||
return null; | ||
} | ||
return headers.get(name); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app-stream-api/src/main/java/com/dingtalk/open/app/api/graph/GraphAPIMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.dingtalk.open.app.api.graph; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public enum GraphAPIMethod { | ||
GET, | ||
|
||
POST | ||
} |
18 changes: 18 additions & 0 deletions
18
app-stream-api/src/main/java/com/dingtalk/open/app/api/graph/GraphAPIRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.dingtalk.open.app.api.graph; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class GraphAPIRequest extends GraphAPIMessage { | ||
|
||
private RequestLine requestLine; | ||
|
||
public RequestLine getRequestLine() { | ||
return requestLine; | ||
} | ||
|
||
public void setRequestLine(RequestLine requestLine) { | ||
this.requestLine = requestLine; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app-stream-api/src/main/java/com/dingtalk/open/app/api/graph/GraphAPIResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.dingtalk.open.app.api.graph; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class GraphAPIResponse extends GraphAPIMessage { | ||
|
||
private StatusLine statusLine; | ||
|
||
public StatusLine getStatusLine() { | ||
return statusLine; | ||
} | ||
|
||
public void setStatusLine(StatusLine statusLine) { | ||
this.statusLine = statusLine; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app-stream-api/src/main/java/com/dingtalk/open/app/api/graph/GraphHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.dingtalk.open.app.api.graph; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class GraphHeaders { | ||
|
||
|
||
public static final String CONTENT_TYPE_NAME = "content-type"; | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
app-stream-api/src/main/java/com/dingtalk/open/app/api/graph/MediaType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.dingtalk.open.app.api.graph; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class MediaType { | ||
|
||
|
||
public final static String APPLICATION_JSON_VALUE = "application/json"; | ||
|
||
|
||
} |
50 changes: 50 additions & 0 deletions
50
app-stream-api/src/main/java/com/dingtalk/open/app/api/graph/RequestLine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.dingtalk.open.app.api.graph; | ||
|
||
import com.alibaba.fastjson.annotation.JSONField; | ||
|
||
import java.net.URI; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class RequestLine { | ||
/** | ||
* 请求方法 | ||
*/ | ||
private GraphAPIMethod method; | ||
/** | ||
* 请求uri | ||
*/ | ||
private URI uri; | ||
public GraphAPIMethod getMethod() { | ||
return method; | ||
} | ||
public void setMethod(GraphAPIMethod method) { | ||
this.method = method; | ||
} | ||
public URI getUri() { | ||
return uri; | ||
} | ||
public void setUri(URI uri) { | ||
this.uri = uri; | ||
} | ||
|
||
/** | ||
* 获取请求路径 | ||
* @return | ||
*/ | ||
@JSONField(serialize = false) | ||
public String getPath() { | ||
return uri == null ? "" : uri.getPath(); | ||
} | ||
|
||
/** | ||
* 获取请求参数 | ||
* @return | ||
*/ | ||
@JSONField(serialize = false) | ||
public String getQuery() { | ||
return uri == null ? "" : uri.getQuery(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
app-stream-api/src/main/java/com/dingtalk/open/app/api/graph/StatusLine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.dingtalk.open.app.api.graph; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class StatusLine { | ||
|
||
public static final StatusLine OK = new StatusLine(200, "OK"); | ||
|
||
public static final StatusLine NOT_FOUND = new StatusLine(404, "NOT FOUND"); | ||
|
||
public static final StatusLine INTERNAL_ERROR = new StatusLine(500, "INTERNAL ERROR"); | ||
|
||
private Integer code; | ||
|
||
private String reasonPhrase; | ||
|
||
public StatusLine() { | ||
|
||
} | ||
|
||
public StatusLine(Integer code, String reasonPhrase) { | ||
this.code = code; | ||
this.reasonPhrase = reasonPhrase; | ||
} | ||
|
||
public Integer getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(Integer code) { | ||
this.code = code; | ||
} | ||
|
||
public String getReasonPhrase() { | ||
return reasonPhrase; | ||
} | ||
|
||
public void setReasonPhrase(String reasonPhrase) { | ||
this.reasonPhrase = reasonPhrase; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app-stream-api/src/main/java/com/dingtalk/open/app/api/models/ai/AIPluginHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.dingtalk.open.app.api.models.ai; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class AIPluginHeaders { | ||
/** | ||
* plugin identity | ||
*/ | ||
public static final String PLUGIN_ID_NAME = "x-plugin-id"; | ||
/** | ||
* plugin version | ||
*/ | ||
public static final String PLUGIN_VERSION_NAME = "x-plugin-version"; | ||
/** | ||
* ability identity | ||
*/ | ||
public static final String ABILITY_KEY_NAME = "x-ability-key"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app-stream-api/src/main/java/com/dingtalk/open/app/api/util/GraphUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.dingtalk.open.app.api.util; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.dingtalk.open.app.api.graph.GraphAPIResponse; | ||
import com.dingtalk.open.app.api.graph.GraphHeaders; | ||
import com.dingtalk.open.app.api.graph.MediaType; | ||
import com.dingtalk.open.app.api.graph.StatusLine; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author feiyin | ||
* @date 2023/9/22 | ||
*/ | ||
public class GraphUtils { | ||
|
||
/** | ||
* 返回成功json | ||
* | ||
* @param result | ||
* @return | ||
*/ | ||
public static GraphAPIResponse successJson(Object result) { | ||
GraphAPIResponse response = baseResponse(StatusLine.OK); | ||
response.setBody(JSON.toJSONString(result)); | ||
return response; | ||
} | ||
|
||
public static GraphAPIResponse failed(StatusLine statusLine) { | ||
return baseResponse(statusLine); | ||
} | ||
|
||
private static GraphAPIResponse baseResponse(StatusLine statusLine) { | ||
Map<String, String> headers = new HashMap<>(); | ||
headers.put(GraphHeaders.CONTENT_TYPE_NAME, MediaType.APPLICATION_JSON_VALUE); | ||
GraphAPIResponse response = new GraphAPIResponse(); | ||
response.setHeaders(headers); | ||
response.setStatusLine(statusLine); | ||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.