From bcf8893b0070a148e135091a9fc351ba89ce3ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=AD=E9=9D=92=E5=8D=8E=E5=B9=B4?= <2957899895@qq.com> Date: Mon, 21 Apr 2025 18:08:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=98=E6=96=B9=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.log | 127 +++++++ .../yang/test/controller/HldzyController.java | 51 ++- .../yang/test/controller/MbtiController.java | 50 +-- .../java/com/yang/test/domain/Answer.java | 9 - .../java/com/yang/test/domain/Category.java | 4 + .../yang/test/domain/DTO/ResultRequest.java | 3 + .../yang/test/domain/DTO/ResultResponse.java | 4 + .../java/com/yang/test/domain/Dimension.java | 3 + .../java/com/yang/test/domain/Question.java | 16 - .../java/com/yang/test/domain/QuestionH.java | 3 + .../test/domain/{Result.java => ResultM.java} | 7 +- .../java/com/yang/test/domain/TestResult.java | 4 + .../com/yang/test/domain/VO/QuestionVO.java | 13 - .../VO/{ResultVO.java => ResultMVO.java} | 5 +- .../java/com/yang/test/mapper/MbtiMapper.java | 33 +- .../com/yang/test/service/HldzyService.java | 2 +- .../com/yang/test/service/MbtiService.java | 33 +- .../serviceImpl/DeepseekServiceImpl.java | 1 - .../service/serviceImpl/HldzyServiceImpl.java | 8 +- .../service/serviceImpl/MbtiServiceImpl.java | 326 ++++++++---------- src/main/resources/mapper/MbtiMapper.xml | 46 ++- 21 files changed, 431 insertions(+), 317 deletions(-) delete mode 100644 src/main/java/com/yang/test/domain/Answer.java delete mode 100644 src/main/java/com/yang/test/domain/Question.java rename src/main/java/com/yang/test/domain/{Result.java => ResultM.java} (85%) delete mode 100644 src/main/java/com/yang/test/domain/VO/QuestionVO.java rename src/main/java/com/yang/test/domain/VO/{ResultVO.java => ResultMVO.java} (85%) diff --git a/server.log b/server.log index e69de29..de10d45 100644 --- a/server.log +++ b/server.log @@ -0,0 +1,127 @@ +2025-04-21 17:06:00 [main] INFO com.yang.test.TestApplication - Starting TestApplication using Java 17.0.13 with PID 21100 (D:\project\Mbti\test\target\classes started by DENG in D:\project\Mbti\test) +2025-04-21 17:06:00 [main] DEBUG com.yang.test.TestApplication - Running with Spring Boot v3.4.4, Spring v6.2.5 +2025-04-21 17:06:00 [main] INFO com.yang.test.TestApplication - No active profile set, falling back to 1 default profile: "default" +2025-04-21 17:06:01 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port 8080 (http) +2025-04-21 17:06:01 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat] +2025-04-21 17:06:01 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.39] +2025-04-21 17:06:01 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext +2025-04-21 17:06:01 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1111 ms +2025-04-21 17:06:01 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting... +2025-04-21 17:06:06 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@64518270 +2025-04-21 17:06:06 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed. +2025-04-21 17:06:07 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port 8080 (http) with context path '/' +2025-04-21 17:06:07 [main] INFO com.yang.test.TestApplication - Started TestApplication in 7.638 seconds (process running for 8.243) +2025-04-21 17:06:07 [main] INFO com.yang.test.TestApplication - MBTI测试系统启动成功! 服务运行在端口: 8080 +2025-04-21 17:06:46 [http-nio-8080-exec-3] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet' +2025-04-21 17:06:46 [http-nio-8080-exec-3] INFO o.s.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet' +2025-04-21 17:06:46 [http-nio-8080-exec-3] INFO o.s.web.servlet.DispatcherServlet - Completed initialization in 1 ms +2025-04-21 17:06:46 [http-nio-8080-exec-3] INFO c.y.test.controller.MbtiController - 开始获取题目, 测试ID: 1 +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.mapper.MbtiMapper.getTestById - ==> Preparing: SELECT id, name FROM test WHERE id = ? +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.mapper.MbtiMapper.getTestById - ==> Parameters: 1(String) +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.mapper.MbtiMapper.getTestById - <== Total: 1 +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.m.M.getQuestionsByTestId - ==> Preparing: SELECT id, name, type, ? as testId FROM question WHERE test_id = ? ORDER BY id +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.m.M.getQuestionsByTestId - ==> Parameters: 1(String), 1(String) +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.m.M.getQuestionsByTestId - <== Total: 93 +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.m.M.getOptionsByQuestionIds - ==> Preparing: SELECT id, code, name, question_id as questionId, character_type as characterType FROM option_table WHERE question_id IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ORDER BY question_id, id +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.m.M.getOptionsByQuestionIds - ==> Parameters: 1(Integer), 2(Integer), 3(Integer), 4(Integer), 5(Integer), 6(Integer), 7(Integer), 8(Integer), 9(Integer), 10(Integer), 11(Integer), 12(Integer), 13(Integer), 14(Integer), 15(Integer), 16(Integer), 17(Integer), 18(Integer), 19(Integer), 20(Integer), 21(Integer), 22(Integer), 23(Integer), 24(Integer), 25(Integer), 26(Integer), 27(Integer), 28(Integer), 29(Integer), 30(Integer), 31(Integer), 32(Integer), 33(Integer), 34(Integer), 35(Integer), 36(Integer), 37(Integer), 38(Integer), 39(Integer), 40(Integer), 41(Integer), 42(Integer), 43(Integer), 44(Integer), 45(Integer), 46(Integer), 47(Integer), 48(Integer), 49(Integer), 50(Integer), 51(Integer), 52(Integer), 53(Integer), 54(Integer), 55(Integer), 56(Integer), 57(Integer), 58(Integer), 59(Integer), 60(Integer), 61(Integer), 62(Integer), 63(Integer), 64(Integer), 65(Integer), 66(Integer), 67(Integer), 68(Integer), 69(Integer), 70(Integer), 71(Integer), 72(Integer), 73(Integer), 74(Integer), 75(Integer), 76(Integer), 77(Integer), 78(Integer), 79(Integer), 80(Integer), 81(Integer), 82(Integer), 83(Integer), 84(Integer), 85(Integer), 86(Integer), 87(Integer), 88(Integer), 89(Integer), 90(Integer), 91(Integer), 92(Integer), 93(Integer) +2025-04-21 17:06:46 [http-nio-8080-exec-3] DEBUG c.y.t.m.M.getOptionsByQuestionIds - <== Total: 186 +2025-04-21 17:06:46 [http-nio-8080-exec-3] INFO c.y.test.controller.MbtiController - 获取题目完成, 测试ID: 1, 题目数量: 93, 总耗时: PT0.3134364S +2025-04-21 17:10:28 [http-nio-8080-exec-6] INFO c.y.test.controller.MbtiController - 开始获取题目, 测试ID: 1 +2025-04-21 17:10:28 [http-nio-8080-exec-6] DEBUG c.y.t.mapper.MbtiMapper.getTestById - ==> Preparing: SELECT id, name FROM test WHERE id = ? +2025-04-21 17:10:28 [http-nio-8080-exec-6] DEBUG c.y.t.mapper.MbtiMapper.getTestById - ==> Parameters: 1(String) +2025-04-21 17:10:29 [http-nio-8080-exec-6] DEBUG c.y.t.mapper.MbtiMapper.getTestById - <== Total: 1 +2025-04-21 17:10:29 [http-nio-8080-exec-6] DEBUG c.y.t.m.M.getQuestionsByTestId - ==> Preparing: SELECT id, name, type, ? as testId FROM question WHERE test_id = ? ORDER BY id +2025-04-21 17:10:29 [http-nio-8080-exec-6] DEBUG c.y.t.m.M.getQuestionsByTestId - ==> Parameters: 1(String), 1(String) +2025-04-21 17:10:29 [http-nio-8080-exec-6] DEBUG c.y.t.m.M.getQuestionsByTestId - <== Total: 93 +2025-04-21 17:10:29 [http-nio-8080-exec-6] DEBUG c.y.t.m.M.getOptionsByQuestionIds - ==> Preparing: SELECT id, code, name, question_id as questionId, character_type as characterType FROM option_table WHERE question_id IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ORDER BY question_id, id +2025-04-21 17:10:29 [http-nio-8080-exec-6] DEBUG c.y.t.m.M.getOptionsByQuestionIds - ==> Parameters: 1(Integer), 2(Integer), 3(Integer), 4(Integer), 5(Integer), 6(Integer), 7(Integer), 8(Integer), 9(Integer), 10(Integer), 11(Integer), 12(Integer), 13(Integer), 14(Integer), 15(Integer), 16(Integer), 17(Integer), 18(Integer), 19(Integer), 20(Integer), 21(Integer), 22(Integer), 23(Integer), 24(Integer), 25(Integer), 26(Integer), 27(Integer), 28(Integer), 29(Integer), 30(Integer), 31(Integer), 32(Integer), 33(Integer), 34(Integer), 35(Integer), 36(Integer), 37(Integer), 38(Integer), 39(Integer), 40(Integer), 41(Integer), 42(Integer), 43(Integer), 44(Integer), 45(Integer), 46(Integer), 47(Integer), 48(Integer), 49(Integer), 50(Integer), 51(Integer), 52(Integer), 53(Integer), 54(Integer), 55(Integer), 56(Integer), 57(Integer), 58(Integer), 59(Integer), 60(Integer), 61(Integer), 62(Integer), 63(Integer), 64(Integer), 65(Integer), 66(Integer), 67(Integer), 68(Integer), 69(Integer), 70(Integer), 71(Integer), 72(Integer), 73(Integer), 74(Integer), 75(Integer), 76(Integer), 77(Integer), 78(Integer), 79(Integer), 80(Integer), 81(Integer), 82(Integer), 83(Integer), 84(Integer), 85(Integer), 86(Integer), 87(Integer), 88(Integer), 89(Integer), 90(Integer), 91(Integer), 92(Integer), 93(Integer) +2025-04-21 17:10:29 [http-nio-8080-exec-6] DEBUG c.y.t.m.M.getOptionsByQuestionIds - <== Total: 186 +2025-04-21 17:10:29 [http-nio-8080-exec-6] INFO c.y.test.controller.MbtiController - 获取题目完成, 测试ID: 1, 题目数量: 93, 总耗时: PT0.2429666S +2025-04-21 17:12:07 [SpringApplicationShutdownHook] INFO o.s.b.w.e.tomcat.GracefulShutdown - Commencing graceful shutdown. Waiting for active requests to complete +2025-04-21 17:12:08 [tomcat-shutdown] INFO o.s.b.w.e.tomcat.GracefulShutdown - Graceful shutdown complete +2025-04-21 17:12:08 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated... +2025-04-21 17:12:08 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed. +2025-04-21 17:12:09 [main] INFO com.yang.test.TestApplication - Starting TestApplication using Java 17.0.13 with PID 12056 (D:\project\Mbti\test\target\classes started by DENG in D:\project\Mbti\test) +2025-04-21 17:12:09 [main] DEBUG com.yang.test.TestApplication - Running with Spring Boot v3.4.4, Spring v6.2.5 +2025-04-21 17:12:09 [main] INFO com.yang.test.TestApplication - No active profile set, falling back to 1 default profile: "default" +2025-04-21 17:12:10 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port 8080 (http) +2025-04-21 17:12:10 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat] +2025-04-21 17:12:10 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.39] +2025-04-21 17:12:10 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext +2025-04-21 17:12:10 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 841 ms +2025-04-21 17:12:10 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting... +2025-04-21 17:12:16 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@2bb62414 +2025-04-21 17:12:16 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed. +2025-04-21 17:12:16 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port 8080 (http) with context path '/' +2025-04-21 17:12:16 [main] INFO com.yang.test.TestApplication - Started TestApplication in 7.415 seconds (process running for 8.039) +2025-04-21 17:12:16 [main] INFO com.yang.test.TestApplication - MBTI测试系统启动成功! 服务运行在端口: 8080 +2025-04-21 17:12:23 [http-nio-8080-exec-2] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet' +2025-04-21 17:12:23 [http-nio-8080-exec-2] INFO o.s.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet' +2025-04-21 17:12:23 [http-nio-8080-exec-2] INFO o.s.web.servlet.DispatcherServlet - Completed initialization in 0 ms +2025-04-21 17:12:23 [http-nio-8080-exec-2] INFO c.y.test.controller.MbtiController - 开始获取题目, 测试ID: 1 +2025-04-21 17:12:23 [http-nio-8080-exec-2] DEBUG c.y.t.mapper.MbtiMapper.getTestById - ==> Preparing: SELECT id, name FROM test WHERE id = ? +2025-04-21 17:12:23 [http-nio-8080-exec-2] DEBUG c.y.t.mapper.MbtiMapper.getTestById - ==> Parameters: 1(String) +2025-04-21 17:12:24 [http-nio-8080-exec-2] DEBUG c.y.t.mapper.MbtiMapper.getTestById - <== Total: 1 +2025-04-21 17:12:24 [http-nio-8080-exec-2] DEBUG c.y.t.m.M.getQuestionsByTestId - ==> Preparing: SELECT id, name, type, ? as testId FROM question WHERE test_id = ? ORDER BY id +2025-04-21 17:12:24 [http-nio-8080-exec-2] DEBUG c.y.t.m.M.getQuestionsByTestId - ==> Parameters: 1(String), 1(String) +2025-04-21 17:12:24 [http-nio-8080-exec-2] DEBUG c.y.t.m.M.getQuestionsByTestId - <== Total: 93 +2025-04-21 17:12:24 [http-nio-8080-exec-2] DEBUG c.y.t.m.M.getOptionsByQuestionIds - ==> Preparing: SELECT id, code, name, question_id as questionId, character_type as characterType FROM option_table WHERE question_id IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ORDER BY question_id, id +2025-04-21 17:12:24 [http-nio-8080-exec-2] DEBUG c.y.t.m.M.getOptionsByQuestionIds - ==> Parameters: 1(Integer), 2(Integer), 3(Integer), 4(Integer), 5(Integer), 6(Integer), 7(Integer), 8(Integer), 9(Integer), 10(Integer), 11(Integer), 12(Integer), 13(Integer), 14(Integer), 15(Integer), 16(Integer), 17(Integer), 18(Integer), 19(Integer), 20(Integer), 21(Integer), 22(Integer), 23(Integer), 24(Integer), 25(Integer), 26(Integer), 27(Integer), 28(Integer), 29(Integer), 30(Integer), 31(Integer), 32(Integer), 33(Integer), 34(Integer), 35(Integer), 36(Integer), 37(Integer), 38(Integer), 39(Integer), 40(Integer), 41(Integer), 42(Integer), 43(Integer), 44(Integer), 45(Integer), 46(Integer), 47(Integer), 48(Integer), 49(Integer), 50(Integer), 51(Integer), 52(Integer), 53(Integer), 54(Integer), 55(Integer), 56(Integer), 57(Integer), 58(Integer), 59(Integer), 60(Integer), 61(Integer), 62(Integer), 63(Integer), 64(Integer), 65(Integer), 66(Integer), 67(Integer), 68(Integer), 69(Integer), 70(Integer), 71(Integer), 72(Integer), 73(Integer), 74(Integer), 75(Integer), 76(Integer), 77(Integer), 78(Integer), 79(Integer), 80(Integer), 81(Integer), 82(Integer), 83(Integer), 84(Integer), 85(Integer), 86(Integer), 87(Integer), 88(Integer), 89(Integer), 90(Integer), 91(Integer), 92(Integer), 93(Integer) +2025-04-21 17:12:24 [http-nio-8080-exec-2] DEBUG c.y.t.m.M.getOptionsByQuestionIds - <== Total: 186 +2025-04-21 17:12:24 [http-nio-8080-exec-2] INFO c.y.test.controller.MbtiController - 获取题目完成, 测试ID: 1, 题目数量: 93, 总耗时: PT0.3188868S +2025-04-21 17:22:13 [http-nio-8080-exec-4] INFO c.y.test.controller.MbtiController - 开始获取题目, 测试ID: 1 +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.mapper.MbtiMapper.getTestById - ==> Preparing: SELECT id, name FROM test WHERE id = ? +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.mapper.MbtiMapper.getTestById - ==> Parameters: 1(String) +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.mapper.MbtiMapper.getTestById - <== Total: 1 +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.M.getQuestionsByTestId - ==> Preparing: SELECT id, name, type, ? as testId FROM question WHERE test_id = ? ORDER BY id +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.M.getQuestionsByTestId - ==> Parameters: 1(String), 1(String) +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.M.getQuestionsByTestId - <== Total: 93 +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.M.getOptionsByQuestionIds - ==> Preparing: SELECT id, code, name, question_id as questionId, character_type as characterType FROM option_table WHERE question_id IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ORDER BY question_id, id +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.M.getOptionsByQuestionIds - ==> Parameters: 1(Integer), 2(Integer), 3(Integer), 4(Integer), 5(Integer), 6(Integer), 7(Integer), 8(Integer), 9(Integer), 10(Integer), 11(Integer), 12(Integer), 13(Integer), 14(Integer), 15(Integer), 16(Integer), 17(Integer), 18(Integer), 19(Integer), 20(Integer), 21(Integer), 22(Integer), 23(Integer), 24(Integer), 25(Integer), 26(Integer), 27(Integer), 28(Integer), 29(Integer), 30(Integer), 31(Integer), 32(Integer), 33(Integer), 34(Integer), 35(Integer), 36(Integer), 37(Integer), 38(Integer), 39(Integer), 40(Integer), 41(Integer), 42(Integer), 43(Integer), 44(Integer), 45(Integer), 46(Integer), 47(Integer), 48(Integer), 49(Integer), 50(Integer), 51(Integer), 52(Integer), 53(Integer), 54(Integer), 55(Integer), 56(Integer), 57(Integer), 58(Integer), 59(Integer), 60(Integer), 61(Integer), 62(Integer), 63(Integer), 64(Integer), 65(Integer), 66(Integer), 67(Integer), 68(Integer), 69(Integer), 70(Integer), 71(Integer), 72(Integer), 73(Integer), 74(Integer), 75(Integer), 76(Integer), 77(Integer), 78(Integer), 79(Integer), 80(Integer), 81(Integer), 82(Integer), 83(Integer), 84(Integer), 85(Integer), 86(Integer), 87(Integer), 88(Integer), 89(Integer), 90(Integer), 91(Integer), 92(Integer), 93(Integer) +2025-04-21 17:22:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.M.getOptionsByQuestionIds - <== Total: 186 +2025-04-21 17:22:13 [http-nio-8080-exec-4] INFO c.y.test.controller.MbtiController - 获取题目完成, 测试ID: 1, 题目数量: 93, 总耗时: PT0.2650471S +2025-04-21 17:24:33 [SpringApplicationShutdownHook] INFO o.s.b.w.e.tomcat.GracefulShutdown - Commencing graceful shutdown. Waiting for active requests to complete +2025-04-21 17:24:33 [tomcat-shutdown] INFO o.s.b.w.e.tomcat.GracefulShutdown - Graceful shutdown complete +2025-04-21 17:24:33 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated... +2025-04-21 17:24:33 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed. +2025-04-21 17:28:16 [main] INFO com.yang.test.TestApplication - Starting TestApplication using Java 17.0.13 with PID 13076 (D:\project\Mbti\test\target\classes started by DENG in D:\project\Mbti\test) +2025-04-21 17:28:16 [main] DEBUG com.yang.test.TestApplication - Running with Spring Boot v3.4.4, Spring v6.2.5 +2025-04-21 17:28:16 [main] INFO com.yang.test.TestApplication - No active profile set, falling back to 1 default profile: "default" +2025-04-21 17:28:17 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port 8080 (http) +2025-04-21 17:28:17 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat] +2025-04-21 17:28:17 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.39] +2025-04-21 17:28:17 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext +2025-04-21 17:28:17 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 842 ms +2025-04-21 17:28:17 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting... +2025-04-21 17:28:23 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@2bb62414 +2025-04-21 17:28:23 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed. +2025-04-21 17:28:23 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port 8080 (http) with context path '/' +2025-04-21 17:28:23 [main] INFO com.yang.test.TestApplication - Started TestApplication in 7.294 seconds (process running for 7.834) +2025-04-21 17:28:23 [main] INFO com.yang.test.TestApplication - MBTI测试系统启动成功! 服务运行在端口: 8080 +2025-04-21 17:28:54 [http-nio-8080-exec-1] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet' +2025-04-21 17:28:54 [http-nio-8080-exec-1] INFO o.s.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet' +2025-04-21 17:28:54 [http-nio-8080-exec-1] INFO o.s.web.servlet.DispatcherServlet - Completed initialization in 0 ms +2025-04-21 17:28:54 [http-nio-8080-exec-1] INFO c.y.test.controller.MbtiController - 开始获取结果, ID: result_1744874809561 +2025-04-21 17:28:54 [http-nio-8080-exec-1] DEBUG c.y.t.m.MbtiMapper.getResultById - ==> Preparing: SELECT id, type, dimensions, report, created_at as createdAt FROM results WHERE id = ? +2025-04-21 17:28:54 [http-nio-8080-exec-1] DEBUG c.y.t.m.MbtiMapper.getResultById - ==> Parameters: result_1744874809561(String) +2025-04-21 17:28:54 [http-nio-8080-exec-1] DEBUG c.y.t.m.MbtiMapper.getResultById - <== Total: 1 +2025-04-21 17:28:54 [http-nio-8080-exec-1] INFO c.y.test.controller.MbtiController - 获取结果完成, ID: result_1744874809561, 总耗时: PT0.1893936S +2025-04-21 17:29:00 [http-nio-8080-exec-2] INFO c.y.test.controller.MbtiController - 开始获取结果, ID: result_1744874809561 +2025-04-21 17:29:00 [http-nio-8080-exec-2] DEBUG c.y.t.m.MbtiMapper.getResultById - ==> Preparing: SELECT id, type, dimensions, report, created_at as createdAt FROM results WHERE id = ? +2025-04-21 17:29:00 [http-nio-8080-exec-2] DEBUG c.y.t.m.MbtiMapper.getResultById - ==> Parameters: result_1744874809561(String) +2025-04-21 17:29:01 [http-nio-8080-exec-2] DEBUG c.y.t.m.MbtiMapper.getResultById - <== Total: 1 +2025-04-21 17:29:01 [http-nio-8080-exec-2] INFO c.y.test.controller.MbtiController - 获取结果完成, ID: result_1744874809561, 总耗时: PT0.1230948S +2025-04-21 17:29:13 [http-nio-8080-exec-4] INFO c.y.test.controller.MbtiController - 开始获取结果, ID: result_1744874809561 +2025-04-21 17:29:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.MbtiMapper.getResultById - ==> Preparing: SELECT id, type, dimensions, report, created_at as createdAt FROM results WHERE id = ? +2025-04-21 17:29:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.MbtiMapper.getResultById - ==> Parameters: result_1744874809561(String) +2025-04-21 17:29:13 [http-nio-8080-exec-4] DEBUG c.y.t.m.MbtiMapper.getResultById - <== Total: 1 +2025-04-21 17:29:13 [http-nio-8080-exec-4] INFO c.y.test.controller.MbtiController - 获取结果完成, ID: result_1744874809561, 总耗时: PT0.1314746S +2025-04-21 17:29:16 [http-nio-8080-exec-3] INFO c.y.test.controller.MbtiController - 开始获取结果, ID: result_1744874809561 +2025-04-21 17:29:16 [http-nio-8080-exec-3] DEBUG c.y.t.m.MbtiMapper.getResultById - ==> Preparing: SELECT id, type, dimensions, report, created_at as createdAt FROM results WHERE id = ? +2025-04-21 17:29:16 [http-nio-8080-exec-3] DEBUG c.y.t.m.MbtiMapper.getResultById - ==> Parameters: result_1744874809561(String) +2025-04-21 17:29:16 [http-nio-8080-exec-3] DEBUG c.y.t.m.MbtiMapper.getResultById - <== Total: 1 +2025-04-21 17:29:16 [http-nio-8080-exec-3] INFO c.y.test.controller.MbtiController - 获取结果完成, ID: result_1744874809561, 总耗时: PT0.0970814S +2025-04-21 17:29:40 [SpringApplicationShutdownHook] INFO o.s.b.w.e.tomcat.GracefulShutdown - Commencing graceful shutdown. Waiting for active requests to complete +2025-04-21 17:29:40 [tomcat-shutdown] INFO o.s.b.w.e.tomcat.GracefulShutdown - Graceful shutdown complete +2025-04-21 17:29:40 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated... +2025-04-21 17:29:40 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed. diff --git a/src/main/java/com/yang/test/controller/HldzyController.java b/src/main/java/com/yang/test/controller/HldzyController.java index 039e8e1..4e7ebd1 100644 --- a/src/main/java/com/yang/test/controller/HldzyController.java +++ b/src/main/java/com/yang/test/controller/HldzyController.java @@ -3,15 +3,19 @@ package com.yang.test.controller; import com.yang.test.domain.DTO.ResultRequest; import com.yang.test.domain.DTO.ResultResponse; import com.yang.test.domain.QuestionH; +import com.yang.test.domain.Result; import com.yang.test.service.HldzyService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.time.Duration; +import java.time.Instant; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; +@Slf4j @RestController @RequestMapping("/api") public class HldzyController { @@ -23,30 +27,41 @@ public class HldzyController { * 获取所有测试题目 */ @GetMapping("/questionsH") - public Map getAllQuestions() { - List questions = hldzyService.getAllQuestions(); - Collections.shuffle(questions); // 随机排序问题 + public Result getAllQuestions() { + Instant start = Instant.now(); + log.info("开始获取所有题目"); - Map response = new HashMap<>(); - response.put("code", 0); - response.put("message", "success"); - response.put("data", questions); - - return response; + try { + List questions = hldzyService.getAllQuestions(); + Collections.shuffle(questions); // 随机排序问题 + + log.info("获取题目完成, 题目数量: {}, 总耗时: {}", + questions.size(), Duration.between(start, Instant.now())); + + return Result.success(questions); + } catch (Exception e) { + log.error("获取题目失败: {}", e.getMessage(), e); + return Result.error("获取题目失败: " + e.getMessage()); + } } /** * 提交测试结果并获取分析 */ @PostMapping("/results") - public Map submitResult(@RequestBody ResultRequest request) { - ResultResponse result = hldzyService.calculateResult(request.getAnswers()); + public Result submitResult(@RequestBody ResultRequest request) { + Instant start = Instant.now(); + log.info("开始处理结果提交请求"); - Map response = new HashMap<>(); - response.put("code", 0); - response.put("message", "success"); - response.put("data", result); - - return response; + try { + ResultResponse result = hldzyService.calculateResult(request.getAnswers()); + + log.info("结果计算完成, 总耗时: {}", Duration.between(start, Instant.now())); + + return Result.success(result); + } catch (Exception e) { + log.error("处理结果提交请求失败: {}", e.getMessage(), e); + return Result.error("处理请求失败: " + e.getMessage()); + } } } \ No newline at end of file diff --git a/src/main/java/com/yang/test/controller/MbtiController.java b/src/main/java/com/yang/test/controller/MbtiController.java index 4abb168..c96ab65 100644 --- a/src/main/java/com/yang/test/controller/MbtiController.java +++ b/src/main/java/com/yang/test/controller/MbtiController.java @@ -1,17 +1,15 @@ package com.yang.test.controller; -import com.yang.test.domain.Answer; -import com.yang.test.domain.VO.QuestionVO; -import com.yang.test.domain.VO.ResultVO; +import com.yang.test.domain.Result; +import com.yang.test.domain.VO.ResultMVO; +import com.yang.test.domain.VO.TestQuestionsVO; import com.yang.test.service.MbtiService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.time.Duration; import java.time.Instant; -import java.util.List; import java.util.Map; @Slf4j @@ -23,60 +21,64 @@ public class MbtiController { private MbtiService mbtiService; @GetMapping("/questions") - public ResponseEntity getQuestions(@RequestParam(value = "type", defaultValue = "simple") String testType) { + public Result getQuestions(@RequestParam(value = "testId", defaultValue = "1") String testId) { Instant start = Instant.now(); - log.info("开始获取题目, 类型: {}", testType); + log.info("开始获取题目, 测试ID: {}", testId); try { - List questions = mbtiService.getQuestions(testType); + TestQuestionsVO testQuestions = mbtiService.getTestQuestions(testId); - log.info("获取题目完成, 类型: {}, 题目数量: {}, 总耗时: {}", - testType, questions.size(), Duration.between(start, Instant.now())); + if (testQuestions == null) { + return Result.error("未找到相关测试或题目"); + } - return ResponseEntity.ok(questions); + log.info("获取题目完成, 测试ID: {}, 题目数量: {}, 总耗时: {}", + testId, testQuestions.getList().size(), Duration.between(start, Instant.now())); + + return Result.success(testQuestions); } catch (Exception e) { log.error("获取题目失败: {}", e.getMessage(), e); - return ResponseEntity.internalServerError().body(Map.of("error", "获取题目失败")); + return Result.error("获取题目失败: " + e.getMessage()); } } @PostMapping("/submit") - public ResponseEntity submitAnswers(@RequestBody Answer answer, - @RequestParam(value = "type", defaultValue = "simple") String testType) { + public Result submitAnswers(@RequestBody Map answers, + @RequestParam(value = "testId", defaultValue = "1") String testId) { Instant start = Instant.now(); log.info("开始处理答案提交请求"); try { - String resultId = mbtiService.processAnswers(answer.getAnswers(), testType); + String resultId = mbtiService.processAnswers(answers, testId); log.info("答案提交处理完成, 结果ID: {}, 总耗时: {}", resultId, Duration.between(start, Instant.now())); - return ResponseEntity.ok(Map.of("resultId", resultId)); + return Result.success(Map.of("resultId", resultId)); } catch (Exception e) { log.error("处理答案提交请求失败: {}", e.getMessage(), e); - return ResponseEntity.internalServerError().body(Map.of("error", "处理请求失败")); + return Result.error("处理请求失败: " + e.getMessage()); } } @GetMapping("/result/{id}") - public ResponseEntity getResult(@PathVariable("id") String resultId) { + public Result getResult(@PathVariable("id") String resultId) { Instant start = Instant.now(); log.info("开始获取结果, ID: {}", resultId); try { - ResultVO result = mbtiService.getResult(resultId); + ResultMVO result = mbtiService.getResult(resultId); if (result == null) { - return ResponseEntity.notFound().build(); + return Result.error("未找到相关结果"); } - log.info("获取结果完成, ID: {}, 类型: {}, 总耗时: {}", - resultId, result.getType(), Duration.between(start, Instant.now())); + log.info("获取结果完成, ID: {}, 总耗时: {}", + resultId, Duration.between(start, Instant.now())); - return ResponseEntity.ok(result); + return Result.success(result); } catch (Exception e) { log.error("获取结果失败: {}", e.getMessage(), e); - return ResponseEntity.internalServerError().body(Map.of("error", "获取结果失败")); + return Result.error("获取结果失败: " + e.getMessage()); } } } \ No newline at end of file diff --git a/src/main/java/com/yang/test/domain/Answer.java b/src/main/java/com/yang/test/domain/Answer.java deleted file mode 100644 index 21aa0fe..0000000 --- a/src/main/java/com/yang/test/domain/Answer.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.yang.test.domain; - -import lombok.Data; -import java.util.List; - -@Data -public class Answer { - private List answers; -} \ No newline at end of file diff --git a/src/main/java/com/yang/test/domain/Category.java b/src/main/java/com/yang/test/domain/Category.java index c68bed7..4c18018 100644 --- a/src/main/java/com/yang/test/domain/Category.java +++ b/src/main/java/com/yang/test/domain/Category.java @@ -1,8 +1,12 @@ package com.yang.test.domain; import lombok.Data; + import java.util.Date; +/** + * Hldzy + */ @Data public class Category { private Integer id; diff --git a/src/main/java/com/yang/test/domain/DTO/ResultRequest.java b/src/main/java/com/yang/test/domain/DTO/ResultRequest.java index 9ddfedd..6d6292a 100644 --- a/src/main/java/com/yang/test/domain/DTO/ResultRequest.java +++ b/src/main/java/com/yang/test/domain/DTO/ResultRequest.java @@ -3,6 +3,9 @@ package com.yang.test.domain.DTO; import lombok.Data; import java.util.Map; +/** + * Hldzy + */ @Data public class ResultRequest { private Map answers; diff --git a/src/main/java/com/yang/test/domain/DTO/ResultResponse.java b/src/main/java/com/yang/test/domain/DTO/ResultResponse.java index 0de0af9..c1979f2 100644 --- a/src/main/java/com/yang/test/domain/DTO/ResultResponse.java +++ b/src/main/java/com/yang/test/domain/DTO/ResultResponse.java @@ -2,8 +2,12 @@ package com.yang.test.domain.DTO; import com.yang.test.domain.Category; import lombok.Data; + import java.util.Map; +/** + * Hldzy + */ @Data public class ResultResponse { private String resultCode; diff --git a/src/main/java/com/yang/test/domain/Dimension.java b/src/main/java/com/yang/test/domain/Dimension.java index e41c1d9..716f09e 100644 --- a/src/main/java/com/yang/test/domain/Dimension.java +++ b/src/main/java/com/yang/test/domain/Dimension.java @@ -4,6 +4,9 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +/** + * Mbti + */ @Data @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/yang/test/domain/Question.java b/src/main/java/com/yang/test/domain/Question.java deleted file mode 100644 index 15b4ffe..0000000 --- a/src/main/java/com/yang/test/domain/Question.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.yang.test.domain; - -import lombok.Data; -import java.util.List; -import java.util.Date; - -@Data -public class Question { - private Integer id; - private String question; - private String dimension; - private Integer direction; - private String type; - private Date createdAt; - private List options; -} \ No newline at end of file diff --git a/src/main/java/com/yang/test/domain/QuestionH.java b/src/main/java/com/yang/test/domain/QuestionH.java index 571ecd7..d8ba3fc 100644 --- a/src/main/java/com/yang/test/domain/QuestionH.java +++ b/src/main/java/com/yang/test/domain/QuestionH.java @@ -3,6 +3,9 @@ package com.yang.test.domain; import lombok.Data; import java.util.Date; +/** + * Hldzy + */ @Data public class QuestionH { private Long id; diff --git a/src/main/java/com/yang/test/domain/Result.java b/src/main/java/com/yang/test/domain/ResultM.java similarity index 85% rename from src/main/java/com/yang/test/domain/Result.java rename to src/main/java/com/yang/test/domain/ResultM.java index 36a5df5..2389c3c 100644 --- a/src/main/java/com/yang/test/domain/Result.java +++ b/src/main/java/com/yang/test/domain/ResultM.java @@ -4,11 +4,14 @@ import lombok.Data; import java.util.Date; import java.util.List; +/** + * Mbti + */ @Data -public class Result { +public class ResultM { private String id; private String type; private List dimensions; private String report; private Date createdAt; -} \ No newline at end of file +} diff --git a/src/main/java/com/yang/test/domain/TestResult.java b/src/main/java/com/yang/test/domain/TestResult.java index 77feb6d..4109f2e 100644 --- a/src/main/java/com/yang/test/domain/TestResult.java +++ b/src/main/java/com/yang/test/domain/TestResult.java @@ -1,8 +1,12 @@ package com.yang.test.domain; import lombok.Data; + import java.util.Date; +/** + * Hldzy + */ @Data public class TestResult { private Long id; diff --git a/src/main/java/com/yang/test/domain/VO/QuestionVO.java b/src/main/java/com/yang/test/domain/VO/QuestionVO.java deleted file mode 100644 index 988020e..0000000 --- a/src/main/java/com/yang/test/domain/VO/QuestionVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.yang.test.domain.VO; - -import lombok.Data; -import java.util.List; - -@Data -public class QuestionVO { - private Integer id; - private String question; - private List options; - private String dimension; - private Integer direction; -} \ No newline at end of file diff --git a/src/main/java/com/yang/test/domain/VO/ResultVO.java b/src/main/java/com/yang/test/domain/VO/ResultMVO.java similarity index 85% rename from src/main/java/com/yang/test/domain/VO/ResultVO.java rename to src/main/java/com/yang/test/domain/VO/ResultMVO.java index 13cdc99..c7b7615 100644 --- a/src/main/java/com/yang/test/domain/VO/ResultVO.java +++ b/src/main/java/com/yang/test/domain/VO/ResultMVO.java @@ -5,8 +5,11 @@ import com.yang.test.domain.Dimension; import lombok.Data; import java.util.List; +/** + * Mbti + */ @Data -public class ResultVO { +public class ResultMVO { private String id; private String type; private List dimensions; diff --git a/src/main/java/com/yang/test/mapper/MbtiMapper.java b/src/main/java/com/yang/test/mapper/MbtiMapper.java index 876d399..1a327f0 100644 --- a/src/main/java/com/yang/test/mapper/MbtiMapper.java +++ b/src/main/java/com/yang/test/mapper/MbtiMapper.java @@ -1,41 +1,44 @@ package com.yang.test.mapper; - - -import com.yang.test.domain.Question; -import com.yang.test.domain.Result; +import com.yang.test.domain.*; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; -import java.util.Map; @Mapper public interface MbtiMapper { /** - * 根据类型获取题目列表 - * @param types 题目类型 - * @return 题目列表 + * 根据ID获取测试信息 */ - List getQuestionsByTypes(List types); + Test getTestById(@Param("id") String id); /** - * 获取题目的维度和方向信息 - * @param types 题目类型 - * @return 维度和方向信息列表 + * 获取测试的所有问题 */ - List> getQuestionDimensionsAndDirections(List types); + List getQuestionsByTestId(@Param("testId") String testId); + + /** + * 获取问题的所有选项 + */ + List