From 2e802ea2039f531728390c2a55b265bfdf99bb12 Mon Sep 17 00:00:00 2001 From: p5yt4qn87 <2058152148@qq.com> Date: Sat, 14 Dec 2024 19:41:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86entity=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E6=B3=A8=E9=87=8A=20(#10)=20Co-auth?= =?UTF-8?q?ored-by:=20p5yt4qn87=20<2058152148@qq.com>=20Co-committed-by:?= =?UTF-8?q?=20p5yt4qn87=20<2058152148@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/lsgwr/exam/entity/Action.java | 20 ++++++++--- .../main/java/lsgwr/exam/entity/Question.java | 35 ++++++++++++++++++- .../lsgwr/exam/entity/QuestionCategory.java | 16 ++++++--- .../java/lsgwr/exam/entity/QuestionLevel.java | 14 ++++++-- .../lsgwr/exam/entity/QuestionOption.java | 13 ++++++- .../java/lsgwr/exam/entity/QuestionType.java | 15 ++++++-- .../src/main/java/lsgwr/exam/entity/Role.java | 17 +++++++++ .../src/main/java/lsgwr/exam/entity/User.java | 31 +++++++++++++++- 8 files changed, 146 insertions(+), 15 deletions(-) diff --git a/backend/src/main/java/lsgwr/exam/entity/Action.java b/backend/src/main/java/lsgwr/exam/entity/Action.java index 2c9d1df..8fb8180 100644 --- a/backend/src/main/java/lsgwr/exam/entity/Action.java +++ b/backend/src/main/java/lsgwr/exam/entity/Action.java @@ -11,17 +11,29 @@ import lombok.Data; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; - +/** + * 动作实体类 + * 它记录了操作的相关信息,包括操作ID、操作名称、操作描述以及是否默认选中 + */ @Data @Entity public class Action { + /** + * 动作ID + */ @Id @GeneratedValue private Integer actionId; - + /** + * 动作名称 + */ private String actionName; - + /** + * 动作描述 + */ private String actionDescription; - + /** + * 是否默认选中 + */ private Boolean defaultCheck; } diff --git a/backend/src/main/java/lsgwr/exam/entity/Question.java b/backend/src/main/java/lsgwr/exam/entity/Question.java index 67adf0b..d2c050a 100644 --- a/backend/src/main/java/lsgwr/exam/entity/Question.java +++ b/backend/src/main/java/lsgwr/exam/entity/Question.java @@ -14,21 +14,54 @@ import org.hibernate.annotations.DynamicUpdate; import javax.persistence.Entity; import javax.persistence.Id; import java.util.Date; - +/** + * 题目实体类,用于存储题目信息 + * 利用注解生成getter/setter方法 + */ @Data @Entity @DynamicUpdate public class Question { + /** + * 题目id + */ @Id private String questionId; + /** + * 题目名称 + */ private String questionName; + /** + * 题目分数 + */ private Integer questionScore; + /** + * 题目创建人id + */ private String questionCreatorId; + /** + * 题目难度id + */ private Integer questionLevelId; + /** + * 题目类型id + */ private Integer questionTypeId; + /** + * 题目分类id + */ private Integer questionCategoryId; + /** + * 题目描述 + */ private String questionDescription; + /** + * 题目选项id,用逗号隔开,例如:A,B,C,D + */ private String questionOptionIds; + /** + * 题目正确答案选项id,用逗号隔开,例如:A + */ private String questionAnswerOptionIds; /** * 创建时间, 设计表时设置了自动插入当前时间,无需在Java代码中设置了 diff --git a/backend/src/main/java/lsgwr/exam/entity/QuestionCategory.java b/backend/src/main/java/lsgwr/exam/entity/QuestionCategory.java index ca08f22..a68dfdd 100644 --- a/backend/src/main/java/lsgwr/exam/entity/QuestionCategory.java +++ b/backend/src/main/java/lsgwr/exam/entity/QuestionCategory.java @@ -13,19 +13,27 @@ import lombok.Data; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; - +/** + * 题目的类别表,从内容角度划分,比如数学、语文、英语等 + */ @Data @Entity public class QuestionCategory { - + /** + * 题目类别的id + */ @Id @GeneratedValue @JsonProperty("id") private Integer questionCategoryId; - + /** + * 题目类别的名称 + */ @JsonProperty("name") private String questionCategoryName; - + /** + * 题目类别的描述 + */ @JsonProperty("description") private String questionCategoryDescription; } diff --git a/backend/src/main/java/lsgwr/exam/entity/QuestionLevel.java b/backend/src/main/java/lsgwr/exam/entity/QuestionLevel.java index a056cbc..d0c0fcd 100644 --- a/backend/src/main/java/lsgwr/exam/entity/QuestionLevel.java +++ b/backend/src/main/java/lsgwr/exam/entity/QuestionLevel.java @@ -14,17 +14,27 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +/** + * 题目难度等级实体类,用于表示题目的难度级别信息,如难、中、易等。 + */ @Entity @Data public class QuestionLevel { + /** + * 题目难度等级ID,自增 + */ @Id @GeneratedValue @JsonProperty("id") private Integer questionLevelId; - + /** + * 题目难度等级名称,如难、中、易等 + */ @JsonProperty("name") private String questionLevelName; - + /** + * 题目难度等级描述 + */ @JsonProperty("description") private String questionLevelDescription; } diff --git a/backend/src/main/java/lsgwr/exam/entity/QuestionOption.java b/backend/src/main/java/lsgwr/exam/entity/QuestionOption.java index 3c06ef7..fc29400 100644 --- a/backend/src/main/java/lsgwr/exam/entity/QuestionOption.java +++ b/backend/src/main/java/lsgwr/exam/entity/QuestionOption.java @@ -11,12 +11,23 @@ import lombok.Data; import javax.persistence.Entity; import javax.persistence.Id; - +/** + * 问题选项实体类 + */ @Data @Entity public class QuestionOption { + /** + * 选项的编号,如A、B、C、D + */ @Id private String questionOptionId; + /** + * 选项的内容 + */ private String questionOptionContent; + /** + * 选项的描述,提供关于选项的额外解释或说明 + */ private String questionOptionDescription; } diff --git a/backend/src/main/java/lsgwr/exam/entity/QuestionType.java b/backend/src/main/java/lsgwr/exam/entity/QuestionType.java index 46a4f55..602a7b1 100644 --- a/backend/src/main/java/lsgwr/exam/entity/QuestionType.java +++ b/backend/src/main/java/lsgwr/exam/entity/QuestionType.java @@ -14,17 +14,28 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +/** + * QuestionType类代表了一个实体,用于在数据库中存储问题类型的信息。 + * 它包括问题类型的ID、名称和描述。 + */ @Data @Entity public class QuestionType { + /** + * 问题类型ID + */ @Id @GeneratedValue @JsonProperty("id") private Integer questionTypeId; - + /** + * 问题类型名称 + */ @JsonProperty("name") private String questionTypeName; - + /** + * 问题类型的描述 + */ @JsonProperty("description") private String questionTypeDescription; } diff --git a/backend/src/main/java/lsgwr/exam/entity/Role.java b/backend/src/main/java/lsgwr/exam/entity/Role.java index 31d529a..dbb7b8d 100644 --- a/backend/src/main/java/lsgwr/exam/entity/Role.java +++ b/backend/src/main/java/lsgwr/exam/entity/Role.java @@ -13,14 +13,31 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +/** + * 角色实体类 + * 用于表示系统中的角色信息,包括角色的ID、名称、描述和详细信息等 + */ @Data @Entity public class Role { + /** + * 角色ID + * @Id标识为主键 + */ @Id @GeneratedValue private Integer roleId; + /** + * 角色名称 + */ private String roleName; + /** + * 角色描述 + */ private String roleDescription; + /** + * 角色详细信息 + */ private String roleDetail; /** * 角色所能访问的页面的主键集合(用-连接起来字符串) diff --git a/backend/src/main/java/lsgwr/exam/entity/User.java b/backend/src/main/java/lsgwr/exam/entity/User.java index 23875bc..417ce93 100644 --- a/backend/src/main/java/lsgwr/exam/entity/User.java +++ b/backend/src/main/java/lsgwr/exam/entity/User.java @@ -14,20 +14,49 @@ import org.hibernate.annotations.DynamicUpdate; import javax.persistence.Entity; import javax.persistence.Id; import java.util.Date; - +/** + * 用户表,记录用户信息 + */ @Data @Entity @DynamicUpdate public class User { + /** + * 用户id,主键 + */ @Id private String userId; + /** + * 用户名,唯一 + */ private String userUsername; + /** + * 昵称 + */ private String userNickname; + /** + * 密码 + */ private String userPassword; + /** + * 角色id + */ private Integer userRoleId; + /** + * 头像 + */ private String userAvatar; + /** + * 描述 + */ private String userDescription; + /** + * 邮箱 + */ private String userEmail; + /** + * 电话 + */ private String userPhone; /** * 创建时间, 设计表时设置了自动插入当前时间,无需在Java代码中设置了 From db8aaf463e7b18ed242e4695e60d73cf1a5abc4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=95=E8=BE=89?= <2754728380@qq.com> Date: Sun, 15 Dec 2024 16:14:05 +0800 Subject: [PATCH 2/2] Update docs(fronted/res/api/) --- frontend/src/api/exam.js | 80 ++++++++++++++++++++++++++++++++++- frontend/src/api/index.js | 89 ++++++++++++++++++++++++++++++++++++--- frontend/src/api/login.js | 30 +++++++++---- frontend/src/api/user.js | 10 +++++ 4 files changed, 194 insertions(+), 15 deletions(-) diff --git a/frontend/src/api/exam.js b/frontend/src/api/exam.js index c6d98b5..1344922 100644 --- a/frontend/src/api/exam.js +++ b/frontend/src/api/exam.js @@ -1,8 +1,15 @@ -// 考试相关的接口,包括考试、问题、选项和评分等接口 +/** + * @description: 考试模块接口,包括考试、问题、选项和评分等接口 + */ import api from './index' import { axios } from '../utils/request' +/** + * @description: 根据传入的参数获取问题列表 + * @param {Object} parameter - 查询参数 + * @returns {Promise} - 返回问题列表的Promise对象 + */ export function getQuestionList (parameter) { return axios({ url: api.ExamQuestionList, @@ -11,6 +18,10 @@ export function getQuestionList (parameter) { }) } +/** + * @description: 获取所有问题 + * @returns {Promise} - 返回所有问题的Promise对象 + */ export function getQuestionAll () { return axios({ url: api.ExamQuestionAll, @@ -18,6 +29,11 @@ export function getQuestionAll () { }) } +/** + * @description: 更新问题信息 + * @param {Object} parameter - 问题更新参数 + * @returns {Promise} - 返回更新操作的Promise对象 + */ export function questionUpdate (parameter) { console.log(parameter) return axios({ @@ -27,6 +43,10 @@ export function questionUpdate (parameter) { }) } +/** + * @description: 获取问题的选项 + * @returns {Promise} - 返回问题选项的Promise对象 + */ export function getQuestionSelection () { return axios({ url: api.ExamQuestionSelection, @@ -37,6 +57,11 @@ export function getQuestionSelection () { }) } +/** + * @description: 创建新问题 + * @param {Object} parameter - 问题创建参数 + * @returns {Promise} - 返回创建操作的Promise对象 + */ export function questionCreate (parameter) { console.log(parameter) return axios({ @@ -46,6 +71,11 @@ export function questionCreate (parameter) { }) } +/** + * @description: 根据传入的参数获取考试列表 + * @param {Object} parameter - 查询参数 + * @returns {Promise} - 返回考试列表的Promise对象 + */ export function getExamList (parameter) { return axios({ url: api.ExamList, @@ -54,6 +84,10 @@ export function getExamList (parameter) { }) } +/** + * @description: 获取所有考试 + * @returns {Promise} - 返回所有考试的Promise对象 + */ export function getExamAll () { return axios({ url: api.ExamAll, @@ -61,7 +95,10 @@ export function getExamAll () { }) } -// 获取所有问题,按照单选、多选和判断进行分类 +/** + * @description: 获取所有问题,并按单选、多选和判断进行分类 + * @returns {Promise} - 返回分类问题列表的Promise对象 + */ export function getExamQuestionTypeList () { return axios({ url: api.ExamQuestionTypeList, @@ -72,6 +109,10 @@ export function getExamQuestionTypeList () { }) } +/** + * @description: 获取考试卡片列表 + * @returns {Promise} - 返回考试卡片列表的Promise对象 + */ export function getExamCardList () { return axios({ url: api.ExamCardList, @@ -82,6 +123,11 @@ export function getExamCardList () { }) } +/** + * @description: 创建新考试 + * @param {Object} parameter - 考试创建参数 + * @returns {Promise} - 返回创建操作的Promise对象 + */ export function examCreate (parameter) { console.log(parameter) return axios({ @@ -91,6 +137,11 @@ export function examCreate (parameter) { }) } +/** + * @description: 更新考试信息 + * @param {Object} parameter - 考试更新参数 + * @returns {Promise} - 返回更新操作的Promise对象 + */ export function examUpdate (parameter) { console.log(parameter) return axios({ @@ -100,6 +151,11 @@ export function examUpdate (parameter) { }) } +/** + * @description: 根据考试ID获取考试详情 + * @param {String} examId - 考试ID + * @returns {Promise} - 返回考试详情的Promise对象 + */ export function getExamDetail (examId) { return axios({ url: api.ExamDetail + examId, @@ -110,6 +166,11 @@ export function getExamDetail (examId) { }) } +/** + * @description: 根据记录ID获取考试记录详情 + * @param {String} recordId - 记录ID + * @returns {Promise} - 返回考试记录详情的Promise对象 + */ export function getExamRecordDetail (recordId) { return axios({ url: api.recordDetail + recordId, @@ -120,6 +181,11 @@ export function getExamRecordDetail (recordId) { }) } +/** + * @description: 根据问题ID获取问题详情 + * @param {String} questionId - 问题ID + * @returns {Promise} - 返回问题详情的Promise对象 + */ export function getQuestionDetail (questionId) { return axios({ url: api.QuestionDetail + questionId, @@ -130,6 +196,12 @@ export function getQuestionDetail (questionId) { }) } +/** + * @description: 提交考试答案,完成考试 + * @param {String} examId - 考试ID + * @param {Object} answersMap - 答案映射 + * @returns {Promise} - 返回完成考试的Promise对象 + */ export function finishExam (examId, answersMap) { console.log(answersMap) return axios({ @@ -142,6 +214,10 @@ export function finishExam (examId, answersMap) { }) } +/** + * @description: 获取所有考试记录 + * @returns {Promise} - 返回所有考试记录的Promise对象 + */ export function getExamRecordList () { return axios({ url: api.ExamRecordList, diff --git a/frontend/src/api/index.js b/frontend/src/api/index.js index 05423bf..6867621 100644 --- a/frontend/src/api/index.js +++ b/frontend/src/api/index.js @@ -1,38 +1,117 @@ +/** + * @description: api接口统一管理 + */ const api = { + /** + * @description: 用户登录的接口 + */ Login: '/auth/login', + /** + * @description: 用户注销的接口 + */ Logout: '/auth/logout', + /** + * @description: 重置密码的接口 + */ ForgePassword: '/auth/forge-password', + /** + * @description: 用户注册的接口 + */ Register: '/auth/register', + /** + * @description: 两步验证码的接口 + */ twoStepCode: '/auth/2step-code', + /** + * @description: 发送短信的接口 + */ SendSms: '/account/sms', + /** + * @description: 发送短信错误的接口 + */ SendSmsErr: '/account/sms_err', - // get my info + /** + * @description: 获取用户信息的接口 + */ UserInfo: '/user/info', // 下面是自己的用户认证的接口 + /** + * @description: 用户注册(自定义)的接口 + */ UserRegister: '/user/register', + /** + * @description: 用户登录(自定义)的接口 + */ UserLogin: '/user/login', // 考试的接口 + /** + * @description: 获取考试问题列表的接口 + */ ExamQuestionList: '/exam/question/list', + /** + * @description: 获取所有考试问题的接口 + */ ExamQuestionAll: '/exam/question/all', + /** + * @description: 更新考试问题的接口 + */ ExamQuestionUpdate: '/exam/question/update', + /** + * @description: 选择考试问题的接口 + */ ExamQuestionSelection: '/exam/question/selection', + /** + * @description: 创建考试问题的接口 + */ ExamQuestionCreate: '/exam/question/create', + /** + * @description: 获取考试列表的接口 + */ ExamList: '/exam/list', + /** + * @description: 获取所有考试的接口 + */ ExamAll: '/exam/all', - // 获取问题列表,按照单选、多选和判断进行分类 + /** + * @description: 按照单选、多选和判断分类获取问题列表的接口 + */ ExamQuestionTypeList: '/exam/question/type/list', + /** + * @description: 创建考试的接口 + */ ExamCreate: '/exam/create', + /** + * @description: 更新考试的接口 + */ ExamUpdate: '/exam/update', + /** + * @description: 获取考试卡片列表的接口 + */ ExamCardList: '/exam/card/list', - // 获取考试详情 + /** + * @description: 获取考试详情的接口 + */ ExamDetail: '/exam/detail/', - // 获取考试详情 + /** + * @description: 获取问题详情的接口 + */ QuestionDetail: '/exam/question/detail/', - // 交卷 + /** + * @description: 交卷的接口 + */ FinishExam: '/exam/finish/', + /** + * @description: 获取考试记录列表的接口 + */ ExamRecordList: '/exam/record/list', + /** + * @description: 获取考试记录详情的接口 + */ recordDetail: '/exam/record/detail/' } +/** + * @description: 默认导出api对象 + */ export default api diff --git a/frontend/src/api/login.js b/frontend/src/api/login.js index 9f71d6b..6ab7817 100644 --- a/frontend/src/api/login.js +++ b/frontend/src/api/login.js @@ -2,12 +2,12 @@ import api from './index' import { axios } from '../utils/request' /** - * login func - * parameter: { - * username: '', - * password: '', - * remember_me: true, - * captcha: '12345' + * 用户登录功能 + * 参数: { + * username: 用户名 + * password: 密码 + * remember_me: 是否记住 + * captcha: 验证码 * } * @param parameter * @returns {*} @@ -21,6 +21,11 @@ export function login (parameter) { }) } +/** + * 获取短信验证码 + * @param parameter + * @returns {*} + */ export function getSmsCaptcha (parameter) { return axios({ url: api.SendSms, @@ -29,6 +34,10 @@ export function getSmsCaptcha (parameter) { }) } +/** + * 获取用户信息 + * @returns {*} + */ export function getInfo () { return axios({ url: api.UserInfo, @@ -39,6 +48,10 @@ export function getInfo () { }) } +/** + * 用户登出 + * @returns {*} + */ export function logout () { return axios({ url: api.Logout, @@ -50,8 +63,9 @@ export function logout () { } /** - * get user 2step code open? - * @param parameter {*} + * 获取用户两步验证码开启状态 + * @param parameter + * @returns {*} */ export function get2step (parameter) { return axios({ diff --git a/frontend/src/api/user.js b/frontend/src/api/user.js index 71e361b..162ca03 100644 --- a/frontend/src/api/user.js +++ b/frontend/src/api/user.js @@ -3,6 +3,11 @@ import api from './index' import { axios } from '../utils/request' +/** + * 用户登录 + * @param {Object} parameter - 登录参数 + * @returns {Promise} - 返回登录请求的Promise + */ export function login (parameter) { return axios({ url: api.UserLogin, @@ -11,6 +16,11 @@ export function login (parameter) { }) } +/** + * 用户注册 + * @param {Object} parameter - 注册参数 + * @returns {Promise} - 返回注册请求的Promise + */ export function register (parameter) { return axios({ url: api.UserRegister,