From 2e8893bd525ec40c4570891b4de8758fe9ec9bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=95=B8=E9=9D=9E?= <8153694@qq.com> Date: Tue, 21 Nov 2023 18:13:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=94=E5=9B=9E=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/ReceiveMsgController.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main/java/com/lilosoft/api/controller/ReceiveMsgController.java diff --git a/src/main/java/com/lilosoft/api/controller/ReceiveMsgController.java b/src/main/java/com/lilosoft/api/controller/ReceiveMsgController.java new file mode 100644 index 0000000..4a3b794 --- /dev/null +++ b/src/main/java/com/lilosoft/api/controller/ReceiveMsgController.java @@ -0,0 +1,61 @@ +package com.lilosoft.api.controller; + +import cn.hutool.core.util.IdUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.lilosoft.api.api.RobotApi; +import com.lilosoft.api.bean.RobotCaseRecord; +import com.lilosoft.api.bean.receive.ReceiveMsgInfo; +import com.lilosoft.api.service.ComplexService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; +import java.util.HashMap; + +@RestController +@Slf4j +@RequestMapping("complex") +public class ReceiveMsgController { + + @Autowired + private ComplexService complexService; + + @Autowired + private RobotApi robotApi; + + @PostMapping("receiveMessage") + public String refreshMessage(@RequestBody HashMap<String, String> text) { + + JSONObject jsonObject = new JSONObject(); + RobotCaseRecord caseRecord = new RobotCaseRecord(); + caseRecord.setId(IdUtil.simpleUUID()); + caseRecord.setContent(text.get("content")); + caseRecord.setSendFlag("0"); + caseRecord.setUpdateTime(new Date()); + try { + robotApi.saveRecord(caseRecord); + String content = text.get("content"); + ReceiveMsgInfo receiveMsgInfo = JSON.parseObject(content, ReceiveMsgInfo.class); + complexService.windowApply(receiveMsgInfo); + robotApi.saveRecord(caseRecord); + jsonObject.put("code", 1); + jsonObject.put("msg", "鎴愬姛"); + } catch (Exception e) { + caseRecord.setSendFlag("1"); + caseRecord.setMsg(e.getMessage()); + robotApi.saveRecord(caseRecord); + log.error(e.getMessage()); + jsonObject.put("code", -1); + jsonObject.put("msg", e.getMessage()); + } + + return jsonObject.toJSONString(); + } + + +} -- 2.24.3