WIP: test #2

Closed
bob wants to merge 36 commits from test into master

@ -8,6 +8,7 @@
Java 1.8 Java 1.8
## flowable ## flowable
表结构 表结构
act_hi_identitylink 审批任务信息 act_hi_identitylink 审批任务信息

@ -215,6 +215,11 @@
<artifactId>ruoyi-flowable</artifactId> <artifactId>ruoyi-flowable</artifactId>
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-flyingbook</artifactId>
<version>3.4.1-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>org.flowable</groupId> <groupId>org.flowable</groupId>
@ -274,6 +279,7 @@
<module>ruoyi-generator</module> <module>ruoyi-generator</module>
<module>ruoyi-common</module> <module>ruoyi-common</module>
<module>ruoyi-flowable</module> <module>ruoyi-flowable</module>
<module>ruoyi-flyingbook</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>

@ -6,6 +6,6 @@ ARG SPRING_PROFILE
ENV JAVA_OPTS "${JAVA_OPTS} ${CUSTOM_OPTS}" ENV JAVA_OPTS "${JAVA_OPTS} ${CUSTOM_OPTS}"
COPY target/*.jar /javarun COPY *.jar /javarun
CMD ["bash","-c","java ${JAVA_OPTS} -Dspring.profiles.active=${SPRING_PROFILE} -jar /javarun/*.jar"] CMD ["bash","-c","java ${JAVA_OPTS} -Dspring.profiles.active=${SPRING_PROFILE} -jar /javarun/*.jar"]

@ -78,20 +78,14 @@
<artifactId>ruoyi-flowable</artifactId> <artifactId>ruoyi-flowable</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.larksuite.oapi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>oapi-sdk</artifactId> <artifactId>ruoyi-flyingbook</artifactId>
<version>2.0.13</version>
</dependency> </dependency>
<!--飞书-->
<dependency> <dependency>
<groupId>com.larksuite.oapi</groupId> <groupId>com.larksuite.oapi</groupId>
<artifactId>oapi-sdk</artifactId> <artifactId>oapi-sdk</artifactId>
<version>2.0.13</version> <version>2.0.13</version>
</dependency> </dependency>
</dependencies> </dependencies>

@ -18,6 +18,5 @@ public class RuoYiApplication
{ {
// System.setProperty("spring.devtools.restart.enabled", "false"); // System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args); SpringApplication.run(RuoYiApplication.class, args);
log.info("=========================cd auto deploy success=========");
} }
} }

@ -22,3 +22,4 @@ Spring Boot Version: ${spring-boot.version}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG // // 佛祖保佑 永不宕机 永无BUG //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
log.info("=========================cd auto deploy success=========");

@ -0,0 +1,14 @@
package com.ruoyi.common.constant;
/**
* @author yuxiangyong
* @create 2023-03-12 19:30
*/
public class CompanyNameConstants {
/**
*
*/
public static final String COMPANY_NAME = "COMPANY_NAME";
}

@ -0,0 +1,24 @@
package com.ruoyi.common.constant;
/**
* @author yuxiangyong
* @create 2023-03-12 19:30
*/
public class RedisConstants {
public static void main(String[] args) {
System.out.println("multiple tabular feedback".replaceAll(" ","").toUpperCase());
}
/**
* key
*/
public static final String MULTIDIMENSIONALTABULARFEEDBACK = "MULTIDIMENSIONALTABULARFEEDBACK";
/**
*
*/
public static final String MULTIPLE_TABLE_RECORD = "MULTIPLE_TABLE_RECORD";
}

@ -0,0 +1,29 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum AppType {
/**
*
*/
APPROVAL("APPROVAL", "多维表格");
private final String code;
private final String info;
AppType(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -0,0 +1,39 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum CallBackTypeEnum {
/**
*
*/
TABLE_ROW_CHANGE("drive.file.bitable_record_changed_v1", "多维表格行记录变更"),
APPROVAL_TASK("approval_task", "审批事件回调");
private final String code;
private final String info;
CallBackTypeEnum(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
public static CallBackTypeEnum getByCode(String code){
for (CallBackTypeEnum value : CallBackTypeEnum.values()) {
if (value.getCode().equals(code)){
return value;
}
}
return null;
}
}

@ -0,0 +1,31 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum EventOperateStatus {
/**
*
*/
PENDING("PENDING", "未处理"),
SUCCESS("SUCCESS", "处理完成");
private final String code;
private final String info;
EventOperateStatus(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -0,0 +1,32 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum EventOperateType {
/**
*
*/
CALL_BACK("CALL_BACK", "反馈"),
CREATE("CREATE", "创建"),
UPDATE("UPDATE", "更新"),
DELETE("DELETE", "删除");
private final String code;
private final String info;
EventOperateType(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -0,0 +1,31 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum FlagStatus {
/**
*
*/
OK(0L, "正常"),
DELETED(1L, "删除");
private final Long code;
private final String info;
FlagStatus(Long code, String info) {
this.code = code;
this.info = info;
}
public Long getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -0,0 +1,29 @@
package com.ruoyi.common.enums;
/**
* @author ruoyi
*/
public enum TableDetailRelationTypeEnum {
/**
*
*/
ROW("ROW", "行"),
COL("COL", "列");
private final String code;
private final String info;
TableDetailRelationTypeEnum(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -0,0 +1,61 @@
package com.ruoyi.common.utils;
import lombok.extern.slf4j.Slf4j;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
/**
* @author yuxiangyong
* @create 2023-03-12 20:48
*/
@Slf4j
public class DecryptUtil {
public static void main(String[] args) throws Exception {
System.out.println(decrypt("P37w+VZImNgPEO1RBhJ6RtKl7n6zymIbEG1pReEzghk=")); //hello world
}
private static byte[] keyBs;
public DecryptUtil(String key) {
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
// won't happen
}
keyBs = digest.digest(key.getBytes(StandardCharsets.UTF_8));
}
public static String decrypt(String base64) {
try {
DecryptUtil d = new DecryptUtil("ND2ANZB8F7NplUqcrmKD530lDRFssNWJ");
byte[] decode = Base64.getDecoder().decode(base64);
Cipher cipher = Cipher.getInstance("AES/CBC/NOPADDING");
byte[] iv = new byte[16];
System.arraycopy(decode, 0, iv, 0, 16);
byte[] data = new byte[decode.length - 16];
System.arraycopy(decode, 16, data, 0, data.length);
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(keyBs, "AES"), new IvParameterSpec(iv));
byte[] r = cipher.doFinal(data);
if (r.length > 0) {
int p = r.length - 1;
for (; p >= 0 && r[p] <= 16; p--) {
}
if (p != r.length - 1) {
byte[] rr = new byte[p + 1];
System.arraycopy(r, 0, rr, 0, p + 1);
r = rr;
}
}
return new String(r, StandardCharsets.UTF_8);
}catch (Exception e){
log.error("DecryptUtil error",e);
}
return null;
}
}

@ -1,33 +0,0 @@
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.

@ -1,18 +0,0 @@
# 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

@ -3,14 +3,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <artifactId>ruoyi</artifactId>
<artifactId>spring-boot-starter-parent</artifactId> <groupId>com.ruoyi</groupId>
<version>2.5.5</version> <version>3.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>com.flyingbook</groupId> <version>3.4.1-SNAPSHOT</version>
<artifactId>ruoyi-flyingbook</artifactId> <artifactId>ruoyi-flyingbook</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ruoyi-flyingbook</name> <name>ruoyi-flyingbook</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<properties> <properties>
@ -39,7 +37,15 @@
<artifactId>oapi-sdk</artifactId> <artifactId>oapi-sdk</artifactId>
<version>2.0.13</version> <version>2.0.13</version>
</dependency> </dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
</dependency>
<dependency> <dependency>
<artifactId>oapi-sdk-servlet-ext</artifactId> <artifactId>oapi-sdk-servlet-ext</artifactId>
<groupId>com.larksuite.oapi</groupId> <groupId>com.larksuite.oapi</groupId>
@ -55,21 +61,5 @@
</dependencies> </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> </project>

@ -1,65 +0,0 @@
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,138 @@
package com.ruoyi.flyingbook.LarkHelper;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author yuxiangyong
* @create 2023-03-12 18:10
*/
@Slf4j
@Component
public class LarkTokenHelper {
private static OkHttpClient client = new OkHttpClient().newBuilder()
.callTimeout(10, TimeUnit.SECONDS)
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(10, TimeUnit.SECONDS)
.build();
private JSONObject execute(Request request) {
Response execute = null;
JSONObject jsonObject = null;
try {
execute = client.newCall(request).execute();
if (execute == null || execute.body() == null){
throw new RuntimeException("飞书返回结果为空");
}
jsonObject = JSONObject.parseObject(execute.body().string());
} catch (IOException e) {
String errorMessage = String.format("飞书接口调用失败:{}",e.getMessage());
throw new RuntimeException(errorMessage);
}
if ("0".equals(jsonObject.getString("code"))){
return jsonObject;
}else {
String errorMessage = String.format("%s##%s", jsonObject.getString("code"), jsonObject.getString("msg"));
throw new RuntimeException(errorMessage);
}
}
public String getToken(String appId, String srcret,String tokenType) {
Map<String, String> map = new HashMap<>();
map.put("app_id", appId);
map.put("app_secret", srcret);
Request.Builder builder = new Request.Builder();
builder.url("https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal");
RequestBody requestBody = RequestBody.create(MediaType.get("application/json"),JSONObject.toJSONString(map));
builder.post(requestBody);
return execute(builder.build()).getString(tokenType);
}
/**
* @param url
* @param token
* @return
*/
public JSONObject getLark(String url,Map<String, String> body, String token) {
Response execute = null;
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization",String.format("Bearer %s",token))
.build();
JSONObject jsonObject = null;
try {
execute = client.newCall(request).execute();
if (execute == null || execute.body() == null){
throw new RuntimeException("飞书返回结果为空");
}
jsonObject = JSONObject.parseObject(execute.body().string());
} catch (IOException e) {
String errorMessage = String.format("飞书接口调用失败:{}",e.getMessage());
throw new RuntimeException(errorMessage);
}
String code = jsonObject.getString("code");
if ("0".equals(code) || "1254043".equals(code)){
return jsonObject;
}else {
String errorMessage = String.format("%s##%s", code, jsonObject.getString("msg"));
throw new RuntimeException(errorMessage);
}
}
public JSONObject postLark(String url,Map<Object, Map<Object, Object>> body, String token) {
Request request = new Request.Builder()
.method("POST", RequestBody
.create(MediaType.get("application/json"),JSONObject.toJSONString(body)))
.url(url)
.addHeader("Authorization",String.format("Bearer %s",token))
.build();
return execute(request);
}
public JSONObject putLark(String url,Map<Object, Map<Object, Object>> body, String token) {
Request request = new Request.Builder()
.put(RequestBody
.create( MediaType.get("application/json"),JSONObject.toJSONString(body)))
.url(url)
.addHeader("Authorization",String.format("Bearer %s",token))
.build();
return execute(request);
}
public JSONObject deleteLark(String url,Map<Object, Map<Object, Object>> body, String token) {
Request.Builder builder = new Request.Builder()
.url(url)
.addHeader("Authorization", String.format("Bearer %s", token));
if (body == null || body.isEmpty()){
builder.delete();
}else {
builder.delete(RequestBody
.create(MediaType.get("application/json"),JSONObject.toJSONString(body)));
}
return execute(builder.build());
}
public static void main(String[] args) {
LarkTokenHelper helper = new LarkTokenHelper();
String token = helper.getToken( "cli_a482a8572cbc9013", "lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos","tenant_access_token");
System.out.println(token);
JSONObject jsonObject = JSONObject.parseObject(token);
Map<Object,Object> map = new HashMap<>();
JSONObject b = new JSONObject();
map.put("fields",b);
b.put("多行文本","345");
// helper.putLark("https://open.feishu.cn/open-apis/bitable/v1/apps/Gyu1b8VAFaYiEysfEUjcCKomnVc/tables/tbloMVR0ACW2uO33/records/rece1nuKGU",map,jsonObject.getString("tenant_access_token"));
}
}

@ -1,4 +1,4 @@
package com.flyingbook; package com.ruoyi.flyingbook;
import com.lark.oapi.sdk.servlet.ext.ServletAdapter; import com.lark.oapi.sdk.servlet.ext.ServletAdapter;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;

@ -1,4 +1,4 @@
package com.flyingbook.config; package com.ruoyi.flyingbook.config;
import com.lark.oapi.Client; import com.lark.oapi.Client;

@ -1,4 +1,4 @@
package com.flyingbook.config; package com.ruoyi.flyingbook.config;
import com.lark.oapi.Client; import com.lark.oapi.Client;
import com.lark.oapi.core.enums.AppType; import com.lark.oapi.core.enums.AppType;
import com.lark.oapi.core.response.RawResponse; import com.lark.oapi.core.response.RawResponse;

@ -0,0 +1,99 @@
package com.ruoyi.flyingbook.consumer;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import com.ruoyi.common.constant.RedisConstants;
import com.ruoyi.common.enums.AppType;
import com.ruoyi.common.enums.EventOperateStatus;
import com.ruoyi.flyingbook.domain.Event;
import com.ruoyi.flyingbook.domain.LarkRequest;
import com.ruoyi.flyingbook.mapper.EventMapper;
import com.ruoyi.flyingbook.service.IEventService;
import com.ruoyi.flyingbook.strategy.operate.MultidimensionalTableOperate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author yuxiangyong
* @create 2023-03-12 23:04
*/
@Slf4j
@Component
public class LarkApplicationRunner implements ApplicationRunner {
/**
* 线
*/
private static final Integer CORE_POOL_SIZE = 1;
/**
* 线
*/
private static final Integer MAX_POOL_SIZE = 1;
/**
*
*/
private static final Integer KEEP_ALIVE_TIME = 30;
/**
*
*/
private static final Integer QUEUE_SIZE = 20;
/**
* 线
*/
private static final Integer WAIT_TIME = 10000;
@Autowired
private EventMapper eventMapper;
@Autowired
private MultidimensionalTableOperate multidimensionalTableOperate;
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME,
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(QUEUE_SIZE), new ThreadPoolExecutor.AbortPolicy());
@Override
public void run(ApplicationArguments args) throws Exception {
//这里用线程池,后续如果出现量大的情况下可以调整
threadPool.execute(() -> {
while (true) {
List<Event> eventList = eventMapper.queryEventList(EventOperateStatus.PENDING.getCode(), AppType.APPROVAL.getCode());
if (CollectionUtils.isEmpty(eventList)) {
try {
// 没有订单,休息一下
Thread.sleep(WAIT_TIME);
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
try {
for (Event event : eventList) {
LarkRequest request = new LarkRequest();
request.setEvent(event);
multidimensionalTableOperate.execute(request);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
}

@ -0,0 +1,46 @@
package com.ruoyi.flyingbook.controller;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.flyingbook.domain.LarkRequest;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.utils.DecryptUtil;
import com.ruoyi.flyingbook.strategy.callback.MultidimensionalTableCallback;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@RestController
public class EventController extends BaseController {
@Autowired
private MultidimensionalTableCallback multidimensionalTableCallback;
//3. 创建路由处理器
@PostMapping("/approval")
public String event(@RequestBody JSONObject jsonObject) {
String result = "";
if (jsonObject == null) {
log.error("没有值");
return result;
}
log.info("/event/test1/approval request:{} encrypt:{}", jsonObject.toJSONString(), result);
if (jsonObject.containsKey("encrypt")) {
result = DecryptUtil.decrypt(jsonObject.getString("encrypt"));
log.info("/event/test1/approval request:{} encrypt:{}", jsonObject.toJSONString(), result);
}
if (jsonObject.containsKey("challenge")) {
result = jsonObject.getString("challenge");
log.info("/event/test1/approval request:{} challenge:{}", jsonObject.toJSONString(), result);
}
LarkRequest larkRequest = new LarkRequest();
larkRequest.setMessage(result);
multidimensionalTableCallback.execute(larkRequest);
return result;
}
}

@ -1,4 +1,8 @@
package com.flyingbook.controller; package com.ruoyi.flyingbook.controller;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.DecryptUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.lark.oapi.core.utils.Jsons; import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.event.EventDispatcher; import com.lark.oapi.event.EventDispatcher;
@ -23,7 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Map;
@Slf4j
@RestController @RestController
public class EventControllers { public class EventControllers {
@ -167,11 +173,13 @@ public class EventControllers {
private ServletAdapter servletAdapter; private ServletAdapter servletAdapter;
//3. 创建路由处理器 //3. 创建路由处理器
@RequestMapping("/webhook/events") @PostMapping("/approval2")
public void event(HttpServletRequest request, HttpServletResponse response) public void event(HttpServletRequest request, HttpServletResponse response)
throws Throwable { throws Throwable {
//3.1 回调扩展包提供的事件回调处理器 //3.1 回调扩展包提供的事件回调处理器
servletAdapter.handleEvent(request, response, EVENT_DISPATCHER); servletAdapter.handleEvent(request, response, EVENT_DISPATCHER);
Map<String, String[]> parameterMap = request.getParameterMap();
log.info("/event/test2/approval request:{}", JSONObject.toJSONString(parameterMap));
} }

@ -0,0 +1,36 @@
package com.ruoyi.flyingbook.domain;
import lombok.Data;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* event
*
* @author ruoyi
* @date 2023-03-15
*/
@Data
public class Event extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long id;
private String appId;
/**
* @see com.ruoyi.common.enums.AppType
*/
private String type;
private String appToken;
private String tableId;
private String recordId;
private Long numbers;
/**
* @see com.ruoyi.common.enums.EventOperateStatus
*/
private String operateStatus;
/**
* @see com.ruoyi.common.enums.FlagStatus
*/
private Long flag;
}

@ -0,0 +1,49 @@
package com.ruoyi.flyingbook.domain;
import lombok.Data;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
/**
* event_log
*
* @author ruoyi
* @date 2023-03-15
*/
@Data
public class EventLog extends BaseEntity {
private static final long serialVersionUID = 1L;
public EventLog() {
}
public EventLog(Long eventId, String operateType, String operateInfo) {
this.eventId = eventId;
this.operateType = operateType;
this.operateInfo = operateInfo;
this.setCreateTime(new Date());
this.setCreateBy("System");
}
public EventLog(Long eventId, String operateType, String operateInfo, String errorCode, String errorMessage) {
this.eventId = eventId;
this.operateType = operateType;
this.operateInfo = operateInfo;
this.errorCode = errorCode;
this.errorMessage = errorMessage;
this.setCreateTime(new Date());
this.setCreateBy("System");
}
private Long id;
private Long eventId;
/**
* @see com.ruoyi.common.enums.EventOperateType
*/
private String operateType;
private String operateInfo;
private String errorCode;
private String errorMessage;
}

@ -0,0 +1,28 @@
package com.ruoyi.flyingbook.domain;
import lombok.Data;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* @author ruoyi
* @date 2023-03-15
*/
@Data
public class LarkCompanyRelation extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long id;
private Long companyId;
private String companyName;
private String appId;
private String secret;
/**
* @see com.ruoyi.common.enums.AppType
*/
private String appType;
/**
* @see com.ruoyi.common.enums.FlagStatus
*/
private Long flag;
}

@ -0,0 +1,56 @@
package com.ruoyi.flyingbook.domain;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.enums.EventOperateType;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author yuxiangyong
* @create 2023-03-12 16:00
*/
@Data
public class LarkRequest {
/**
*
*/
private String token;
private String appId;
private String fromAppToken;
private String toAppToken;
private String errorCode;
private String errorMessage;
/**
* ApprovalCallback
*/
private Long eventId;
private String message;
private String eventType;
/**
* MultidimensionalTableOperate
*/
private JSONObject record;
private Long companyRelationId;
private Long tableRelationId;
private String fromTableId;
private String toTableId;
private String fromRecordId;
private String toRecordId;
private String operateType;
private String callBackMessage;
private Event event;
private EventOperateType eventOperateType;
private String operateInfo;
/**
*
*/
private Map<String/**toToken+toTable*/, Long/**id*/> tableRelationMap;
private Map<Long/**tableRelationId*/,Map<String/**fromRow*/,String/**toRow*/>> tableRowRelationMap;
private Map<Long/**tableRelationId*/,Map<String/**fromCol*/,String/**toCol*/>> tableColRelationMap;
}

@ -0,0 +1,27 @@
package com.ruoyi.flyingbook.domain;
import lombok.Data;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* lark_table_relation
*
* @author ruoyi
* @date 2023-03-15
*/
@Data
public class LarkTableRelation extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long id;
private Long larkCompanyRelationId;
private String fromAppToken;
private String fromTableId;
private String toAppToken;
private String toTableId;
/**
* @see com.ruoyi.common.enums.FlagStatus
*/
private Long flag;
}

@ -0,0 +1,53 @@
package com.ruoyi.flyingbook.domain;
import com.ruoyi.common.enums.FlagStatus;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
/**
* lark_table_row_relation
*
* @author ruoyi
* @date 2023-03-15
*/
@Data
public class LarkTableRowRelation extends BaseEntity
{
private static final long serialVersionUID = 1L;
public LarkTableRowRelation() {
}
public LarkTableRowRelation(Long tableRelationId, String fromId, String toId, String type, String subType) {
this.tableRelationId = tableRelationId;
this.fromId = fromId;
this.toId = toId;
this.type = type;
this.subType = subType;
this.setCreateTime(new Date());
this.setCreateBy("System");
this.flag = FlagStatus.OK.getCode();
}
/** $column.columnComment */
private Long id;
private Long tableRelationId;
private String fromId;
private String toId;
/**
* @see com.ruoyi.common.enums.TableDetailRelationTypeEnum
*/
private String type;
private String subType;
/**
* @see com.ruoyi.common.enums.FlagStatus
*/
private Long flag;
}

@ -0,0 +1,43 @@
package com.ruoyi.flyingbook.factory;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.enums.CallBackTypeEnum;
import com.ruoyi.flyingbook.domain.LarkRequest;
import com.ruoyi.flyingbook.strategy.callback.MultidimensionalTableCallback;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author yuxiangyong
* @create 2023-03-16 20:54
*/
@Component
public class LarkFactory {
@Autowired
private MultidimensionalTableCallback approvalCallback;
public void execute(LarkRequest larkRequest) {
String message = larkRequest.getMessage();
if (StringUtils.isBlank(message)) {
return;
}
JSONObject jsonObject = JSONObject.parseObject(message);
String eventType = jsonObject.getJSONObject("header").getString("event_type");
CallBackTypeEnum callBackTypeEnum = CallBackTypeEnum.getByCode(eventType);
if (callBackTypeEnum == null) {
return;
}
switch (callBackTypeEnum) {
case TABLE_ROW_CHANGE:
approvalCallback.execute(larkRequest);
break;
case APPROVAL_TASK:
break;
default:
break;
}
}
}

@ -0,0 +1,63 @@
package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.EventLog;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-03-12
*/
public interface EventLogMapper
{
/**
*
*
* @param id ID
* @return
*/
public EventLog selectEventLogById(Long id);
/**
*
*
* @param eventLog
* @return
*/
public List<EventLog> selectEventLogList(EventLog eventLog);
/**
*
*
* @param eventLog
* @return
*/
public int insertEventLog(EventLog eventLog);
/**
*
*
* @param eventLog
* @return
*/
public int updateEventLog(EventLog eventLog);
/**
*
*
* @param id ID
* @return
*/
public int deleteEventLogById(Long id);
/**
*
*
* @param ids ID
* @return
*/
public int deleteEventLogByIds(Long[] ids);
}

@ -0,0 +1,69 @@
package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.Event;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-03-12
*/
public interface EventMapper
{
/**
*
*
* @param id ID
* @return
*/
public Event selectEventById(Long id);
/**
*
*
* @param event
* @return
*/
public List<Event> selectEventList(Event event);
/**
*
*
* @param event
* @return
*/
public int insertEvent(Event event);
/**
*
*
* @param event
* @return
*/
public int updateEvent(Event event);
/**
*
*
* @param id ID
* @return
*/
public int deleteEventById(Long id);
/**
*
*
* @param ids ID
* @return
*/
public int deleteEventByIds(Long[] ids);
public List<Event> queryEventList(@Param("status") String status,@Param("type") String type);
public int updateStatus(@Param("id") Long id,@Param("status") String status,@Param("numbers") Long numbers);
}

@ -0,0 +1,63 @@
package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkCompanyRelation;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-03-12
*/
public interface LarkCompanyRelationMapper
{
/**
*
*
* @param id ID
* @return
*/
public LarkCompanyRelation selectLarkCompanyRelationById(Long id);
/**
*
*
* @param larkCompanyRelation
* @return
*/
public List<LarkCompanyRelation> selectLarkCompanyRelationList(LarkCompanyRelation larkCompanyRelation);
/**
*
*
* @param larkCompanyRelation
* @return
*/
public int insertLarkCompanyRelation(LarkCompanyRelation larkCompanyRelation);
/**
*
*
* @param larkCompanyRelation
* @return
*/
public int updateLarkCompanyRelation(LarkCompanyRelation larkCompanyRelation);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkCompanyRelationById(Long id);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkCompanyRelationByIds(Long[] ids);
}

@ -0,0 +1,65 @@
package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkTableRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-03-12
*/
public interface LarkTableRelationMapper
{
/**
*
*
* @param id ID
* @return
*/
public LarkTableRelation selectLarkTableRelationById(Long id);
/**
*
*
* @param larkTableRelation
* @return
*/
public List<LarkTableRelation> selectLarkTableRelationList(LarkTableRelation larkTableRelation);
/**
*
*
* @param larkTableRelation
* @return
*/
public int insertLarkTableRelation(LarkTableRelation larkTableRelation);
/**
*
*
* @param larkTableRelation
* @return
*/
public int updateLarkTableRelation(LarkTableRelation larkTableRelation);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkTableRelationById(Long id);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkTableRelationByIds(Long[] ids);
}

@ -0,0 +1,66 @@
package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkTableRowRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2023-03-15
*/
public interface LarkTableRowRelationMapper
{
/**
*
*
* @param id ID
* @return
*/
public LarkTableRowRelation selectLarkTableRowRelationById(Long id);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public List<LarkTableRowRelation> selectLarkTableRowRelationList(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public int insertLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public int updateLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkTableRowRelationById(Long id);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkTableRowRelationByIds(Long[] ids);
public List<LarkTableRowRelation> queryListByTableRelationIdList(@Param("tableRelationIdList") List<Long> tableRelationIdList);
}

@ -0,0 +1,63 @@
package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.EventLog;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-12
*/
public interface IEventLogService
{
/**
*
*
* @param id ID
* @return
*/
public EventLog selectEventLogById(Long id);
/**
*
*
* @param eventLog
* @return
*/
public List<EventLog> selectEventLogList(EventLog eventLog);
/**
*
*
* @param eventLog
* @return
*/
public int insertEventLog(EventLog eventLog);
/**
*
*
* @param eventLog
* @return
*/
public int updateEventLog(EventLog eventLog);
/**
*
*
* @param ids ID
* @return
*/
public int deleteEventLogByIds(Long[] ids);
/**
*
*
* @param id ID
* @return
*/
public int deleteEventLogById(Long id);
}

@ -0,0 +1,65 @@
package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.Event;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-12
*/
public interface IEventService
{
/**
*
*
* @param id ID
* @return
*/
public Event selectEventById(Long id);
/**
*
*
* @param event
* @return
*/
public List<Event> selectEventList(Event event);
/**
*
*
* @param event
* @return
*/
public int insertEvent(Event event);
/**
*
*
* @param event
* @return
*/
public int updateEvent(Event event);
/**
*
*
* @param ids ID
* @return
*/
public int deleteEventByIds(Long[] ids);
/**
*
*
* @param id ID
* @return
*/
public int deleteEventById(Long id);
public int updateStatus(Long id,String status,Long numbsers);
}

@ -0,0 +1,65 @@
package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.LarkCompanyRelation;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-12
*/
public interface ILarkCompanyRelationService
{
/**
*
*
* @param id ID
* @return
*/
public LarkCompanyRelation selectLarkCompanyRelationById(Long id);
/**
*
*
* @param larkCompanyRelation
* @return
*/
public List<LarkCompanyRelation> selectLarkCompanyRelationList(LarkCompanyRelation larkCompanyRelation);
/**
*
*
* @param larkCompanyRelation
* @return
*/
public int insertLarkCompanyRelation(LarkCompanyRelation larkCompanyRelation);
/**
*
*
* @param larkCompanyRelation
* @return
*/
public int updateLarkCompanyRelation(LarkCompanyRelation larkCompanyRelation);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkCompanyRelationByIds(Long[] ids);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkCompanyRelationById(Long id);
public LarkCompanyRelation getByAppIdAndType(String appId,String appType);
}

@ -0,0 +1,65 @@
package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.LarkTableRelation;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-12
*/
public interface ILarkTableRelationService
{
/**
*
*
* @param id ID
* @return
*/
public LarkTableRelation selectLarkTableRelationById(Long id);
/**
*
*
* @param larkTableRelation
* @return
*/
public List<LarkTableRelation> selectLarkTableRelationList(LarkTableRelation larkTableRelation);
/**
*
*
* @param larkTableRelation
* @return
*/
public int insertLarkTableRelation(LarkTableRelation larkTableRelation);
/**
*
*
* @param larkTableRelation
* @return
*/
public int updateLarkTableRelation(LarkTableRelation larkTableRelation);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkTableRelationByIds(Long[] ids);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkTableRelationById(Long id);
}

@ -0,0 +1,65 @@
package com.ruoyi.flyingbook.service;
import com.ruoyi.flyingbook.domain.LarkTableRowRelation;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-15
*/
public interface ILarkTableRowRelationService
{
/**
*
*
* @param id ID
* @return
*/
public LarkTableRowRelation selectLarkTableRowRelationById(Long id);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public List<LarkTableRowRelation> selectLarkTableRowRelationList(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public int insertLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param larkTableRowRelation
* @return
*/
public int updateLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation);
/**
*
*
* @param ids ID
* @return
*/
public int deleteLarkTableRowRelationByIds(Long[] ids);
/**
*
*
* @param id ID
* @return
*/
public int deleteLarkTableRowRelationById(Long id);
public List<LarkTableRowRelation> queryListByTableRelationIdList(List<Long> tableRelationIdList);
}

@ -0,0 +1,97 @@
package com.ruoyi.flyingbook.service.impl;
import java.util.List;
import com.ruoyi.flyingbook.domain.EventLog;
import com.ruoyi.flyingbook.mapper.EventLogMapper;
import com.ruoyi.flyingbook.service.IEventLogService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service
*
* @author ruoyi
* @date 2023-03-12
*/
@Service
public class EventLogServiceImpl implements IEventLogService
{
@Autowired
private EventLogMapper eventLogMapper;
/**
*
*
* @param id ID
* @return
*/
@Override
public EventLog selectEventLogById(Long id)
{
return eventLogMapper.selectEventLogById(id);
}
/**
*
*
* @param eventLog
* @return
*/
@Override
public List<EventLog> selectEventLogList(EventLog eventLog)
{
return eventLogMapper.selectEventLogList(eventLog);
}
/**
*
*
* @param eventLog
* @return
*/
@Override
public int insertEventLog(EventLog eventLog)
{
eventLog.setCreateTime(DateUtils.getNowDate());
return eventLogMapper.insertEventLog(eventLog);
}
/**
*
*
* @param eventLog
* @return
*/
@Override
public int updateEventLog(EventLog eventLog)
{
eventLog.setUpdateTime(DateUtils.getNowDate());
return eventLogMapper.updateEventLog(eventLog);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteEventLogByIds(Long[] ids)
{
return eventLogMapper.deleteEventLogByIds(ids);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public int deleteEventLogById(Long id)
{
return eventLogMapper.deleteEventLogById(id);
}
}

@ -0,0 +1,103 @@
package com.ruoyi.flyingbook.service.impl;
import com.ruoyi.flyingbook.domain.Event;
import com.ruoyi.flyingbook.mapper.EventMapper;
import com.ruoyi.flyingbook.service.IEventService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-12
*/
@Service
public class EventServiceImpl implements IEventService
{
@Autowired
private EventMapper eventMapper;
/**
*
*
* @param id ID
* @return
*/
@Override
public Event selectEventById(Long id)
{
return eventMapper.selectEventById(id);
}
/**
*
*
* @param event
* @return
*/
@Override
public List<Event> selectEventList(Event event)
{
return eventMapper.selectEventList(event);
}
/**
*
*
* @param event
* @return
*/
@Override
public int insertEvent(Event event)
{
event.setCreateTime(DateUtils.getNowDate());
return eventMapper.insertEvent(event);
}
/**
*
*
* @param event
* @return
*/
@Override
public int updateEvent(Event event)
{
event.setUpdateTime(DateUtils.getNowDate());
return eventMapper.updateEvent(event);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteEventByIds(Long[] ids)
{
return eventMapper.deleteEventByIds(ids);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public int deleteEventById(Long id)
{
return eventMapper.deleteEventById(id);
}
@Override
public int updateStatus(Long id, String status,Long numbsers) {
return eventMapper.updateStatus(id,status,numbsers);
}
}

@ -0,0 +1,120 @@
package com.ruoyi.flyingbook.service.impl;
import java.util.List;
import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.flyingbook.domain.LarkCompanyRelation;
import com.ruoyi.flyingbook.mapper.LarkCompanyRelationMapper;
import com.ruoyi.flyingbook.service.ILarkCompanyRelationService;
import com.ruoyi.common.utils.DateUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service
*
* @author ruoyi
* @date 2023-03-12
*/
@Service
public class LarkCompanyRelationServiceImpl implements ILarkCompanyRelationService
{
@Autowired
private LarkCompanyRelationMapper larkCompanyRelationMapper;
/**
*
*
* @param id ID
* @return
*/
@Override
public LarkCompanyRelation selectLarkCompanyRelationById(Long id)
{
return larkCompanyRelationMapper.selectLarkCompanyRelationById(id);
}
/**
*
*
* @param larkCompanyRelation
* @return
*/
@Override
public List<LarkCompanyRelation> selectLarkCompanyRelationList(LarkCompanyRelation larkCompanyRelation)
{
return larkCompanyRelationMapper.selectLarkCompanyRelationList(larkCompanyRelation);
}
/**
*
*
* @param larkCompanyRelation
* @return
*/
@Override
public int insertLarkCompanyRelation(LarkCompanyRelation larkCompanyRelation)
{
larkCompanyRelation.setCreateTime(DateUtils.getNowDate());
return larkCompanyRelationMapper.insertLarkCompanyRelation(larkCompanyRelation);
}
/**
*
*
* @param larkCompanyRelation
* @return
*/
@Override
public int updateLarkCompanyRelation(LarkCompanyRelation larkCompanyRelation)
{
larkCompanyRelation.setUpdateTime(DateUtils.getNowDate());
return larkCompanyRelationMapper.updateLarkCompanyRelation(larkCompanyRelation);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteLarkCompanyRelationByIds(Long[] ids)
{
return larkCompanyRelationMapper.deleteLarkCompanyRelationByIds(ids);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public int deleteLarkCompanyRelationById(Long id)
{
return larkCompanyRelationMapper.deleteLarkCompanyRelationById(id);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public LarkCompanyRelation getByAppIdAndType(String appId,String appType)
{
if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(appType)){
return null;
}
LarkCompanyRelation relation = new LarkCompanyRelation();
relation.setAppId(appId);
relation.setAppType(appType);
relation.setFlag(FlagStatus.OK.getCode());
List<LarkCompanyRelation> larkCompanyRelations = larkCompanyRelationMapper.selectLarkCompanyRelationList(relation);
return CollectionUtils.isEmpty(larkCompanyRelations) ? null : larkCompanyRelations.get(0);
}
}

@ -0,0 +1,100 @@
package com.ruoyi.flyingbook.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.flyingbook.domain.LarkTableRelation;
import com.ruoyi.flyingbook.mapper.LarkTableRelationMapper;
import com.ruoyi.flyingbook.service.ILarkTableRelationService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service
*
* @author ruoyi
* @date 2023-03-12
*/
@Service
public class LarkTableRelationServiceImpl implements ILarkTableRelationService
{
@Autowired
private LarkTableRelationMapper larkTableRelationMapper;
/**
*
*
* @param id ID
* @return
*/
@Override
public LarkTableRelation selectLarkTableRelationById(Long id)
{
return larkTableRelationMapper.selectLarkTableRelationById(id);
}
/**
*
*
* @param larkTableRelation
* @return
*/
@Override
public List<LarkTableRelation> selectLarkTableRelationList(LarkTableRelation larkTableRelation)
{
return larkTableRelationMapper.selectLarkTableRelationList(larkTableRelation);
}
/**
*
*
* @param larkTableRelation
* @return
*/
@Override
public int insertLarkTableRelation(LarkTableRelation larkTableRelation)
{
larkTableRelation.setCreateTime(DateUtils.getNowDate());
return larkTableRelationMapper.insertLarkTableRelation(larkTableRelation);
}
/**
*
*
* @param larkTableRelation
* @return
*/
@Override
public int updateLarkTableRelation(LarkTableRelation larkTableRelation)
{
larkTableRelation.setUpdateTime(DateUtils.getNowDate());
return larkTableRelationMapper.updateLarkTableRelation(larkTableRelation);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteLarkTableRelationByIds(Long[] ids)
{
return larkTableRelationMapper.deleteLarkTableRelationByIds(ids);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public int deleteLarkTableRelationById(Long id)
{
return larkTableRelationMapper.deleteLarkTableRelationById(id);
}
}

@ -0,0 +1,107 @@
package com.ruoyi.flyingbook.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.flyingbook.domain.LarkTableRowRelation;
import com.ruoyi.flyingbook.mapper.LarkTableRowRelationMapper;
import com.ruoyi.flyingbook.service.ILarkTableRowRelationService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2023-03-15
*/
@Service
public class LarkTableRowRelationServiceImpl implements ILarkTableRowRelationService
{
@Autowired
private LarkTableRowRelationMapper larkTableRowRelationMapper;
/**
*
*
* @param id ID
* @return
*/
@Override
public LarkTableRowRelation selectLarkTableRowRelationById(Long id)
{
return larkTableRowRelationMapper.selectLarkTableRowRelationById(id);
}
/**
*
*
* @param larkTableRowRelation
* @return
*/
@Override
public List<LarkTableRowRelation> selectLarkTableRowRelationList(LarkTableRowRelation larkTableRowRelation)
{
return larkTableRowRelationMapper.selectLarkTableRowRelationList(larkTableRowRelation);
}
/**
*
*
* @param larkTableRowRelation
* @return
*/
@Override
public int insertLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation)
{
larkTableRowRelation.setCreateTime(DateUtils.getNowDate());
return larkTableRowRelationMapper.insertLarkTableRowRelation(larkTableRowRelation);
}
/**
*
*
* @param larkTableRowRelation
* @return
*/
@Override
public int updateLarkTableRowRelation(LarkTableRowRelation larkTableRowRelation)
{
larkTableRowRelation.setUpdateTime(DateUtils.getNowDate());
return larkTableRowRelationMapper.updateLarkTableRowRelation(larkTableRowRelation);
}
/**
*
*
* @param ids ID
* @return
*/
@Override
public int deleteLarkTableRowRelationByIds(Long[] ids)
{
return larkTableRowRelationMapper.deleteLarkTableRowRelationByIds(ids);
}
/**
*
*
* @param id ID
* @return
*/
@Override
public int deleteLarkTableRowRelationById(Long id)
{
return larkTableRowRelationMapper.deleteLarkTableRowRelationById(id);
}
@Override
public List<LarkTableRowRelation> queryListByTableRelationIdList(List<Long> tableRelationIdList) {
if (CollectionUtils.isEmpty(tableRelationIdList)){
return new ArrayList<>();
}
return larkTableRowRelationMapper.queryListByTableRelationIdList(tableRelationIdList);
}
}

@ -0,0 +1,76 @@
package com.ruoyi.flyingbook.strategy;
import com.ruoyi.common.enums.EventOperateType;
import com.ruoyi.flyingbook.domain.EventLog;
import com.ruoyi.flyingbook.domain.LarkRequest;
import lombok.extern.slf4j.Slf4j;
/**
* @author yuxiangyong
* @create 2023-03-12 15:58
*/
@Slf4j
public abstract class LarkOperateAbstract{
public String execute(LarkRequest request){
try {
//参数校验逻辑
if (!check(request)){
//构建返回对象
return buildResult(request);
}
//对入参进行预处理,例如解密
preOperate(request);
//真正的业务处理逻辑
businessProcessing(request);
}catch (Exception e){
log.error("{} execute error: {}",getName(),e);
String message = e.getMessage();
if (message.contains("##")){
String[] split = message.split("##");
request.setErrorCode(split[0]);
request.setErrorMessage(split[1]);
}else {
request.setErrorMessage(message);
}
}finally {
//业务处理完成后的系列操作,例如日志
endHandle(request);
}
//构建返回对象并返回
return buildResult(request);
}
/**
*
*
*/
protected Boolean check(LarkRequest request){
return Boolean.TRUE;
}
/**
*
*/
protected abstract void preOperate(LarkRequest request);
/**
*
* @param request
*/
protected abstract void businessProcessing(LarkRequest request);
/**
*
*/
protected void endHandle(LarkRequest request){};
/**
*
*/
protected abstract String buildResult(LarkRequest request);
protected abstract String getName();
}

@ -0,0 +1,14 @@
package com.ruoyi.flyingbook.strategy.callback;
import com.ruoyi.flyingbook.strategy.LarkOperateAbstract;
import lombok.extern.slf4j.Slf4j;
/**
* @author yuxiangyong
* @create 2023-03-12 15:58
*/
@Slf4j
public abstract class CallbackAbstract extends LarkOperateAbstract {
}

@ -0,0 +1,158 @@
package com.ruoyi.flyingbook.strategy.callback;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.enums.AppType;
import com.ruoyi.flyingbook.domain.Event;
import com.ruoyi.flyingbook.domain.EventLog;
import com.ruoyi.flyingbook.service.IEventLogService;
import com.ruoyi.flyingbook.service.IEventService;
import com.ruoyi.flyingbook.domain.LarkRequest;
import com.ruoyi.common.constant.RedisConstants;
import com.ruoyi.common.enums.EventOperateStatus;
import com.ruoyi.common.enums.EventOperateType;
import com.ruoyi.common.enums.FlagStatus;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @author yuxiangyong
* @create 2023-03-12 15:58
*/
@Slf4j
@Service
public class MultidimensionalTableCallback extends CallbackAbstract {
@Autowired
private IEventService eventService;
@Autowired
private IEventLogService eventLogService;
@Autowired
private RedisTemplate redisTemplate;
@Override
protected Boolean check(LarkRequest request) {
return Boolean.TRUE;
}
@Override
protected void preOperate(LarkRequest request) {
if (StringUtils.isBlank(request.getMessage())) {
return;
}
String message = request.getMessage();
JSONObject jsonObject = JSONObject.parseObject(message);
JSONObject event = jsonObject.getJSONObject("event");
if (event == null) {
return;
}
request.setFromAppToken(event.getString("file_token"));
request.setFromTableId(event.getString("table_id"));
JSONArray actionList = event.getJSONArray("action_list");
if (CollectionUtils.isEmpty(actionList)) {
return;
}
JSONObject action = actionList.getJSONObject(0);
//如果不存在说明是行变更以外的事件,跳过
String recordId = action.getString("record_id");
if (StringUtils.isBlank(recordId)) {
return;
}
request.setFromRecordId(recordId);
JSONObject header = jsonObject.getJSONObject("header");
if (header == null) {
return;
}
String appId = header.getString("app_id");
request.setAppId(appId);
request.setEventType(header.getString("event_type"));
}
@Override
protected void businessProcessing(LarkRequest request) {
String cacheKey = String.format("%s_%s_%s_%s", RedisConstants.MULTIPLE_TABLE_RECORD, request.getFromAppToken(),request.getFromTableId(), request.getFromRecordId());
String eventStr = (String)redisTemplate.opsForValue().get(cacheKey);
Event event = null;
if (StringUtils.isBlank(eventStr)){
event = queryEvent(request.getFromAppToken(),request.getFromTableId(), request.getFromRecordId());
}else {
event = JSONObject.parseObject(eventStr,Event.class);
}
//如果已经存在处理中的就不需要操作数据库了
if (event != null && EventOperateStatus.PENDING.getCode().equals(event.getOperateStatus())){
return;
}
event = this.buildDto(request,event);
if (event.getId() == null){
eventService.insertEvent(event);
redisTemplate.opsForValue().set(cacheKey,JSONObject.toJSONString(event));
}else {
eventService.updateStatus(event.getId(),EventOperateStatus.PENDING.getCode(),0L);
}
request.setEventId(event.getId());
}
@Override
protected void endHandle(LarkRequest request) {
if (request.getEventId() == null){
return;
}
if (StringUtils.isNotBlank(request.getErrorMessage())){
}
EventLog eventLog = StringUtils.isBlank(request.getErrorMessage()) ?
new EventLog(request.getEventId(),EventOperateType.CALL_BACK.getCode(),request.getMessage())
: new EventLog(request.getEventId(),EventOperateType.CALL_BACK.getCode(),request.getMessage(),request.getErrorCode(),request.getErrorMessage());
eventLogService.insertEventLog(eventLog);
}
@Override
protected String buildResult(LarkRequest request) {
return "";
}
@Override
protected String getName() {
return this.getClass().getSimpleName();
}
private Event queryEvent(String appToken,String tableId,String recordId){
Event event = new Event();
event.setAppToken(appToken);
event.setTableId(tableId);
event.setRecordId(recordId);
List<Event> events = eventService.selectEventList(event);
if (CollectionUtils.isNotEmpty(events)){
return events.get(0);
}
return null;
}
private Event buildDto(LarkRequest request,Event event){
event = event == null ? new Event() :event;
event.setFlag(FlagStatus.OK.getCode());
event.setAppToken(request.getFromAppToken());
event.setTableId(request.getFromTableId());
event.setRecordId(request.getFromRecordId());
event.setNumbers(0L);
event.setOperateStatus(EventOperateStatus.PENDING.getCode());
event.setCreateBy("System");
event.setCreateTime(new Date());
event.setUpdateTime(new Date());
event.setUpdateBy("System");
event.setAppId(request.getAppId());
event.setType(AppType.APPROVAL.getCode());
return event;
}
}

@ -0,0 +1,29 @@
package com.ruoyi.flyingbook.strategy.operate;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.flyingbook.domain.LarkRequest;
import com.ruoyi.flyingbook.strategy.LarkOperateAbstract;
import org.apache.commons.lang3.StringUtils;
import java.util.Map;
/**
* @author yuxiangyong
* @create 2023-03-13 20:45
*/
public abstract class LarkAbstract extends LarkOperateAbstract {
/**
* URL
*/
protected abstract String getUrl(LarkRequest request);
/**
* body
*/
protected abstract Map<Object, Map<Object, Object>> getBody(LarkRequest request);
}

@ -0,0 +1,261 @@
package com.ruoyi.flyingbook.strategy.operate;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.CompanyNameConstants;
import com.ruoyi.common.constant.RedisConstants;
import com.ruoyi.common.enums.*;
import com.ruoyi.flyingbook.LarkHelper.LarkTokenHelper;
import com.ruoyi.flyingbook.domain.*;
import com.ruoyi.flyingbook.service.*;
import lombok.extern.slf4j.Slf4j;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
* @author yuxiangyong
* @create 2023-03-13 20:47
*/
@Slf4j
@Component("MultidimensionalTableOperate")
public class MultidimensionalTableOperate extends LarkAbstract {
@Autowired
protected LarkTokenHelper larkTokenHelper;
@Autowired
protected ILarkCompanyRelationService larkCompanyRelationService;
@Autowired
protected IEventService iEventService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
protected ILarkTableRelationService iLarkTableRelationService;
@Autowired
protected ILarkTableRowRelationService iLarkTableRowRelationService;
@Autowired
private IEventService eventService;
@Autowired
private IEventLogService eventLogService;
/**
*
*/
private static final String DETAIL = "DETAIL";
private String getDetail = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id";
//新增明细行
private static final String CREATE_OPERATE = "CREATE_OPERATE";
private String addLine = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records";
//修改明细行
private static final String UPDATE_OPERATE = "UPDATE_OPERATE";
private String updateLine = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id";
//删除明细行
private static final String DELETE_OPERATE = "DELETE_OPERATE";
private String deleteLine = "https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id";
private void fillTableRelation(LarkRequest request) {
LarkTableRelation tableRelation = new LarkTableRelation();
tableRelation.setLarkCompanyRelationId(request.getCompanyRelationId());
tableRelation.setFromTableId(request.getEvent().getTableId());
tableRelation.setFlag(FlagStatus.OK.getCode());
List<LarkTableRelation> larkTableRelations = iLarkTableRelationService.selectLarkTableRelationList(tableRelation);
if (CollectionUtils.isEmpty(larkTableRelations)) {
String errorMessage = String.format("tableId:{}表关系未配置", request.getEvent().getTableId());
log.error("iLarkTableRelationService.selectLarkTableRelationList:{}", errorMessage);
throw new RuntimeException(errorMessage);
}
//主表与副表的列对应关系
List<Long> tableRelationIdList = new ArrayList<>();
Map<String, Long> tableRelationMap = new HashMap<>();
for (LarkTableRelation larkTableRelation : larkTableRelations) {
String to = String.format("%s_%s", larkTableRelation.getToAppToken(), larkTableRelation.getToTableId());
tableRelationMap.put(to, larkTableRelation.getId());
tableRelationIdList.add(larkTableRelation.getId());
}
request.setTableRelationMap(tableRelationMap);
//主表与副表的行对应关系
List<LarkTableRowRelation> larkTableRowRelations = iLarkTableRowRelationService.queryListByTableRelationIdList(tableRelationIdList);
Map<Long, Map<String, String>> tableRowRelationMap = new HashMap<>();
Map<Long, Map<String, String>> tableColRelationMap = new HashMap<>();
for (LarkTableRowRelation larkTableRowRelation : larkTableRowRelations) {
Map<String, String> map = new HashMap<>();
map.put(larkTableRowRelation.getFromId(), larkTableRowRelation.getToId());
if (TableDetailRelationTypeEnum.ROW.getCode().equals(larkTableRowRelation.getType())) {
tableRowRelationMap.put(larkTableRowRelation.getTableRelationId(), map);
} else if (TableDetailRelationTypeEnum.COL.getCode().equals(larkTableRowRelation.getType())) {
tableColRelationMap.put(larkTableRowRelation.getTableRelationId(), map);
}
}
if (tableColRelationMap.isEmpty()) {
String errorMessage = String.format("tableId:{} 列关系未配置", request.getEvent().getTableId());
log.error("iLarkTableRowRelationService.queryListByTableRelationIdList:{}", errorMessage);
throw new RuntimeException(errorMessage);
}
request.setTableRowRelationMap(tableRowRelationMap);
request.setTableColRelationMap(tableColRelationMap);
}
@Override
protected void preOperate(LarkRequest request) {
Event event = request.getEvent();
if (event == null) {
throw new RuntimeException("当前事件为空");
}
LarkCompanyRelation relation = larkCompanyRelationService.getByAppIdAndType(request.getEvent().getAppId(), AppType.APPROVAL.getCode());
if (relation == null) {
String errorMessage = String.format("获取app值为空 appId:{} appType:{}", request.getEvent().getAppId(), AppType.APPROVAL.getCode());
log.error("larkCompanyRelationService.getByCompanyName:{}", errorMessage);
throw new RuntimeException(errorMessage);
}
//用于后续追加row时候做关联关系
request.setCompanyRelationId(relation.getId());
//关联关系表填充
this.fillTableRelation(request);
String token = larkTokenHelper.getToken(relation.getAppId(), relation.getSecret(), "tenant_access_token");
request.setToken(token);
}
@Override
protected void businessProcessing(LarkRequest request) {
request.setOperateType(DETAIL);
JSONObject message = larkTokenHelper.getLark(getUrl(request), null, request.getToken());
request.setRecord(message);
for (Map.Entry<String, Long> entry : request.getTableRelationMap().entrySet()) {
String[] arr = entry.getKey().split("_");
request.setToAppToken(arr[0]);
request.setToTableId(arr[1]);
request.setTableRelationId(entry.getValue());
Map<Object, Map<Object, Object>> body = getBody(request);
String url = getUrl(request);
if (StringUtils.isBlank(url)) {
return;
}
send(request.getOperateType(), url, body, request);
}
}
@Override
protected String getUrl(LarkRequest request) {
Event event = request.getEvent();
Map<String, String> rowRelation = request.getTableRowRelationMap().get(request.getTableRelationId());
String cacheKey = String.format("%s_%s_%s_%s", RedisConstants.MULTIPLE_TABLE_RECORD, event.getAppToken(), event.getTableId(), event.getRecordId());
redisTemplate.delete(cacheKey);
if (UPDATE_OPERATE.equals(request.getOperateType())) {
if (rowRelation.containsKey(event.getRecordId())) {
return updateLine.replace(":app_token", request.getToAppToken()).replace(":table_id", request.getToTableId()).replace(":record_id", rowRelation.get(event.getRecordId()));
}
} else if (CREATE_OPERATE.equals(request.getOperateType())) {
return addLine.replace(":app_token", request.getToAppToken()).replace(":table_id", request.getToTableId());
} else if (DELETE_OPERATE.equals(request.getOperateType())) {
if (rowRelation.containsKey(event.getRecordId())) {
return deleteLine.replace(":app_token", request.getToAppToken()).replace(":table_id", request.getToTableId()).replace(":record_id", rowRelation.get(event.getRecordId()));
}
} else if (DETAIL.equals(request.getOperateType())) {
return getDetail.replace(":app_token", event.getAppToken()).replace(":table_id", event.getTableId()).replace(":record_id", event.getRecordId());
}
return null;
}
@Override
protected Map<Object, Map<Object, Object>> getBody(LarkRequest request) {
Map<Object, Map<Object, Object>> result = new HashMap<>();
JSONObject record = request.getRecord();
String responseCode = record.getString("code");
Map<String, String> rowMap = request.getTableRowRelationMap().getOrDefault(request.getTableRelationId(), new HashMap<>());
if ("1254043".equals(responseCode)) {
request.setOperateType(DELETE_OPERATE);
} else if ("0".equals(responseCode)) {
result = parseMap(request);
if (rowMap.containsKey(request.getEvent().getRecordId())) {
request.setOperateType(UPDATE_OPERATE);
} else {
request.setOperateType(CREATE_OPERATE);
}
}
return result;
}
private Map<Object, Map<Object, Object>> parseMap(LarkRequest request) {
Map<Object, Object> result = new HashMap<>();
JSONObject record = request.getRecord();
Map<String, String> colRelation = request.getTableColRelationMap().getOrDefault(request.getTableRelationId(), new HashMap<>());
String fields = record.getJSONObject("data").getJSONObject("record").getString("fields");
Map<Object, Object> midMap = JSONObject.parseObject(fields, Map.class);
for (Map.Entry<Object, Object> entry : midMap.entrySet()) {
String key = String.valueOf(entry.getKey());
if (!colRelation.containsKey(key)) {
continue;
}
result.put(colRelation.get(key), entry.getValue());
}
Map<Object, Map<Object, Object>> map = new HashMap<>();
map.put("fields", result);
return map;
}
protected void send(String type, String url, Map<Object, Map<Object, Object>> body, LarkRequest request) {
request.setOperateInfo(String.valueOf(body));
String token = request.getToken();
if (CREATE_OPERATE.equals(type)) {
JSONObject result = larkTokenHelper.postLark(url, body, token);
JSONObject data = result.getJSONObject("data");
if (data != null) {
JSONObject record = data.getJSONObject("record");
if (record != null && StringUtils.isNotBlank(record.getString("record_id"))) {
String recordId = record.getString("record_id");
LarkTableRowRelation rowRelation = new LarkTableRowRelation(request.getCompanyRelationId(), request.getEvent().getRecordId(), recordId, TableDetailRelationTypeEnum.ROW.getCode(), TableDetailRelationTypeEnum.ROW.getCode());
iLarkTableRowRelationService.insertLarkTableRowRelation(rowRelation);
}
}
request.setEventOperateType(EventOperateType.CREATE);
} else if (UPDATE_OPERATE.equals(type)) {
request.setEventOperateType(EventOperateType.UPDATE);
larkTokenHelper.putLark(url, body, token);
} else if (DELETE_OPERATE.equals(type)) {
request.setEventOperateType(EventOperateType.DELETE);
larkTokenHelper.deleteLark(url, body, token);
}
}
@Override
protected void endHandle(LarkRequest request) {
Event event = request.getEvent();
EventLog eventLog = null;
if (StringUtils.isBlank(request.getErrorMessage())) {
eventService.updateStatus(event.getId(), EventOperateStatus.SUCCESS.getCode(), event.getNumbers());
eventLog = new EventLog(event.getId(), request.getEventOperateType().getCode(), request.getMessage());
} else {
eventService.updateStatus(event.getId(), EventOperateStatus.PENDING.getCode(), event.getNumbers() + 1);
if (request.getEventOperateType() != null) {
new EventLog(event.getId(), request.getEventOperateType().getCode(), request.getMessage(), request.getErrorCode(), request.getErrorMessage());
}
}
if (eventLog != null) {
eventLog.setOperateInfo(request.getOperateType());
eventLogService.insertEventLog(eventLog);
}
}
@Override
protected String buildResult(LarkRequest request) {
return null;
}
@Override
protected String getName() {
return this.getClass().getSimpleName();
}
}

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.EventLogMapper">
<resultMap type="com.ruoyi.flyingbook.domain.EventLog" id="EventLogResult">
<result property="id" column="id" />
<result property="eventId" column="event_id" />
<result property="operateType" column="operate_type" />
<result property="operateInfo" column="operate_info" />
<result property="errorCode" column="error_code" />
<result property="errorMessage" column="error_message" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectEventLogVo">
select id, event_id, operate_type, operate_info, error_code, error_message, remark, create_by, create_time, update_by, update_time from event_log
</sql>
<select id="selectEventLogList" parameterType="com.ruoyi.flyingbook.domain.EventLog" resultMap="EventLogResult">
<include refid="selectEventLogVo"/>
<where>
<if test="eventId != null "> and event_id = #{eventId}</if>
<if test="operateType != null and operateType != ''"> and operate_type = #{operateType}</if>
<if test="operateInfo != null and operateInfo != ''"> and operate_info = #{operateInfo}</if>
<if test="errorCode != null and errorCode != ''"> and error_code = #{errorCode}</if>
<if test="errorMessage != null and errorMessage != ''"> and error_message = #{errorMessage}</if>
</where>
</select>
<select id="selectEventLogById" parameterType="Long" resultMap="EventLogResult">
<include refid="selectEventLogVo"/>
where id = #{id}
</select>
<insert id="insertEventLog" parameterType="com.ruoyi.flyingbook.domain.EventLog" useGeneratedKeys="true" keyProperty="id">
insert into event_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventId != null">event_id,</if>
<if test="operateType != null">operate_type,</if>
<if test="operateInfo != null">operate_info,</if>
<if test="errorCode != null">error_code,</if>
<if test="errorMessage != null">error_message,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="eventId != null">#{eventId},</if>
<if test="operateType != null">#{operateType},</if>
<if test="operateInfo != null">#{operateInfo},</if>
<if test="errorCode != null">#{errorCode},</if>
<if test="errorMessage != null">#{errorMessage},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateEventLog" parameterType="com.ruoyi.flyingbook.domain.EventLog">
update event_log
<trim prefix="SET" suffixOverrides=",">
<if test="eventId != null">event_id = #{eventId},</if>
<if test="operateType != null">operate_type = #{operateType},</if>
<if test="operateInfo != null">operate_info = #{operateInfo},</if>
<if test="errorCode != null">error_code = #{errorCode},</if>
<if test="errorMessage != null">error_message = #{errorMessage},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEventLogById" parameterType="Long">
delete from event_log where id = #{id}
</delete>
<delete id="deleteEventLogByIds" parameterType="String">
delete from event_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.EventMapper">
<resultMap type="com.ruoyi.flyingbook.domain.Event" id="EventResult">
<result property="id" column="id"/>
<result property="appId" column="app_id"/>
<result property="type" column="type"/>
<result property="appToken" column="app_token"/>
<result property="tableId" column="table_id"/>
<result property="recordId" column="record_id"/>
<result property="numbers" column="numbers"/>
<result property="operateStatus" column="operate_status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="flag" column="flag"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectEventVo">
select id,
app_id,
`type`,
app_token,
table_id,
record_id,
numbers,
operate_status,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from event
</sql>
<select id="selectEventList" parameterType="com.ruoyi.flyingbook.domain.Event" resultMap="EventResult">
<include refid="selectEventVo"/>
<where>
<if test="appId != null and appId != ''">and app_id = #{appId}</if>
<if test="type != null and type != ''">and `type` = #{type}</if>
<if test="appToken != null and appToken != ''">and app_token = #{appToken}</if>
<if test="tableId != null and tableId != ''">and table_id = #{tableId}</if>
<if test="recordId != null and recordId != ''">and record_id = #{recordId}</if>
<if test="numbers != null ">and numbers = #{numbers}</if>
<if test="operateStatus != null and operateStatus != ''">and operate_status = #{operateStatus}</if>
<if test="flag != null ">and flag = #{flag}</if>
</where>
</select>
<select id="selectEventById" parameterType="Long" resultMap="EventResult">
<include refid="selectEventVo"/>
where id = #{id}
</select>
<insert id="insertEvent" parameterType="com.ruoyi.flyingbook.domain.Event" useGeneratedKeys="true" keyProperty="id">
insert into event
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="appId != null">app_id,</if>
<if test="type != null">`type`,</if>
<if test="appToken != null">app_token,</if>
<if test="tableId != null">table_id,</if>
<if test="recordId != null">record_id,</if>
<if test="numbers != null">numbers,</if>
<if test="operateStatus != null">operate_status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="flag != null">flag,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="appId != null">#{appId},</if>
<if test="type != null">#{type},</if>
<if test="appToken != null">#{appToken},</if>
<if test="tableId != null">#{tableId},</if>
<if test="recordId != null">#{recordId},</if>
<if test="numbers != null">#{numbers},</if>
<if test="operateStatus != null">#{operateStatus},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateEvent" parameterType="com.ruoyi.flyingbook.domain.Event">
update event
<trim prefix="SET" suffixOverrides=",">
<if test="appId != null">app_id = #{appId},</if>
<if test="type != null">`type` = #{type},</if>
<if test="appToken != null">app_token = #{appToken},</if>
<if test="tableId != null">table_id = #{tableId},</if>
<if test="recordId != null">record_id = #{recordId},</if>
<if test="numbers != null">numbers = #{numbers},</if>
<if test="operateStatus != null">operate_status = #{operateStatus},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEventById" parameterType="Long">
delete
from event
where id = #{id}
</delete>
<delete id="deleteEventByIds" parameterType="String">
delete from event where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="queryEventList" parameterType="com.ruoyi.flyingbook.domain.Event" resultMap="EventResult">
<include refid="selectEventVo"/>
where operate_status = #{status} and `type` = #{type} and 3 > numbers
</select>
<update id="updateStatus" parameterType="com.ruoyi.flyingbook.domain.Event">
update event
set operate_status = #{status},
numbers = #{numbers}
where id = #{id}
</update>
</mapper>

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkCompanyRelationMapper">
<resultMap type="com.ruoyi.flyingbook.domain.LarkCompanyRelation" id="LarkCompanyRelationResult">
<result property="id" column="id" />
<result property="companyId" column="company_id" />
<result property="companyName" column="company_name" />
<result property="appId" column="app_id" />
<result property="secret" column="secret" />
<result property="appType" column="app_type" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="flag" column="flag" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectLarkCompanyRelationVo">
select id, company_id, company_name, app_id, secret, app_type, create_by, create_time, update_by, update_time, flag, remark from lark_company_relation
</sql>
<select id="selectLarkCompanyRelationList" parameterType="com.ruoyi.flyingbook.domain.LarkCompanyRelation" resultMap="LarkCompanyRelationResult">
<include refid="selectLarkCompanyRelationVo"/>
<where>
<if test="companyId != null "> and company_id = #{companyId}</if>
<if test="companyName != null and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
<if test="appId != null and appId != ''"> and app_id = #{appId}</if>
<if test="secret != null and secret != ''"> and secret = #{secret}</if>
<if test="appType != null and appType != ''"> and app_type = #{appType}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where>
</select>
<select id="selectLarkCompanyRelationById" parameterType="Long" resultMap="LarkCompanyRelationResult">
<include refid="selectLarkCompanyRelationVo"/>
where id = #{id}
</select>
<insert id="insertLarkCompanyRelation" parameterType="com.ruoyi.flyingbook.domain.LarkCompanyRelation" useGeneratedKeys="true" keyProperty="id">
insert into lark_company_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="companyId != null">company_id,</if>
<if test="companyName != null">company_name,</if>
<if test="appId != null and appId != ''">app_id,</if>
<if test="secret != null and secret != ''">secret,</if>
<if test="appType != null">app_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="flag != null">flag,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyId != null">#{companyId},</if>
<if test="companyName != null">#{companyName},</if>
<if test="appId != null and appId != ''">#{appId},</if>
<if test="secret != null and secret != ''">#{secret},</if>
<if test="appType != null">#{appType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateLarkCompanyRelation" parameterType="com.ruoyi.flyingbook.domain.LarkCompanyRelation">
update lark_company_relation
<trim prefix="SET" suffixOverrides=",">
<if test="companyId != null">company_id = #{companyId},</if>
<if test="companyName != null">company_name = #{companyName},</if>
<if test="appId != null and appId != ''">app_id = #{appId},</if>
<if test="secret != null and secret != ''">secret = #{secret},</if>
<if test="appType != null">app_type = #{appType},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLarkCompanyRelationById" parameterType="Long">
delete from lark_company_relation where id = #{id}
</delete>
<delete id="deleteLarkCompanyRelationByIds" parameterType="String">
delete from lark_company_relation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkTableRelationMapper">
<resultMap type="com.ruoyi.flyingbook.domain.LarkTableRelation" id="LarkTableRelationResult">
<result property="id" column="id" />
<result property="larkCompanyRelationId" column="lark_company_relation_id" />
<result property="fromAppToken" column="from_app_token" />
<result property="fromTableId" column="from_table_id" />
<result property="toAppToken" column="to_app_token" />
<result property="toTableId" column="to_table_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="flag" column="flag" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectLarkTableRelationVo">
select id, lark_company_relation_id, from_app_token, from_table_id, to_app_token, to_table_id, create_by, create_time, update_by, update_time, flag, remark from lark_table_relation
</sql>
<select id="selectLarkTableRelationList" parameterType="com.ruoyi.flyingbook.domain.LarkTableRelation" resultMap="LarkTableRelationResult">
<include refid="selectLarkTableRelationVo"/>
<where>
<if test="larkCompanyRelationId != null "> and lark_company_relation_id = #{larkCompanyRelationId}</if>
<if test="fromAppToken != null and fromAppToken != ''"> and from_app_token = #{fromAppToken}</if>
<if test="fromTableId != null and fromTableId != ''"> and from_table_id = #{fromTableId}</if>
<if test="toAppToken != null and toAppToken != ''"> and to_app_token = #{toAppToken}</if>
<if test="toTableId != null and toTableId != ''"> and to_table_id = #{toTableId}</if>
<if test="flag != null "> and flag = #{flag}</if>
</where>
</select>
<select id="selectLarkTableRelationById" parameterType="Long" resultMap="LarkTableRelationResult">
<include refid="selectLarkTableRelationVo"/>
where id = #{id}
</select>
<insert id="insertLarkTableRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRelation" useGeneratedKeys="true" keyProperty="id">
insert into lark_table_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="larkCompanyRelationId != null">lark_company_relation_id,</if>
<if test="fromAppToken != null">from_app_token,</if>
<if test="fromTableId != null">from_table_id,</if>
<if test="toAppToken != null">to_app_token,</if>
<if test="toTableId != null">to_table_id,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="flag != null">flag,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="larkCompanyRelationId != null">#{larkCompanyRelationId},</if>
<if test="fromAppToken != null">#{fromAppToken},</if>
<if test="fromTableId != null">#{fromTableId},</if>
<if test="toAppToken != null">#{toAppToken},</if>
<if test="toTableId != null">#{toTableId},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateLarkTableRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRelation">
update lark_table_relation
<trim prefix="SET" suffixOverrides=",">
<if test="larkCompanyRelationId != null">lark_company_relation_id = #{larkCompanyRelationId},</if>
<if test="fromAppToken != null">from_app_token = #{fromAppToken},</if>
<if test="fromTableId != null">from_table_id = #{fromTableId},</if>
<if test="toAppToken != null">to_app_token = #{toAppToken},</if>
<if test="toTableId != null">to_table_id = #{toTableId},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLarkTableRelationById" parameterType="Long">
delete from lark_table_relation where id = #{id}
</delete>
<delete id="deleteLarkTableRelationByIds" parameterType="String">
delete from lark_table_relation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.flyingbook.mapper.LarkTableRowRelationMapper">
<resultMap type="com.ruoyi.flyingbook.domain.LarkTableRowRelation" id="LarkTableRowRelationResult">
<result property="id" column="id"/>
<result property="tableRelationId" column="table_relation_id"/>
<result property="fromId" column="from_id"/>
<result property="toId" column="to_id"/>
<result property="type" column="type"/>
<result property="subType" column="sub_type"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="flag" column="flag"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectLarkTableRowRelationVo">
select id,
table_relation_id,
from_id,
to_id,
type,
sub_type,
create_by,
create_time,
update_by,
update_time,
flag,
remark
from lark_table_row_relation
</sql>
<select id="selectLarkTableRowRelationList" parameterType="com.ruoyi.flyingbook.domain.LarkTableRowRelation"
resultMap="LarkTableRowRelationResult">
<include refid="selectLarkTableRowRelationVo"/>
<where>
<if test="tableRelationId != null ">and table_relation_id = #{tableRelationId}</if>
<if test="fromId != null and fromId != ''">and from_id = #{fromId}</if>
<if test="toId != null and toId != ''">and to_id = #{toId}</if>
<if test="type != null and type != ''">and type = #{type}</if>
<if test="subType != null and subType != ''">and sub_type = #{subType}</if>
<if test="flag != null ">and flag = #{flag}</if>
</where>
</select>
<select id="selectLarkTableRowRelationById" parameterType="Long" resultMap="LarkTableRowRelationResult">
<include refid="selectLarkTableRowRelationVo"/>
where id = #{id}
</select>
<insert id="insertLarkTableRowRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRowRelation"
useGeneratedKeys="true" keyProperty="id">
insert into lark_table_row_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tableRelationId != null">table_relation_id,</if>
<if test="fromId != null">from_id,</if>
<if test="toId != null">to_id,</if>
<if test="type != null">type,</if>
<if test="subType != null">sub_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="flag != null">flag,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tableRelationId != null">#{tableRelationId},</if>
<if test="fromId != null">#{fromId},</if>
<if test="toId != null">#{toId},</if>
<if test="type != null">#{type},</if>
<if test="subType != null">#{subType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="flag != null">#{flag},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateLarkTableRowRelation" parameterType="com.ruoyi.flyingbook.domain.LarkTableRowRelation">
update lark_table_row_relation
<trim prefix="SET" suffixOverrides=",">
<if test="tableRelationId != null">table_relation_id = #{tableRelationId},</if>
<if test="fromId != null">from_id = #{fromId},</if>
<if test="toId != null">to_id = #{toId},</if>
<if test="type != null">type = #{type},</if>
<if test="subType != null">sub_type = #{subType},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="flag != null">flag = #{flag},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLarkTableRowRelationById" parameterType="Long">
delete
from lark_table_row_relation
where id = #{id}
</delete>
<delete id="deleteLarkTableRowRelationByIds" parameterType="String">
delete from lark_table_row_relation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="queryListByTableRelationIdList" parameterType="Long" resultMap="LarkTableRowRelationResult">
<include refid="selectLarkTableRowRelationVo"/>
where table_relation_id in
<foreach collection="tableRelationIdList" item="tableRelationId" separator="," open="(" close=")">
#{tableRelationId}
</foreach>
</select>
</mapper>

@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 验证码captchaImage 允许匿名访问 // 对于登录login 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/captchaImage").anonymous() .antMatchers("/login", "/captchaImage", "/approval", "/approval2").anonymous()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/*.html", "/*.html",

@ -0,0 +1,91 @@
DROP TABLE IF EXISTS `event`;
CREATE TABLE `event`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`app_id` varchar(255) DEFAULT NULL COMMENT '关联查找secret',
`type` varchar(255) DEFAULT NULL COMMENT '事件类型',
`app_token` varchar(255) DEFAULT NULL COMMENT '文件id',
`table_id` varchar(255) DEFAULT NULL COMMENT '表格id',
`record_id` varchar(255) DEFAULT NULL COMMENT '行id',
`numbers` int DEFAULT '0' COMMENT '重推次数',
`operate_status` varchar(255) DEFAULT NULL COMMENT '状态标记(未处理,处理完成)',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记(0未删除1删除)',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
DROP TABLE IF EXISTS `event_log`;
CREATE TABLE `event_log`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`event_id` bigint DEFAULT NULL,
`operate_type` varchar(255) DEFAULT NULL COMMENT '操作类型',
`operate_info` text COMMENT '操作日志',
`error_code` varchar(255) DEFAULT NULL COMMENT '错误编码',
`error_message` varchar(255) DEFAULT NULL COMMENT '错误信息',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
DROP TABLE IF EXISTS `lark_company_relation`;
CREATE TABLE `lark_company_relation`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`company_id` bigint DEFAULT NULL COMMENT '公司id',
`company_name` varchar(255) DEFAULT NULL COMMENT '公司名称',
`app_id` varchar(255) NOT NULL COMMENT '飞书的appId',
`secret` varchar(255) NOT NULL COMMENT '公司+appId对应的唯一密钥',
`app_type` varchar(255) DEFAULT NULL COMMENT 'app应用类型',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记0未删除、1已删除',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
DROP TABLE IF EXISTS `lark_table_relation`;
CREATE TABLE `lark_table_relation`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`lark_company_relation_id` bigint DEFAULT NULL COMMENT '公司与飞书关联表id',
`from_app_token` varchar(255) DEFAULT NULL,
`from_table_id` varchar(255) DEFAULT NULL COMMENT '来源表',
`to_app_token` varchar(255) DEFAULT NULL,
`to_table_id` varchar(255) DEFAULT NULL COMMENT '对应更新表',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记0未删除、1已删除',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
DROP TABLE IF EXISTS `lark_table_row_relation`;
CREATE TABLE `lark_table_row_relation`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一主键',
`table_relation_id` bigint DEFAULT NULL COMMENT '公司与飞书关联表id',
`from_id` varchar(255) DEFAULT NULL COMMENT '来源表',
`to_id` varchar(255) DEFAULT NULL COMMENT '对应更新表',
`type` varchar(20) DEFAULT NULL COMMENT '行,或者 列',
`sub_type` varchar(20) DEFAULT NULL COMMENT '列或行的明细属性',
`create_by` varchar(255) NOT NULL,
`create_time` datetime NOT NULL,
`update_by` varchar(255) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记0未删除、1已删除',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
Loading…
Cancel
Save