diff --git a/backend/src/main/java/ltd/qubit/survey/dao/OptionDao.java b/backend/src/main/java/ltd/qubit/survey/dao/OptionDao.java index 16ca3d4..11657e0 100644 --- a/backend/src/main/java/ltd/qubit/survey/dao/OptionDao.java +++ b/backend/src/main/java/ltd/qubit/survey/dao/OptionDao.java @@ -20,10 +20,10 @@ public interface OptionDao extends BaseDao { * 根据问题ID和选项代码查询 * * @param questionId 问题ID - * @param optionCode 选项代码 + * @param code 选项代码 * @return 选项对象 */ - Optional findByQuestionIdAndCode(Long questionId, String optionCode); + Optional findByQuestionIdAndCode(Long questionId, String code); /** * 批量插入选项 diff --git a/backend/src/main/java/ltd/qubit/survey/model/Option.java b/backend/src/main/java/ltd/qubit/survey/model/Option.java index f704614..0953634 100644 --- a/backend/src/main/java/ltd/qubit/survey/model/Option.java +++ b/backend/src/main/java/ltd/qubit/survey/model/Option.java @@ -21,7 +21,7 @@ public class Option { /** * 选项代码(如A、B、C) */ - private String optionCode; + private String code; /** * 选项内容 diff --git a/backend/src/main/java/ltd/qubit/survey/model/SurveyResponse.java b/backend/src/main/java/ltd/qubit/survey/model/SurveyResponse.java index e360f78..378128d 100644 --- a/backend/src/main/java/ltd/qubit/survey/model/SurveyResponse.java +++ b/backend/src/main/java/ltd/qubit/survey/model/SurveyResponse.java @@ -30,7 +30,7 @@ public class SurveyResponse { private List selectedOptions; /** - * 文本答案 + * 文本答案(用于文本题或需要填写文本的选项) */ private String textAnswer; diff --git a/backend/src/main/java/ltd/qubit/survey/service/impl/SurveyResponseServiceImpl.java b/backend/src/main/java/ltd/qubit/survey/service/impl/SurveyResponseServiceImpl.java index 3b6fb0c..e103bb2 100644 --- a/backend/src/main/java/ltd/qubit/survey/service/impl/SurveyResponseServiceImpl.java +++ b/backend/src/main/java/ltd/qubit/survey/service/impl/SurveyResponseServiceImpl.java @@ -81,19 +81,6 @@ public class SurveyResponseServiceImpl implements SurveyResponseService { @Override public List submitSurvey(Long userId, List responses) { - // 验证所有必答题是否已回答 - List questions = questionService.getUserQuestions(userId); - for (Question question : questions) { - if (question.getIsRequired()) { - boolean answered = responses.stream() - .anyMatch(response -> response.getQuestionId().equals(question.getId())); - if (!answered) { - throw new IllegalArgumentException( - String.format("问题 %d 为必答题,请填写答案", question.getNumber())); - } - } - } - // 删除用户之前的答案 deleteByUserId(userId); diff --git a/backend/src/main/resources/mybatis/mapper/OptionMapper.xml b/backend/src/main/resources/mybatis/mapper/OptionMapper.xml index da7f3c3..59ded57 100644 --- a/backend/src/main/resources/mybatis/mapper/OptionMapper.xml +++ b/backend/src/main/resources/mybatis/mapper/OptionMapper.xml @@ -5,7 +5,7 @@ - + @@ -13,21 +13,21 @@ - `id`, `question_id`, `option_code`, `content`, `requires_text`, `created_at` + `id`, `question_id`, `code`, `content`, `requires_text`, `created_at` - INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) - VALUES (#{questionId}, #{optionCode}, #{content}, #{requiresText}) + INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) + VALUES (#{questionId}, #{code}, #{content}, #{requiresText}) - INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) + INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES - (#{item.questionId}, #{item.optionCode}, #{item.content}, #{item.requiresText}) + (#{item.questionId}, #{item.code}, #{item.content}, #{item.requiresText}) @@ -35,7 +35,7 @@ UPDATE `option` SET `question_id` = #{questionId}, - `option_code` = #{optionCode}, + `code` = #{code}, `content` = #{content}, `requires_text` = #{requiresText} WHERE `id` = #{id} @@ -62,7 +62,7 @@ SELECT FROM `option` - ORDER BY `question_id`, `option_code` + ORDER BY `question_id`, `code` @@ -70,14 +70,14 @@ SELECT FROM `option` WHERE `question_id` = #{questionId} - ORDER BY `option_code` + ORDER BY `code` - + SELECT FROM `option` WHERE `question_id` = #{questionId} - AND `option_code` = #{optionCode} + AND `code` = #{code} \ No newline at end of file diff --git a/backend/src/main/resources/mybatis/mapper/SurveyResponseMapper.xml b/backend/src/main/resources/mybatis/mapper/SurveyResponseMapper.xml index c954675..bce6ae1 100644 --- a/backend/src/main/resources/mybatis/mapper/SurveyResponseMapper.xml +++ b/backend/src/main/resources/mybatis/mapper/SurveyResponseMapper.xml @@ -19,7 +19,9 @@ INSERT INTO `survey_response` (`user_id`, `question_id`, `selected_options`, `text_answer`) - VALUES (#{userId}, #{questionId}, #{selectedOptions,typeHandler=ltd.qubit.survey.common.mybatis.JsonTypeHandler}, #{textAnswer}) + VALUES (#{userId}, #{questionId}, + #{selectedOptions,typeHandler=ltd.qubit.survey.common.mybatis.JsonTypeHandler}, + #{textAnswer}) diff --git a/database/init_database.sql b/database/init_database.sql index a13e2c7..58833e9 100644 --- a/database/init_database.sql +++ b/database/init_database.sql @@ -36,14 +36,14 @@ CREATE TABLE IF NOT EXISTS `question` ( -- 创建选项表 CREATE TABLE IF NOT EXISTS `option` ( `id` BIGINT PRIMARY KEY AUTO_INCREMENT, - `question_id` BIGINT NOT NULL COMMENT '问题ID', - `option_code` VARCHAR(10) NOT NULL COMMENT '选项代码', + `question_id` BIGINT NOT NULL COMMENT '关联的问题ID', + `code` VARCHAR(10) NOT NULL COMMENT '选项代码', `content` TEXT NOT NULL COMMENT '选项内容', `requires_text` BOOLEAN NOT NULL DEFAULT FALSE COMMENT '是否需要填写文本', `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - FOREIGN KEY (`question_id`) REFERENCES `question`(`id`), - UNIQUE KEY `uk_question_option` (`question_id`, `option_code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='选项表'; + FOREIGN KEY (`question_id`) REFERENCES `question` (`id`), + UNIQUE KEY `uk_question_code` (`question_id`, `code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='问题选项表'; -- 创建问卷答案表 CREATE TABLE IF NOT EXISTS `survey_response` ( @@ -51,10 +51,10 @@ CREATE TABLE IF NOT EXISTS `survey_response` ( `user_id` BIGINT NOT NULL COMMENT '用户ID', `question_id` BIGINT NOT NULL COMMENT '问题ID', `selected_options` JSON DEFAULT NULL COMMENT '选中的选项代码列表', - `text_answer` TEXT DEFAULT NULL COMMENT '文本答案', + `text_answer` TEXT DEFAULT NULL COMMENT '文本答案(用于文本题或需要填写文本的选项)', `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - FOREIGN KEY (`user_id`) REFERENCES `user`(`id`), - FOREIGN KEY (`question_id`) REFERENCES `question`(`id`) + FOREIGN KEY (`user_id`) REFERENCES `user` (`id`), + FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='问卷答案表'; -- 清空现有数据 @@ -69,7 +69,7 @@ SET FOREIGN_KEY_CHECKS = 1; INSERT INTO `question` (`number`, `content`, `type`, `is_required`, `is_last`) VALUES (1, '您对大模型(如ChatGPT、通义千问、DeepSeek)的了解程度:', 'SINGLE_CHOICE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`) VALUES (LAST_INSERT_ID(), 'A', '从未接触过'), (LAST_INSERT_ID(), 'B', '仅在日常简单使用过通用功能(如问答)'), (LAST_INSERT_ID(), 'C', '在工作中尝试过基础应用'), @@ -78,7 +78,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`) VALUES INSERT INTO `question` (`number`, `content`, `type`, `is_required`, `is_last`) VALUES (2, '您觉得大模型可以做到下面哪些事?', 'MULTIPLE_CHOICE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '精准知识问答', FALSE), (LAST_INSERT_ID(), 'B', '文档撰写/报告生成/代码编写/图片视频生成等', FALSE), (LAST_INSERT_ID(), 'C', '数据清洗与分析', FALSE), @@ -90,7 +90,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `is_required`, `is_last`) VALUES (3, '您最关注大模型应用的哪些风险?', 'MULTIPLE_CHOICE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '数据隐私泄露', FALSE), (LAST_INSERT_ID(), 'B', '生成内容不准确', FALSE), (LAST_INSERT_ID(), 'C', '合规审查风险', FALSE), @@ -100,7 +100,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `is_required`, `is_last`) VALUES (4, '您的主要工作内容是:', 'SINGLE_CHOICE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`) VALUES (LAST_INSERT_ID(), 'A', '研发(产品、开发、算法、测试、运维等)'), (LAST_INSERT_ID(), 'B', '项目管理(项目立项、进度跟踪、风险管理等)'), (LAST_INSERT_ID(), 'C', '保险(产品、核保、理赔、精算等)'), @@ -116,7 +116,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`) VALUES INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (5, '您在开发过程中最耗时的重复性工作:', 'MULTIPLE_CHOICE', 'RD', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '文档编写(如需求文档、技术文档等)', FALSE), (LAST_INSERT_ID(), 'B', '产品原型、界面设计(如使用图片生成模型自动生成等)', FALSE), (LAST_INSERT_ID(), 'C', '代码编写', FALSE), @@ -127,7 +127,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (6, '您希望大模型如何与现有系统集成:', 'MULTIPLE_CHOICE', 'RD', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '回答技术问题', FALSE), (LAST_INSERT_ID(), 'B', '自动生成代码片段(如 Github Copilot等)', FALSE), (LAST_INSERT_ID(), 'C', '智能测试用例生成', FALSE), @@ -141,7 +141,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (7, '项目管理中最常遇到的挑战是:', 'MULTIPLE_CHOICE', 'PROJECT', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '项目进度跟踪与更新', FALSE), (LAST_INSERT_ID(), 'B', '风险评估与管控', FALSE), (LAST_INSERT_ID(), 'C', '项目报告生成', FALSE), @@ -150,7 +150,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (8, '您希望如何利用大模型提升项目管理效率:', 'MULTIPLE_CHOICE', 'PROJECT', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '自动生成立项报告、进度报告、总结报告等', FALSE), (LAST_INSERT_ID(), 'B', '风险预测与预警', FALSE), (LAST_INSERT_ID(), 'C', '项目资料自动化整理', FALSE), @@ -161,7 +161,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (9, '理赔处理中的主要瓶颈是:', 'MULTIPLE_CHOICE', 'INSURANCE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '理赔文档处理', FALSE), (LAST_INSERT_ID(), 'B', '医疗票据审核与核对', FALSE), (LAST_INSERT_ID(), 'C', '客户资料信息录入与处理', FALSE), @@ -171,7 +171,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (10, '大模型可以优化哪些保险工作环节:', 'MULTIPLE_CHOICE', 'INSURANCE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '新员工入职培训', FALSE), (LAST_INSERT_ID(), 'B', '保险产品设计的优化', FALSE), (LAST_INSERT_ID(), 'C', '自动生成理赔报告与告知书', FALSE), @@ -183,7 +183,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (11, '日常工作中最重复的任务是:', 'MULTIPLE_CHOICE', 'FINANCE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '财务数据整理与报表生成', FALSE), (LAST_INSERT_ID(), 'B', '发票和报销单审核', FALSE), (LAST_INSERT_ID(), 'C', '财务审计与合规检查', FALSE), @@ -192,7 +192,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (12, '大模型能如何协助提升财务工作效率:', 'MULTIPLE_CHOICE', 'FINANCE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '各种报表格式的自动转换', FALSE), (LAST_INSERT_ID(), 'B', '自动生成财务报表与分析摘要', FALSE), (LAST_INSERT_ID(), 'C', '自动化审计和合规检查', FALSE), @@ -203,7 +203,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (13, '客户咨询中最常遇到的重复性问题:', 'MULTIPLE_CHOICE', 'CUSTOMER_SERVICE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '参保资格咨询', FALSE), (LAST_INSERT_ID(), 'B', '理赔进度查询', FALSE), (LAST_INSERT_ID(), 'C', '材料补交通知', FALSE), @@ -212,7 +212,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (14, '您希望大模型如何辅助客服工作:', 'MULTIPLE_CHOICE', 'CUSTOMER_SERVICE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '自动生成客户回复模板', FALSE), (LAST_INSERT_ID(), 'B', '客户咨询自动分类与转接', FALSE), (LAST_INSERT_ID(), 'C', '智能分析客户情绪与需求', FALSE), @@ -222,7 +222,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (15, '在运营工作中,最需要自动化支持的任务是:', 'MULTIPLE_CHOICE', 'OPERATION', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '热点讯息的获取和跟踪', FALSE), (LAST_INSERT_ID(), 'B', '数据分析与报告生成', FALSE), (LAST_INSERT_ID(), 'C', '社交媒体内容创作', FALSE), @@ -232,7 +232,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (16, '大模型可以如何帮助提升运营效率:', 'MULTIPLE_CHOICE', 'OPERATION', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '自动抓取热点讯息', FALSE), (LAST_INSERT_ID(), 'B', '自动生成社交媒体内容', FALSE), (LAST_INSERT_ID(), 'C', '用户评论分析与舆情监测', FALSE), @@ -243,7 +243,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (17, '在市场拓展和商务沟通中,您最常遇到的挑战是:', 'MULTIPLE_CHOICE', 'MARKET', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '市场分析和竞争对手跟踪', FALSE), (LAST_INSERT_ID(), 'B', '渠道拓展计划的自动化和优化', FALSE), (LAST_INSERT_ID(), 'C', '商务沟通中的信息处理与反馈跟踪', FALSE), @@ -252,7 +252,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (18, '您希望大模型如何帮助提升市场拓展效率:', 'MULTIPLE_CHOICE', 'MARKET', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '自动生成市场分析报告与趋势预测', FALSE), (LAST_INSERT_ID(), 'B', '根据目标客户数据生成个性化营销策略', FALSE), (LAST_INSERT_ID(), 'C', '自动化生成商务沟通邮件和提案文档', FALSE), @@ -262,7 +262,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (19, '人事部门最耗时的日常任务是:', 'MULTIPLE_CHOICE', 'HR', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '招聘简历筛选与面试安排', FALSE), (LAST_INSERT_ID(), 'B', '员工培训与学习进度管理', FALSE), (LAST_INSERT_ID(), 'C', '绩效评估与报告生成', FALSE), @@ -271,7 +271,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (20, '您希望大模型如何协助提升人事工作效率:', 'MULTIPLE_CHOICE', 'HR', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '自动筛选招聘简历并推荐候选人', FALSE), (LAST_INSERT_ID(), 'B', '自动化培训内容推送与学习路径规划', FALSE), (LAST_INSERT_ID(), 'C', '绩效评估与员工反馈的自动化分析', FALSE), @@ -281,7 +281,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (21, '在行政工作中,最耗时的任务是:', 'MULTIPLE_CHOICE', 'ADMIN', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '合同审查与管理', FALSE), (LAST_INSERT_ID(), 'B', '会议纪要整理', FALSE), (LAST_INSERT_ID(), 'C', '文档管理与更新', FALSE), @@ -290,7 +290,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (22, '您希望大模型如何协助提升行政工作效率:', 'MULTIPLE_CHOICE', 'ADMIN', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '自动生成合同和协议模板', FALSE), (LAST_INSERT_ID(), 'B', '自动化会议纪要整理与分发', FALSE), (LAST_INSERT_ID(), 'C', '自动化文档归档与管理', FALSE), @@ -300,7 +300,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (23, '您认为大模型在哪些战略层面的决策中可以发挥作用?', 'MULTIPLE_CHOICE', 'EXECUTIVE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '市场趋势预测与分析', FALSE), (LAST_INSERT_ID(), 'B', '组织结构优化与调整', FALSE), (LAST_INSERT_ID(), 'C', '业务流程优化与重组', FALSE), @@ -309,7 +309,7 @@ INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) INSERT INTO `question` (`number`, `content`, `type`, `work_area`, `is_required`, `is_last`) VALUES (24, '在公司管理工作中,您最希望大模型协助哪些任务?', 'MULTIPLE_CHOICE', 'EXECUTIVE', TRUE, FALSE); -INSERT INTO `option` (`question_id`, `option_code`, `content`, `requires_text`) VALUES +INSERT INTO `option` (`question_id`, `code`, `content`, `requires_text`) VALUES (LAST_INSERT_ID(), 'A', '数据分析与报告自动生成', FALSE), (LAST_INSERT_ID(), 'B', '战略规划与方案优化', FALSE), (LAST_INSERT_ID(), 'C', '业务协同与跨部门信息流通', FALSE), diff --git a/deploy-local.sh b/deploy-local.sh new file mode 100755 index 0000000..532d1f3 --- /dev/null +++ b/deploy-local.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# 获取脚本所在目录的绝对路径 +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# 设置Docker数据目录 +DOCKER_DATA_DIR="/Volumes/working/docker" +TOMCAT_WEBAPPS_DIR="$DOCKER_DATA_DIR/tomcat/webapps" +TOMCAT_LOGS_DIR="$DOCKER_DATA_DIR/tomcat/logs/llm-survey-api" + +echo "=== 开始部署 ===" + +# 1. 进入后端项目目录 +cd "$SCRIPT_DIR/backend" || exit 1 +echo "✓ 已切换到后端项目目录" + +# 2. 清理并打包项目 +echo "正在打包后端项目..." +mvn clean package -DskipTests +if [ $? -ne 0 ]; then + echo "✗ Maven打包失败" + exit 1 +fi +echo "✓ Maven打包成功" + +# 3. 复制WAR包到Tomcat的webapps目录 +echo "正在复制WAR包到Tomcat..." +cp target/llm-survey-api.war "$TOMCAT_WEBAPPS_DIR/" +if [ $? -ne 0 ]; then + echo "✗ WAR包复制失败" + exit 1 +fi +echo "✓ WAR包复制成功" + +# 4. 等待部署完成 +echo "等待应用部署完成..." +sleep 5 + +# 5. 检查部署日志 +echo "检查业务日志..." +tail "$TOMCAT_LOGS_DIR/app.log" + +echo "=== 部署完成 ===" +echo "请访问 http://localhost:18080/llm-survey-api 验证部署结果" \ No newline at end of file diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 5537af0..9a0a403 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -19,6 +19,12 @@ const router = createRouter({ component: () => import('@/views/SurveyView.vue'), meta: { requiresAuth: true }, }, + { + path: '/completed', + name: 'completed', + component: () => import('@/views/CompletedView.vue'), + meta: { requiresAuth: true }, + }, ], }); diff --git a/frontend/src/stores/survey.js b/frontend/src/stores/survey.js index 96ebc52..f9090da 100644 --- a/frontend/src/stores/survey.js +++ b/frontend/src/stores/survey.js @@ -44,18 +44,20 @@ export const useSurveyStore = defineStore('survey', () => { } // 获取下一个问题 - async function fetchNextQuestion(userId, selectedOptions) { + async function fetchNextQuestion(userId, selectedOptions, targetQuestionNumber) { try { - console.log('获取下一个问题,参数:', { userId, selectedOptions, currentQuestionNumber: currentQuestionNumber.value }); + console.log('获取问题,参数:', { userId, selectedOptions, targetQuestionNumber, currentQuestionNumber: currentQuestionNumber.value }); - // 如果没有当前问题号,说明是新开始的问卷 - const isNewSurvey = !currentQuestionNumber.value; + let question; + if (targetQuestionNumber) { + // 如果指定了目标问题号,直接获取该问题 + const questions = await getUserQuestions(userId); + question = questions.find(q => q.number === targetQuestionNumber); + } else { + // 否则获取下一题 + question = await getNextQuestion(userId, selectedOptions, currentQuestionNumber.value); + } - const question = await getNextQuestion( - userId, - selectedOptions, - isNewSurvey ? undefined : currentQuestionNumber.value - ); console.log('获取到的问题:', question); if (question) { @@ -74,7 +76,7 @@ export const useSurveyStore = defineStore('survey', () => { return question; } catch (error) { - console.error('获取下一个问题失败:', error); + console.error('获取问题失败:', error); throw error; } } diff --git a/frontend/src/views/CompletedView.vue b/frontend/src/views/CompletedView.vue new file mode 100644 index 0000000..3d32ac2 --- /dev/null +++ b/frontend/src/views/CompletedView.vue @@ -0,0 +1,88 @@ + + + + + + + + + + + 您的反馈对我们非常重要 + 我们将根据调查结果持续改进和优化 + + + + 返回首页 + + + + + + + + \ No newline at end of file diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index 8215dcf..1be8e5a 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -13,7 +13,13 @@ 欢迎参与 LLM 问卷调查 - 本问卷旨在了解您对大语言模型(LLM)的使用体验和看法。您的反馈对我们非常重要。 + 本问卷旨在了解智慧医疗员工对大语言模型的使用体验和看法。您的反馈对我们非常重要。 + + + 此应用使用Cursor生成。所有代码,包括数据库脚本、前后端代码、配置文件等均通过提示词指挥AI生成;git提交、测试、代码打包发布等操作也是通过提示词指挥AI完成。 + + + 此项目开发到上线共计耗时1人5小时,传统开发方式需要产品、前端、后端、测试4人1~2天工作量。 @@ -32,9 +38,9 @@ round block type="primary" - @click="router.push('/survey')" + @click="surveyStore.isCompleted ? startNewSurvey() : router.push('/survey')" > - 继续答题 + {{ surveyStore.isCompleted ? '重新答题' : '继续答题' }} import { useRouter } from 'vue-router'; import { useUserStore } from '@/stores/user'; +import { useSurveyStore } from '@/stores/survey'; import { showToast } from 'vant'; const router = useRouter(); const userStore = useUserStore(); +const surveyStore = useSurveyStore(); function onLogout() { userStore.logout(); showToast('已退出登录'); } + +// 开始新的问卷 +function startNewSurvey() { + surveyStore.resetSurvey(); + router.push('/survey'); +} \ No newline at end of file
您的反馈对我们非常重要
我们将根据调查结果持续改进和优化
- 本问卷旨在了解您对大语言模型(LLM)的使用体验和看法。您的反馈对我们非常重要。 + 本问卷旨在了解智慧医疗员工对大语言模型的使用体验和看法。您的反馈对我们非常重要。 +
+ 此应用使用Cursor生成。所有代码,包括数据库脚本、前后端代码、配置文件等均通过提示词指挥AI生成;git提交、测试、代码打包发布等操作也是通过提示词指挥AI完成。 +
+ 此项目开发到上线共计耗时1人5小时,传统开发方式需要产品、前端、后端、测试4人1~2天工作量。