diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..1318d0a --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,36 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ +.kotlin + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/backend/pom.xml b/backend/pom.xml new file mode 100644 index 0000000..7423b42 --- /dev/null +++ b/backend/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + cn.hezhaohui + chatbox + 1.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 3.4.3 + + + + 21 + 21 + UTF-8 + + + + + org.springframework.boot + spring-boot-starter-web + + + com.fasterxml.jackson.core + jackson-databind + + + + + + + org.springframework.ai + spring-ai-client-chat + 1.0.3 + + + + org.springframework.boot + spring-boot-starter-security + + + + mysql + mysql-connector-java + 8.0.29 + + + + com.baomidou + mybatis-plus-spring-boot3-starter + 3.5.14 + + + + org.projectlombok + lombok + 1.18.40 + provided + + + + com.google.code.gson + gson + 2.13.2 + + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + 4.4.0 + + + + + \ No newline at end of file diff --git a/backend/src/main/java/cn/hezhaohui/chatbox/Application.java b/backend/src/main/java/cn/hezhaohui/chatbox/Application.java new file mode 100644 index 0000000..4ca9b82 --- /dev/null +++ b/backend/src/main/java/cn/hezhaohui/chatbox/Application.java @@ -0,0 +1,13 @@ +package cn.hezhaohui.chatbox; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@MapperScan("cn.hezhaohui.chatbox.mapper") +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/backend/src/main/java/cn/hezhaohui/chatbox/config/GsonConfig.java b/backend/src/main/java/cn/hezhaohui/chatbox/config/GsonConfig.java new file mode 100644 index 0000000..a0bcca0 --- /dev/null +++ b/backend/src/main/java/cn/hezhaohui/chatbox/config/GsonConfig.java @@ -0,0 +1,22 @@ +package cn.hezhaohui.chatbox.config; + +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.GsonHttpMessageConverter; + +import java.util.ArrayList; +import java.util.Collection; + +@Configuration +public class GsonConfig { + + @Bean + public HttpMessageConverters customConverters() { + Collection> messageConverters = new ArrayList<>(); + GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter(); + messageConverters.add(gsonHttpMessageConverter); + return new HttpMessageConverters(true, messageConverters); + } +} diff --git a/backend/src/main/java/cn/hezhaohui/chatbox/controller/HealthController.java b/backend/src/main/java/cn/hezhaohui/chatbox/controller/HealthController.java new file mode 100644 index 0000000..1bd5cd8 --- /dev/null +++ b/backend/src/main/java/cn/hezhaohui/chatbox/controller/HealthController.java @@ -0,0 +1,20 @@ +package cn.hezhaohui.chatbox.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Tag(name = "健康") +@RequestMapping("/health") +public class HealthController { + + @Operation(summary = "健康检查") + @GetMapping + public ResponseEntity health() { + return ResponseEntity.ok("Hello, wonder!"); + } +} diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml new file mode 100644 index 0000000..582392a --- /dev/null +++ b/backend/src/main/resources/application.yml @@ -0,0 +1,31 @@ + + +# springdoc-openapi项目配置 +springdoc: + swagger-ui: + path: /swagger-ui.html + tags-sorter: alpha + operations-sorter: alpha + api-docs: + path: /v3/api-docs + group-configs: + - group: 'default' + paths-to-match: '/**' + packages-to-scan: cn.hezhaohui.chatbox.controller +# knife4j的增强配置,不需要增强可以不配 +knife4j: + enable: true + setting: + language: zh_cn + + +spring: + datasource: + url: jdbc:mysql://47.121.181.112:3306/chat_box + username: root + password: dn293830 + driver-class-name: com.mysql.cj.jdbc.Driver + security: + user: + name: wonder + password: dn293830 \ No newline at end of file