parent
2c0007af12
commit
3730eda6ad
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
Binary file not shown.
@ -0,0 +1,18 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
|
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.5</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.flyingbook</groupId>
|
||||
<artifactId>ruoyi-flyingbook</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>ruoyi-flyingbook</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--飞书-->
|
||||
<dependency>
|
||||
<groupId>com.larksuite.oapi</groupId>
|
||||
<artifactId>oapi-sdk</artifactId>
|
||||
<version>2.0.13</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>oapi-sdk-servlet-ext</artifactId>
|
||||
<groupId>com.larksuite.oapi</groupId>
|
||||
<version>1.0.0-rc3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>oapi-sdk</artifactId>
|
||||
<groupId>com.larksuite.oapi</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,21 @@
|
||||
package com.flyingbook;
|
||||
|
||||
import com.lark.oapi.sdk.servlet.ext.ServletAdapter;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class RuoyiFlyingbookApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RuoyiFlyingbookApplication.class, args);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public ServletAdapter getServletAdapter() {
|
||||
return new ServletAdapter();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.flyingbook.config;
|
||||
|
||||
|
||||
import com.lark.oapi.Client;
|
||||
import com.lark.oapi.core.request.RequestOptions;
|
||||
import com.lark.oapi.core.utils.Jsons;
|
||||
import com.lark.oapi.core.utils.Lists;
|
||||
import com.lark.oapi.service.docx.v1.model.CreateDocumentReq;
|
||||
import com.lark.oapi.service.docx.v1.model.CreateDocumentReqBody;
|
||||
import com.lark.oapi.service.docx.v1.model.CreateDocumentResp;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
public class DocxSample {
|
||||
|
||||
public static void main(String arg[]) throws Exception {
|
||||
// 构建client
|
||||
Client client = Client.newBuilder("appId", "appSecret").build();
|
||||
|
||||
// 创建自定义 Headers
|
||||
Map<String, List<String>> headers = new HashMap<>();
|
||||
headers.put("key1", Lists.newArrayList("value1"));
|
||||
headers.put("key2", Lists.newArrayList("value2"));
|
||||
|
||||
// 发起请求
|
||||
CreateDocumentResp resp = client.docx().document()
|
||||
.create(CreateDocumentReq.newBuilder()
|
||||
.createDocumentReqBody(CreateDocumentReqBody.newBuilder()
|
||||
.title("cli_a482a8572cbc9013")
|
||||
.folderToken("lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos")
|
||||
.build())
|
||||
.build()
|
||||
, RequestOptions.newBuilder()
|
||||
.userAccessToken("lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos") // 传递用户token
|
||||
.headers(headers) // 传递自定义 Headers
|
||||
.build());
|
||||
|
||||
// 处理服务端错误
|
||||
if (!resp.success()) {
|
||||
System.out.println(String.format("code:%s,msg:%s,reqId:%s"
|
||||
, resp.getCode(), resp.getMsg(), resp.getRequestId()));
|
||||
return;
|
||||
}
|
||||
|
||||
// 业务数据处理
|
||||
System.out.println(Jsons.DEFAULT.toJson(resp.getData()));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
package com.flyingbook.config;
|
||||
import com.lark.oapi.Client;
|
||||
import com.lark.oapi.core.enums.AppType;
|
||||
import com.lark.oapi.core.response.RawResponse;
|
||||
import com.lark.oapi.core.token.AccessTokenType;
|
||||
import com.lark.oapi.core.utils.Jsons;
|
||||
import com.lark.oapi.service.im.v1.enums.MsgTypeEnum;
|
||||
import com.lark.oapi.service.im.v1.model.ext.MessageText;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class RawApiCall {
|
||||
|
||||
/**
|
||||
* 原生http 调用方式
|
||||
*/
|
||||
|
||||
public static void main(String arg[]) throws Exception {
|
||||
// 构建client
|
||||
Client client = Client.newBuilder("appId", "appSecret").build();
|
||||
|
||||
// 构建http body
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("receive_id", "ou_c245b0a7dff2725cfa2fb104f8b48b9d");
|
||||
body.put("content", MessageText.newBuilder()
|
||||
.atUser("ou_155184d1e73cbfb8973e5a9e698e74f2", "Tom")
|
||||
.text("test content")
|
||||
.build());
|
||||
body.put("msg_type", MsgTypeEnum.MSG_TYPE_TEXT);
|
||||
|
||||
// 发起请求
|
||||
RawResponse resp = client.post(
|
||||
"https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal"
|
||||
, body
|
||||
, AccessTokenType.Tenant);
|
||||
|
||||
// 处理结果
|
||||
System.out.println(resp.getStatusCode());
|
||||
System.out.println(Jsons.DEFAULT.toJson(resp.getHeaders()));
|
||||
System.out.println(new String(resp.getBody()));
|
||||
System.out.println(resp.getRequestID());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
package com.flyingbook.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.lark.oapi.core.utils.Jsons;
|
||||
import com.lark.oapi.event.EventDispatcher;
|
||||
import com.lark.oapi.service.contact.v3.ContactService;
|
||||
import com.lark.oapi.service.contact.v3.model.P2UserCreatedV3;
|
||||
import com.lark.oapi.service.im.v1.ImService;
|
||||
import com.lark.oapi.service.im.v1.model.P1MessageReadV1;
|
||||
import com.lark.oapi.service.im.v1.model.P2MessageReadV1;
|
||||
import com.lark.oapi.service.im.v1.model.P2MessageReceiveV1;
|
||||
import com.lark.oapi.sdk.servlet.ext.ServletAdapter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
|
||||
@RestController
|
||||
public class EventController {
|
||||
|
||||
//1. 注册消息处理器
|
||||
private final EventDispatcher EVENT_DISPATCHER = EventDispatcher.newBuilder("verificationToken",
|
||||
"encryptKey")
|
||||
.onP2MessageReceiveV1(new ImService.P2MessageReceiveV1Handler() {
|
||||
@Override
|
||||
public void handle(P2MessageReceiveV1 event) {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP2UserCreatedV3(new ContactService.P2UserCreatedV3Handler() {
|
||||
@Override
|
||||
public void handle(P2UserCreatedV3 event) {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
})
|
||||
.onP2MessageReadV1(new ImService.P2MessageReadV1Handler() {
|
||||
@Override
|
||||
public void handle(P2MessageReadV1 event) {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1MessageReadV1(new ImService.P1MessageReadV1Handler() {
|
||||
@Override
|
||||
public void handle(P1MessageReadV1 event) {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
//2. 注入 ServletAdapter 实例
|
||||
@Autowired
|
||||
private ServletAdapter servletAdapter;
|
||||
|
||||
//3. 创建路由处理器
|
||||
@RequestMapping("/webhook/event")
|
||||
public void event(HttpServletRequest request, HttpServletResponse response)
|
||||
throws Throwable {
|
||||
//3.1 回调扩展包提供的事件回调处理器
|
||||
servletAdapter.handleEvent(request, response, EVENT_DISPATCHER);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,179 @@
|
||||
package com.flyingbook.controller;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.lark.oapi.core.utils.Jsons;
|
||||
import com.lark.oapi.event.EventDispatcher;
|
||||
import com.lark.oapi.sdk.servlet.ext.ServletAdapter;
|
||||
import com.lark.oapi.service.application.v6.ApplicationService.P1AppOpenV6Handler;
|
||||
import com.lark.oapi.service.application.v6.ApplicationService.P1AppStatusChangedV6Handler;
|
||||
import com.lark.oapi.service.application.v6.ApplicationService.P1AppUninstalledV6Handler;
|
||||
import com.lark.oapi.service.application.v6.ApplicationService.P1OrderPaidV6Handler;
|
||||
import com.lark.oapi.service.application.v6.model.P1AppOpenV6;
|
||||
import com.lark.oapi.service.application.v6.model.P1AppStatusChangedV6;
|
||||
import com.lark.oapi.service.application.v6.model.P1AppUninstalledV6;
|
||||
import com.lark.oapi.service.application.v6.model.P1OrderPaidV6;
|
||||
import com.lark.oapi.service.approval.v4.ApprovalService.*;
|
||||
import com.lark.oapi.service.approval.v4.model.*;
|
||||
import com.lark.oapi.service.contact.v3.ContactService.*;
|
||||
import com.lark.oapi.service.contact.v3.model.*;
|
||||
import com.lark.oapi.service.im.v1.ImService.*;
|
||||
import com.lark.oapi.service.im.v1.model.*;
|
||||
import com.lark.oapi.service.meeting_room.v1.MeetingRoomService.P1ThirdPartyMeetingRoomChangedV1Handler;
|
||||
import com.lark.oapi.service.meeting_room.v1.model.P1ThirdPartyMeetingRoomChangedV1;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RestController
|
||||
public class EventControllers {
|
||||
|
||||
|
||||
//1. 注册消息处理器
|
||||
private final EventDispatcher EVENT_DISPATCHER = EventDispatcher.newBuilder("xJJE7c2rlHzDCk2uPZk77fQNJFtXgTW3",
|
||||
"ND2ANZB8F7NplUqcrmKD530lDRFssNWJ")
|
||||
.onP2MessageReceiveV1(new P2MessageReceiveV1Handler() {
|
||||
@Override
|
||||
public void handle(P2MessageReceiveV1 event) throws Exception {
|
||||
// 处理消息
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP2UserCreatedV3(new P2UserCreatedV3Handler() {
|
||||
@Override
|
||||
public void handle(P2UserCreatedV3 event) {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
})
|
||||
.onP2MessageReadV1(new P2MessageReadV1Handler() {
|
||||
@Override
|
||||
public void handle(P2MessageReadV1 event) {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1MessageReadV1(new P1MessageReadV1Handler() {
|
||||
@Override
|
||||
public void handle(P1MessageReadV1 event) {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1MessageReceivedV1(new P1MessageReceivedV1Handler() {
|
||||
@Override
|
||||
public void handle(P1MessageReceivedV1 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1UserChangedV3(new P1UserChangedV3Handler() {
|
||||
@Override
|
||||
public void handle(P1UserChangedV3 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1UserStatusChangedV3(new P1UserStatusChangedV3Handler() {
|
||||
@Override
|
||||
public void handle(P1UserStatusChangedV3 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1DepartmentChangedV3(new P1DepartmentChangedV3Handler() {
|
||||
@Override
|
||||
public void handle(P1DepartmentChangedV3 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1ContactScopeChangedV3(new P1ContactScopeChangedV3Handler() {
|
||||
@Override
|
||||
public void handle(P1ContactScopeChangedV3 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1P2PChatCreatedV1(new P1P2PChatCreatedV1Handler() {
|
||||
@Override
|
||||
public void handle(P1P2PChatCreatedV1 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1ThirdPartyMeetingRoomChangedV1(new P1ThirdPartyMeetingRoomChangedV1Handler() {
|
||||
@Override
|
||||
public void handle(P1ThirdPartyMeetingRoomChangedV1 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1LeaveApprovalV4(new P1LeaveApprovalV4Handler() {
|
||||
@Override
|
||||
public void handle(P1LeaveApprovalV4 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1WorkApprovalV4(new P1WorkApprovalV4Handler() {
|
||||
@Override
|
||||
public void handle(P1WorkApprovalV4 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1ShiftApprovalV4(new P1ShiftApprovalV4Handler() {
|
||||
@Override
|
||||
public void handle(P1ShiftApprovalV4 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1RemedyApprovalV4(new P1RemedyApprovalV4Handler() {
|
||||
@Override
|
||||
public void handle(P1RemedyApprovalV4 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1TripApprovalV4(new P1TripApprovalV4Handler() {
|
||||
@Override
|
||||
public void handle(P1TripApprovalV4 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1OutApprovalV4(new P1OutApprovalV4Handler() {
|
||||
@Override
|
||||
public void handle(P1OutApprovalV4 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1AppOpenV6(new P1AppOpenV6Handler() {
|
||||
@Override
|
||||
public void handle(P1AppOpenV6 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1AppStatusChangedV6(new P1AppStatusChangedV6Handler() {
|
||||
@Override
|
||||
public void handle(P1AppStatusChangedV6 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1OrderPaidV6(new P1OrderPaidV6Handler() {
|
||||
@Override
|
||||
public void handle(P1OrderPaidV6 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
}).onP1AppUninstalledV6(new P1AppUninstalledV6Handler() {
|
||||
@Override
|
||||
public void handle(P1AppUninstalledV6 event) throws Exception {
|
||||
System.out.println(Jsons.DEFAULT.toJson(event));
|
||||
System.out.println(event.getRequestId());
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
//2. 注入 ServletAdapter 实例
|
||||
@Autowired
|
||||
private ServletAdapter servletAdapter;
|
||||
|
||||
//3. 创建路由处理器
|
||||
@RequestMapping("/webhook/events")
|
||||
public void event(HttpServletRequest request, HttpServletResponse response)
|
||||
throws Throwable {
|
||||
//3.1 回调扩展包提供的事件回调处理器
|
||||
servletAdapter.handleEvent(request, response, EVENT_DISPATCHER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.flyingbook;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class RuoyiFlyingbookApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue