diff --git a/pom.xml b/pom.xml index 1d1091d..cb370af 100644 --- a/pom.xml +++ b/pom.xml @@ -215,6 +215,11 @@ ruoyi-flowable ${ruoyi.version} + + com.ruoyi + ruoyi-flyingbook + 3.4.1-SNAPSHOT + org.flowable @@ -274,6 +279,7 @@ ruoyi-generator ruoyi-common ruoyi-flowable + ruoyi-flyingbook pom diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 7574694..2627926 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -78,20 +78,14 @@ ruoyi-flowable - com.larksuite.oapi - oapi-sdk - 2.0.13 + com.ruoyi + ruoyi-flyingbook - - com.larksuite.oapi oapi-sdk 2.0.13 - - - diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index aaa7b50..70adbb6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -1,8 +1,10 @@ package com.ruoyi; +import com.lark.oapi.sdk.servlet.ext.ServletAdapter; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.context.annotation.Bean; /** * 启动程序 @@ -17,4 +19,5 @@ public class RuoYiApplication // System.setProperty("spring.devtools.restart.enabled", "false"); SpringApplication.run(RuoYiApplication.class, args); } + } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CompanyNameConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CompanyNameConstants.java new file mode 100644 index 0000000..5b89d6e --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CompanyNameConstants.java @@ -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"; + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/RedisConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/RedisConstants.java new file mode 100644 index 0000000..f5d3e58 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/RedisConstants.java @@ -0,0 +1,18 @@ +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("Multidimensional tabular feedback".replaceAll(" ","").toUpperCase()); + } + + /** + * 多维表格回调时间缓存key + */ + public static final String MULTIDIMENSIONALTABULARFEEDBACK = "MULTIDIMENSIONALTABULARFEEDBACK"; + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/EventOperateStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/EventOperateStatus.java new file mode 100644 index 0000000..3c2e52d --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/EventOperateStatus.java @@ -0,0 +1,32 @@ +package com.ruoyi.common.enums; + +/** + * 用户状态 + * + * @author ruoyi + */ +public enum EventOperateStatus { + + /** + * + */ + PENDING("PENDING", "未处理"), + SUCCESS("SUCCESS", "成功"), + FAIL("FAIL", "失败"); + + 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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/EventOperateType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/EventOperateType.java new file mode 100644 index 0000000..97054b3 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/EventOperateType.java @@ -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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/FlagStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/FlagStatus.java new file mode 100644 index 0000000..497d43d --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/FlagStatus.java @@ -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; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DecryptUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DecryptUtil.java new file mode 100644 index 0000000..5b90eb6 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DecryptUtil.java @@ -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; + } + +} diff --git a/ruoyi-flyingbook/.gitignore b/ruoyi-flyingbook/.gitignore deleted file mode 100644 index 549e00a..0000000 --- a/ruoyi-flyingbook/.gitignore +++ /dev/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/ diff --git a/ruoyi-flyingbook/.mvn/wrapper/maven-wrapper.jar b/ruoyi-flyingbook/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff0..0000000 Binary files a/ruoyi-flyingbook/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/ruoyi-flyingbook/.mvn/wrapper/maven-wrapper.properties b/ruoyi-flyingbook/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index ca5ab4b..0000000 --- a/ruoyi-flyingbook/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -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 diff --git a/ruoyi-flyingbook/pom.xml b/ruoyi-flyingbook/pom.xml index 3b6c6a5..26b17c9 100644 --- a/ruoyi-flyingbook/pom.xml +++ b/ruoyi-flyingbook/pom.xml @@ -3,14 +3,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.5.5 - + ruoyi + com.ruoyi + 3.4.0 - com.flyingbook + 3.4.1-SNAPSHOT ruoyi-flyingbook - 0.0.1-SNAPSHOT ruoyi-flyingbook Demo project for Spring Boot @@ -39,7 +37,15 @@ oapi-sdk 2.0.13 - + + com.ruoyi + ruoyi-common + + + com.squareup.okhttp3 + okhttp + 4.9.1 + oapi-sdk-servlet-ext com.larksuite.oapi @@ -55,21 +61,5 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - - - - diff --git a/ruoyi-flyingbook/src/main/java/com/flyingbook/controller/EventController.java b/ruoyi-flyingbook/src/main/java/com/flyingbook/controller/EventController.java deleted file mode 100644 index 49c13c9..0000000 --- a/ruoyi-flyingbook/src/main/java/com/flyingbook/controller/EventController.java +++ /dev/null @@ -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); - } - } - diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/LarkHelper/LarkTokenHelper.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/LarkHelper/LarkTokenHelper.java new file mode 100644 index 0000000..f4205a5 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/LarkHelper/LarkTokenHelper.java @@ -0,0 +1,98 @@ +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(); + + + public String getToken(String appId, String srcret) { + Response execute = null; + Map map = new HashMap<>(); + map.put("app_id", appId); + map.put("app_secret", srcret); + Request request = new Request.Builder() + .method("POST", RequestBody.create(JSONObject.toJSONString(map), MediaType.get("application/json"))) + .url("https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal") + .build(); + try { + execute = client.newCall(request).execute(); + if (ObjectUtil.isNotNull(execute) && execute.isSuccessful()) { + return execute.body().string(); + } + } catch (IOException e) { + log.error("http post 请求失败--{}", e); + } + return null; + } + + /** + * @param url + * @param token + * @return + */ + public String getLark(String url,Map body, String token) { + Response execute = null; + Request request = new Request.Builder() + .url(url) + .addHeader("Authorization",String.format("Bearer %s",token)) + .build(); + try { + execute = client.newCall(request).execute(); + log.info(JSONObject.toJSONString(execute.body().string())); + if (ObjectUtil.isNotNull(execute) && execute.isSuccessful()) { + return execute.body().string(); + } + } catch (IOException e) { + log.error("http get 请求失败--{}", e); + } + return null; + } + + public String postLark(String url,Map body, String token) { + Response execute = null; + Request request = new Request.Builder() + .method("POST", RequestBody + .create(JSONObject.toJSONString(body), MediaType.get("application/json"))) + .url(url) +// .addHeader("Authorization",String.format("Bearer %s",token)) + .build(); + try { + execute = client.newCall(request).execute(); + if (ObjectUtil.isNotNull(execute) && execute.isSuccessful()) { + return execute.body().string(); + } + } catch (IOException e) { + log.error("http post 请求失败--{}", e); + } + return null; + } + + public static void main(String[] args) { + LarkTokenHelper helper = new LarkTokenHelper(); + String token = helper.getToken( "cli_a482a8572cbc9013", "lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos"); + System.out.println(token); + JSONObject jsonObject = JSONObject.parseObject(token); + helper.getLark("https://open.feishu.cn/open-apis/approval/v4/instances/81D31358-93AF-92D6-7425-01A5D67C4E71",null,jsonObject.getString("tenant_access_token")); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/flyingbook/RuoyiFlyingbookApplication.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/RuoyiFlyingbookApplication.java similarity index 94% rename from ruoyi-flyingbook/src/main/java/com/flyingbook/RuoyiFlyingbookApplication.java rename to ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/RuoyiFlyingbookApplication.java index 9a47537..dd5f1a0 100644 --- a/ruoyi-flyingbook/src/main/java/com/flyingbook/RuoyiFlyingbookApplication.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/RuoyiFlyingbookApplication.java @@ -1,4 +1,4 @@ -package com.flyingbook; +package com.ruoyi.flyingbook; import com.lark.oapi.sdk.servlet.ext.ServletAdapter; import org.springframework.boot.SpringApplication; diff --git a/ruoyi-flyingbook/src/main/java/com/flyingbook/config/DocxSample.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/config/DocxSample.java similarity index 98% rename from ruoyi-flyingbook/src/main/java/com/flyingbook/config/DocxSample.java rename to ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/config/DocxSample.java index c188257..c622c38 100644 --- a/ruoyi-flyingbook/src/main/java/com/flyingbook/config/DocxSample.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/config/DocxSample.java @@ -1,4 +1,4 @@ -package com.flyingbook.config; +package com.ruoyi.flyingbook.config; import com.lark.oapi.Client; diff --git a/ruoyi-flyingbook/src/main/java/com/flyingbook/config/RawApiCall.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/config/RawApiCall.java similarity index 97% rename from ruoyi-flyingbook/src/main/java/com/flyingbook/config/RawApiCall.java rename to ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/config/RawApiCall.java index 2ed7a91..fd5db3d 100644 --- a/ruoyi-flyingbook/src/main/java/com/flyingbook/config/RawApiCall.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/config/RawApiCall.java @@ -1,4 +1,4 @@ -package com.flyingbook.config; +package com.ruoyi.flyingbook.config; import com.lark.oapi.Client; import com.lark.oapi.core.enums.AppType; import com.lark.oapi.core.response.RawResponse; diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/consumer/LarkApplicationRunner.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/consumer/LarkApplicationRunner.java new file mode 100644 index 0000000..53be82d --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/consumer/LarkApplicationRunner.java @@ -0,0 +1,100 @@ +package com.ruoyi.flyingbook.consumer; + +import cn.hutool.core.thread.ThreadFactoryBuilder; +import com.ruoyi.common.constant.RedisConstants; +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 = 5000; + + @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(QUEUE_SIZE), new ThreadPoolExecutor.AbortPolicy()); + + @Override + public void run(ApplicationArguments args) throws Exception { + //这里用线程池,后续如果出现量大的情况下可以调整 + threadPool.execute(() -> { + + while (true) { + List statusList = Arrays.asList(EventOperateStatus.PENDING.getCode(),EventOperateStatus.FAIL.getCode()); + List eventList = eventMapper.queryListOperate(statusList); + 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(); + } + } + } + }); + } + +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EventController.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EventController.java new file mode 100644 index 0000000..021e186 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EventController.java @@ -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.ApprovalCallback; +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 ApprovalCallback approvalCallback; + + //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); + approvalCallback.execute(larkRequest); + return result; + } +} + diff --git a/ruoyi-flyingbook/src/main/java/com/flyingbook/controller/EventControllers.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EventControllers.java similarity index 95% rename from ruoyi-flyingbook/src/main/java/com/flyingbook/controller/EventControllers.java rename to ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EventControllers.java index 5fc9b87..5d649e0 100644 --- a/ruoyi-flyingbook/src/main/java/com/flyingbook/controller/EventControllers.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EventControllers.java @@ -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 com.lark.oapi.core.utils.Jsons; 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 javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Map; +@Slf4j @RestController public class EventControllers { @@ -167,11 +173,13 @@ public class EventControllers { private ServletAdapter servletAdapter; //3. 创建路由处理器 - @RequestMapping("/webhook/events") + @PostMapping("/approval2") public void event(HttpServletRequest request, HttpServletResponse response) throws Throwable { //3.1 回调扩展包提供的事件回调处理器 servletAdapter.handleEvent(request, response, EVENT_DISPATCHER); + Map parameterMap = request.getParameterMap(); + log.info("/event/test2/approval request:{}", JSONObject.toJSONString(parameterMap)); } diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/Event.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/Event.java new file mode 100644 index 0000000..64899e8 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/Event.java @@ -0,0 +1,88 @@ +package com.ruoyi.flyingbook.domain; + +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; + +/** + * 【请填写功能名称】对象 event + * + * @author ruoyi + * @date 2023-03-12 + */ +public class Event extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + private Integer numbers; + private String eventCode; + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String message; + + /** pendingsuccessfaild */ + @Excel(name = "pendingsuccessfaild") + private String flag; + + public Integer getNumbers() { + return numbers; + } + + public void setNumbers(Integer numbers) { + this.numbers = numbers; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setMessage(String message) + { + this.message = message; + } + + public String getMessage() + { + return message; + } + public void setFlag(String flag) + { + this.flag = flag; + } + + public String getFlag() + { + return flag; + } + + public String getEventCode() { + return eventCode; + } + + public void setEventCode(String eventCode) { + this.eventCode = eventCode; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("message", getMessage()) + .append("numbers", getMessage()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("flag", getFlag()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/EventLog.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/EventLog.java new file mode 100644 index 0000000..a84d57b --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/EventLog.java @@ -0,0 +1,154 @@ +package com.ruoyi.flyingbook.domain; + +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; + +/** + * 【请填写功能名称】对象 event_log + * + * @author ruoyi + * @date 2023-03-12 + */ +public class EventLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** id */ + @Excel(name = "id") + private String tableId; + + /** id */ + @Excel(name = "id") + private String recordId; + + /** id */ + @Excel(name = "id") + private Long eventId; + + /** $column.columnComment */ + @Excel(name = "id") + private String operateType; + + /** $column.columnComment */ + @Excel(name = "id") + private String operateStatus; + + /** $column.columnComment */ + @Excel(name = "id") + private String errorCode; + + /** $column.columnComment */ + @Excel(name = "id") + private String errorMessage; + + /** 01 */ + @Excel(name = "01") + private Long flag; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setTableId(String tableId) + { + this.tableId = tableId; + } + + public String getTableId() + { + return tableId; + } + public void setRecordId(String recordId) + { + this.recordId = recordId; + } + + public String getRecordId() + { + return recordId; + } + public void setEventId(Long eventId) + { + this.eventId = eventId; + } + + public Long getEventId() + { + return eventId; + } + public void setOperateType(String operateType) + { + this.operateType = operateType; + } + + public String getOperateType() + { + return operateType; + } + public void setOperateStatus(String operateStatus) + { + this.operateStatus = operateStatus; + } + + public String getOperateStatus() + { + return operateStatus; + } + public void setErrorCode(String errorCode) + { + this.errorCode = errorCode; + } + + public String getErrorCode() + { + return errorCode; + } + public void setErrorMessage(String errorMessage) + { + this.errorMessage = errorMessage; + } + + public String getErrorMessage() + { + return errorMessage; + } + public void setFlag(Long flag) + { + this.flag = flag; + } + + public Long getFlag() + { + return flag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("tableId", getTableId()) + .append("recordId", getRecordId()) + .append("eventId", getEventId()) + .append("operateType", getOperateType()) + .append("operateStatus", getOperateStatus()) + .append("errorCode", getErrorCode()) + .append("errorMessage", getErrorMessage()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("flag", getFlag()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkCompanyRelation.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkCompanyRelation.java new file mode 100644 index 0000000..d9e03b6 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkCompanyRelation.java @@ -0,0 +1,112 @@ +package com.ruoyi.flyingbook.domain; + +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; + +/** + * 【请填写功能名称】对象 lark_company_relation + * + * @author ruoyi + * @date 2023-03-12 + */ +public class LarkCompanyRelation extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** id */ + @Excel(name = "id") + private Long companyId; + + /** $column.columnComment */ + @Excel(name = "id") + private String companyName; + + /** appId */ + @Excel(name = "appId") + private String appId; + + /** +appId */ + @Excel(name = "+appId") + private String secret; + + /** 01 */ + @Excel(name = "01") + private Long flag; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setCompanyId(Long companyId) + { + this.companyId = companyId; + } + + public Long getCompanyId() + { + return companyId; + } + public void setCompanyName(String companyName) + { + this.companyName = companyName; + } + + public String getCompanyName() + { + return companyName; + } + public void setAppId(String appId) + { + this.appId = appId; + } + + public String getAppId() + { + return appId; + } + public void setSecret(String secret) + { + this.secret = secret; + } + + public String getSecret() + { + return secret; + } + public void setFlag(Long flag) + { + this.flag = flag; + } + + public Long getFlag() + { + return flag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("companyId", getCompanyId()) + .append("companyName", getCompanyName()) + .append("appId", getAppId()) + .append("secret", getSecret()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("flag", getFlag()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkRequest.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkRequest.java new file mode 100644 index 0000000..23a29eb --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkRequest.java @@ -0,0 +1,30 @@ +package com.ruoyi.flyingbook.domain; + +import lombok.Data; + +/** + * @author yuxiangyong + * @create 2023-03-12 16:00 + */ +@Data +public class LarkRequest { + + /** + * 通用信息,不可修改不可删除 + */ + private String token; + private String appId; + private String url; + private String errorMessage; + + /** + * ApprovalCallback 用参数 + */ + private Long eventId; + private String message; + + /** + * MultidimensionalTableOperate 用参数 + */ + private Event event; +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkTableRelation.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkTableRelation.java new file mode 100644 index 0000000..5f1f7bc --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/LarkTableRelation.java @@ -0,0 +1,112 @@ +package com.ruoyi.flyingbook.domain; + +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; + +/** + * 【请填写功能名称】对象 lark_table_relation + * + * @author ruoyi + * @date 2023-03-12 + */ +public class LarkTableRelation extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** id */ + @Excel(name = "id") + private Long larkCompanyRelationId; + + /** $column.columnComment */ + @Excel(name = "id") + private String fromTableId; + + /** $column.columnComment */ + @Excel(name = "id") + private String toTableId; + + /** url */ + @Excel(name = "url") + private Long url; + + /** 01 */ + @Excel(name = "01") + private Long flag; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setLarkCompanyRelationId(Long larkCompanyRelationId) + { + this.larkCompanyRelationId = larkCompanyRelationId; + } + + public Long getLarkCompanyRelationId() + { + return larkCompanyRelationId; + } + public void setFromTableId(String fromTableId) + { + this.fromTableId = fromTableId; + } + + public String getFromTableId() + { + return fromTableId; + } + public void setToTableId(String toTableId) + { + this.toTableId = toTableId; + } + + public String getToTableId() + { + return toTableId; + } + public void setUrl(Long url) + { + this.url = url; + } + + public Long getUrl() + { + return url; + } + public void setFlag(Long flag) + { + this.flag = flag; + } + + public Long getFlag() + { + return flag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("larkCompanyRelationId", getLarkCompanyRelationId()) + .append("fromTableId", getFromTableId()) + .append("toTableId", getToTableId()) + .append("url", getUrl()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("flag", getFlag()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/EventLogMapper.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/EventLogMapper.java new file mode 100644 index 0000000..af10514 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/EventLogMapper.java @@ -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 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); +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/EventMapper.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/EventMapper.java new file mode 100644 index 0000000..4cd1e18 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/EventMapper.java @@ -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 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 queryListOperate(@Param("statusList") List statusList); +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/LarkCompanyRelationMapper.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/LarkCompanyRelationMapper.java new file mode 100644 index 0000000..64ad41a --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/LarkCompanyRelationMapper.java @@ -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 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); +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/LarkTableRelationMapper.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/LarkTableRelationMapper.java new file mode 100644 index 0000000..9efe617 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/mapper/LarkTableRelationMapper.java @@ -0,0 +1,63 @@ +package com.ruoyi.flyingbook.mapper; + + +import com.ruoyi.flyingbook.domain.LarkTableRelation; + +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 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); +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/IEventLogService.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/IEventLogService.java new file mode 100644 index 0000000..5ee0d25 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/IEventLogService.java @@ -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 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); +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/IEventService.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/IEventService.java new file mode 100644 index 0000000..57afc98 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/IEventService.java @@ -0,0 +1,63 @@ +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 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); +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/ILarkCompanyRelationService.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/ILarkCompanyRelationService.java new file mode 100644 index 0000000..a324994 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/ILarkCompanyRelationService.java @@ -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 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 getByCompanyName(String companyName); +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/ILarkTableRelationService.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/ILarkTableRelationService.java new file mode 100644 index 0000000..22e6bdd --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/ILarkTableRelationService.java @@ -0,0 +1,63 @@ +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 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); +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/EventLogServiceImpl.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/EventLogServiceImpl.java new file mode 100644 index 0000000..827a50c --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/EventLogServiceImpl.java @@ -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 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); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/EventServiceImpl.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/EventServiceImpl.java new file mode 100644 index 0000000..98bd8b1 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/EventServiceImpl.java @@ -0,0 +1,98 @@ +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 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); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/LarkCompanyRelationServiceImpl.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/LarkCompanyRelationServiceImpl.java new file mode 100644 index 0000000..ffac965 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/LarkCompanyRelationServiceImpl.java @@ -0,0 +1,116 @@ +package com.ruoyi.flyingbook.service.impl; + +import java.util.List; + +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 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 getByCompanyName(String companyName) + { + if (StringUtils.isEmpty(companyName)){ + return null; + } + LarkCompanyRelation relation = new LarkCompanyRelation(); + List larkCompanyRelations = larkCompanyRelationMapper.selectLarkCompanyRelationList(relation); + return CollectionUtils.isEmpty(larkCompanyRelations) ? null : larkCompanyRelations.get(0); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/LarkTableRelationServiceImpl.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/LarkTableRelationServiceImpl.java new file mode 100644 index 0000000..4e5b2cc --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/service/impl/LarkTableRelationServiceImpl.java @@ -0,0 +1,97 @@ +package com.ruoyi.flyingbook.service.impl; + +import java.util.List; + +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 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); + } +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/LarkOperateAbstract.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/LarkOperateAbstract.java new file mode 100644 index 0000000..309af69 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/LarkOperateAbstract.java @@ -0,0 +1,66 @@ +package com.ruoyi.flyingbook.strategy; + +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); + //业务处理完成后的系列操作,例如日志 + endHandle(request); + }catch (Exception e){ + log.error("{} execute error: {}",getName(),e); + } + //构建返回对象并返回 + 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(); + +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/callback/ApprovalCallback.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/callback/ApprovalCallback.java new file mode 100644 index 0000000..d416731 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/callback/ApprovalCallback.java @@ -0,0 +1,94 @@ +package com.ruoyi.flyingbook.strategy.callback; + +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.Date; + +/** + * @author yuxiangyong + * @create 2023-03-12 15:58 + */ +@Slf4j +@Service +public class ApprovalCallback extends CallbackAbstract { + + @Autowired + private IEventService eventService; + @Autowired + private IEventLogService eventLogService; + @Autowired + private RedisTemplate redisTemplate; + + @Override + protected Boolean check(LarkRequest request) { + String message = ""; + return Boolean.TRUE; + } + + @Override + protected void preOperate(LarkRequest request) { + + } + + @Override + protected void businessProcessing(LarkRequest request) { + String message = request.getMessage(); + Event event = this.buildDto(message); + int i = eventService.insertEvent(event); + request.setEventId(event.getId()); + + } + + @Override + protected void endHandle(LarkRequest request) { + if (request.getEventId() == null){ + return; + } + redisTemplate.opsForList().rightPush(RedisConstants.MULTIDIMENSIONALTABULARFEEDBACK,request.getEventId()); + EventLog eventLog = new EventLog(); + eventLog.setCreateBy("Syetem"); + eventLog.setCreateTime(new Date()); + eventLog.setFlag(FlagStatus.OK.getCode()); + eventLog.setOperateStatus(EventOperateStatus.PENDING.getCode()); + eventLog.setOperateType(EventOperateType.CALL_BACK.getCode()); + eventLog.setEventId(request.getEventId()); + eventLogService.insertEventLog(eventLog); + Object o = redisTemplate.opsForList().leftPop(RedisConstants.MULTIDIMENSIONALTABULARFEEDBACK); + System.out.println(String.valueOf(o)); + } + + @Override + protected String buildResult(LarkRequest request) { + return ""; + } + + + @Override + protected String getName() { + return this.getClass().getSimpleName(); + } + + + private Event buildDto(String message){ + Event event = new Event(); + event.setFlag(EventOperateStatus.PENDING.getCode()); + event.setMessage(message); + event.setEventCode("test"); + event.setCreateBy("System"); + event.setCreateTime(new Date()); + return event; + } + +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/callback/CallbackAbstract.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/callback/CallbackAbstract.java new file mode 100644 index 0000000..deca072 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/callback/CallbackAbstract.java @@ -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 { + + +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/LarkAbstract.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/LarkAbstract.java new file mode 100644 index 0000000..f03a8b6 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/LarkAbstract.java @@ -0,0 +1,33 @@ +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 getBody(String message); + + /** + * 文本解析 + */ + protected abstract JSONObject send(String url,Map body,String token); + + + +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableOperate.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableOperate.java new file mode 100644 index 0000000..24a49a8 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableOperate.java @@ -0,0 +1,92 @@ +package com.ruoyi.flyingbook.strategy.operate; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.constant.CompanyNameConstants; +import com.ruoyi.flyingbook.LarkHelper.LarkTokenHelper; +import com.ruoyi.flyingbook.domain.Event; +import com.ruoyi.flyingbook.domain.LarkCompanyRelation; +import com.ruoyi.flyingbook.domain.LarkRequest; +import com.ruoyi.flyingbook.service.IEventService; +import com.ruoyi.flyingbook.service.ILarkCompanyRelationService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; + + +/** + * 多维表格操作类 + * @author yuxiangyong + * @create 2023-03-13 20:47 + */ +@Component("MultidimensionalTableOperate") +public class MultidimensionalTableOperate extends LarkAbstract { + + @Autowired + protected LarkTokenHelper larkTokenHelper; + @Autowired + protected ILarkCompanyRelationService larkCompanyRelationService; + @Autowired + protected IEventService iEventService; + + private String getDetailUrl = "https://open.feishu.cn/open-apis/approval/v4/instances/:instance_id"; + + @Override + protected void preOperate(LarkRequest request) { + Event event = request.getEvent(); + if (event == null) { + return; + } + LarkCompanyRelation relation = larkCompanyRelationService.getByCompanyName(CompanyNameConstants.COMPANY_NAME); + if (relation == null) { + return; + } + String token = larkTokenHelper.getToken(relation.getAppId(), relation.getSecret()); + if (StringUtils.isBlank(token)) { + return; + } + request.setToken(token); + if (StringUtils.isNotBlank(event.getMessage())) { + return; + } + getDetailUrl.replace(":instance_id", "aaa"); + String message = larkTokenHelper.postLark(getDetailUrl, null, token); + event.setMessage(message); + } + + @Override + protected void businessProcessing(LarkRequest request) { + if (StringUtils.isBlank(request.getToken()) || request.getEvent() == null || StringUtils.isBlank(request.getEvent().getMessage())) { + return; + } + send(getUrl(request), getBody(request.getMessage()), request.getToken()); + } + + @Override + protected String getUrl(LarkRequest request) { + return null; + } + + @Override + protected Map getBody(String message) { + return null; + } + + @Override + protected JSONObject send(String url, Map body, String token) { + larkTokenHelper.postLark(url,body,token); + return null; + } + + @Override + protected String buildResult(LarkRequest request) { + return null; + } + + @Override + protected String getName() { + return this.getClass().getSimpleName(); + } + +} diff --git a/ruoyi-flyingbook/src/main/resources/mapper/EventLogMapper.xml b/ruoyi-flyingbook/src/main/resources/mapper/EventLogMapper.xml new file mode 100644 index 0000000..cbf0bcc --- /dev/null +++ b/ruoyi-flyingbook/src/main/resources/mapper/EventLogMapper.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, + table_id, + record_id, + event_id, + operate_type, + operate_status, + error_code, + error_message, + create_by, + create_time, + update_by, + update_time, + flag, + remark + from event_log + + + + + + + + insert into event_log + + table_id, + record_id, + event_id, + operate_type, + operate_status, + error_code, + error_message, + create_by, + create_time, + update_by, + update_time, + flag, + remark, + + + #{tableId}, + #{recordId}, + #{eventId}, + #{operateType}, + #{operateStatus}, + #{errorCode}, + #{errorMessage}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{flag}, + #{remark}, + + + + + update event_log + + table_id = #{tableId}, + record_id = #{recordId}, + event_id = #{eventId}, + operate_type = #{operateType}, + operate_status = #{operateStatus}, + error_code = #{errorCode}, + error_message = #{errorMessage}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + flag = #{flag}, + remark = #{remark}, + + where id = #{id} + + + + delete + from event_log + where id = #{id} + + + + delete from event_log where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-flyingbook/src/main/resources/mapper/EventMapper.xml b/ruoyi-flyingbook/src/main/resources/mapper/EventMapper.xml new file mode 100644 index 0000000..0a792d3 --- /dev/null +++ b/ruoyi-flyingbook/src/main/resources/mapper/EventMapper.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + select id, + event_code, + message, + numbers, + create_by, + create_time, + update_by, + update_time, + flag, + remark + from event + + + + + + + + insert into event + + event_code, + message, + numbers, + create_by, + create_time, + update_by, + update_time, + flag, + remark, + + + #{event_code}, + #{message}, + #{numbers}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{flag}, + #{remark}, + + + + + update event + + message = #{event_code}, + message = #{message}, + message = #{numbers}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + flag = #{flag}, + remark = #{remark}, + + where id = #{id} + + + + delete + from event + where id = #{id} + + + + delete from event where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ruoyi-flyingbook/src/main/resources/mapper/LarkCompanyRelationMapper.xml b/ruoyi-flyingbook/src/main/resources/mapper/LarkCompanyRelationMapper.xml new file mode 100644 index 0000000..256c298 --- /dev/null +++ b/ruoyi-flyingbook/src/main/resources/mapper/LarkCompanyRelationMapper.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + select id, + company_id, + company_name, + app_id, + secret, + create_by, + create_time, + update_by, + update_time, + flag, + remark + from lark_company_relation + + + + + + + + insert into lark_company_relation + + company_id, + company_name, + app_id, + secret, + create_by, + create_time, + update_by, + update_time, + flag, + remark, + + + #{companyId}, + #{companyName}, + #{appId}, + #{secret}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{flag}, + #{remark}, + + + + + update lark_company_relation + + company_id = #{companyId}, + company_name = #{companyName}, + app_id = #{appId}, + secret = #{secret}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + flag = #{flag}, + remark = #{remark}, + + where id = #{id} + + + + delete + from lark_company_relation + where id = #{id} + + + + delete from lark_company_relation where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-flyingbook/src/main/resources/mapper/LarkTableRelationMapper.xml b/ruoyi-flyingbook/src/main/resources/mapper/LarkTableRelationMapper.xml new file mode 100644 index 0000000..553eaf5 --- /dev/null +++ b/ruoyi-flyingbook/src/main/resources/mapper/LarkTableRelationMapper.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + select id, + lark_company_relation_id, + from_table_id, + to_table_id, + url, + create_by, + create_time, + update_by, + update_time, + flag, + remark + from lark_table_relation + + + + + + + + insert into lark_table_relation + + lark_company_relation_id, + from_table_id, + to_table_id, + url, + create_by, + create_time, + update_by, + update_time, + flag, + remark, + + + #{larkCompanyRelationId}, + #{fromTableId}, + #{toTableId}, + #{url}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{flag}, + #{remark}, + + + + + update lark_table_relation + + lark_company_relation_id = #{larkCompanyRelationId}, + from_table_id = #{fromTableId}, + to_table_id = #{toTableId}, + url = #{url}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + flag = #{flag}, + remark = #{remark}, + + where id = #{id} + + + + delete + from lark_table_relation + where id = #{id} + + + + delete from lark_table_relation where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 8cbd872..aa0b33c 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 过滤请求 .authorizeRequests() // 对于登录login 验证码captchaImage 允许匿名访问 - .antMatchers("/login", "/captchaImage").anonymous() + .antMatchers("/login", "/captchaImage", "/approval", "/approval2").anonymous() .antMatchers( HttpMethod.GET, "/*.html", diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/LarkCallbackRequest.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/LarkCallbackRequest.java new file mode 100644 index 0000000..5a11647 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/LarkCallbackRequest.java @@ -0,0 +1,11 @@ +package com.ruoyi.system.domain; + +import com.ruoyi.common.base.LarkRequest; + +/** + * @author yuxiangyong + * @create 2023-03-12 16:00 + */ +public class LarkCallbackRequest extends LarkRequest { + +} diff --git a/sql/lark.sql b/sql/lark.sql new file mode 100644 index 0000000..82f0906 --- /dev/null +++ b/sql/lark.sql @@ -0,0 +1,71 @@ +-- 飞书-公司关联表 +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对应的唯一密钥', + `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; +-- AppId-table关联表 +CREATE TABLE `lark_table_relation` +( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '唯一主键', + `lark_company_relation_id` BIGINT DEFAULT NULL COMMENT '公司与飞书关联表id', + `from_table_id` VARCHAR(255) DEFAULT NULL COMMENT '来源表', + `to_table_id` VARCHAR(255) DEFAULT NULL COMMENT '对应更新表', + `url` BIGINT DEFAULT NULL COMMENT 'url地址', + `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; + +-- 事务操作日志 +CREATE TABLE `event_log` +( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '唯一主键', + `table_id` VARCHAR(255) DEFAULT NULL COMMENT '多维表格id', + `record_id` VARCHAR(255) DEFAULT NULL COMMENT '实际行id', + `event_id` BIGINT DEFAULT NULL COMMENT '实际事务id', + `operate_type` VARCHAR(255) DEFAULT NULL COMMENT '操作类型', + `operate_status` VARCHAR(255) DEFAULT NULL COMMENT '操作编码', + `error_code` VARCHAR(255) DEFAULT NULL COMMENT '错误编码', + `error_message` 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; + +-- 事务详情 +CREATE TABLE `event` +( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '唯一主键', + `message` text 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` VARCHAR(20) NOT NULL COMMENT '状态标记(pending处理中、success成功、faild失败)', + `remark` VARCHAR(255) DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`id`) +) ENGINE = INNODB; + + + + +