From 73f1356399ec90eb43c2483d9918c81ae581204b Mon Sep 17 00:00:00 2001 From: coding_liang Date: Wed, 3 May 2023 14:32:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=B2=A1?= =?UTF-8?q?=E6=9C=89vo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/lyt/ViewModel/BasePage.java | 12 +++ src/main/java/com/lyt/ViewModel/IdList.java | 7 ++ src/main/java/com/lyt/ViewModel/PageInfo.java | 15 ++++ .../lyt/ViewModel/QuestionEditRequestVM.java | 75 +++++++++++++++++++ .../lyt/ViewModel/QuestionPageRequestVM.java | 11 +++ .../com/lyt/ViewModel/QuestionResponseVM.java | 24 ++++++ .../java/com/lyt/ViewModel/QuestionVm.java | 12 +++ src/main/java/com/lyt/ViewModel/Wx/Item.java | 10 +++ .../java/com/lyt/ViewModel/fixedPaper.java | 11 +++ src/main/java/com/lyt/bean/Menu.java | 22 ++++++ .../com/lyt/bean/OnlineExam/ExamPaper.java | 24 ++++++ .../java/com/lyt/bean/OnlineExam/Item.java | 11 +++ .../com/lyt/bean/OnlineExam/Question.java | 56 ++++++++++++++ .../com/lyt/bean/OnlineExam/RestResponse.java | 67 +++++++++++++++++ .../java/com/lyt/bean/OnlineExam/Score.java | 16 ++++ .../com/lyt/bean/OnlineExam/SystemCode.java | 66 ++++++++++++++++ .../com/lyt/bean/OnlineExam/TextContent.java | 12 +++ src/main/java/com/lyt/bean/Paper.java | 1 + src/main/java/com/lyt/bean/PaperQuestion.java | 24 ++++++ src/main/java/com/lyt/bean/Studnet.java | 9 +++ src/main/java/com/lyt/bean/TitleContent.java | 18 +++++ src/main/java/com/lyt/dao/PaperDao.java | 4 +- .../java/com/lyt/service/PaperService.java | 30 ++++++-- src/main/java/com/lyt/util/BeanUtil.java | 62 +++++++++++++++ src/main/java/com/lyt/vo/ItemVo.java | 25 +++++++ src/main/java/com/lyt/vo/PaperVo.java | 37 +++++++++ src/main/java/com/lyt/vo/QuestionVo.java | 33 ++++++++ src/main/java/com/lyt/vo/QuestionsVo.java | 20 +++++ 28 files changed, 707 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/lyt/ViewModel/BasePage.java create mode 100644 src/main/java/com/lyt/ViewModel/IdList.java create mode 100644 src/main/java/com/lyt/ViewModel/PageInfo.java create mode 100644 src/main/java/com/lyt/ViewModel/QuestionEditRequestVM.java create mode 100644 src/main/java/com/lyt/ViewModel/QuestionPageRequestVM.java create mode 100644 src/main/java/com/lyt/ViewModel/QuestionResponseVM.java create mode 100644 src/main/java/com/lyt/ViewModel/QuestionVm.java create mode 100644 src/main/java/com/lyt/ViewModel/Wx/Item.java create mode 100644 src/main/java/com/lyt/ViewModel/fixedPaper.java create mode 100644 src/main/java/com/lyt/bean/Menu.java create mode 100644 src/main/java/com/lyt/bean/OnlineExam/ExamPaper.java create mode 100644 src/main/java/com/lyt/bean/OnlineExam/Item.java create mode 100644 src/main/java/com/lyt/bean/OnlineExam/Question.java create mode 100644 src/main/java/com/lyt/bean/OnlineExam/RestResponse.java create mode 100644 src/main/java/com/lyt/bean/OnlineExam/Score.java create mode 100644 src/main/java/com/lyt/bean/OnlineExam/SystemCode.java create mode 100644 src/main/java/com/lyt/bean/OnlineExam/TextContent.java create mode 100644 src/main/java/com/lyt/bean/PaperQuestion.java create mode 100644 src/main/java/com/lyt/bean/Studnet.java create mode 100644 src/main/java/com/lyt/bean/TitleContent.java create mode 100644 src/main/java/com/lyt/util/BeanUtil.java create mode 100644 src/main/java/com/lyt/vo/ItemVo.java create mode 100644 src/main/java/com/lyt/vo/PaperVo.java create mode 100644 src/main/java/com/lyt/vo/QuestionVo.java create mode 100644 src/main/java/com/lyt/vo/QuestionsVo.java diff --git a/src/main/java/com/lyt/ViewModel/BasePage.java b/src/main/java/com/lyt/ViewModel/BasePage.java new file mode 100644 index 0000000..2b0b6eb --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/BasePage.java @@ -0,0 +1,12 @@ +package com.lyt.ViewModel; + + +import lombok.Data; + +@Data +public class BasePage { + private Integer pageIndex; + + private Integer pageSize; + +} diff --git a/src/main/java/com/lyt/ViewModel/IdList.java b/src/main/java/com/lyt/ViewModel/IdList.java new file mode 100644 index 0000000..8ae0fca --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/IdList.java @@ -0,0 +1,7 @@ +package com.lyt.ViewModel; + +import java.util.List; + +public class IdList { + List id; +} diff --git a/src/main/java/com/lyt/ViewModel/PageInfo.java b/src/main/java/com/lyt/ViewModel/PageInfo.java new file mode 100644 index 0000000..868632f --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/PageInfo.java @@ -0,0 +1,15 @@ +package com.lyt.ViewModel; + +import lombok.Data; + +@Data +public class PageInfo { + private int pageNum; + private int pageSize; + private int size; + private int startRow; + private int endRow; + private int pages; + private int prePage; + private int nextPage; +} diff --git a/src/main/java/com/lyt/ViewModel/QuestionEditRequestVM.java b/src/main/java/com/lyt/ViewModel/QuestionEditRequestVM.java new file mode 100644 index 0000000..91c1236 --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/QuestionEditRequestVM.java @@ -0,0 +1,75 @@ +package com.lyt.ViewModel; + +import com.lyt.ViewModel.Wx.Item; +import lombok.Data; + +import java.util.List; + +@Data +public class QuestionEditRequestVM extends BasePage{ + + // + private String correct; + private Integer textContentId; + private String analyze; + private List items; + private Integer id; + private String questionType; + private Integer itemOrder; + private String subjectId; + private Integer difficult; + private String title; + private Integer score; + private String gradeLevel; + private List correctArray; + + public int findMax(){ + + return 0; + } + +// public int findKey(){ +// int arr[][]=new int[3][3]; +// arr= new int[][]{{3,2,1}, {4, 5, 6}, {7, 8, 9}}; +// +// int row,col; +// int rowCache; +// int colCache; +// int RowMax = 0; +// int colMin; +// int rowIndex=0; +// // System.out.println("数组的长度 :"+arr.length); +// for(int i=0;irowCache){ +// //找到当前行的最大元素 +// RowMax=rowCache; +// System.out.println(""+RowMax); +// }else { +// RowMax=rowCache; +// } +// //找到当前列的最小数 +//// for(int j=0;jcolCache){ +//// //找到当前列的最小元素 +//// colMin=colCache; +//// } +//// } +// // rowIndex++; +// +// } +// +// System.out.println("rowMax"+RowMax); +// return 0; +// } +// @Test +// public void test(){ +// findKey(); +// } +} diff --git a/src/main/java/com/lyt/ViewModel/QuestionPageRequestVM.java b/src/main/java/com/lyt/ViewModel/QuestionPageRequestVM.java new file mode 100644 index 0000000..bf0e9fa --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/QuestionPageRequestVM.java @@ -0,0 +1,11 @@ +package com.lyt.ViewModel; + +import lombok.Data; + +@Data +public class QuestionPageRequestVM extends BasePage{ + private Integer id; + private Integer level; + private Integer subjectId; + private Integer questionType; +} diff --git a/src/main/java/com/lyt/ViewModel/QuestionResponseVM.java b/src/main/java/com/lyt/ViewModel/QuestionResponseVM.java new file mode 100644 index 0000000..37c525d --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/QuestionResponseVM.java @@ -0,0 +1,24 @@ +package com.lyt.ViewModel; + +import lombok.Data; + +import java.util.List; + +@Data +public class QuestionResponseVM { + + + private String correct; + private Integer textContentId; + private String analyze; + private String items; + private Integer id; + private String questionType; + private Integer itemOrder; + private String subjectId; + private Integer difficult; + private String title; + private Integer score; + private String gradeLevel; + private List correctArray; +} diff --git a/src/main/java/com/lyt/ViewModel/QuestionVm.java b/src/main/java/com/lyt/ViewModel/QuestionVm.java new file mode 100644 index 0000000..230c71e --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/QuestionVm.java @@ -0,0 +1,12 @@ +package com.lyt.ViewModel; + +import lombok.Data; + +import java.util.List; + +@Data +public class QuestionVm { + private List list; + + private String name; +} diff --git a/src/main/java/com/lyt/ViewModel/Wx/Item.java b/src/main/java/com/lyt/ViewModel/Wx/Item.java new file mode 100644 index 0000000..bfa417c --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/Wx/Item.java @@ -0,0 +1,10 @@ +package com.lyt.ViewModel.Wx; + +import lombok.Data; + +@Data +public class Item { + private Integer id; + private String name; + // private Integer limitStartTime; +} diff --git a/src/main/java/com/lyt/ViewModel/fixedPaper.java b/src/main/java/com/lyt/ViewModel/fixedPaper.java new file mode 100644 index 0000000..d5b1a59 --- /dev/null +++ b/src/main/java/com/lyt/ViewModel/fixedPaper.java @@ -0,0 +1,11 @@ +package com.lyt.ViewModel; + +import com.lyt.ViewModel.Wx.Item; +import lombok.Data; + +import java.util.List; + +@Data +public class fixedPaper { + private List items; +} diff --git a/src/main/java/com/lyt/bean/Menu.java b/src/main/java/com/lyt/bean/Menu.java new file mode 100644 index 0000000..455874a --- /dev/null +++ b/src/main/java/com/lyt/bean/Menu.java @@ -0,0 +1,22 @@ +package com.lyt.bean; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * @Author: lyt + * @Date: 2023/04/09/20:03 + * @Description: + */ +@Data +@AllArgsConstructor +public class Menu { + + private long menuId; + private String menuName; + private String deleted; + private long used; + + + +} diff --git a/src/main/java/com/lyt/bean/OnlineExam/ExamPaper.java b/src/main/java/com/lyt/bean/OnlineExam/ExamPaper.java new file mode 100644 index 0000000..18a68c9 --- /dev/null +++ b/src/main/java/com/lyt/bean/OnlineExam/ExamPaper.java @@ -0,0 +1,24 @@ +package com.lyt.bean.OnlineExam; + +import lombok.Data; + +@Data +public class ExamPaper { + + private Integer id; + private String name; + private String paperType; + private String gradeLevel; + private Integer score; + private Integer suggestTime; + private String createUser; + private Boolean deleted; + private Integer isRead; + private String titleItems; + private String subjectId; + private Integer limitDateTime; + private Integer level; + + + +} diff --git a/src/main/java/com/lyt/bean/OnlineExam/Item.java b/src/main/java/com/lyt/bean/OnlineExam/Item.java new file mode 100644 index 0000000..9d7be22 --- /dev/null +++ b/src/main/java/com/lyt/bean/OnlineExam/Item.java @@ -0,0 +1,11 @@ +package com.lyt.bean.OnlineExam; + +import lombok.Data; + +@Data +public class Item { + private String prefix; + private String content; + private String itemUuid; + +} diff --git a/src/main/java/com/lyt/bean/OnlineExam/Question.java b/src/main/java/com/lyt/bean/OnlineExam/Question.java new file mode 100644 index 0000000..788713f --- /dev/null +++ b/src/main/java/com/lyt/bean/OnlineExam/Question.java @@ -0,0 +1,56 @@ +package com.lyt.bean.OnlineExam; + +import lombok.Data; + +@Data +public class Question { + + private Integer id; + /** + * 1.单选题 2.多选题 3.判断题 4.填空题 5.简答题 + */ + private String questionType; + + private String analyze1; + /** + * 学科 + */ + private String subjectId; + + /** + * 题目总分(千分制) + */ + private Integer score; + + /** + * 级别 + */ + private String gradeLevel; + + /** + * 题目难度 + */ + private Integer difficult; + + /** + * 正确答案 + */ + private String correct; + + + /** + * 1.正常 + */ + private String status; + + /** + * 创建时间 + */ + + private String deleted; + private String title; + + private String crateUser; + + +} diff --git a/src/main/java/com/lyt/bean/OnlineExam/RestResponse.java b/src/main/java/com/lyt/bean/OnlineExam/RestResponse.java new file mode 100644 index 0000000..f69df80 --- /dev/null +++ b/src/main/java/com/lyt/bean/OnlineExam/RestResponse.java @@ -0,0 +1,67 @@ +package com.lyt.bean.OnlineExam; + + +import lombok.Data; + +@Data +public class RestResponse{ + private int code; + private String message; + private T response; + /** + * Instantiates a new Rest response. + * + * @param code the code + * @param message the message + */ + public RestResponse(int code, String message) { + this.code = code; + this.message = message; + } + + /** + * Instantiates a new Rest response. + * + * @param code the code + * @param message the message + * @param response the response + */ + public RestResponse(int code, String message, T response) { + this.code = code; + this.message = message; + this.response = response; + } + + /** + * Fail rest response. + * + * @param code the code + * @param msg the msg + * @return the rest response + */ + public static RestResponse fail(Integer code, String msg) { + return new RestResponse<>(code, msg); + } + + /** + * Ok rest response. + * + * @return the rest response + */ + public static RestResponse ok() { + SystemCode systemCode = SystemCode.OK; + return new RestResponse<>(systemCode.getCode(), systemCode.getMessage()); + } + + /** + * Ok rest response. + * + * @param the type parameter + * @param response the response + * @return the rest response + */ + public static RestResponse ok(F response) { + SystemCode systemCode = SystemCode.OK; + return new RestResponse<>(systemCode.getCode(), systemCode.getMessage(), response); + } +} diff --git a/src/main/java/com/lyt/bean/OnlineExam/Score.java b/src/main/java/com/lyt/bean/OnlineExam/Score.java new file mode 100644 index 0000000..b9c0078 --- /dev/null +++ b/src/main/java/com/lyt/bean/OnlineExam/Score.java @@ -0,0 +1,16 @@ +package com.lyt.bean.OnlineExam; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Score { + + private long id; + private long paperId; + private long subjectId; + private long userScore; + private String createUser; + +} diff --git a/src/main/java/com/lyt/bean/OnlineExam/SystemCode.java b/src/main/java/com/lyt/bean/OnlineExam/SystemCode.java new file mode 100644 index 0000000..c9ab0fc --- /dev/null +++ b/src/main/java/com/lyt/bean/OnlineExam/SystemCode.java @@ -0,0 +1,66 @@ +package com.lyt.bean.OnlineExam; + +public enum SystemCode { + /** + * OK + */ + OK(1, "成功"), + /** + * AccessTokenError + */ + AccessTokenError(400, "用户登录令牌失效"), + /** + * UNAUTHORIZED + */ + UNAUTHORIZED(401, "用户未登录"), + /** + * UNAUTHORIZED + */ + AuthError(402, "用户名或密码错误"), + /** + * InnerError + */ + InnerError(500, "系统内部错误"), + /** + * ParameterValidError + */ + ParameterValidError(501, "参数验证错误"), + + /** + * AccessDenied + */ + AccessDenied(502, "用户没有权限访问"); + + /** + * The Code. + */ + int code; + /** + * The Message. + */ + String message; + + SystemCode(int code, String message) { + this.code = code; + this.message = message; + } + + /** + * Gets code. + * + * @return the code + */ + public int getCode() { + return code; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } +} + diff --git a/src/main/java/com/lyt/bean/OnlineExam/TextContent.java b/src/main/java/com/lyt/bean/OnlineExam/TextContent.java new file mode 100644 index 0000000..d8ca4c1 --- /dev/null +++ b/src/main/java/com/lyt/bean/OnlineExam/TextContent.java @@ -0,0 +1,12 @@ +package com.lyt.bean.OnlineExam; + +import lombok.Data; + +@Data +public class TextContent { + private Integer id; + private String content; //把items json存为content就行 + private String shortTitle; + private String questionType; + +} diff --git a/src/main/java/com/lyt/bean/Paper.java b/src/main/java/com/lyt/bean/Paper.java index b13d6cd..9c396ae 100644 --- a/src/main/java/com/lyt/bean/Paper.java +++ b/src/main/java/com/lyt/bean/Paper.java @@ -21,6 +21,7 @@ public class Paper { private Integer userId;//创建者名字 private String time;//创建者名字 + private String titleContent;//大题列表 // private List questions;//试卷中的题目集合 } diff --git a/src/main/java/com/lyt/bean/PaperQuestion.java b/src/main/java/com/lyt/bean/PaperQuestion.java new file mode 100644 index 0000000..f659bca --- /dev/null +++ b/src/main/java/com/lyt/bean/PaperQuestion.java @@ -0,0 +1,24 @@ +package com.lyt.bean; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: zjx + * @Date: 2023/04/09/20:03 + * @Description: + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PaperQuestion { + + private Integer id; + private Integer paperId; + private Integer questionId; + + + + +} diff --git a/src/main/java/com/lyt/bean/Studnet.java b/src/main/java/com/lyt/bean/Studnet.java new file mode 100644 index 0000000..22e1837 --- /dev/null +++ b/src/main/java/com/lyt/bean/Studnet.java @@ -0,0 +1,9 @@ +package com.lyt.bean; + +/** + * @Author: + * @Date: 2023/04/09/20:03 + * @Description: + */ +public class Studnet { +} diff --git a/src/main/java/com/lyt/bean/TitleContent.java b/src/main/java/com/lyt/bean/TitleContent.java new file mode 100644 index 0000000..88b852e --- /dev/null +++ b/src/main/java/com/lyt/bean/TitleContent.java @@ -0,0 +1,18 @@ +package com.lyt.bean; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: lyt + * @Date: 2023/05/03/13:30 + * @Description: + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TitleContent { + private String titleName; + private int sort; +} diff --git a/src/main/java/com/lyt/dao/PaperDao.java b/src/main/java/com/lyt/dao/PaperDao.java index b971046..5709117 100644 --- a/src/main/java/com/lyt/dao/PaperDao.java +++ b/src/main/java/com/lyt/dao/PaperDao.java @@ -22,8 +22,8 @@ public interface PaperDao { public int deletePaper(Integer paperId);//根据试卷编号删除试卷 @Insert("insert into paper (paper_id,paper_name,score,course_id,one,two,three,"+ - "status,grade) values(#{paperId},#{paperName},#{score},#{courseId},#{one},#{two}" + - ",#{three},#{status},#{grade})") + "status,grade,title_content) values(#{paperId},#{paperName},#{score},#{courseId},#{one},#{two}" + + ",#{three},#{status},#{grade},#{titleContent})") public int addPaper(Paper paper);//创建试卷 @Insert("insert into paper_question values(#{id},#{paperId},#{questionId})") diff --git a/src/main/java/com/lyt/service/PaperService.java b/src/main/java/com/lyt/service/PaperService.java index 4836ee7..833f32b 100644 --- a/src/main/java/com/lyt/service/PaperService.java +++ b/src/main/java/com/lyt/service/PaperService.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.lyt.bean.Paper; import com.lyt.bean.PaperQuestion; import com.lyt.bean.Question; +import com.lyt.bean.TitleContent; import com.lyt.dao.PaperDao; import com.lyt.dao.QuestionDao; import com.lyt.util.BeanUtil; @@ -28,6 +29,7 @@ public class PaperService { public PaperVo getPaperById(Integer id){ //id是用户的id Paper paper = paperDao.selectPaperByPaperId(id); + System.out.println("打印一下查询到的paper "+ paper); PaperVo paperVo = new PaperVo(); //转换为paperVo BeanUtil.beanConvert(paper,paperVo); @@ -57,11 +59,12 @@ public class PaperService { //创建一个 大题list List questionsVos = new ArrayList(); - //先去查有多少个大题 现在假设有3个大题 - - for (int i = 0; i <3 ; i++) { + //先去查有多少个大题 + List titleContents = (List )JSON.parseObject(paper.getTitleContent()); +// 设置大题title + for (TitleContent titleContent : titleContents) { QuestionsVo questionsVo = new QuestionsVo(); - questionsVo.setName("暂时的第"+i+"大题:"); + questionsVo.setQuestionName(titleContent.getTitleName()); questionsVos.add(questionsVo); } System.out.println("输出一下暂时创建的 大题List :"+questionsVos); @@ -103,8 +106,25 @@ public class PaperService { //先写paper表 // TODO: 2023/5/2 还有很多逻辑需要处理 例如 one two three - paper.setPaperId(5); //这个是自增的 + paper.setPaperId(6); //这个是自增的 + System.out.println("转换后的paper "+paper); + //处理 titleContent + List titleContents = new ArrayList<>(); + + //遍历所有的大题获取 name + List titleItems = paperVo.getTitleItems(); + for (int i = 0; i < titleItems.size(); i++) { + QuestionsVo titleItem = titleItems.get(i); + TitleContent titleContent = new TitleContent(); + titleContent.setTitleName(titleItem.getQuestionName()); + + titleContent.setSort(i); + + titleContents.add(titleContent); + } + String titleContentJson = JSON.toJSONString(titleContents); + paper.setTitleContent(titleContentJson); paperDao.addPaper(paper); //再写试卷 -- 题目关系表 diff --git a/src/main/java/com/lyt/util/BeanUtil.java b/src/main/java/com/lyt/util/BeanUtil.java new file mode 100644 index 0000000..863b1ce --- /dev/null +++ b/src/main/java/com/lyt/util/BeanUtil.java @@ -0,0 +1,62 @@ +package com.lyt.util; + +import com.lyt.ViewModel.Wx.Item; +import com.lyt.vo.ItemVo; +import org.junit.Test; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +/** + * @Author: lyt + * @Date: 2023/04/29/20:14 + * @Description: + */ +public class BeanUtil { +// 根据属性名称进行转换 + public static T beanConvert(Object provide,T Target){ + Class voClass=provide.getClass(); + Class pojoClass=Target.getClass(); + + for (Field field : pojoClass.getDeclaredFields()) { + for (Field declaredField : voClass.getDeclaredFields()) { + //如果对象名匹配成功的话 就赋值 +// System.out.println("对象转换中"); + declaredField.setAccessible(true); + field.setAccessible(true); + +// System.out.println("目标对象的字段名称"+field); + if(declaredField.getName().equals(field.getName())){ + try { + if(declaredField.get(provide)!=null){ + field.set(Target,declaredField.get(provide)); + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + } + + return Target; + } + + @Test + public void testUtils(){ + Item item=new Item(); + List list=new ArrayList(); + list.add(1); + list.add(2); + list.add(3); + list.add(4); + ItemVo itemVo=new ItemVo("11","22"); + try { + System.out.println("转换前的结果 :"+item); +//beanConvert() System.out.println("转换后的结果 :"+item); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/lyt/vo/ItemVo.java b/src/main/java/com/lyt/vo/ItemVo.java new file mode 100644 index 0000000..cdf4e05 --- /dev/null +++ b/src/main/java/com/lyt/vo/ItemVo.java @@ -0,0 +1,25 @@ +package com.lyt.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author: lyt + * @Date: 2023/04/21/14:41 + * @Description: + * 创建的题目 从数据库里选出 题目的json串 + * json 答案 选项的值比对 目标 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ItemVo { +// private String title; +// +// private String option; // A,B,C,D,E +// +// private String value; // 选项的值 + private String prefix; + private String content; +} diff --git a/src/main/java/com/lyt/vo/PaperVo.java b/src/main/java/com/lyt/vo/PaperVo.java new file mode 100644 index 0000000..9386955 --- /dev/null +++ b/src/main/java/com/lyt/vo/PaperVo.java @@ -0,0 +1,37 @@ +package com.lyt.vo; + +import com.lyt.bean.OnlineExam.Question; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author: lyt + * @Date: 2023/04/11/21:56 + * @Description: + * + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PaperVo { + + private Integer paperId;//试卷编号 + private int paperType; //试卷类型 ab卷? + private Integer grade;//试卷年级 + private Integer courseId;//课程编号 + + private String paperName;//试卷名字 + private String suggestTime; + private Integer status;//试卷状态 + private String score;//试卷总分分数 + private List titleItems; //大题 +// private String limitTime; +// +// private String startTime; +// +// private String endTime; + +} diff --git a/src/main/java/com/lyt/vo/QuestionVo.java b/src/main/java/com/lyt/vo/QuestionVo.java new file mode 100644 index 0000000..312c9fb --- /dev/null +++ b/src/main/java/com/lyt/vo/QuestionVo.java @@ -0,0 +1,33 @@ +package com.lyt.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author: lyt + * @Date: 2023/04/21/14:40 + * @Description: + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class QuestionVo { + private int questionId; //试题编号 + private int gradeLevel; //班级 + private String courseId; //subjectId; + private String questionName; // (title)标题:例如第一题。。。 + private Integer type; //试卷类型,0单选题,1多选题,2判断题,3问答题 + private String detail; //详细解答 + private String answer; //答案 + private Integer score; //总分 + private String difficult; //难度 + private Integer userId;//用户编号 + private String time;//创建时间 + List items; //选择题选项 后面会转换成json + + + +} diff --git a/src/main/java/com/lyt/vo/QuestionsVo.java b/src/main/java/com/lyt/vo/QuestionsVo.java new file mode 100644 index 0000000..6ba93e5 --- /dev/null +++ b/src/main/java/com/lyt/vo/QuestionsVo.java @@ -0,0 +1,20 @@ +package com.lyt.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author: lyt + * @Date: 2023/04/29/19:15 + * @Description: + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class QuestionsVo { + private String questionName; + private List questionItems; +} -- Gitee From 212e346170cc1f26891c4e14353b3b4e06ab1c80 Mon Sep 17 00:00:00 2001 From: coding_liang Date: Wed, 3 May 2023 15:42:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86paper=E8=87=AA?= =?UTF-8?q?=E5=A2=9Eid=20=E7=94=B1=E6=89=8B=E5=8A=A8=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=8F=98=E4=B8=BA=E8=87=AA=E5=8A=A8=E8=AE=BE=E7=BD=AE=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=A4=A7=E9=A2=98=E7=9A=84titleCont?= =?UTF-8?q?ent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/lyt/dao/PaperDao.java | 5 ++++ .../java/com/lyt/service/PaperService.java | 24 +++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/lyt/dao/PaperDao.java b/src/main/java/com/lyt/dao/PaperDao.java index 5709117..7cb71b0 100644 --- a/src/main/java/com/lyt/dao/PaperDao.java +++ b/src/main/java/com/lyt/dao/PaperDao.java @@ -9,6 +9,11 @@ import org.springframework.stereotype.Repository; import java.util.List; @Repository public interface PaperDao { + + //获取paper最大id + @Select("select paper_id from paper ORDER BY paper_id desc limit 1") + public int getPaperMaxId();//根据 + @Select("select * from paper where paper_id = #{paperId}") public Paper selectPaperByUserId(Integer paperId);//根据试卷编号查询试卷 diff --git a/src/main/java/com/lyt/service/PaperService.java b/src/main/java/com/lyt/service/PaperService.java index 833f32b..81d8ff1 100644 --- a/src/main/java/com/lyt/service/PaperService.java +++ b/src/main/java/com/lyt/service/PaperService.java @@ -1,6 +1,7 @@ package com.lyt.service; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.lyt.bean.Paper; import com.lyt.bean.PaperQuestion; import com.lyt.bean.Question; @@ -58,16 +59,24 @@ public class PaperService { //创建一个 大题list List questionsVos = new ArrayList(); - + System.out.println("查到的 content"+ paper.getTitleContent()); //先去查有多少个大题 - List titleContents = (List )JSON.parseObject(paper.getTitleContent()); -// 设置大题title + List titleContents = (List)JSON.parseArray(paper.getTitleContent(),TitleContent.class); +// 输出一下转换后的 titleContent + +// JSONObject msgEncap = JSON.parseObject(paper.getTitleContent()); +// List titleContents = JSON.parseArray(msgEncap.getString("msgList"), Record.class); +// + + System.out.println("json转换后的titleContent的长度"+titleContents.size()); + // 设置大题title for (TitleContent titleContent : titleContents) { + System.out.println("遍历输出 titleName"+titleContent.getTitleName()); QuestionsVo questionsVo = new QuestionsVo(); questionsVo.setQuestionName(titleContent.getTitleName()); questionsVos.add(questionsVo); } - System.out.println("输出一下暂时创建的 大题List :"+questionsVos); + for (QuestionsVo questionsVo : questionsVos) { //把小题塞进大题里面 @@ -106,7 +115,10 @@ public class PaperService { //先写paper表 // TODO: 2023/5/2 还有很多逻辑需要处理 例如 one two three - paper.setPaperId(6); //这个是自增的 + + //因为id是自增的 取数据库中最大id然后+1即可 ,但是这样处理存在并发风险 + int newId = paperDao.getPaperMaxId()+1; + paper.setPaperId(newId); //这个是自增的 System.out.println("转换后的paper "+paper); //处理 titleContent @@ -118,9 +130,7 @@ public class PaperService { QuestionsVo titleItem = titleItems.get(i); TitleContent titleContent = new TitleContent(); titleContent.setTitleName(titleItem.getQuestionName()); - titleContent.setSort(i); - titleContents.add(titleContent); } String titleContentJson = JSON.toJSONString(titleContents); -- Gitee