From 1cc51e8216f3e0da6245d98c84c46b020b067926 Mon Sep 17 00:00:00 2001 From: Sakura <2337674687@qq.com> Date: Sun, 9 Feb 2025 14:36:52 +0800 Subject: [PATCH 1/2] 2.9 --- .../template/action/ToolTemplateAction.java | 19 +++++++------------ .../target/classes/config.properties | 1 - HomeWork-java/tempResources/config.properties | 1 - 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/HomeWork-java/src/com/wetoband/template/action/ToolTemplateAction.java b/HomeWork-java/src/com/wetoband/template/action/ToolTemplateAction.java index 2d72b19..6f964a6 100644 --- a/HomeWork-java/src/com/wetoband/template/action/ToolTemplateAction.java +++ b/HomeWork-java/src/com/wetoband/template/action/ToolTemplateAction.java @@ -23,7 +23,10 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.Part; +import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -104,9 +107,6 @@ public class ToolTemplateAction extends ActionToolBase { return R.ok().put("data",wrongQuestion); } - - - //提交作业(简答题) @Action public R submitHomework(HttpServletRequest request) throws Exception { @@ -121,8 +121,6 @@ public class ToolTemplateAction extends ActionToolBase { return R.ok().message("请求成功"); } - - //提交疑难点 @Action public R submitQuestions(HttpServletRequest request) throws Exception { @@ -138,18 +136,15 @@ public class ToolTemplateAction extends ActionToolBase { return R.ok().message("请求成功"); } - //文件上传miniIo @Action - public R fileUploadService(@RequestParam(value = "file") MultipartFile multipartFile) {//前端要传一个名字叫 file 的参数 - - String fileUrl = fileUploadService.fileUpload(multipartFile) ; - return R.ok().put("data",fileUrl);//返回一个fileurl给前端 + public R fileUploadService(HttpServletRequest request) throws ServletException, IOException {//前端要传一个名字叫 file 的参数 + MultipartFile filePart = (MultipartFile) request.getPart("file"); +// String fileUrl = fileUploadService.fileUpload(filePart) ; + return R.ok().put("data",filePart);//返回一个fileurl给前端 } - - public static String runTool(String toolId, String action, Map map, String bandId) { HashMap params = new HashMap<>(); params.put("toolID", toolId); diff --git a/HomeWork-java/target/classes/config.properties b/HomeWork-java/target/classes/config.properties index bb52fb7..41af9f7 100644 --- a/HomeWork-java/target/classes/config.properties +++ b/HomeWork-java/target/classes/config.properties @@ -42,4 +42,3 @@ GET_SWAP_VALUE_PORT=6666 - diff --git a/HomeWork-java/tempResources/config.properties b/HomeWork-java/tempResources/config.properties index bb52fb7..41af9f7 100644 --- a/HomeWork-java/tempResources/config.properties +++ b/HomeWork-java/tempResources/config.properties @@ -42,4 +42,3 @@ GET_SWAP_VALUE_PORT=6666 - -- Gitee From 9614494d3dc2456d32822e31b4e4dfa6f2933759 Mon Sep 17 00:00:00 2001 From: Sakura <2337674687@qq.com> Date: Sun, 9 Feb 2025 21:06:20 +0800 Subject: [PATCH 2/2] 2.9.1 --- .../template/action/ToolTemplateAction.java | 69 +++++------ .../wetoband/template/dao/QuestionDao.java | 5 +- .../template/dao/TroubleshootingDao.java | 10 ++ .../template/dao/impl/QuestionDaoImpl.java | 38 ++++-- .../dao/impl/TroubleshootingDaoImpl.java | 28 +++++ .../wetoband/template/entity/Question.java | 34 +++--- .../template/entity/Troubleshooting.java | 34 ++++++ .../template/service/QuestionService.java | 4 +- .../service/TroubleshootingService.java | 8 ++ .../service/impl/QuestionServiceImpl.java | 6 +- .../impl/TroubleshootingServiceImpl.java | 25 ++++ .../target/classes/config.properties | 6 - HomeWork-java/tempResources/config.properties | 6 - .../views/HomeWorkManager/HomeWorkManger.vue | 7 +- .../MultipleChoiceQuestions.vue | 110 +++++++++++------- .../views/HomeWorkManager/uploadHomeWork.vue | 10 +- 16 files changed, 271 insertions(+), 129 deletions(-) create mode 100644 HomeWork-java/src/com/wetoband/template/dao/TroubleshootingDao.java create mode 100644 HomeWork-java/src/com/wetoband/template/dao/impl/TroubleshootingDaoImpl.java create mode 100644 HomeWork-java/src/com/wetoband/template/entity/Troubleshooting.java create mode 100644 HomeWork-java/src/com/wetoband/template/service/TroubleshootingService.java create mode 100644 HomeWork-java/src/com/wetoband/template/service/impl/TroubleshootingServiceImpl.java diff --git a/HomeWork-java/src/com/wetoband/template/action/ToolTemplateAction.java b/HomeWork-java/src/com/wetoband/template/action/ToolTemplateAction.java index 6f964a6..74407fd 100644 --- a/HomeWork-java/src/com/wetoband/template/action/ToolTemplateAction.java +++ b/HomeWork-java/src/com/wetoband/template/action/ToolTemplateAction.java @@ -1,40 +1,21 @@ package com.wetoband.template.action; -import cn.hutool.core.date.DateUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import com.fy.basejar.tool.ActionToolBase; import com.wetoband.template.AppConfig; -import com.wetoband.template.entity.HomeWork; - -import com.wetoband.template.entity.Question; -import com.wetoband.template.entity.User; -import com.wetoband.template.entity.WrongQuestion; - +import com.wetoband.template.entity.*; import com.wetoband.template.service.*; -import com.wetoband.template.service.impl.HomeWorkServiceImpl; -import com.wetoband.template.service.impl.QuestionServiceImpl; -import com.wetoband.template.service.impl.UserServiceImpl; -import com.wetoband.template.service.impl.WrongQuestionServiceImpl; +import com.wetoband.template.service.impl.*; import com.wetoband.template.util.R; -import org.springframework.beans.factory.annotation.Autowired; +import org.jetbrains.annotations.NotNull; import org.springframework.context.ApplicationContext; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; - import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.Part; import java.io.IOException; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @@ -45,14 +26,13 @@ public class ToolTemplateAction extends ActionToolBase { //获取service实例 HomeWorkService homeWorkService=IOC.getBean(HomeWorkServiceImpl.class); WrongQuestionService wrongQuestionService=IOC.getBean(WrongQuestionServiceImpl.class); - QuestionService questionService=IOC.getBean(QuestionServiceImpl.class); UserService userService=IOC.getBean(UserServiceImpl.class); - FileUploadService fileUploadService= IOC.getBean(FileUploadService.class); + TroubleshootingService troubleshootingService=IOC.getBean(TroubleshootingServiceImpl.class); + QuestionService questionService=IOC.getBean(QuestionServiceImpl.class); @Action public R get(HttpServletRequest request ) throws Exception { - return R.ok().put("msg", "Hello World").message("GET请求成功"); } @@ -110,32 +90,53 @@ public class ToolTemplateAction extends ActionToolBase { //提交作业(简答题) @Action public R submitHomework(HttpServletRequest request) throws Exception { + + + + + + + + String[] userAnswers = request.getParameterValues("user_answers"); + System.out.println(123); + System.out.println("userAnswers:"+userAnswers); Integer studentId =Integer.parseInt(request.getParameter("student_id")); Integer homeworkId =Integer.parseInt(request.getParameter("homework_id")); //获取提交时间设置为年月日格式 String submitTimeStr = request.getParameter("submitTime"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date submitTimeDate = sdf.parse(submitTimeStr); - String text = request.getParameter("text"); + String text = "123"; homeWorkService.submitHomework(studentId,homeworkId,submitTimeDate,text); return R.ok().message("请求成功"); } + //提交疑难点 @Action - public R submitQuestions(HttpServletRequest request) throws Exception { - Question question = new Question(); - question.setHomework_id(Integer.parseInt(request.getParameter("homework_id"))); - question.setStudent_id(Integer.parseInt(request.getParameter("student_id"))); - question.setContent(request.getParameter("content")); + public R submitTroubleshooting(@NotNull HttpServletRequest request) throws Exception { + Troubleshooting troubleshooting = new Troubleshooting(); + troubleshooting.setQuestion_id(Integer.parseInt(request.getParameter("question_id"))); + troubleshooting.setHomework_id(Integer.parseInt(request.getParameter("homework_id"))); + troubleshooting.setStudent_id(Integer.parseInt(request.getParameter("student_id"))); + troubleshooting.setContent(request.getParameter("content")); String submitTimeStr = request.getParameter("submitTime"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date submitTimeDate = sdf.parse(submitTimeStr); - question.setSubmit_time(submitTimeDate); - questionService.submitQuestions(question); + troubleshooting.setSubmit_time(submitTimeDate); + troubleshootingService.submitTroubleshooting(troubleshooting); return R.ok().message("请求成功"); } + //获取题目(选择题) + @Action + public R getQuestion(HttpServletRequest request) throws Exception { + Integer homework_id =Integer.parseInt(request.getParameter("homework_id")); + List question = questionService.getQuestion(homework_id); + return R.ok().put("data",question); + } + + //文件上传miniIo @Action public R fileUploadService(HttpServletRequest request) throws ServletException, IOException {//前端要传一个名字叫 file 的参数 diff --git a/HomeWork-java/src/com/wetoband/template/dao/QuestionDao.java b/HomeWork-java/src/com/wetoband/template/dao/QuestionDao.java index f2beb66..c24dadf 100644 --- a/HomeWork-java/src/com/wetoband/template/dao/QuestionDao.java +++ b/HomeWork-java/src/com/wetoband/template/dao/QuestionDao.java @@ -1,9 +1,12 @@ package com.wetoband.template.dao; import com.wetoband.template.entity.Question; +import com.wetoband.template.entity.Troubleshooting; import java.sql.Connection; +import java.util.ArrayList; +import java.util.Map; public interface QuestionDao { - public void submitQuestions(Connection connection, Question question); + public ArrayList getQuestion(Connection connection, int homeworkId) throws Exception; } diff --git a/HomeWork-java/src/com/wetoband/template/dao/TroubleshootingDao.java b/HomeWork-java/src/com/wetoband/template/dao/TroubleshootingDao.java new file mode 100644 index 0000000..28359a4 --- /dev/null +++ b/HomeWork-java/src/com/wetoband/template/dao/TroubleshootingDao.java @@ -0,0 +1,10 @@ +package com.wetoband.template.dao; + +import com.wetoband.template.entity.Question; +import com.wetoband.template.entity.Troubleshooting; + +import java.sql.Connection; + +public interface TroubleshootingDao { + public void submitTroubleshooting(Connection connection, Troubleshooting troubleshooting); +} diff --git a/HomeWork-java/src/com/wetoband/template/dao/impl/QuestionDaoImpl.java b/HomeWork-java/src/com/wetoband/template/dao/impl/QuestionDaoImpl.java index 2d93fa5..712cef3 100644 --- a/HomeWork-java/src/com/wetoband/template/dao/impl/QuestionDaoImpl.java +++ b/HomeWork-java/src/com/wetoband/template/dao/impl/QuestionDaoImpl.java @@ -3,25 +3,43 @@ package com.wetoband.template.dao.impl; import com.wetoband.template.dao.QuestionDao; import com.wetoband.template.entity.HomeWork; import com.wetoband.template.entity.Question; +import com.wetoband.template.entity.Troubleshooting; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.sql.*; +import java.util.ArrayList; @Repository public class QuestionDaoImpl implements QuestionDao { @Override - public void submitQuestions(Connection connection, Question question) { - String sql = "INSERT INTO question (homework_id,content,student_id,teacher_id) VALUES (?,?,?,(SELECT teacher_id FROM homework WHERE homework_id = ?))" ; - try (PreparedStatement pstm = connection.prepareStatement(sql)) { - pstm.setInt(1, question.getHomework_id()); - pstm.setString(2, question.getContent()); - pstm.setInt(3, question.getStudent_id()); - pstm.setInt(4, question.getHomework_id()); - pstm.executeUpdate(); - } catch (SQLException e) { - throw new RuntimeException(e); + public ArrayList getQuestion(Connection connection, int homework_id) throws Exception { + ArrayList questions = new ArrayList<>(); + try (PreparedStatement pstm = connection.prepareStatement("SELECT * FROM question WHERE question_id in(SELECT homework_question.question_id FROM homework_question WHERE homework_id = ?)")) { + pstm.setInt(1, homework_id); + try (ResultSet rs = pstm.executeQuery()) { + while (rs.next()) { + Question question = new Question(); + question.setQuestion_id(rs.getInt("question_id")); + question.setTitle(rs.getString("title")); + question.setType(rs.getInt("type")); + if (rs.getString("option_A")!=null){ + question.setOption_A(rs.getString("option_A")); + } + if (rs.getString("option_B")!=null){ + question.setOption_B(rs.getString("option_B")); + } + if (rs.getString("option_C")!=null){ + question.setOption_C(rs.getString("option_C")); + } + if (rs.getString("option_D")!=null){ + question.setOption_D(rs.getString("option_D")); + } + questions.add(question); + } + } } + return questions; } } diff --git a/HomeWork-java/src/com/wetoband/template/dao/impl/TroubleshootingDaoImpl.java b/HomeWork-java/src/com/wetoband/template/dao/impl/TroubleshootingDaoImpl.java new file mode 100644 index 0000000..fefc003 --- /dev/null +++ b/HomeWork-java/src/com/wetoband/template/dao/impl/TroubleshootingDaoImpl.java @@ -0,0 +1,28 @@ +package com.wetoband.template.dao.impl; + +import com.wetoband.template.dao.TroubleshootingDao; +import com.wetoband.template.entity.Question; +import com.wetoband.template.entity.Troubleshooting; +import org.springframework.stereotype.Repository; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +@Repository +public class TroubleshootingDaoImpl implements TroubleshootingDao { + @Override + public void submitTroubleshooting(Connection connection, Troubleshooting Troubleshooting) { + String sql = "INSERT INTO Troubleshooting (question_id,homework_id,content,student_id,teacher_id) VALUES (?,?,?,?,(SELECT teacher_id FROM homework WHERE homework_id = ?))" ; + try (PreparedStatement pstm = connection.prepareStatement(sql)) { + pstm.setInt(1, Troubleshooting.getQuestion_id()); + pstm.setInt(2, Troubleshooting.getHomework_id()); + pstm.setString(3, Troubleshooting.getContent()); + pstm.setInt(4, Troubleshooting.getStudent_id()); + pstm.setInt(5, Troubleshooting.getHomework_id()); + pstm.executeUpdate(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/HomeWork-java/src/com/wetoband/template/entity/Question.java b/HomeWork-java/src/com/wetoband/template/entity/Question.java index 02d2b41..08aa8c0 100644 --- a/HomeWork-java/src/com/wetoband/template/entity/Question.java +++ b/HomeWork-java/src/com/wetoband/template/entity/Question.java @@ -11,22 +11,22 @@ import java.util.Date; @Table(name = "question") public class Question { @Id - @Column(name = "question_id") + @Column(name ="question_id") private Integer question_id; - @Column(name = "student_id") - private Integer student_id; - @Column(name = "teacher_id") - private Integer teacher_id; - @Column(name = "homework_id") - private Integer homework_id; - @Column(name = "submit_time") - private Date submit_time; - @Column(name = "content") - private String content; - @Column(name = "solve_status") - private String solve_status; - @Column(name = "solve_content") - private String solve_content; - @Column(name = "solve_time") - private String solve_time; + @Column(name ="title") + private String title; + @Column(name ="type") + private int type; + @Column(name ="option_A") + private String option_A; + @Column(name ="option_B") + private String option_B; + @Column(name ="option_C") + private String option_C; + @Column(name ="option_D") + private String option_D; + @Column(name ="correct_answer") + private String correct_answer; + + } diff --git a/HomeWork-java/src/com/wetoband/template/entity/Troubleshooting.java b/HomeWork-java/src/com/wetoband/template/entity/Troubleshooting.java new file mode 100644 index 0000000..7694c35 --- /dev/null +++ b/HomeWork-java/src/com/wetoband/template/entity/Troubleshooting.java @@ -0,0 +1,34 @@ +package com.wetoband.template.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +@Data +@Table(name = "Troubleshooting") +public class Troubleshooting { + @Id + @Column(name = "troubleshooting_id") + private Integer troubleshooting_id; + @Column(name = "question_id") + private Integer question_id; + @Column(name = "student_id") + private Integer student_id; + @Column(name = "teacher_id") + private Integer teacher_id; + @Column(name = "homework_id") + private Integer homework_id; + @Column(name = "submit_time") + private Date submit_time; + @Column(name = "content") + private String content; + @Column(name = "solve_status") + private String solve_status; + @Column(name = "solve_content") + private String solve_content; + @Column(name = "solve_time") + private String solve_time; +} \ No newline at end of file diff --git a/HomeWork-java/src/com/wetoband/template/service/QuestionService.java b/HomeWork-java/src/com/wetoband/template/service/QuestionService.java index 0b309cc..0f037c7 100644 --- a/HomeWork-java/src/com/wetoband/template/service/QuestionService.java +++ b/HomeWork-java/src/com/wetoband/template/service/QuestionService.java @@ -2,6 +2,8 @@ package com.wetoband.template.service; import com.wetoband.template.entity.Question; +import java.util.ArrayList; + public interface QuestionService { - public void submitQuestions(Question question) throws Exception; + public ArrayList getQuestion(int homework_id) throws Exception; } diff --git a/HomeWork-java/src/com/wetoband/template/service/TroubleshootingService.java b/HomeWork-java/src/com/wetoband/template/service/TroubleshootingService.java new file mode 100644 index 0000000..ed92f04 --- /dev/null +++ b/HomeWork-java/src/com/wetoband/template/service/TroubleshootingService.java @@ -0,0 +1,8 @@ +package com.wetoband.template.service; + +import com.wetoband.template.entity.Question; +import com.wetoband.template.entity.Troubleshooting; + +public interface TroubleshootingService { + public void submitTroubleshooting(Troubleshooting troubleshooting) throws Exception; +} diff --git a/HomeWork-java/src/com/wetoband/template/service/impl/QuestionServiceImpl.java b/HomeWork-java/src/com/wetoband/template/service/impl/QuestionServiceImpl.java index c839733..7d66003 100644 --- a/HomeWork-java/src/com/wetoband/template/service/impl/QuestionServiceImpl.java +++ b/HomeWork-java/src/com/wetoband/template/service/impl/QuestionServiceImpl.java @@ -9,15 +9,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.sql.Connection; +import java.util.ArrayList; @Service @NoArgsConstructor public class QuestionServiceImpl implements QuestionService { + @Autowired private QuestionDao questionDao; @Override - public void submitQuestions(Question question) throws Exception { + public ArrayList getQuestion(int homework_id) throws Exception { final Connection connection = ActionToolBase.getDBConnection(); - questionDao.submitQuestions(connection, question); + return questionDao.getQuestion(connection,homework_id); } } diff --git a/HomeWork-java/src/com/wetoband/template/service/impl/TroubleshootingServiceImpl.java b/HomeWork-java/src/com/wetoband/template/service/impl/TroubleshootingServiceImpl.java new file mode 100644 index 0000000..c1bb62c --- /dev/null +++ b/HomeWork-java/src/com/wetoband/template/service/impl/TroubleshootingServiceImpl.java @@ -0,0 +1,25 @@ +package com.wetoband.template.service.impl; + +import com.fy.basejar.tool.ActionToolBase; +import com.wetoband.template.dao.QuestionDao; +import com.wetoband.template.dao.TroubleshootingDao; +import com.wetoband.template.entity.Question; +import com.wetoband.template.entity.Troubleshooting; +import com.wetoband.template.service.TroubleshootingService; +import lombok.NoArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.sql.Connection; + +@Service +@NoArgsConstructor +public class TroubleshootingServiceImpl implements TroubleshootingService { + @Autowired + private TroubleshootingDao troubleshootingDao; + @Override + public void submitTroubleshooting(Troubleshooting troubleshooting) throws Exception { + final Connection connection = ActionToolBase.getDBConnection(); + troubleshootingDao.submitTroubleshooting(connection, troubleshooting); + } +} diff --git a/HomeWork-java/target/classes/config.properties b/HomeWork-java/target/classes/config.properties index 41af9f7..5842d6b 100644 --- a/HomeWork-java/target/classes/config.properties +++ b/HomeWork-java/target/classes/config.properties @@ -27,12 +27,6 @@ JDBC_PASSWORD=123456 #JDBC_USERNAME=root #JDBC_PASSWORD=root -MONGODB_IP=localhost -MONGODB_PORT=27017 -MONGODB_DBNAME=admin -MONGODB_USERNAME=root -MONGODB_PASSWORD=root - SWAP_VALUE_MAX_SIZE=0 SWAP_VALUE_SERVER_PORT=6666 GET_SWAP_VALUE_IP=192.168.10.254 diff --git a/HomeWork-java/tempResources/config.properties b/HomeWork-java/tempResources/config.properties index 41af9f7..5842d6b 100644 --- a/HomeWork-java/tempResources/config.properties +++ b/HomeWork-java/tempResources/config.properties @@ -27,12 +27,6 @@ JDBC_PASSWORD=123456 #JDBC_USERNAME=root #JDBC_PASSWORD=root -MONGODB_IP=localhost -MONGODB_PORT=27017 -MONGODB_DBNAME=admin -MONGODB_USERNAME=root -MONGODB_PASSWORD=root - SWAP_VALUE_MAX_SIZE=0 SWAP_VALUE_SERVER_PORT=6666 GET_SWAP_VALUE_IP=192.168.10.254 diff --git a/HomeWork-vite/src/views/HomeWorkManager/HomeWorkManger.vue b/HomeWork-vite/src/views/HomeWorkManager/HomeWorkManger.vue index da80e1e..a35f20b 100644 --- a/HomeWork-vite/src/views/HomeWorkManager/HomeWorkManger.vue +++ b/HomeWork-vite/src/views/HomeWorkManager/HomeWorkManger.vue @@ -34,7 +34,9 @@ 上传作业 + style="background-color:blueviolet;">上传作业 + + @@ -97,7 +99,8 @@ const worng = () => { } const upload = () => { - router.push('./uploadHomeWork') + // router.push('./uploadHomeWork') + router.push('./MultipleChoiceQuestions') } const tableData = ref([ diff --git a/HomeWork-vite/src/views/HomeWorkManager/MultipleChoiceQuestions.vue b/HomeWork-vite/src/views/HomeWorkManager/MultipleChoiceQuestions.vue index 6171631..2d92a93 100644 --- a/HomeWork-vite/src/views/HomeWorkManager/MultipleChoiceQuestions.vue +++ b/HomeWork-vite/src/views/HomeWorkManager/MultipleChoiceQuestions.vue @@ -25,7 +25,6 @@ - {{ String.fromCharCode(65 + index) }}. @@ -42,57 +41,80 @@