|
|
|
@ -1,33 +1,15 @@
|
|
|
|
|
package com.ruoyi.flyingbook.controller;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ruoyi.common.utils.DecryptUtil;
|
|
|
|
|
import com.lark.oapi.service.drive.v1.DriveService;
|
|
|
|
|
import com.lark.oapi.service.drive.v1.model.P2FileBitableFieldChangedV1;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
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;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
@ -37,133 +19,11 @@ public class EventControllers {
|
|
|
|
|
//1. 注册消息处理器
|
|
|
|
|
private final EventDispatcher EVENT_DISPATCHER = EventDispatcher.newBuilder("xJJE7c2rlHzDCk2uPZk77fQNJFtXgTW3",
|
|
|
|
|
"ND2ANZB8F7NplUqcrmKD530lDRFssNWJ")
|
|
|
|
|
.onP2MessageReceiveV1(new P2MessageReceiveV1Handler() {
|
|
|
|
|
.onP2FileBitableFieldChangedV1(new DriveService.P2FileBitableFieldChangedV1Handler(){
|
|
|
|
|
@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());
|
|
|
|
|
public void handle(P2FileBitableFieldChangedV1 p2FileBitableFieldChangedV1) throws Exception {
|
|
|
|
|
System.out.println(Jsons.DEFAULT.toJson(p2FileBitableFieldChangedV1));
|
|
|
|
|
System.out.println(p2FileBitableFieldChangedV1.getRequestId());
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.build();
|
|
|
|
@ -172,14 +32,13 @@ public class EventControllers {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ServletAdapter servletAdapter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3. 创建路由处理器
|
|
|
|
|
@PostMapping("/approval2")
|
|
|
|
|
public void event(HttpServletRequest request, HttpServletResponse response)
|
|
|
|
|
throws Throwable {
|
|
|
|
|
//3.1 回调扩展包提供的事件回调处理器
|
|
|
|
|
servletAdapter.handleEvent(request, response, EVENT_DISPATCHER);
|
|
|
|
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
|
|
|
|
log.info("/event/test2/approval request:{}", JSONObject.toJSONString(parameterMap));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|