Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
chzealot committed Nov 10, 2023
2 parents 51b1ebc + 3c7b409 commit e9d9aef
Show file tree
Hide file tree
Showing 26 changed files with 314 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app-stream-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>open-app-stream-client</artifactId>
<groupId>com.dingtalk.open</groupId>
<version>1.0.9</version>
<version>1.1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* @author feiyin
* @date 2023/4/3
*/
public interface OpenDingTalkCallbackListener<Input, Output> extends Serializable {
public interface OpenDingTalkCallbackListener<Request, Response> extends Serializable {

/**
* 执行回调
*
* @param param
* @param request
* @return
*/
Output execute(Input param);
Response execute(Request request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ private static boolean isDecoratingProxy(Object candidate) {

private static boolean instanceOf(Class clazz, String interfaceName) {
Class<?>[] superInterfaces = clazz.getInterfaces();
for (Class<?> interf : superInterfaces) {
if (interf.getCanonicalName().equals(interfaceName)) {
for (Class<?> interfaceClass : superInterfaces) {
if (interfaceClass.getCanonicalName().equals(interfaceName)) {
return true;
}
}
return false;
}

@SuppressWarnings("unchecked")
private static Object invoke(Object object, String clazzName, String methodName, Object... args) {
try {
Class klass = Class.forName(clazzName);
Class<?> klass = Class.forName(clazzName);
Method method = klass.getDeclaredMethod(methodName);
method.setAccessible(true);
return method.invoke(object, args);
Expand Down
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);
}
}
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
}
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;
}
}
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;
}
}
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";

}
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";


}
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();
}
}
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;
}
}
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";

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
* @date 2023/3/1
*/
public class HttpConstants {

public static final String METHOD_POST = "POST";

public static final int CONNECTION_TIME_OUT = 3000;

public static final int READ_TIME_OUT = 3000;

public static final int STATUS_OK = 200;
public static final String HEADER_CONTENT_TYPE = "Content-Type";
public static final String HEADER_ACCEPT = "Accept";
Expand Down
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;
}
}
4 changes: 2 additions & 2 deletions app-stream-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<parent>
<groupId>com.dingtalk.open</groupId>
<artifactId>open-app-stream-client</artifactId>
<version>1.0.9</version>
<version>1.1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>app-stream-client</artifactId>
<packaging>jar</packaging>
<version>1.0.9</version>
<version>1.1.0</version>
<name>app-stream-client</name>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions app-stream-network/app-stream-network-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>com.dingtalk.open</groupId>
<artifactId>app-stream-network</artifactId>
<version>1.0.9</version>
<version>1.1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>app-stream-network-api</artifactId>
<version>1.0.9</version>
<version>1.1.0</version>
<packaging>jar</packaging>

<name>app-stream-network-api</name>
Expand Down
Loading

0 comments on commit e9d9aef

Please sign in to comment.