From b4300cc19f50d4d47778e53b558ba5cc991767e5 Mon Sep 17 00:00:00 2001 From: YXY <932687738@qq.com> Date: Sun, 16 Jul 2023 13:59:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=97=E7=95=85=E6=8D=B7=E9=80=9A?= =?UTF-8?q?=E7=9A=84=E5=AF=86=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flyingbook/controller/EdiController.java | 84 ++++++------------- .../domain/edi/CJTEdiRequestVo.java | 13 +++ .../framework/config/SecurityConfig.java | 2 +- 3 files changed, 40 insertions(+), 59 deletions(-) create mode 100644 ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/edi/CJTEdiRequestVo.java diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EdiController.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EdiController.java index 5f01e2d..4ab1f5e 100644 --- a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EdiController.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EdiController.java @@ -1,24 +1,24 @@ package com.ruoyi.flyingbook.controller; +import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.utils.PdfUtils; import com.ruoyi.flyingbook.LarkHelper.LarkFileHelper; -import com.ruoyi.flyingbook.domain.Event; import com.ruoyi.flyingbook.domain.EventLog; import com.ruoyi.flyingbook.domain.edi.EdiResponseVo; import com.ruoyi.flyingbook.domain.edi.SyncToTableRequest; +import com.ruoyi.flyingbook.domain.edi.CJTEdiRequestVo; import com.ruoyi.flyingbook.edi.EdiOperateService; import com.ruoyi.flyingbook.service.IEventLogService; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.FileUtils; +import org.apache.commons.codec.binary.Base64; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.web.bind.annotation.*; -import java.io.File; -import java.io.InputStream; +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; import java.util.Arrays; @Slf4j @@ -51,59 +51,27 @@ public class EdiController extends BaseController { iEventLogService.insertEventLog(log1); EventLog log2 = new EventLog(); iEventLogService.insertBatchEventLog(Arrays.asList(log1,log2)); + } -// System.out.println(System.getProperty("user.dir")); -// ClassPathResource classPathResource = new ClassPathResource("photo/title.png"); -// InputStream inputStream = null; -// try { -// inputStream = classPathResource.getInputStream(); -// File inuModel = new File("/"); -// FileUtils.copyToFile(inputStream, inuModel); -// System.out.println(inuModel.getName()); -// } catch (Exception e) { -// log.error("", e); -// }finally { -// if (inputStream != null){ -// inputStream.close(); -// } -// } -// Resource resource = resourceLoader.getResource("classpath:photo/title.png"); -// InputStream inputStream2 = null; -// try { -// inputStream2 = resource.getInputStream(); -// File inuModel = new File("/"); -// FileUtils.copyToFile(inputStream, inuModel); -// System.out.println(inuModel.getName()); -// } catch (Exception e) { -// log.error("", e); -// }finally { -// if (inputStream2 != null){ -// inputStream2.close(); -// } -// } -// CourseFeedbackTemplateDto resultDTO = new CourseFeedbackTemplateDto(); -// resultDTO.setProgram("program"); -// resultDTO.setStudentName("student"); -// resultDTO.setTutor("tutor"); -// resultDTO.setStartClassTime("2023-05-21 15:51:45"); -// resultDTO.setEndClassTime("2023-05-22 15:51:45"); -// resultDTO.setFeedback("作业完成情况"); -// resultDTO.setFeedbackScore("7 /10"); -// resultDTO.setPerformance("课堂表现"); -// resultDTO.setPerformanceScore("9/10"); -// resultDTO.setContent("

1、课堂内容1

1、课堂内容2

"); -// resultDTO.setWork("

1、课后作业1

1、课后作业2

1、课后作业3

"); -// pdfUtils.createFile("COURSE_FEEDBACK.ftl",resultDTO); -// String path1 = System.getProperty("user.dir") + "/" + "test.pdf"; -// File file1 = new File(path1); -// file1.delete(); -// String path2 = System.getProperty("user.dir") + "/" + "test1.pdf"; -// File file2 = new File(path2); -// Long length = file2.length(); -// LarkFileRequest fileRequest = new LarkFileRequest("cli_a482a8572cbc9013","lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos", -// file2,file2.getName(),length.intValue(),"fldcnLt2RyUgDDD6rgC6K9gIWlM"); -// larkFileHelper.uploadFile(fileRequest); -// file2.delete(); + /** + * 同步数据到飞书表格 + */ + @PostMapping("/cjtTicket") + public JSONObject receiveCjtTicket(@RequestBody CJTEdiRequestVo request) { + try { + log.error("receiveWscTicket request:{}",JSONObject.toJSONString(request)); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec("ND2ANZB8F7NplUqc".getBytes(StandardCharsets.UTF_8), "AES")); + byte[] bytes = Base64.decodeBase64(request.getEncryptMsg()); + bytes = cipher.doFinal(bytes); + String encryptMsg = new String(bytes, StandardCharsets.UTF_8); + log.error("receiveWscTicket encryptMsg:{}",encryptMsg); + }catch (Exception e){ + log.error("receiveWscTicket error request:{}",JSONObject.toJSONString(request),e); + } + JSONObject result = new JSONObject(); + result.put("result","success"); + return result; } } diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/edi/CJTEdiRequestVo.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/edi/CJTEdiRequestVo.java new file mode 100644 index 0000000..e33e7f0 --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/domain/edi/CJTEdiRequestVo.java @@ -0,0 +1,13 @@ +package com.ruoyi.flyingbook.domain.edi; + +import lombok.Data; + +/** + * @author yuxiangyong + * @create 2023-03-12 16:00 + */ +@Data +public class CJTEdiRequestVo { + + private String encryptMsg; +} 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 33092a8..ef0004a 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 @@ -98,7 +98,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter .authorizeRequests() // 对于登录login 验证码captchaImage 允许匿名访问 .antMatchers("/login", "/captchaImage", "/approval","/syncEmail","/scheduledReminders", - "/robot/callback", "/sync2Table", "/createPdf").anonymous() + "/robot/callback", "/sync2Table", "/createPdf", "/cjtTicket").anonymous() .antMatchers( HttpMethod.GET, "/*.html",