commit 997f383de61bcc63c75ea7ef355e255ab7c50355 Author: 李寻欢 Date: Wed May 31 09:56:52 2023 +0800 :tada: 创建项目 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..28d8743 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +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/ + +### LOGS ### +logs + +### Maven ### +.mvn/ +mvnw +mvnw.cmd diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..172f02a --- /dev/null +++ b/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.0 + + + io.lxh + cqhttp + 0.0.1-SNAPSHOT + cqhttp + cqhttp + + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + + cn.hutool + hutool-all + 5.8.16 + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/src/main/java/io/lxh/cqhttp/CqhttpApplication.java b/src/main/java/io/lxh/cqhttp/CqhttpApplication.java new file mode 100644 index 0000000..0bfc362 --- /dev/null +++ b/src/main/java/io/lxh/cqhttp/CqhttpApplication.java @@ -0,0 +1,13 @@ +package io.lxh.cqhttp; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CqhttpApplication { + + public static void main(String[] args) { + SpringApplication.run(CqhttpApplication.class, args); + } + +} diff --git a/src/main/java/io/lxh/cqhttp/controller/NotifyController.java b/src/main/java/io/lxh/cqhttp/controller/NotifyController.java new file mode 100644 index 0000000..770df40 --- /dev/null +++ b/src/main/java/io/lxh/cqhttp/controller/NotifyController.java @@ -0,0 +1,26 @@ +package io.lxh.cqhttp.controller; + +import io.lxh.cqhttp.entity.vo.NotifyVO; +import lombok.AllArgsConstructor; +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.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@AllArgsConstructor +@RestController +@RequestMapping("/qq") +public class NotifyController { + + @PostMapping("") + public void notify(@RequestBody NotifyVO body) { + if ("heartbeat".equals(body.getMetaEventType())) { + log.debug("收到[{}]的心跳事件", body.getSelfId()); + } else { + log.warn("QQ回调内容: {}", body); + } + } + +} diff --git a/src/main/java/io/lxh/cqhttp/entity/vo/NotifyVO.java b/src/main/java/io/lxh/cqhttp/entity/vo/NotifyVO.java new file mode 100644 index 0000000..6eaa93e --- /dev/null +++ b/src/main/java/io/lxh/cqhttp/entity/vo/NotifyVO.java @@ -0,0 +1,33 @@ +package io.lxh.cqhttp.entity.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * 通知事件 + */ +@Data +public class NotifyVO { + /** + * 事件类型 + */ + @JsonProperty("post_type") + private String postType; + + /** + * 通知类型 + */ + @JsonProperty("meta_event_type") + private String metaEventType; + + /** + * 通知时间戳 + */ + private long time; + + /** + * 机器人Id + */ + @JsonProperty("self_id") + private long selfId; +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..96f6e83 --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,2 @@ +server: + port: 12345 diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..acd147a --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${log.path}/debug.log + + ${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + + + + ${log.path}/error.log + + ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + ERROR + + + + + + + + + + diff --git a/src/test/java/io/lxh/cqhttp/CqhttpApplicationTests.java b/src/test/java/io/lxh/cqhttp/CqhttpApplicationTests.java new file mode 100644 index 0000000..3dfa6a4 --- /dev/null +++ b/src/test/java/io/lxh/cqhttp/CqhttpApplicationTests.java @@ -0,0 +1,13 @@ +package io.lxh.cqhttp; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CqhttpApplicationTests { + + @Test + void contextLoads() { + } + +}