diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..208e2c3 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..bd4a3c4 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/remotebelongstous.iml b/.idea/remotebelongstous.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/remotebelongstous.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/online-exam-backend/.gitignore b/online-exam-backend/.gitignore new file mode 100644 index 0000000..24062a7 --- /dev/null +++ b/online-exam-backend/.gitignore @@ -0,0 +1,37 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target +/.mvn/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +*.log +*.jar + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + + +### VS Code ### +.vscode/ diff --git a/online-exam-backend/pom.xml b/online-exam-backend/pom.xml new file mode 100644 index 0000000..0b03e77 --- /dev/null +++ b/online-exam-backend/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.1.2.RELEASE + + + + com.shanzhu + OnlineExam-backend + 0.0.1-SNAPSHOT + OnlineExam-backend + 在线考试系统 + + + 1.8 + + + + + + + com.baomidou + mybatis-plus-boot-starter + 3.5.0 + + + + + org.springframework.boot + spring-boot-starter-jdbc + + + + + org.springframework.boot + spring-boot-starter-web + + + + + mysql + mysql-connector-java + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + com.alibaba + druid + 1.1.8 + + + + + org.springframework.boot + spring-boot-devtools + true + + + org.springframework + spring-tx + 4.3.9.RELEASE + + + + + org.projectlombok + lombok + 1.18.10 + provided + + + + diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/BackendApplication.java b/online-exam-backend/src/main/java/com/shanzhu/oe/BackendApplication.java new file mode 100644 index 0000000..7b40f0e --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/BackendApplication.java @@ -0,0 +1,27 @@ +package com.shanzhu.oe; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * SpringBoot 启动类 + * 项目启动入口(点击右键 选择 "BackendApplication" 启动项目) + * + * 什么是SpringBoot?(https://www.php.cn/faq/498384.html) + * + * @author: ShanZhu + * @date: 2023-11-10 + */ +@Slf4j +@SpringBootApplication +public class BackendApplication { + + public static void main(String[] args) { + //SpringBoot 执行启动 + SpringApplication.run(BackendApplication.class, args); + + log.info("=====================项目后端启动成功============================"); + } + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/common/R.java b/online-exam-backend/src/main/java/com/shanzhu/oe/common/R.java new file mode 100644 index 0000000..31107ea --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/common/R.java @@ -0,0 +1,33 @@ +package com.shanzhu.oe.common; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 接口返回对象包装类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class R { + + /** + * 错误码 + */ + private int code; + + /** + * 错误消息 + */ + private String message; + + /** + * 结果数据 + */ + private T data; + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/config/LoginInterceptor.java b/online-exam-backend/src/main/java/com/shanzhu/oe/config/LoginInterceptor.java new file mode 100644 index 0000000..7087c62 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/config/LoginInterceptor.java @@ -0,0 +1,32 @@ +package com.shanzhu.oe.config; + +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 登录检查 + * 1.配置到拦截器要拦截哪些请求 + * 2.把这些配置放在容器中 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public class LoginInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + if (request.getCookies() == null) { + return false; + } + for (Cookie cookie : request.getCookies()) { + if ("rb_token".equals(cookie.getName()) && cookie.getValue() != null && !cookie.getValue().equals("")) { + return true; + } + } + return false; + } + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/config/MvcConfig.java b/online-exam-backend/src/main/java/com/shanzhu/oe/config/MvcConfig.java new file mode 100644 index 0000000..b509f6e --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/config/MvcConfig.java @@ -0,0 +1,56 @@ +package com.shanzhu.oe.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * SpringMvc 配置 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + /** + * 配置拦截器 + * + * @param registry 相当于拦截器的注册中心 + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new LoginInterceptor()) + .addPathPatterns() + .excludePathPatterns("/login"); + } + + + /** + * 跨域配置 + * + * @return 跨域 + */ + @Bean + public CorsFilter corsFilter() { + // 1.创建 CORS 配置对象 + CorsConfiguration config = new CorsConfiguration(); + // 支持域 + config.addAllowedOrigin("*"); + // 是否发送 Cookie + config.setAllowCredentials(true); + // 支持请求方式 + config.addAllowedMethod("*"); + // 允许的原始请求头部信息 + config.addAllowedHeader("*"); + // 2.添加地址映射 + UrlBasedCorsConfigurationSource corsConfigurationSource = new UrlBasedCorsConfigurationSource(); + corsConfigurationSource.registerCorsConfiguration("/**", config); + // 3.返回 CorsFilter 对象 + return new CorsFilter(corsConfigurationSource); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/config/MybatisPlusConfig.java b/online-exam-backend/src/main/java/com/shanzhu/oe/config/MybatisPlusConfig.java new file mode 100644 index 0000000..c7b7c81 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/config/MybatisPlusConfig.java @@ -0,0 +1,30 @@ +package com.shanzhu.oe.config; + +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Mybatis - plus 配置 + * + * 什么是MybatisPlus? (https://blog.csdn.net/qq_52922453/article/details/127196313) + * + * @author: ShanZhu + * @date: 2023-11-10 + */ +@Configuration +public class MybatisPlusConfig { + + /** + * 分页插件配置 + * + * @return MybatisPlusInterceptor + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + return interceptor; + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/AdminController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/AdminController.java new file mode 100644 index 0000000..74d858f --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/AdminController.java @@ -0,0 +1,92 @@ +package com.shanzhu.oe.controller; + +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.Admin; +import com.shanzhu.oe.service.AdminService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 管理员 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class AdminController { + + private final AdminService adminService; + + /** + * 查询所有管理员 + * + * @return 管理员列表 + */ + @GetMapping("/admins") + public R> findAll(){ + return ApiResultHandler.success(adminService.findAll()); + } + + /** + * 通过管理员id查询 + * + * @param adminId 管理员id + * @return 管理员 + */ + @GetMapping("/admin/{adminId}") + public R findById(@PathVariable("adminId") Integer adminId){ + return ApiResultHandler.success(adminService.findById(adminId)); + } + + /** + * 通过管理员id删除 + * + * @param adminId 管理员id + * @return 结果 + */ + @DeleteMapping("/admin/{adminId}") + public R deleteById(@PathVariable("adminId") Integer adminId){ + adminService.deleteById(adminId); + return ApiResultHandler.success(); + } + + /** + * 更新管理员 + * + * @param adminId 管理员id + * @param admin 管理员信息 + * @return 结果 + */ + @PutMapping("/admin/{adminId}") + public R update(@PathVariable("adminId") Integer adminId, Admin admin){ + return ApiResultHandler.success(adminService.update(admin)); + } + + /** + * 添加管理员 + * + * @param admin 管理员信息 + * @return 结果 + */ + @PostMapping("/admin") + public R add(Admin admin){ + return ApiResultHandler.success(adminService.add(admin)); + } + + /** + * 更新密码 + * + * @param adminId 管理员id + * @param newPsw 新密码 + * @param oldPsw 旧密码 + * @return 结果 + */ + @GetMapping("/admin/resetPsw/{adminId}/{oldPsw}/{newPsw}") + public R resetPsw(@PathVariable("adminId") Integer adminId, @PathVariable("newPsw") String newPsw, @PathVariable("oldPsw") String oldPsw) { + return ApiResultHandler.success(adminService.resetPsw(adminId, newPsw, oldPsw)); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/AnswerController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/AnswerController.java new file mode 100644 index 0000000..982f1b0 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/AnswerController.java @@ -0,0 +1,66 @@ +package com.shanzhu.oe.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.service.AnswerService; +import com.shanzhu.oe.util.ApiResultHandler; +import com.shanzhu.oe.vo.AnswerVO; +import com.shanzhu.oe.vo.QuestionVO; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + + +/** + * 题库 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class AnswerController { + + private final AnswerService answerService; + + /** + * 查询题库 分页 + * + * @param page 分页页数 + * @param size 分页大小 + * @param subject 学科 + * @param section 章节 + * @param question 问题 + * @return 题目 + */ + @GetMapping("/answers/{page}/{size}/{subject}/{section}/{question}") + public R > findAllQuestion( + @PathVariable("page") Integer page, + @PathVariable("size") Integer size, + @PathVariable("subject") String subject, + @PathVariable("section") String section, + @PathVariable("question") String question + ){ + IPage answerVOIPage = answerService.findAll(new Page<>(page,size), subject, section, question); + return ApiResultHandler.buildApiResult(200,"查询所有题库", answerVOIPage); + } + + /** + * 根据类型和id获取题目 + * + * @param type 类型 + * @param questionId 题目id + * @return 题目信息 + */ + @GetMapping("/answers/{type}/{questionId}") + public R findByIdAndType( + @PathVariable("type") String type, + @PathVariable("questionId") Long questionId + ) { + QuestionVO questionVO = answerService.findByIdAndType(type, questionId); + return ApiResultHandler.buildApiResult(200, "查询题目", questionVO); + } + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ExamManageController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ExamManageController.java new file mode 100644 index 0000000..e699b8f --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ExamManageController.java @@ -0,0 +1,112 @@ +package com.shanzhu.oe.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.ExamManage; +import com.shanzhu.oe.service.ExamManageService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 考试管理 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class ExamManageController { + + private final ExamManageService examManageService; + + /** + * 查询所有考试 + * + * @return 考试列表 + */ + @GetMapping("/exams") + public R> findAll() { + return ApiResultHandler.buildApiResult(200, "请求成功!", examManageService.findAll()); + } + + /** + * 查询考试 分页 + * + * @param page 分页页数 + * @param size 分页大小 + * @return 考试列表 + */ + @GetMapping("/exams/{page}/{size}") + public R> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size) { + return ApiResultHandler.buildApiResult(200, "请求成功!", examManageService.findAll(new Page<>(page, size))); + } + + /** + * 根据考试编号查询考试信息 + * + * @param examCode 考试编号 + * @return 考试信息 + */ + @GetMapping("/exam/{examCode}") + public R findById(@PathVariable("examCode") Integer examCode) { + ExamManage res = examManageService.findById(examCode); + if (res == null) { + return ApiResultHandler.buildApiResult(10000, "考试编号不存在", null); + } + return ApiResultHandler.buildApiResult(200, "请求成功!", res); + } + + /** + * 根据考试编号删除 + * + * @param examCode 考试编号 + */ + @DeleteMapping("/exam/{examCode}") + public R deleteById(@PathVariable("examCode") Integer examCode) { + return ApiResultHandler.buildApiResult(200, "删除成功", examManageService.delete(examCode)); + } + + /** + * 根据考试编号更新 + * + * @param examManage 考试信息 + */ + @PutMapping("/exam") + public R update(@RequestBody ExamManage examManage) { + return ApiResultHandler.buildApiResult(200, "更新成功", examManageService.update(examManage)); + } + + /** + * 添加考试信息 + * + * @param examManage 考试信息 + */ + @PostMapping("/exam") + public R add(@RequestBody ExamManage examManage) { + int res = examManageService.add(examManage); + if (res == 1) { + return ApiResultHandler.buildApiResult(200, "添加成功", res); + } else { + return ApiResultHandler.buildApiResult(400, "添加失败", res); + } + } + + /** + * 查询最后一条记录的paperId,返回给前端达到自增效果 + * + * @return 最后一条记录 + */ + @GetMapping("/examManagePaperId") + public R findOnlyPaperId() { + ExamManage res = examManageService.findOnlyPaperId(); + if (res != null) { + return ApiResultHandler.buildApiResult(200, "请求成功", res); + } + + return ApiResultHandler.buildApiResult(400, "请求失败", res); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/FillQuestionController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/FillQuestionController.java new file mode 100644 index 0000000..2cae08a --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/FillQuestionController.java @@ -0,0 +1,65 @@ +package com.shanzhu.oe.controller; + +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.FillQuestion; +import com.shanzhu.oe.service.FillQuestionService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * 填空题 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class FillQuestionController { + + private final FillQuestionService fillQuestionService; + + /** + * 添加填空题 + * + * @param fillQuestion 填空题内容 + * @return 结果 + */ + @PostMapping("/fillQuestion") + public R add(@RequestBody FillQuestion fillQuestion) { + int res = fillQuestionService.add(fillQuestion); + if (res != 0) { + return ApiResultHandler.buildApiResult(200, "添加成功", res); + } + return ApiResultHandler.buildApiResult(400, "添加失败", res); + } + + /** + * 查询最后一条填空题 + * + * @return 最后一条填空题 + */ + @GetMapping("/fillQuestionId") + public R findOnlyQuestionId() { + FillQuestion res = fillQuestionService.findOnlyQuestionId(); + return ApiResultHandler.buildApiResult(200, "查询成功", res); + } + + /** + * 编辑填空题 + * + * @param fillQuestion 填空题内容 + * @return 结果 + */ + @PostMapping("/editFillQuestion") + public R edit(@RequestBody FillQuestion fillQuestion) { + int res = fillQuestionService.edit(fillQuestion); + if (res != 0) { + return ApiResultHandler.buildApiResult(200, "修改成功", res); + } + return ApiResultHandler.buildApiResult(400, "修改失败", res); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ItemController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ItemController.java new file mode 100644 index 0000000..9b697da --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ItemController.java @@ -0,0 +1,97 @@ +package com.shanzhu.oe.controller; + +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.PaperManage; +import com.shanzhu.oe.service.FillQuestionService; +import com.shanzhu.oe.service.JudgeQuestionService; +import com.shanzhu.oe.service.MultiQuestionService; +import com.shanzhu.oe.service.PaperService; +import com.shanzhu.oe.util.ApiResultHandler; +import com.shanzhu.oe.vo.Item; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 组卷 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class ItemController { + + private final MultiQuestionService multiQuestionService; + + private final FillQuestionService fillQuestionService; + + private final JudgeQuestionService judgeQuestionService; + + private final PaperService paperService; + + /** + * 组卷 + * + * @param item 题目模型 + * @return 结果 + */ + @PostMapping("/item") + public R ItemController(@RequestBody Item item) { + // 选择题 + Integer changeNumber = item.getChangeNumber(); + // 填空题 + Integer fillNumber = item.getFillNumber(); + // 判断题 + Integer judgeNumber = item.getJudgeNumber(); + //出卷id + Integer paperId = item.getPaperId(); + + // 数据库获取数据 + List changeNumbers = multiQuestionService.findBySubject(item.getSubject(), changeNumber); + List fills = fillQuestionService.findBySubject(item.getSubject(), fillNumber); + List judges = judgeQuestionService.findBySubject(item.getSubject(), judgeNumber); + + if (changeNumbers == null || changeNumbers.size() != changeNumber) { + return ApiResultHandler.buildApiResult(400, + "科目【" + item.getSubject() + "】题库【选择题】题目数量不足【" + changeNumber + "】,组卷失败", null); + } + if (fills == null || fills.size() != fillNumber) { + return ApiResultHandler.buildApiResult(400, "科目【" + item.getSubject() + "】题库【填空题】题目数量不足【" + fillNumber + + "】,组卷失败", null); + } + if (judges == null || judges.size() != judgeNumber) { + return ApiResultHandler.buildApiResult(400, + "科目【" + item.getSubject() + "】题库【判断题】题目数量不足【" + judgeNumber + "】,组卷失败", null); + } + + // 符合组题条件,执行组题 + // 选择题 + for (Integer number : changeNumbers) { + PaperManage paperManage = new PaperManage(paperId, 1, number); + int index = paperService.add(paperManage); + if (index == 0) + return ApiResultHandler.buildApiResult(400, "选择题组卷保存失败", null); + } + + // 填空题 + for (Integer fillNum : fills) { + PaperManage paperManage = new PaperManage(paperId, 2, fillNum); + int index = paperService.add(paperManage); + if (index == 0) + return ApiResultHandler.buildApiResult(400, "填空题题组卷保存失败", null); + } + // 判断题 + for (Integer judge : judges) { + PaperManage paperManage = new PaperManage(paperId, 3, judge); + int index = paperService.add(paperManage); + if (index == 0) + return ApiResultHandler.buildApiResult(400, "判断题题组卷保存失败", null); + } + + return ApiResultHandler.buildApiResult(200, "试卷组卷成功", null); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/JudgeQuestionController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/JudgeQuestionController.java new file mode 100644 index 0000000..133deaf --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/JudgeQuestionController.java @@ -0,0 +1,65 @@ +package com.shanzhu.oe.controller; + +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.JudgeQuestion; +import com.shanzhu.oe.service.JudgeQuestionService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * 判断题 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class JudgeQuestionController { + + private final JudgeQuestionService judgeQuestionService; + + /** + * 添加判断题 + * + * @param judgeQuestion 判断题信息 + * @return 结果 + */ + @PostMapping("/judgeQuestion") + public R add(@RequestBody JudgeQuestion judgeQuestion) { + int res = judgeQuestionService.add(judgeQuestion); + if (res != 0) { + return ApiResultHandler.buildApiResult(200,"添加成功",res); + } + return ApiResultHandler.buildApiResult(400,"添加失败",res); + } + + /** + * 查询最后一个判断题id + * + * @return 最后一个判断题 + */ + @GetMapping("/judgeQuestionId") + public R findOnlyQuestionId() { + JudgeQuestion res = judgeQuestionService.findOnlyQuestionId(); + return ApiResultHandler.buildApiResult(200,"查询成功",res); + } + + /** + * 编辑判断题 + * + * @param judgeQuestion 判断题 + * @return 结果 + */ + @PostMapping("/editJudgeQuestion") + public R edit(@RequestBody JudgeQuestion judgeQuestion) { + int res = judgeQuestionService.edit(judgeQuestion); + if (res != 0) { + return ApiResultHandler.buildApiResult(200,"修改成功",res); + } + return ApiResultHandler.buildApiResult(400,"修改失败",res); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/LoginController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/LoginController.java new file mode 100644 index 0000000..13a1554 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/LoginController.java @@ -0,0 +1,101 @@ +package com.shanzhu.oe.controller; + +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.Admin; +import com.shanzhu.oe.entity.Login; +import com.shanzhu.oe.entity.Student; +import com.shanzhu.oe.entity.Teacher; +import com.shanzhu.oe.service.LoginService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; + +/** + * 用户登录 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class LoginController { + + private final LoginService loginService; + + /** + * 用户登录 + * + * @param login 用户信息 + * @param response http response + * @return 登录用户信息 + */ + @PostMapping("/login") + public R login(@RequestBody Login login, HttpServletResponse response) { + Integer username = login.getUsername(); + String password = login.getPassword(); + + //登录管理员 + Admin adminRes = loginService.adminLogin(username, password); + if (adminRes != null) { + Cookie token = new Cookie("rb_token", adminRes.getCardId()); + token.setPath("/"); + Cookie role = new Cookie("rb_role", "0"); + role.setPath("/"); + + //将cookie对象加入response响应 + response.addCookie(token); + response.addCookie(role); + + return ApiResultHandler.buildApiResult(200, "请求成功", adminRes); + } + + //登录教师 + Teacher teacherRes = loginService.teacherLogin(username, password); + if (teacherRes != null) { + Cookie token = new Cookie("rb_token", teacherRes.getCardId()); + token.setPath("/"); + Cookie role = new Cookie("rb_role", "1"); + role.setPath("/"); + response.addCookie(token); + response.addCookie(role); + return ApiResultHandler.buildApiResult(200, "请求成功", teacherRes); + } + + //登录选 + Student studentRes = loginService.studentLogin(username, password); + if (studentRes != null) { + Cookie token = new Cookie("rb_token", studentRes.getCardId()); + token.setPath("/"); + Cookie role = new Cookie("rb_role", "2"); + role.setPath("/"); + response.addCookie(token); + response.addCookie(role); + return ApiResultHandler.buildApiResult(200, "请求成功", studentRes); + } + + return ApiResultHandler.buildApiResult(400, "请求失败", null); + } + + /** + * 登出 + * + * @param response http response + */ + @PostMapping("/logout") + public void logout(HttpServletResponse response) { + //清楚cookie里的token信息 + Cookie token = new Cookie("rb_token", null); + token.setPath("/"); + token.setMaxAge(0); + Cookie role = new Cookie("rb_role", null); + role.setPath("/"); + role.setMaxAge(0); + response.addCookie(token); + response.addCookie(role); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/MessageController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/MessageController.java new file mode 100644 index 0000000..e5d8f03 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/MessageController.java @@ -0,0 +1,77 @@ +package com.shanzhu.oe.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.Message; +import com.shanzhu.oe.service.MessageService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + * 留言 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class MessageController { + + private final MessageService messageService; + + /** + * 留言查询 分页 + * + * @param page 分页页数 + * @param size 分页大小 + * @return 留言数据 + */ + @GetMapping("/messages/{page}/{size}") + public R> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size) { + Page messagePage = new Page<>(page, size); + IPage all = messageService.findPage(messagePage); + return ApiResultHandler.buildApiResult(200, "查询所有留言", all); + } + + /** + * 通过id查询留言 + * + * @param id 留言id + * @return 留言内容 + */ + @GetMapping("/message/{id}") + public R findById(@PathVariable("id") Integer id) { + Message res = messageService.findById(id); + return ApiResultHandler.buildApiResult(200, "根据Id查询", res); + } + + /** + * 删除留言 + * + * @param id 留言id + * @return 删除成功数量 + */ + @DeleteMapping("/message/{id}") + public Integer delete(@PathVariable("id") Integer id) { + return messageService.delete(id); + } + + /** + * 添加留言 + * + * @param message 留言信息 + * @return 结果 + */ + @PostMapping("/message") + public R add(@RequestBody Message message) { + Integer res = messageService.add(message); + if (res == 0) { + return ApiResultHandler.buildApiResult(400, "添加失败", res); + } else { + return ApiResultHandler.buildApiResult(200, "添加成功", res); + } + } + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/MultiQuestionController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/MultiQuestionController.java new file mode 100644 index 0000000..a6c868a --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/MultiQuestionController.java @@ -0,0 +1,66 @@ +package com.shanzhu.oe.controller; + +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.MultiQuestion; +import com.shanzhu.oe.service.MultiQuestionService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * 选择题 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class MultiQuestionController { + + private final MultiQuestionService multiQuestionService; + + /** + * 通过id查询选择题 + * + * @return 选择题 + */ + @GetMapping("/multiQuestionId") + public R findOnlyQuestion() { + MultiQuestion res = multiQuestionService.findOnlyQuestionId(); + return ApiResultHandler.buildApiResult(200,"查询成功",res); + } + + /** + * 添加选择题 + * + * @param multiQuestion 选择题信息 + * @return 结果 + */ + @PostMapping("/MultiQuestion") + public R add(@RequestBody MultiQuestion multiQuestion) { + Integer res = multiQuestionService.add(multiQuestion); + if (res != 0) { + return ApiResultHandler.buildApiResult(200,"添加成功",res); + } + return ApiResultHandler.buildApiResult(400,"添加失败",res); + } + + /** + * 编辑选择题 + * + * @param multiQuestion 选择题信息 + * @return 结果 + */ + @PostMapping("/editMultiQuestion") + public R edit(@RequestBody MultiQuestion multiQuestion) { + Integer res = multiQuestionService.edit(multiQuestion); + if (res != 0) { + return ApiResultHandler.buildApiResult(200,"修改成功",res); + } + return ApiResultHandler.buildApiResult(400,"修改失败",res); + } + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/PaperController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/PaperController.java new file mode 100644 index 0000000..55cc805 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/PaperController.java @@ -0,0 +1,101 @@ +package com.shanzhu.oe.controller; + +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.FillQuestion; +import com.shanzhu.oe.entity.JudgeQuestion; +import com.shanzhu.oe.entity.MultiQuestion; +import com.shanzhu.oe.entity.PaperManage; +import com.shanzhu.oe.serviceimpl.FillQuestionServiceImpl; +import com.shanzhu.oe.serviceimpl.JudgeQuestionServiceImpl; +import com.shanzhu.oe.serviceimpl.MultiQuestionServiceImpl; +import com.shanzhu.oe.serviceimpl.PaperServiceImpl; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 试卷 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class PaperController { + + private final PaperServiceImpl paperService; + + private final JudgeQuestionServiceImpl judgeQuestionService; + + private final MultiQuestionServiceImpl multiQuestionService; + + private final FillQuestionServiceImpl fillQuestionService; + + /** + * 查询所有试卷 + * + * @return 试卷 + */ + @GetMapping("/papers") + public R> findAll() { + return ApiResultHandler.buildApiResult(200, "请求成功", paperService.findAll()); + } + + /** + * 通过试卷id 查询试卷 + * + * @param paperId 试卷id + * @return 试卷内容 + */ + @GetMapping("/paper/{paperId}") + public Map> findById(@PathVariable("paperId") Integer paperId) { + //选择题题库 1 + List multiQuestionRes = multiQuestionService.findByIdAndType(paperId); + //填空题题库 2 + List fillQuestionsRes = fillQuestionService.findByIdAndType(paperId); + //判断题题库 3 + List judgeQuestionRes = judgeQuestionService.findByIdAndType(paperId); + Map> questionMap = new HashMap<>(); + questionMap.put(1, multiQuestionRes); + questionMap.put(2, fillQuestionsRes); + questionMap.put(3, judgeQuestionRes); + + return questionMap; + } + + /** + * 添加试卷 + * + * @param paperManage 试卷内容 + * @return 结果 + */ + @PostMapping("/paperManage") + public R add(@RequestBody PaperManage paperManage) { + int res = paperService.add(paperManage); + if (res != 0) { + return ApiResultHandler.buildApiResult(200, "添加成功", res); + } + return ApiResultHandler.buildApiResult(400, "添加失败", res); + } + + /** + * 删除试卷中的某条试题 + * + * @param paperId 试卷id + * @param type 题目类型。1选择,2填空,3判断 + * @param questionId 题目id + */ + @GetMapping("/paper/delete/{paperId}/{type}/{questionId}") + public R delete( + @PathVariable("paperId") String paperId, + @PathVariable("type") String type, + @PathVariable("questionId") String questionId + ) { + paperService.delete(paperId, type, questionId); + return ApiResultHandler.buildApiResult(200, "删除成功", null); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ReplayController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ReplayController.java new file mode 100644 index 0000000..f8b0251 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ReplayController.java @@ -0,0 +1,50 @@ +package com.shanzhu.oe.controller; + +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.Replay; +import com.shanzhu.oe.service.ReplayService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 回复 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class ReplayController { + + private final ReplayService replayService; + + /** + * 添加回复 + * + * @param replay 回复内容 + * @return 结果 + */ + @PostMapping("/replay") + public R add(@RequestBody Replay replay) { + int data = replayService.add(replay); + if (data != 0) { + return ApiResultHandler.buildApiResult(200, "添加成功!", data); + } else { + return ApiResultHandler.buildApiResult(400, "添加失败!", null); + } + } + + /** + * 通过留言id查询回复 + * + * @param messageId 留言id + * @return 回复 + */ + @GetMapping("/replay/{messageId}") + public R> findAllById(@PathVariable("messageId") Integer messageId) { + return ApiResultHandler.buildApiResult(200, "根据messageId查询", replayService.findAllById(messageId)); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ScoreController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ScoreController.java new file mode 100644 index 0000000..ffeaf3e --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/ScoreController.java @@ -0,0 +1,98 @@ +package com.shanzhu.oe.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.Score; +import com.shanzhu.oe.service.ScoreService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 考试成绩 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class ScoreController { + + private final ScoreService scoreService; + + /** + * 查询所有考试成绩 + * + * @return 考试成绩 + */ + @GetMapping("/scores") + public R> findAll() { + List res = scoreService.findAll(); + return ApiResultHandler.buildApiResult(200, "查询所有学生成绩", res); + } + + /** + * 查询考试成绩 分页 + * + * @param page 分页页数 + * @param size 分页大学 + * @param studentId 学生id + * @return 考试成绩 + */ + @GetMapping("/score/{page}/{size}/{studentId}") + public R> findById( + @PathVariable("page") Integer page, + @PathVariable("size") Integer size, + @PathVariable("studentId") Integer studentId + ) { + IPage res = scoreService.findById(new Page<>(page, size), studentId); + return ApiResultHandler.buildApiResult(200, "根据ID查询成绩", res); + } + + /** + * 查询考试成绩 不分页 + * + * @param studentId 学生id + * @return 考试成绩 + */ + @GetMapping("/score/{studentId}") + public R> findById(@PathVariable("studentId") Integer studentId) { + List res = scoreService.findById(studentId); + if (!res.isEmpty()) { + return ApiResultHandler.buildApiResult(200, "根据ID查询成绩", res); + } else { + return ApiResultHandler.buildApiResult(400, "ID不存在", res); + } + } + + /** + * 添加学生成绩 + * + * @param score 学生成绩 + * @return 考试成绩 + */ + @PostMapping("/score") + public R add(@RequestBody Score score) { + int res = scoreService.add(score); + if (res == 0) { + return ApiResultHandler.buildApiResult(400, "成绩添加失败", res); + } else { + return ApiResultHandler.buildApiResult(200, "成绩添加成功", res); + } + } + + /** + * 通过考试编号 查询学生成绩 + * + * @param examCode 考试编号 + * @return 考试成绩 + */ + @GetMapping("/scores/{examCode}") + public R> findByExamCode(@PathVariable("examCode") Integer examCode) { + List scores = scoreService.findByExamCode(examCode); + return ApiResultHandler.buildApiResult(200, "查询成功", scores); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/StudentController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/StudentController.java new file mode 100644 index 0000000..e2a39f4 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/StudentController.java @@ -0,0 +1,124 @@ +package com.shanzhu.oe.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.Student; +import com.shanzhu.oe.service.StudentService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + * 学生 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class StudentController { + + private final StudentService studentService; + + + /** + * 查询学生 分页 + * + * @param page 分页页数 + * @param size 分页大学 + * @param name 学生姓名 + * @param grade 班级 + * @param tel 电话 + * @param institute 学院 + * @param major 专业 + * @param clazz 班级 + * @return 学生列表 + */ + @GetMapping("/students/{page}/{size}/{name}/{grade}/{tel}/{institute}/{major}/{clazz}") + public R> findAll( + @PathVariable Integer page, + @PathVariable Integer size, + @PathVariable String name, + @PathVariable String grade, + @PathVariable String tel, + @PathVariable String institute, + @PathVariable String major, + @PathVariable String clazz + ) { + IPage res = studentService.findAll( + new Page<>(page, size), name, grade, tel, institute, major, clazz + ); + return ApiResultHandler.buildApiResult(200, "分页查询所有学生", res); + } + + /** + * 通过学生id查询学生 + * + * @param studentId 学生id + * @return 学生 + */ + @GetMapping("/student/{studentId}") + public R findById(@PathVariable("studentId") Integer studentId) { + Student res = studentService.findById(studentId); + if (res != null) { + return ApiResultHandler.buildApiResult(200, "请求成功", res); + } else { + return ApiResultHandler.buildApiResult(404, "查询的用户不存在", null); + } + } + + /** + * 删除学生 + * + * @param studentId 学生id + * @return 结果 + */ + @DeleteMapping("/student/{studentId}") + public R deleteById(@PathVariable("studentId") Integer studentId) { + return ApiResultHandler.buildApiResult(200, "删除成功", studentService.deleteById(studentId)); + } + + /** + * 更新学生 + * + * @param student 学生信息 + * @return 结果 + */ + @PutMapping("/student") + public R update(@RequestBody Student student) { + int res = studentService.update(student); + if (res != 0) { + return ApiResultHandler.buildApiResult(200, "更新成功", res); + } + return ApiResultHandler.buildApiResult(400, "更新失败", res); + } + + /** + * 添加学生 + * + * @param student 学生信息 + * @return 结果 + */ + @PostMapping("/student") + public R add(@RequestBody Student student) { + int res = studentService.add(student); + if (res == 1) { + return ApiResultHandler.buildApiResult(200, "添加成功", null); + } else { + return ApiResultHandler.buildApiResult(400, "添加失败", null); + } + } + + /** + * 更新密码 + * + * @param student 学生信息 + * @return 结果 + */ + @PutMapping("/studentPWD") + public R updatePwd(@RequestBody Student student) { + studentService.updatePwd(student); + return ApiResultHandler.buildApiResult(200, "密码更新成功", null); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/controller/TeacherController.java b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/TeacherController.java new file mode 100644 index 0000000..54b1928 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/controller/TeacherController.java @@ -0,0 +1,82 @@ +package com.shanzhu.oe.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.common.R; +import com.shanzhu.oe.entity.Teacher; +import com.shanzhu.oe.service.TeacherService; +import com.shanzhu.oe.util.ApiResultHandler; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + * 教师 控制层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@RestController +@RequiredArgsConstructor +public class TeacherController { + + private final TeacherService teacherService; + + /** + * 查询教师 分页 + * + * @param page 分页页数 + * @param size 分页大小 + * @return 教师列表 + */ + @GetMapping("/teachers/{page}/{size}") + public R> findAll(@PathVariable Integer page, @PathVariable Integer size){ + Page teacherPage = new Page<>(page,size); + IPage teacherIPage = teacherService.findAll(teacherPage); + + return ApiResultHandler.buildApiResult(200,"查询所有教师",teacherIPage); + } + + /** + * 通过教师id查询 + * + * @param teacherId 教师id + * @return 教师 + */ + @GetMapping("/teacher/{teacherId}") + public R findById(@PathVariable("teacherId") Integer teacherId){ + return ApiResultHandler.success(teacherService.findById(teacherId)); + } + + /** + * 删除教师 + * + * @param teacherId 教师id + * @return 结果 + */ + @DeleteMapping("/teacher/{teacherId}") + public R deleteById(@PathVariable("teacherId") Integer teacherId){ + return ApiResultHandler.success(teacherService.deleteById(teacherId)); + } + + /** + * 更新教师 + * + * @param teacher 教师信息 + * @return 结果 + */ + @PutMapping("/teacher") + public R update(@RequestBody Teacher teacher){ + return ApiResultHandler.success(teacherService.update(teacher)); + } + + /** + * 添加教师 + * + * @param teacher 教师信息 + * @return 结果 + */ + @PostMapping("/teacher") + public R add(@RequestBody Teacher teacher){ + return ApiResultHandler.success(teacherService.add(teacher)); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Admin.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Admin.java new file mode 100644 index 0000000..6b11fae --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Admin.java @@ -0,0 +1,54 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 管理员 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class Admin { + + /** + * 管理员id + */ + private Integer adminId; + + /** + * 管理员名字 + */ + private String adminName; + + /** + * 性别 + */ + private String sex; + + /** + * 电话 + */ + private String tel; + + /** + * 邮箱 + */ + private String email; + + /** + * 密码 + */ + private String pwd; + + /** + * 身份证 + */ + private String cardId; + + /** + * 角色 + */ + private String role; + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/ExamManage.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/ExamManage.java new file mode 100644 index 0000000..8363e75 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/ExamManage.java @@ -0,0 +1,79 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 考试管理 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class ExamManage { + + /** + * 考试编号 + */ + private Integer examCode; + + /** + * 该次考试介绍 + */ + private String description; + + /** + * 课程名称 + */ + private String source; + + /** + * 试卷编号 + */ + private Integer paperId; + + /** + * 考试日期 + */ + private String examDate; + + /** + * 持续时长 + */ + private Integer totalTime; + + /** + * 年级 + */ + private String grade; + + /** + * 学期 + */ + private String term; + + /** + * 专业 + */ + private String major; + + /** + * 学院 + */ + private String institute; + + /** + * 总分 + */ + private Integer totalScore; + + /** + * 考试类型 + */ + private String type; + + /** + * 考生须知 + */ + private String tips; + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/FillQuestion.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/FillQuestion.java new file mode 100644 index 0000000..c6cee4d --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/FillQuestion.java @@ -0,0 +1,54 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 填空题 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class FillQuestion { + + /** + * 试题编号 + */ + private Integer questionId; + + /** + * 考试科目 + */ + private String subject; + + /** + * 试题内容 + */ + private String question; + + /** + * 正确答案 + */ + private String answer; + + /** + * 分数 + */ + private Integer score; + + /** + * 难度等级 + */ + private String level; + + /** + * 难度等级 + */ + private String section; + + /** + * 题目解析 + */ + private String analysis; + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/JudgeQuestion.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/JudgeQuestion.java new file mode 100644 index 0000000..25b4593 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/JudgeQuestion.java @@ -0,0 +1,54 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 判断题 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class JudgeQuestion { + + /** + * 试题编号 + */ + private Integer questionId; + + /** + * 考试科目 + */ + private String subject; + + /** + * 试题内容 + */ + private String question; + + /** + * 正确答案 + */ + private String answer; + + /** + * 难度等级 + */ + private String level; + + /** + * 所属章节 + */ + private String section; + + /** + * 分数 + */ + private Integer score; + + /** + * 题目解析 + */ + private String analysis; + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Login.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Login.java new file mode 100644 index 0000000..15adb37 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Login.java @@ -0,0 +1,24 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 用户登录信息 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class Login { + + /** + * 用户名(id) + */ + private Integer username; + + /** + * 密码 + */ + private String password; + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Message.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Message.java new file mode 100644 index 0000000..c033cb2 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Message.java @@ -0,0 +1,50 @@ +package com.shanzhu.oe.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; +import java.util.List; + + +/** + * 留言 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class Message { + + /** + * id主键 + */ + private Integer id; + + /** + * 解决id为null创建的一个临时id + */ + private Integer temp_id; + + /** + * 标题 + */ + private String title; + + /** + * 留言内容 + */ + private String content; + + /** + * 留言时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8") + private Date time; + + /** + * 一对多关系,评论信息 + */ + List replays; + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/MultiQuestion.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/MultiQuestion.java new file mode 100644 index 0000000..078dcf6 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/MultiQuestion.java @@ -0,0 +1,74 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 选择题 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class MultiQuestion { + + /** + * 实体编号 + */ + private Integer questionId; + + /** + * 考试科目 + */ + private String subject; + + /** + * 所属章节 + */ + private String section; + + /** + * 选项A + */ + private String answerA; + + /** + * 选项B + */ + private String answerB; + + /** + * 选项C + */ + private String answerC; + + /** + * 选项D + */ + private String answerD; + + /** + * 问题 + */ + private String question; + + /** + * 难度等级 + */ + private String level; + + /** + * 正确答案 + */ + private String rightAnswer; + + /** + * 题目解析 + */ + private String analysis; + + /** + * 分数 + */ + private Integer score; + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/PaperManage.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/PaperManage.java new file mode 100644 index 0000000..da6949b --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/PaperManage.java @@ -0,0 +1,33 @@ +package com.shanzhu.oe.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 试卷 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PaperManage { + + /** + * 试卷id + */ + private Integer paperId; + + /** + * 题目类型 + */ + private Integer questionType; + + /** + * 题目编号 + */ + private Integer questionId; + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Replay.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Replay.java new file mode 100644 index 0000000..a4e339c --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Replay.java @@ -0,0 +1,38 @@ +package com.shanzhu.oe.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; + +/** + * 回复 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class Replay { + + /** + * 留言id + */ + private Integer messageId; + + /** + * 回复id + */ + private Integer replayId; + + /** + * 回复内容 + */ + private String replay; + + /** + * 回复时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date replayTime; + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Score.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Score.java new file mode 100644 index 0000000..e9999d2 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Score.java @@ -0,0 +1,55 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 考试成绩 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class Score { + + /** + * 考试编号 + */ + private Integer examCode; + + /** + * 学号 + */ + private Integer studentId; + + /** + * 课程名称 + */ + private String subject; + + /** + * 平时成绩 + */ + private Integer ptScore; + + /** + * 期末成绩 + */ + private Integer etScore; + + /** + * 成绩分数 + */ + private Integer score; + + /** + * 成绩编号 + */ + private Integer scoreId; + + /** + * 答题日期 + */ + private String answerDate; + +} + diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Student.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Student.java new file mode 100644 index 0000000..6976459 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Student.java @@ -0,0 +1,73 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 学生 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class Student { + + /** + * 学生id + */ + private Integer studentId; + + /** + * 学生姓名 + */ + private String studentName; + + /** + * 年级 + */ + private String grade; + + /** + * 专业 + */ + private String major; + + /** + * 班级 + */ + private String clazz; + + /** + * 学院 + */ + private String institute; + + /** + * 性别 + */ + private String sex; + + /** + * 电话 + */ + private String tel; + + /** + * 邮箱 + */ + private String email; + + /** + * 密码 + */ + private String pwd; + + /** + * 身份证 + */ + private String cardId; + + /** + * 角色 + */ + private String role; +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Teacher.java b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Teacher.java new file mode 100644 index 0000000..3cc0932 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/entity/Teacher.java @@ -0,0 +1,64 @@ +package com.shanzhu.oe.entity; + +import lombok.Data; + +/** + * 教师 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class Teacher { + + /** + * 教师id + */ + private Integer teacherId; + + /** + * 教师名字 + */ + private String teacherName; + + /** + * 学院 + */ + private String institute; + + /** + * 性别 + */ + private String sex; + + /** + * 电话 + */ + private String tel; + + /** + * 邮箱 + */ + private String email; + + /** + * 密码 + */ + private String pwd; + + /** + * 身份证 + */ + private String cardId; + + /** + * 职称 + */ + private String type; + + /** + * 角色 + */ + private String role; + +} \ No newline at end of file diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/AdminMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/AdminMapper.java new file mode 100644 index 0000000..d77d170 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/AdminMapper.java @@ -0,0 +1,63 @@ +package com.shanzhu.oe.mapper; + +import com.shanzhu.oe.entity.Admin; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +/** + * 管理员 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface AdminMapper { + + /** + * 查询所有管理员 + * + * @return 管理员 + */ + @Select("select adminName,sex,tel,email,cardId,role from admin") + List findAll(); + + /** + * 通过管理员id查询 + * + * @param adminId 管理员id + * @return 管理员 + */ + @Select("select adminId,adminName,sex,tel,email,cardId,role,pwd from admin where adminId = #{adminId}") + Admin findById(Integer adminId); + + /** + * 通过管理员id删除 + * + * @param adminId 管理员id + * @return 结果 + */ + @Delete("delete from admin where adminId = #{adminId}") + Integer deleteById(Integer adminId); + + /** + * 更新管理员 + * + * @param admin 管理员信息 + * @return 结果 + */ + @Update("update admin set adminName = #{adminName},sex = #{sex}," + + "tel = #{tel}, email = #{email},pwd = #{pwd},cardId = #{cardId},role = #{role} where adminId = #{adminId}") + Integer update(Admin admin); + + /** + * 添加管理员 + * + * @param admin 管理员信息 + * @return 结果 + */ + @Options(useGeneratedKeys = true, keyProperty = "adminId") + @Insert("insert into admin(adminName,sex,tel,email,pwd,cardId,role) " + + "values(#{adminName},#{sex},#{tel},#{email},#{pwd},#{cardId},#{role})") + Integer add(Admin admin); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/AnswerMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/AnswerMapper.java new file mode 100644 index 0000000..bc91541 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/AnswerMapper.java @@ -0,0 +1,63 @@ +package com.shanzhu.oe.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.FillQuestion; +import com.shanzhu.oe.entity.JudgeQuestion; +import com.shanzhu.oe.entity.MultiQuestion; +import com.shanzhu.oe.vo.AnswerVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +/** + * 题库 持久 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface AnswerMapper { + + /** + * 查询题库 分页 + * + * @param page 分页对象 + * @param subject 学科 + * @param section 章节 + * @param question 问题 + * @return 题目 + */ + @Select("select questionId, question, subject, score, section,level, \"选择题\" as type from multi_question where question like concat('%',#{question},'%') and subject like concat('%',#{subject},'%') and section like concat('%',#{section},'%')" + + "union select questionId,question, subject, score, section,level, \"判断题\" as type from judge_question where question like concat('%',#{question},'%') and subject like concat('%',#{subject},'%') and section like concat('%',#{section},'%')" + + "union select questionId,question, subject, score, section,level, \"填空题\" as type from fill_question where question like concat('%',#{question},'%') and subject like concat('%',#{subject},'%') and section like concat('%',#{section},'%')") + IPage findAll(Page page, @Param("subject") String subject, @Param("section") String section, @Param("question") String question); + + + /** + * 查选择题 + * + * @param questionId 选择题id + * @return 选择题 + */ + @Select("select questionId, subject, question, answerA, answerB, answerC, answerD, rightAnswer, section, level, analysis from multi_question where questionId = #{questionId}") + MultiQuestion findMultiQuestionById(Long questionId); + + /** + * 查填空题 + * + * @param questionId 题目id + * @return 填空题 + */ + @Select("select questionId, subject, question, answer, analysis, level, section from fill_question where questionId = #{questionId}") + FillQuestion findFillQuestionById(Long questionId); + + /** + * 查判断题 + * + * @param questionId 题目id + * @return 判断题 + */ + @Select("select questionId, subject, question, answer, analysis, level, section from judge_question where questionId = #{questionId}") + JudgeQuestion findJudgeQuestionById(Long questionId); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ExamManageMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ExamManageMapper.java new file mode 100644 index 0000000..f7a14f3 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ExamManageMapper.java @@ -0,0 +1,57 @@ +package com.shanzhu.oe.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.ExamManage; +import org.apache.ibatis.annotations.*; + +/** + * 考试管理 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface ExamManageMapper { + + @Select("select * from exam_manage") + IPage findAll(Page page); + + /** + * 通过考试编号查询 + * + * @param examCode 考试编号 + * @return 考试信息 + */ + @Select("select * from exam_manage where examCode = #{examCode}") + ExamManage findById(Integer examCode); + + /** + * 根据考试编号删除 + * + * @param examCode 考试编号 + */ + @Delete("delete from exam_manage where examCode = #{examCode}") + int delete(Integer examCode); + + @Update("update exam_manage set description = #{description},source = #{source},paperId = #{paperId}," + + "examDate = #{examDate},totalTime = #{totalTime},grade = #{grade},term = #{term}," + + "major = #{major},institute = #{institute},totalScore = #{totalScore}," + + "type = #{type},tips = #{tips} where examCode = #{examCode}") + int update(ExamManage exammanage); + + @Options(useGeneratedKeys = true, keyProperty = "examCode") + @Insert("insert into exam_manage(description,source,paperId,examDate,totalTime,grade,term,major,institute," + + "totalScore,type,tips)" + + " values(#{description},#{source},#{paperId},#{examDate},#{totalTime},#{grade},#{term},#{major}," + + "#{institute},#{totalScore},#{type},#{tips})") + int add(ExamManage exammanage); + + /** + * 查询最后一条记录的paperId,返回给前端达到自增效果 + * + * @return paperId + */ + @Select("select paperId from exam_manage order by paperId desc limit 1") + ExamManage findOnlyPaperId(); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/FillQuestionMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/FillQuestionMapper.java new file mode 100644 index 0000000..5a9366c --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/FillQuestionMapper.java @@ -0,0 +1,65 @@ +package com.shanzhu.oe.mapper; + +import com.shanzhu.oe.entity.FillQuestion; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +/** + * 填空题 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface FillQuestionMapper { + + /** + * 通过试卷id查询问题 + * + * @param paperId 试卷id + * @return 问题 + */ + @Select("select * from fill_question where questionId in (select questionId from paper_manage where questionType " + + "= 2 and paperId = #{paperId})") + List findByIdAndType(Integer paperId); + + /** + * 查询最后一条填空题 + * + * @return 最后一条填空题 + */ + @Select("select questionId from fill_question order by questionId desc limit 1") + FillQuestion findOnlyQuestionId(); + + /** + * 添加填空题 + * + * @param fillQuestion 填空题内容 + * @return 结果 + */ + @Options(useGeneratedKeys = true, keyProperty = "questionId") + @Insert("insert into fill_question(subject,question,answer,analysis,level,section) values " + + "(#{subject},#{question},#{answer},#{analysis},#{level},#{section})") + Integer add(FillQuestion fillQuestion); + + /** + * 通过学科查询 + * + * @param subject 学科查询 + * @param pageNo 分页数 + * @return 题目 + */ + @Select("select questionId from fill_question where subject = #{subject} order by rand() desc limit #{pageNo}") + List findBySubject(@Param("subject") String subject, @Param("pageNo") Integer pageNo); + + /** + * 编辑填空题 + * + * @param fillQuestion 填空题内容 + * @return 结果 + */ + @Update("update fill_question set section = #{section}, question = #{question}, answer = #{answer}, level = " + + "#{level}, analysis = #{analysis} where questionId = #{questionId}") + Integer edit(FillQuestion fillQuestion); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/JudgeQuestionMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/JudgeQuestionMapper.java new file mode 100644 index 0000000..343077a --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/JudgeQuestionMapper.java @@ -0,0 +1,62 @@ +package com.shanzhu.oe.mapper; + +import com.shanzhu.oe.entity.JudgeQuestion; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +/** + * 判断题 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface JudgeQuestionMapper { + + /** + * 通过试卷id查询问题 + * + * @param paperId 试卷id + * @return 问题 + */ + @Select("select * from judge_question where questionId in (select questionId from paper_manage where questionType = 3 and paperId = #{paperId})") + List findByIdAndType(Integer paperId); + + /** + * 查询最后一个判断题id + * + * @return 最后一个判断题 + */ + @Select("select questionId from judge_question order by questionId desc limit 1") + JudgeQuestion findOnlyQuestionId(); + + /** + * 添加判断题 + * + * @param judgeQuestion 判断题信息 + * @return 结果 + */ + @Insert("insert into judge_question(subject,question,answer,analysis,level,section) values " + + "(#{subject},#{question},#{answer},#{analysis},#{level},#{section})") + int add(JudgeQuestion judgeQuestion); + + /** + * 通过学科查询 + * + * @param subject 学科 + * @param pageNo 分页数 + * @return 题目id + */ + @Select("select questionId from judge_question where subject=#{subject} order by rand() desc limit #{pageNo}") + List findBySubject(@Param("subject") String subject, @Param("pageNo") Integer pageNo); + + /** + * 编辑判断题 + * + * @param judgeQuestion 判断题 + * @return 结果 + */ + @Update("update judge_question set subject = #{subject}, question = #{question}, answer = #{answer}, section = #{section}, analysis = #{analysis}, level = #{level} where questionId = #{questionId}") + int edit(JudgeQuestion judgeQuestion); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/LoginMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/LoginMapper.java new file mode 100644 index 0000000..2ec57dd --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/LoginMapper.java @@ -0,0 +1,51 @@ +package com.shanzhu.oe.mapper; + +import com.shanzhu.oe.entity.Admin; +import com.shanzhu.oe.entity.Student; +import com.shanzhu.oe.entity.Teacher; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +/** + * 用户登录 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface LoginMapper { + + /** + * 管理员登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + @Select("select adminId,adminName,sex,tel,email,cardId,role from admin where adminId = #{username} and pwd = " + + "#{password}") + Admin adminLogin(@Param("username") Integer username, @Param("password") String password); + + /** + * 教师登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + @Select("select teacherId,teacherName,institute,sex,tel,email,cardId," + + "type,role from teacher where teacherId = #{username} and pwd = #{password}") + Teacher teacherLogin(@Param("username") Integer username, @Param("password") String password); + + /** + * 学生登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + @Select("select studentId,studentName,grade,major,clazz,institute,tel," + + "email,cardId,sex,role from student where studentId = #{username} and pwd = #{password}") + Student studentLogin(@Param("username") Integer username, @Param("password") String password); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/MessageMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/MessageMapper.java new file mode 100644 index 0000000..e642326 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/MessageMapper.java @@ -0,0 +1,72 @@ +package com.shanzhu.oe.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Message; +import org.apache.ibatis.annotations.*; + + +/** + * 留言 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface MessageMapper { + + /** + * 留言查询 分页 + * + * @param page 分页内容 + * @return 留言数据 + */ + @Select("select id,id as temp_id,title,content,time from message order by id desc") + @Results({ + @Result(property = "replays", column = "temp_id", many = @Many(select = "com.shanzhu.oe.mapper" + + ".ReplayMapper.findAllById")) + }) + IPage findAll(Page page); + + /** + * 通过id查询留言 + * + * @param id 留言id + * @return 留言内容 + */ + @Select("select id,title,content,time from message where id = #{id}") + @Results({ + @Result(property = "replays", column = "id", many = @Many(select = "com.shanzhu.oe.mapper.ReplayMapper" + + ".findAllById")) + }) + Message findById(Integer id); + + /** + * 删除留言 + * + * @param id 留言id + * @return 删除成功数量 + */ + @Delete("delete from message where id = #{id}") + Integer delete(Integer id); + + /** + * 更新留言 + * + * @param message 留言信息 + * @return 结果 + */ + @Update("update message set title = #{title}, content = #{content}, time = #{time} where " + + "id = #{id}") + Integer update(Message message); + + /** + * 添加留言 + * + * @param message 留言信息 + * @return 结果 + */ + @Options(useGeneratedKeys = true, keyProperty = "id") + @Insert("insert into message(title, content, time) values(#{title},#{content},#{time})") + int add(Message message); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/MultiQuestionMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/MultiQuestionMapper.java new file mode 100644 index 0000000..69290a7 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/MultiQuestionMapper.java @@ -0,0 +1,68 @@ +package com.shanzhu.oe.mapper; + +import com.shanzhu.oe.entity.MultiQuestion; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +/** + * 选择题 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface MultiQuestionMapper { + + /** + * 通过试卷id 查询试卷 + * + * @param paperId 试卷id + * @return 问题 + */ + @Select("select * from multi_question where questionId in (select questionId from paper_manage where questionType" + + " = 1 and paperId = #{paperId})") + List findByIdAndType(Integer paperId); + + /** + * 通过id查询选择题 + * + * @return 选择题 + */ + @Select("select questionId from multi_question order by questionId desc limit 1") + MultiQuestion findOnlyQuestionId(); + + /** + * 添加选择题 + * + * @param multiQuestion 选择题信息 + * @return 结果 + */ + @Options(useGeneratedKeys = true, keyProperty = "questionId") + @Insert("insert into multi_question(subject,question,answerA,answerB,answerC,answerD,rightAnswer,analysis," + + "section,level) " + + "values(#{subject},#{question},#{answerA},#{answerB},#{answerC},#{answerD},#{rightAnswer},#{analysis}," + + "#{section},#{level})") + Integer add(MultiQuestion multiQuestion); + + /** + * 通过学科查询 + * + * @param subject 学科 + * @param pageNo 分页数 + * @return 题目id + */ + @Select("select questionId from multi_question where subject =#{subject} order by rand() desc limit #{pageNo}") + List findBySubject(@Param("subject") String subject, @Param("pageNo") Integer pageNo); + + /** + * 编辑选择题 + * + * @param multiQuestion 选择题信息 + * @return 结果 + */ + @Update("update multi_question set subject = #{subject}, question = #{question}, answerA = #{answerA}, answerB = " + + "#{answerB}, answerC = #{answerC}, answerD = #{answerD}, rightAnswer = #{rightAnswer}, analysis = " + + "#{analysis}, section = #{section}, level = #{level} where questionId = #{questionId}") + int edit(MultiQuestion multiQuestion); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/PaperMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/PaperMapper.java new file mode 100644 index 0000000..361146b --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/PaperMapper.java @@ -0,0 +1,45 @@ +package com.shanzhu.oe.mapper; + +import com.shanzhu.oe.entity.PaperManage; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +/** + * 试卷 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface PaperMapper { + + /** + * 查询所有试卷 + * + * @return 试卷 + */ + @Select("select paperId, questionType,questionId from paper_manage") + List findAll(); + + /** + * 添加试卷 + * + * @param paperManage 试卷信息 + * @return 结果 + */ + @Insert("insert into paper_manage(paperId,questionType,questionId) values " + + "(#{paperId},#{questionType},#{questionId})") + Integer add(PaperManage paperManage); + + /** + * 删除试卷中的某条试题 + * + * @param paperId 试卷id + * @param type 题目类型。1选择,2填空,3判断 + * @param questionId 题目id + */ + @Delete("delete from paper_manage where paperId = #{paperId} and questionType = #{type} and questionId = " + + "#{questionId}") + void delete(@Param("paperId") String paperId, @Param("type") String type, @Param("questionId") String questionId); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ReplayMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ReplayMapper.java new file mode 100644 index 0000000..52ef9fc --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ReplayMapper.java @@ -0,0 +1,54 @@ +package com.shanzhu.oe.mapper; + +import com.shanzhu.oe.entity.Replay; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +/** + * 留言 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface ReplayMapper { + + /** + * 通过留言id查询回复 + * + * @param messageId 留言id + * @return 回复 + */ + @Select("select messageId,replayId,replay,replayTime from replay where messageId = #{messageId}") + List findAllById(Integer messageId); + + /** + * 删除回复 + * + * @param replayId 回复id + * @return 结果 + */ + @Delete("delete from replay where replayId = #{replayId}") + Integer delete(Integer replayId); + + /** + * 更新回复 + * + * @param replay 回复内容 + * @return 结果 + */ + @Update("update replay set title = #{title}, replay = #{replay}, replayTime = #{replayTime} where replayId = " + + "#{replayId}") + Integer update(Replay replay); + + /** + * 添加回复 + * + * @param replay 回复内容 + * @return 结果 + */ + @Options(useGeneratedKeys = true, keyProperty = "replayId") + @Insert("insert into replay(messageId,replay,replayTime) values(#{messageId}, #{replay},#{replayTime})") + int add(Replay replay); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ScoreMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ScoreMapper.java new file mode 100644 index 0000000..219dfc5 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/ScoreMapper.java @@ -0,0 +1,58 @@ +package com.shanzhu.oe.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Score; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +/** + * 分数 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface ScoreMapper { + + /** + * 添加学生成绩 + * + * @param score 学生成绩 + * @return 考试成绩 + */ + @Options(useGeneratedKeys = true, keyProperty = "scoreId") + @Insert("insert into score(examCode,studentId,subject,ptScore,etScore,score,answerDate) values(#{examCode}," + + "#{studentId},#{subject},#{ptScore},#{etScore},#{score},#{answerDate})") + Integer add(Score score); + + /** + * 查询所有考试成绩 + * + * @return 考试成绩 + */ + @Select("select scoreId,examCode,studentId,subject,ptScore,etScore,score,answerDate from score order by scoreId " + + "desc") + List findAll(); + + /** + * 查询考试成绩分页 + * + * @param page 分页对象 + * @param studentId 学生id + * @return 考试成绩 + */ + @Select("select scoreId,examCode,studentId,subject,ptScore,etScore,score,answerDate from score where studentId = " + + "#{studentId} order by scoreId asc") + IPage findById(Page page, @Param("studentId") Integer studentId); + + /** + * 通过考试编号 查询学生成绩 + * + * @param examCode 考试编号 + * @return 考试成绩 + */ + @Select("select max(etScore) as etScore from score where examCode = #{examCode} group by studentId") + List findByExamCode(Integer examCode); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/StudentMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/StudentMapper.java new file mode 100644 index 0000000..99fc6e3 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/StudentMapper.java @@ -0,0 +1,88 @@ +package com.shanzhu.oe.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Student; +import org.apache.ibatis.annotations.*; + +/** + * 学生 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface StudentMapper { + + /** + * 查询学生 分页 + * + * @param page 分页对象 + * @param name 学生姓名 + * @param grade 班级 + * @param tel 电话 + * @param institute 学院 + * @param major 专业 + * @param clazz 班级 + * @return 学生列表 + */ + @Select("select * from student where " + + "studentName like concat('%',#{name},'%') " + + "and grade like concat('%',#{grade},'%') " + + "and tel like concat('%',#{tel},'%') " + + "and major like concat('%',#{major},'%') " + + "and institute like concat('%',#{institute},'%') " + + "and clazz like concat('%',#{clazz},'%')") + IPage findAll(Page page, @Param("name") String name, @Param("grade") String grade, + @Param("tel") String tel, @Param("institute") String institute, + @Param("major")String major, @Param("clazz") String clazz); + + /** + * 通过学生id查询学生 + * + * @param studentId 学生id + * @return 学生 + */ + @Select("select * from student where studentId = #{studentId}") + Student findById(Integer studentId); + + /** + * 删除学生 + * + * @param studentId 学生id + * @return 结果 + */ + @Delete("delete from student where studentId = #{studentId}") + Integer deleteById(Integer studentId); + + /** + * 更新学生 + * + * @param student 学生信息 + * @return 结果 + */ + @Update("update student set studentName = #{studentName},grade = #{grade},major = #{major},clazz = #{clazz}," + + "institute = #{institute},tel = #{tel},email = #{email},pwd = #{pwd},cardId = #{cardId},sex = #{sex},role = #{role} " + + "where studentId = #{studentId}") + Integer update(Student student); + + /** + * 添加学生 + * + * @param student 学生信息 + * @return 结果 + */ + @Options(useGeneratedKeys = true,keyProperty = "studentId") + @Insert("insert into student(studentName,grade,major,clazz,institute,tel,email,pwd,cardId,sex,role) values " + + "(#{studentName},#{grade},#{major},#{clazz},#{institute},#{tel},#{email},#{pwd},#{cardId},#{sex},#{role})") + Integer add(Student student); + + /** + * 更新密码 + * + * @param student 学生信息 + * @return 结果 + */ + @Update("update student set pwd = #{pwd} where studentId = #{studentId}") + Integer updatePwd(Student student); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/TeacherMapper.java b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/TeacherMapper.java new file mode 100644 index 0000000..fcabb23 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/mapper/TeacherMapper.java @@ -0,0 +1,65 @@ +package com.shanzhu.oe.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Teacher; +import org.apache.ibatis.annotations.*; + +/** + * 教师 持久层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Mapper +public interface TeacherMapper { + + /** + * 查询教师 分页 + * + * @param page 分页对象 + * @return 教师列表 + */ + @Select("select * from teacher") + IPage findAll(Page page); + + /** + * 通过教师id查询 + * + * @param teacherId 教师id + * @return 教师 + */ + @Select("select * from teacher where teacherId = #{teacherId}") + Teacher findById(Integer teacherId); + + /** + * 删除教师 + * + * @param teacherId 教师id + * @return 结果 + */ + @Delete("delete from teacher where teacherId = #{teacherId}") + Integer deleteById(Integer teacherId); + + /** + * 更新教师 + * + * @param teacher 教师信息 + * @return 结果 + */ + @Update("update teacher set teacherName = #{teacherName},sex = #{sex}," + + "tel = #{tel}, email = #{email},pwd = #{pwd},cardId = #{cardId}," + + "role = #{role},institute = #{institute},type = #{type} where teacherId = #{teacherId}") + Integer update(Teacher teacher); + + /** + * 添加教师 + * + * @param teacher 教师信息 + * @return 结果 + */ + @Options(useGeneratedKeys = true, keyProperty = "teacherId") + @Insert("insert into teacher(teacherName,sex,tel,email,pwd,cardId,role,type,institute) " + + "values(#{teacherName},#{sex},#{tel},#{email},#{pwd},#{cardId},#{role},#{type},#{institute})") + Integer add(Teacher teacher); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/AdminService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/AdminService.java new file mode 100644 index 0000000..df920ba --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/AdminService.java @@ -0,0 +1,63 @@ +package com.shanzhu.oe.service; + +import com.shanzhu.oe.entity.Admin; + +import java.util.List; + +/** + * 管理员 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface AdminService { + + /** + * 查询所有管理员 + * + * @return 管理员 + */ + List findAll(); + + /** + * 通过管理员id查询 + * + * @param adminId 管理员id + * @return 管理员 + */ + Admin findById(Integer adminId); + + /** + * 通过管理员id删除 + * + * @param adminId 管理员id + * @return 结果 + */ + Integer deleteById(Integer adminId); + + /** + * 更新管理员 + * + * @param admin 管理员信息 + * @return 结果 + */ + Integer update(Admin admin); + + /** + * 添加管理员 + * + * @param admin 管理员信息 + * @return 结果 + */ + Integer add(Admin admin); + + /** + * 更新密码 + * + * @param adminId 管理员id + * @param newPsw 新密码 + * @param oldPsw 旧密码 + * @return 结果 + */ + Object resetPsw(Integer adminId, String newPsw, String oldPsw); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/AnswerService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/AnswerService.java new file mode 100644 index 0000000..e9c99e4 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/AnswerService.java @@ -0,0 +1,35 @@ +package com.shanzhu.oe.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.vo.AnswerVO; +import com.shanzhu.oe.vo.QuestionVO; + +/** + * 题库 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface AnswerService { + + /** + * 查询题库 分页 + * + * @param page 分页对象 + * @param subject 学科 + * @param section 章节 + * @param question 问题 + * @return 题目 + */ + IPage findAll(Page page, String subject, String section, String question); + + /** + * 根据类型和id获取题目 + * + * @param type 类型 + * @param questionId 题目id + * @return 题目信息 + */ + QuestionVO findByIdAndType(String type, Long questionId); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/ExamManageService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/ExamManageService.java new file mode 100644 index 0000000..1b8f74b --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/ExamManageService.java @@ -0,0 +1,69 @@ +package com.shanzhu.oe.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.ExamManage; + +import java.util.List; + +/** + * 考试管理 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface ExamManageService { + + /** + * 查询所有考试 + * + * @return 考试列表 + */ + List findAll(); + + /** + * 查询考试 分页 + * + * @param page 分页对象 + * @return 考试列表 + */ + IPage findAll(Page page); + + /** + * 根据考试编号查询考试信息 + * + * @param examCode 考试编好 + * @return 考试信息 + */ + ExamManage findById(Integer examCode); + + /** + * 根据考试编号删除 + * + * @param examCode 考试编号 + */ + Integer delete(Integer examCode); + + /** + * 更新考试信息 + * + * @param examManage 考试信息 + */ + Integer update(ExamManage examManage); + + /** + * 添加考试信息 + * + * @param examManage 考试信息 + */ + Integer add(ExamManage examManage); + + /** + * 查询最后一条记录的paperId,返回给前端达到自增效果 + * + * @return 最后一条记录 + */ + ExamManage findOnlyPaperId(); + + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/FillQuestionService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/FillQuestionService.java new file mode 100644 index 0000000..7d73c12 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/FillQuestionService.java @@ -0,0 +1,55 @@ +package com.shanzhu.oe.service; + +import com.shanzhu.oe.entity.FillQuestion; + +import java.util.List; + +/** + * 填空题 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface FillQuestionService { + + /** + * 通过试卷id查询问题 + * + * @param paperId 试卷id + * @return 问题 + */ + List findByIdAndType(Integer paperId); + + + /** + * 查询最后一条填空题 + * + * @return 最后一条填空题 + */ + FillQuestion findOnlyQuestionId(); + + /** + * 添加填空题 + * + * @param fillQuestion 填空题内容 + * @return 结果 + */ + Integer add(FillQuestion fillQuestion); + + /** + * 通过学科查询 + * + * @param subject 学科查询 + * @param pageNo 分页数 + * @return 题目 + */ + List findBySubject(String subject,Integer pageNo); + + /** + * 编辑填空题 + * + * @param fillQuestion 填空题内容 + * @return 结果 + */ + Integer edit(FillQuestion fillQuestion); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/JudgeQuestionService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/JudgeQuestionService.java new file mode 100644 index 0000000..0d616ed --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/JudgeQuestionService.java @@ -0,0 +1,54 @@ +package com.shanzhu.oe.service; + +import com.shanzhu.oe.entity.JudgeQuestion; + +import java.util.List; + +/** + * 判断题 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface JudgeQuestionService { + + /** + * 通过试卷id查询问题 + * + * @param paperId 试卷id + * @return 问题 + */ + List findByIdAndType(Integer paperId); + + /** + * 查询最后一个判断题id + * + * @return 最后一个判断题 + */ + JudgeQuestion findOnlyQuestionId(); + + /** + * 添加判断题 + * + * @param judgeQuestion 判断题信息 + * @return 结果 + */ + Integer add(JudgeQuestion judgeQuestion); + + /** + * 通过学科查询 + * + * @param subject 学科 + * @param pageNo 分页数 + * @return 题目id + */ + List findBySubject(String subject,Integer pageNo); + + /** + * 编辑判断题 + * + * @param judgeQuestion 判断题 + * @return 结果 + */ + Integer edit(JudgeQuestion judgeQuestion); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/LoginService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/LoginService.java new file mode 100644 index 0000000..efdee1b --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/LoginService.java @@ -0,0 +1,41 @@ +package com.shanzhu.oe.service; + +import com.shanzhu.oe.entity.Admin; +import com.shanzhu.oe.entity.Student; +import com.shanzhu.oe.entity.Teacher; + +/** + * 用户登录 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface LoginService { + + /** + * 管理员用户登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + Admin adminLogin(Integer username, String password); + + /** + * 教师用户登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + Teacher teacherLogin(Integer username, String password); + + /** + * 学生用户登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + Student studentLogin(Integer username, String password); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/MessageService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/MessageService.java new file mode 100644 index 0000000..dbb820c --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/MessageService.java @@ -0,0 +1,55 @@ +package com.shanzhu.oe.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Message; + + +/** + * 留言 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface MessageService { + + /** + * 留言查询 分页 + * + * @param page 分页内容 + * @return 留言数据 + */ + IPage findPage(Page page); + + /** + * 通过id查询留言 + * + * @param id 留言id + * @return 留言内容 + */ + Message findById(Integer id); + + /** + * 删除留言 + * + * @param id 留言id + * @return 删除成功数量 + */ + Integer delete(Integer id); + + /** + * 更新留言 + * + * @param message 留言信息 + * @return 结果 + */ + Integer update(Message message); + + /** + * 添加留言 + * + * @param message 留言信息 + * @return 结果 + */ + Integer add(Message message); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/MultiQuestionService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/MultiQuestionService.java new file mode 100644 index 0000000..1e43eb0 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/MultiQuestionService.java @@ -0,0 +1,54 @@ +package com.shanzhu.oe.service; + +import com.shanzhu.oe.entity.MultiQuestion; + +import java.util.List; + +/** + * 选择题 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface MultiQuestionService { + + /** + * 通过试卷id 查询试卷 + * + * @param paperId 试卷id + * @return 问题 + */ + List findByIdAndType(Integer paperId); + + /** + * 通过id查询选择题 + * + * @return 选择题 + */ + MultiQuestion findOnlyQuestionId(); + + /** + * 添加选择题 + * + * @param multiQuestion 选择题信息 + * @return 结果 + */ + Integer add(MultiQuestion multiQuestion); + + /** + * 通过学科查询 + * + * @param subject 学科 + * @param pageNo 分页数 + * @return 题目id + */ + List findBySubject(String subject,Integer pageNo); + + /** + * 编辑选择题 + * + * @param multiQuestion 选择题信息 + * @return 结果 + */ + Integer edit(MultiQuestion multiQuestion); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/PaperService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/PaperService.java new file mode 100644 index 0000000..6436e8c --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/PaperService.java @@ -0,0 +1,46 @@ +package com.shanzhu.oe.service; + +import com.shanzhu.oe.entity.PaperManage; + +import java.util.List; + +/** + * 试卷 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface PaperService { + + /** + * 查询所有试卷 + * + * @return 试卷 + */ + List findAll(); + + /** + * 添加试卷 + * + * @param paperManage 试卷信息 + * @return 结果 + */ + Integer add(PaperManage paperManage); + + /** + * 获取试卷总分 + * + * @param paperId 试卷id + * @return 分数 + */ + Integer getMaxScore(Integer paperId); + + /** + * 删除试卷中的某条试题 + * + * @param paperId 试卷id + * @param type 题目类型。1选择,2填空,3判断 + * @param questionId 题目id + */ + void delete(String paperId, String type, String questionId); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/ReplayService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/ReplayService.java new file mode 100644 index 0000000..ba47e1a --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/ReplayService.java @@ -0,0 +1,46 @@ +package com.shanzhu.oe.service; + +import com.shanzhu.oe.entity.Replay; + +import java.util.List; + +/** + * 回复 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface ReplayService { + + /** + * 通过留言id查询回复 + * + * @param messageId 留言id + * @return 回复 + */ + List findAllById(Integer messageId); + + /** + * 删除回复 + * + * @param replayId 回复id + * @return 结果 + */ + Integer delete(Integer replayId); + + /** + * 更新回复 + * + * @param replay 回复内容 + * @return 结果 + */ + Integer update(Replay replay); + + /** + * 添加回复 + * + * @param replay 回复内容 + * @return 结果 + */ + Integer add(Replay replay); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/ScoreService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/ScoreService.java new file mode 100644 index 0000000..219b782 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/ScoreService.java @@ -0,0 +1,56 @@ +package com.shanzhu.oe.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Score; + +import java.util.List; + +/** + * 分数 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface ScoreService { + + /** + * 添加学生成绩 + * + * @param score 学生成绩 + * @return 考试成绩 + */ + Integer add(Score score); + + /** + * 查询所有考试成绩 + * + * @return 考试分数 + */ + List findAll(); + + /** + * 查询考试成绩 分页 + * + * @param page 分页对象 + * @param studentId 学生id + * @return 结果 + */ + IPage findById(Page page, Integer studentId); + + /** + * 查询考试成绩 不分页 + * + * @param studentId 学生id + * @return 考试成绩 + */ + List findById(Integer studentId); + + /** + * 通过考试编号 查询学生成绩 + * + * @param examCode 考试编号 + * @return 考试成绩 + */ + List findByExamCode(Integer examCode); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/StudentService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/StudentService.java new file mode 100644 index 0000000..489b9fb --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/StudentService.java @@ -0,0 +1,72 @@ +package com.shanzhu.oe.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Student; + +/** + * 学生 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface StudentService { + + /** + * 查询学生 分页 + * + * @param page 分页对象 + * @param name 学生姓名 + * @param grade 班级 + * @param tel 电话 + * @param institute 学院 + * @param major 专业 + * @param clazz 班级 + * @return 学生列表 + */ + IPage findAll( + Page page, String name, + String grade, String tel, + String institute, String major, String clazz + ); + + /** + * 通过学生id查询学生 + * + * @param studentId 学生id + * @return 学生 + */ + Student findById(Integer studentId); + + /** + * 删除学生 + * + * @param studentId 学生id + * @return 结果 + */ + Integer deleteById(Integer studentId); + + /** + * 更新学生 + * + * @param student 学生信息 + * @return 结果 + */ + Integer update(Student student); + + /** + * 添加学生 + * + * @param student 学生信息 + * @return 结果 + */ + Integer add(Student student); + + /** + * 更新密码 + * + * @param student 学生信息 + * @return 结果 + */ + Integer updatePwd(Student student); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/service/TeacherService.java b/online-exam-backend/src/main/java/com/shanzhu/oe/service/TeacherService.java new file mode 100644 index 0000000..bd90080 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/service/TeacherService.java @@ -0,0 +1,58 @@ +package com.shanzhu.oe.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Teacher; + +import java.util.List; + +/** + * 教师 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public interface TeacherService { + + /** + * 查询教师 分页 + * + * @param page 分页对象 + * @return 教师列表 + */ + IPage findAll(Page page); + + List findAll(); + + /** + * 通过教师id查询 + * + * @param teacherId 教师id + * @return 教师 + */ + Teacher findById(Integer teacherId); + + /** + * 删除教师 + * + * @param teacherId 教师id + * @return 结果 + */ + Integer deleteById(Integer teacherId); + + /** + * 更新教师 + * + * @param teacher 教师信息 + * @return 结果 + */ + Integer update(Teacher teacher); + + /** + * 添加教师 + * + * @param teacher 教师信息 + * @return 结果 + */ + Integer add(Teacher teacher); +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/AdminServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/AdminServiceImpl.java new file mode 100644 index 0000000..9c82284 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/AdminServiceImpl.java @@ -0,0 +1,98 @@ +package com.shanzhu.oe.serviceimpl; + +import com.shanzhu.oe.entity.Admin; +import com.shanzhu.oe.mapper.AdminMapper; +import com.shanzhu.oe.service.AdminService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 管理员 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class AdminServiceImpl implements AdminService { + + private final AdminMapper adminMapper; + + /** + * 查询所有管理员 + * + * @return 管理员 + */ + @Override + public List findAll() { + return adminMapper.findAll(); + } + + /** + * 通过管理员id查询 + * + * @param adminId 管理员id + * @return 管理员 + */ + @Override + public Admin findById(Integer adminId) { + return adminMapper.findById(adminId); + } + + /** + * 通过管理员id删除 + * + * @param adminId 管理员id + * @return 结果 + */ + @Override + public Integer deleteById(Integer adminId) { + return adminMapper.deleteById(adminId); + } + + /** + * 更新管理员 + * + * @param admin 管理员信息 + * @return 结果 + */ + @Override + public Integer update(Admin admin) { + return adminMapper.update(admin); + } + + /** + * 添加管理员 + * + * @param admin 管理员信息 + * @return 结果 + */ + @Override + public Integer add(Admin admin) { + return adminMapper.add(admin); + } + + /** + * 更新密码 + * + * @param adminId 管理员id + * @param newPsw 新密码 + * @param oldPsw 旧密码 + * @return 结果 + */ + @Override + public Object resetPsw(Integer adminId, String newPsw, String oldPsw) { + Admin admin = findById(adminId); + + if(!admin.getPwd().equals(oldPsw)) { + return "原密码错误"; + } + admin.setPwd(String.valueOf(newPsw)); + update(admin); + return Boolean.TRUE; + } + + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/AnswerServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/AnswerServiceImpl.java new file mode 100644 index 0000000..a872183 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/AnswerServiceImpl.java @@ -0,0 +1,65 @@ +package com.shanzhu.oe.serviceimpl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.mapper.AnswerMapper; +import com.shanzhu.oe.service.AnswerService; +import com.shanzhu.oe.vo.AnswerVO; +import com.shanzhu.oe.vo.QuestionVO; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * 题库 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class AnswerServiceImpl implements AnswerService { + + private final AnswerMapper answerMapper; + + /** + * 查询题库 分页 + * + * @param page 分页对象 + * @param subject 学科 + * @param section 章节 + * @param question 问题 + * @return 题目 + */ + @Override + public IPage findAll(Page page, String subject, String section, String question) { + subject = (subject.equals("@") ? "" : subject); + section = (section.equals("@") ? "" : section); + question = (question.equals("@") ? "" : question); + return answerMapper.findAll(page, subject, section, question); + } + + /** + * 根据类型和id获取题目 + * + * @param type 类型 + * @param questionId 题目id + * @return 题目信息 + */ + @Override + public QuestionVO findByIdAndType(String type, Long questionId) { + QuestionVO questionVO = new QuestionVO(); + questionVO.setType(type); + switch (type) { + case "选择题": + questionVO.setMultiQuestion(answerMapper.findMultiQuestionById(questionId)); + break; + case "判断题": + questionVO.setJudgeQuestion(answerMapper.findJudgeQuestionById(questionId)); + break; + case "填空题": + questionVO.setFillQuestion(answerMapper.findFillQuestionById(questionId)); + break; + } + return questionVO; + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ExamManageServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ExamManageServiceImpl.java new file mode 100644 index 0000000..144c5a9 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ExamManageServiceImpl.java @@ -0,0 +1,117 @@ +package com.shanzhu.oe.serviceimpl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.ExamManage; +import com.shanzhu.oe.mapper.ExamManageMapper; +import com.shanzhu.oe.service.ExamManageService; +import com.shanzhu.oe.service.PaperService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 考试管理 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class ExamManageServiceImpl implements ExamManageService { + + private final ExamManageMapper examManageMapper; + + private final PaperService paperService; + + /** + * 查询所有考试 + * + * @return 考试列表 + */ + @Override + public List findAll() { + Page examManage = new Page<>(0, 9999); + List examManageList = examManageMapper.findAll(examManage).getRecords(); + setMaxScore(examManageList); + return examManageList; + } + + /** + * 查询考试 分页 + * + * @param page 分页对象 + * @return 考试列表 + */ + @Override + public IPage findAll(Page page) { + IPage iPage = examManageMapper.findAll(page); + setMaxScore(iPage.getRecords()); + return iPage; + } + + /** + * 根据考试编号查询考试信息 + * + * @param examCode 考试编好 + * @return 考试信息 + */ + @Override + public ExamManage findById(Integer examCode) { + ExamManage examManage = examManageMapper.findById(examCode); + examManage.setTotalScore(paperService.getMaxScore(examManage.getPaperId())); + return examManage; + } + + /** + * 根据考试编号删除 + * + * @param examCode 考试编号 + */ + @Override + public Integer delete(Integer examCode) { + return examManageMapper.delete(examCode); + } + + /** + * 更新考试信息 + * + * @param examManage 考试信息 + */ + @Override + public Integer update(ExamManage examManage) { + return examManageMapper.update(examManage); + } + + /** + * 添加考试信息 + * + * @param examManage 考试信息 + */ + @Override + public Integer add(ExamManage examManage) { + return examManageMapper.add(examManage); + } + + /** + * 查询最后一条记录的paperId,返回给前端达到自增效果 + * + * @return 最后一条记录 + */ + @Override + public ExamManage findOnlyPaperId() { + return examManageMapper.findOnlyPaperId(); + } + + /** + * 设置最高分 + * + * @param examManageList + */ + private void setMaxScore(List examManageList) { + for (ExamManage examManage : examManageList) { + examManage.setTotalScore(paperService.getMaxScore(examManage.getPaperId())); + } + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/FillQuestionServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/FillQuestionServiceImpl.java new file mode 100644 index 0000000..4635bbd --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/FillQuestionServiceImpl.java @@ -0,0 +1,77 @@ +package com.shanzhu.oe.serviceimpl; + +import com.shanzhu.oe.entity.FillQuestion; +import com.shanzhu.oe.mapper.FillQuestionMapper; +import com.shanzhu.oe.service.FillQuestionService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 填空题 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class FillQuestionServiceImpl implements FillQuestionService { + + private final FillQuestionMapper fillQuestionMapper; + + /** + * 通过试卷id查询问题 + * + * @param paperId 试卷id + * @return 问题 + */ + @Override + public List findByIdAndType(Integer paperId) { + return fillQuestionMapper.findByIdAndType(paperId); + } + + /** + * 查询最后一条填空题 + * + * @return 最后一条填空题 + */ + @Override + public FillQuestion findOnlyQuestionId() { + return fillQuestionMapper.findOnlyQuestionId(); + } + + /** + * 添加填空题 + * + * @param fillQuestion 填空题内容 + * @return 结果 + */ + @Override + public Integer add(FillQuestion fillQuestion) { + return fillQuestionMapper.add(fillQuestion); + } + + /** + * 通过学科查询 + * + * @param subject 学科查询 + * @param pageNo 分页数 + * @return 题目 + */ + @Override + public List findBySubject(String subject, Integer pageNo) { + return fillQuestionMapper.findBySubject(subject,pageNo); + } + + /** + * 编辑填空题 + * + * @param fillQuestion 填空题内容 + * @return 结果 + */ + @Override + public Integer edit(FillQuestion fillQuestion) { + return fillQuestionMapper.edit(fillQuestion); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/JudgeQuestionServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/JudgeQuestionServiceImpl.java new file mode 100644 index 0000000..1cccefc --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/JudgeQuestionServiceImpl.java @@ -0,0 +1,77 @@ +package com.shanzhu.oe.serviceimpl; + +import com.shanzhu.oe.entity.JudgeQuestion; +import com.shanzhu.oe.mapper.JudgeQuestionMapper; +import com.shanzhu.oe.service.JudgeQuestionService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 判断题 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class JudgeQuestionServiceImpl implements JudgeQuestionService { + + private final JudgeQuestionMapper judgeQuestionMapper; + + /** + * 通过试卷id查询问题 + * + * @param paperId 试卷id + * @return 问题 + */ + @Override + public List findByIdAndType(Integer paperId) { + return judgeQuestionMapper.findByIdAndType(paperId); + } + + /** + * 查询最后一个判断题id + * + * @return 最后一个判断题 + */ + @Override + public JudgeQuestion findOnlyQuestionId() { + return judgeQuestionMapper.findOnlyQuestionId(); + } + + /** + * 添加判断题 + * + * @param judgeQuestion 判断题信息 + * @return 结果 + */ + @Override + public Integer add(JudgeQuestion judgeQuestion) { + return judgeQuestionMapper.add(judgeQuestion); + } + + /** + * + * 通过学科查询 + * @param subject 学科 + * @param pageNo 分页数 + * @return 题目id + */ + @Override + public List findBySubject(String subject, Integer pageNo) { + return judgeQuestionMapper.findBySubject(subject,pageNo); + } + + /** + * 编辑判断题 + * + * @param judgeQuestion 判断题 + * @return 结果 + */ + @Override + public Integer edit(JudgeQuestion judgeQuestion) { + return judgeQuestionMapper.edit(judgeQuestion); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/LoginServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/LoginServiceImpl.java new file mode 100644 index 0000000..3053acb --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/LoginServiceImpl.java @@ -0,0 +1,58 @@ +package com.shanzhu.oe.serviceimpl; + +import com.shanzhu.oe.entity.Admin; +import com.shanzhu.oe.entity.Student; +import com.shanzhu.oe.entity.Teacher; +import com.shanzhu.oe.mapper.LoginMapper; +import com.shanzhu.oe.service.LoginService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * 用户登录 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class LoginServiceImpl implements LoginService { + + private final LoginMapper loginMapper; + + /** + * 管理员用户登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + @Override + public Admin adminLogin(Integer username, String password) { + return loginMapper.adminLogin(username,password); + } + + /** + * 教师登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + @Override + public Teacher teacherLogin(Integer username, String password) { + return loginMapper.teacherLogin(username,password); + } + + /** + * 学生登录 + * + * @param username 用户名 + * @param password 密码 + * @return 登录用户信息 + */ + @Override + public Student studentLogin(Integer username, String password) { + return loginMapper.studentLogin(username,password); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/MessageServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/MessageServiceImpl.java new file mode 100644 index 0000000..a43bb7a --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/MessageServiceImpl.java @@ -0,0 +1,78 @@ +package com.shanzhu.oe.serviceimpl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Message; +import com.shanzhu.oe.mapper.MessageMapper; +import com.shanzhu.oe.service.MessageService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + + +/** + * 留言 控制层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class MessageServiceImpl implements MessageService { + + private final MessageMapper messageMapper; + + /** + * 留言查询 分页 + * + * @param page 分页内容 + * @return 留言数据 + */ + @Override + public IPage findPage(Page page) { + return messageMapper.findAll(page); + } + + /** + * 通过id查询留言 + * + * @param id 留言id + * @return 留言内容 + */ + @Override + public Message findById(Integer id) { + return messageMapper.findById(id); + } + + /** + * 删除留言 + * + * @param id 留言id + * @return 删除成功数量 + */ + @Override + public Integer delete(Integer id) { + return messageMapper.delete(id); + } + + /** + * 更新留言 + * + * @param message 留言信息 + * @return 结果 + */ + @Override + public Integer update(Message message) { + return messageMapper.update(message); + } + + /** + * 添加留言 + * + * @param message 留言信息 + * @return 结果 + */ + @Override + public Integer add(Message message) { + return messageMapper.add(message); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/MultiQuestionServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/MultiQuestionServiceImpl.java new file mode 100644 index 0000000..3a296c6 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/MultiQuestionServiceImpl.java @@ -0,0 +1,77 @@ +package com.shanzhu.oe.serviceimpl; + +import com.shanzhu.oe.entity.MultiQuestion; +import com.shanzhu.oe.mapper.MultiQuestionMapper; +import com.shanzhu.oe.service.MultiQuestionService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 选择题 服务层 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class MultiQuestionServiceImpl implements MultiQuestionService { + + private final MultiQuestionMapper multiQuestionMapper; + + /** + * 通过试卷id 查询试卷 + * + * @param paperId 试卷id + * @return 问题 + */ + @Override + public List findByIdAndType(Integer paperId) { + return multiQuestionMapper.findByIdAndType(paperId); + } + + /** + * 通过id查询选择题 + * + * @return 选择题 + */ + @Override + public MultiQuestion findOnlyQuestionId() { + return multiQuestionMapper.findOnlyQuestionId(); + } + + /** + * 添加选择题 + * + * @param multiQuestion 选择题信息 + * @return 结果 + */ + @Override + public Integer add(MultiQuestion multiQuestion) { + return multiQuestionMapper.add(multiQuestion); + } + + /** + * 通过学科查询 + * + * @param subject 学科 + * @param pageNo 分页数 + * @return 题目id + */ + @Override + public List findBySubject(String subject, Integer pageNo) { + return multiQuestionMapper.findBySubject(subject,pageNo); + } + + /** + * 编辑选择题 + * + * @param multiQuestion 选择题信息 + * @return 结果 + */ + @Override + public Integer edit(MultiQuestion multiQuestion) { + return multiQuestionMapper.edit(multiQuestion); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/PaperServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/PaperServiceImpl.java new file mode 100644 index 0000000..fbec813 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/PaperServiceImpl.java @@ -0,0 +1,80 @@ +package com.shanzhu.oe.serviceimpl; + +import com.shanzhu.oe.entity.FillQuestion; +import com.shanzhu.oe.entity.JudgeQuestion; +import com.shanzhu.oe.entity.MultiQuestion; +import com.shanzhu.oe.entity.PaperManage; +import com.shanzhu.oe.mapper.PaperMapper; +import com.shanzhu.oe.service.PaperService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 试卷 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class PaperServiceImpl implements PaperService { + + private final PaperMapper paperMapper; + + private final JudgeQuestionServiceImpl judgeQuestionService; + + private final MultiQuestionServiceImpl multiQuestionService; + + private final FillQuestionServiceImpl fillQuestionService; + + /** + * 查询所有试卷 + * + * @return 试卷 + */ + @Override + public List findAll() { + return paperMapper.findAll(); + } + + /** + * 添加试卷 + * + * @param paperManage 试卷信息 + * @return 结果 + */ + @Override + public Integer add(PaperManage paperManage) { + return paperMapper.add(paperManage); + } + + /** + * 获取试卷总分 + * + * @param paperId 试卷id + * @return 分数 + */ + @Override + public Integer getMaxScore(Integer paperId) { + + List multiQuestionRes = multiQuestionService.findByIdAndType(paperId); //选择题题库 1 + List fillQuestionsRes = fillQuestionService.findByIdAndType(paperId); //填空题题库 2 + List judgeQuestionRes = judgeQuestionService.findByIdAndType(paperId); //判断题题库 3 + return 2 * (multiQuestionRes.size() + fillQuestionsRes.size() + judgeQuestionRes.size()); + } + + /** + * 删除试卷中的某条试题 + * + * @param paperId 试卷id + * @param type 题目类型。1选择,2填空,3判断 + * @param questionId 题目id + */ + @Override + public void delete(String paperId, String type, String questionId) { + paperMapper.delete(paperId, type, questionId); + } + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ReplayServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ReplayServiceImpl.java new file mode 100644 index 0000000..be5b7c1 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ReplayServiceImpl.java @@ -0,0 +1,66 @@ +package com.shanzhu.oe.serviceimpl; + +import com.shanzhu.oe.entity.Replay; +import com.shanzhu.oe.mapper.ReplayMapper; +import com.shanzhu.oe.service.ReplayService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 回复 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class ReplayServiceImpl implements ReplayService { + + private final ReplayMapper replayMapper; + + /** + * 通过留言id查询回复 + * + * @param messageId 留言id + * @return 回复 + */ + @Override + public List findAllById(Integer messageId) { + return replayMapper.findAllById(messageId); + } + + /** + * 删除回复 + * + * @param replayId 回复id + * @return 结果 + */ + @Override + public Integer delete(Integer replayId) { + return replayMapper.delete(replayId); + } + + /** + * 更新回复 + * + * @param replay 回复内容 + * @return 结果 + */ + @Override + public Integer update(Replay replay) { + return replayMapper.update(replay); + } + + /** + * 添加回复 + * + * @param replay 回复内容 + * @return 结果 + */ + @Override + public Integer add(Replay replay) { + return replayMapper.add(replay); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ScoreServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ScoreServiceImpl.java new file mode 100644 index 0000000..c755238 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/ScoreServiceImpl.java @@ -0,0 +1,80 @@ +package com.shanzhu.oe.serviceimpl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Score; +import com.shanzhu.oe.mapper.ScoreMapper; +import com.shanzhu.oe.service.ScoreService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 分数 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class ScoreServiceImpl implements ScoreService { + + private final ScoreMapper scoreMapper; + + /** + * 添加学生成绩 + * + * @param score 学生成绩 + * @return 考试成绩 + */ + @Override + public Integer add(Score score) { + return scoreMapper.add(score); + } + + /** + * 查询所有考试成绩 + * + * @return 考试成绩 + */ + @Override + public List findAll() { + return scoreMapper.findAll(); + } + + /** + * 查询考试成绩 分页 + * + * @param page 分页对象 + * @param studentId 学生id + * @return 考试成绩 + */ + @Override + public IPage findById(Page page, Integer studentId) { + return scoreMapper.findById(page, studentId); + } + + /** + * 查询考试成绩 不分页 + * + * @param studentId 学生id + * @return 考试成绩 + */ + @Override + public List findById(Integer studentId) { + Page scorePage = new Page<>(0, 9999); + return scoreMapper.findById(scorePage, studentId).getRecords(); + } + + /** + * 通过考试编号 查询学生成绩 + * + * @param examCode 考试编号 + * @return 考试成绩 + */ + @Override + public List findByExamCode(Integer examCode) { + return scoreMapper.findByExamCode(examCode); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/StudentServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/StudentServiceImpl.java new file mode 100644 index 0000000..71aa313 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/StudentServiceImpl.java @@ -0,0 +1,103 @@ +package com.shanzhu.oe.serviceimpl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Student; +import com.shanzhu.oe.mapper.StudentMapper; +import com.shanzhu.oe.service.StudentService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * 学生 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class StudentServiceImpl implements StudentService { + + private final StudentMapper studentMapper; + + /** + * 查询学生 分页 + * + * @param page 分页对象 + * @param name 学生姓名 + * @param grade 班级 + * @param tel 电话 + * @param institute 学院 + * @param major 专业 + * @param clazz 班级 + * @return 学生列表 + */ + @Override + public IPage findAll( + Page page, String name, String grade, + String tel, String institute, String major, String clazz + ) { + name = ("@".equals(name) ? "" : name); + grade = ("@".equals(grade) ? "" : grade); + tel = ("@".equals(tel) ? "" : tel); + institute = ("@".equals(institute) ? "" : institute); + major = ("@".equals(major) ? "" : major); + clazz = ("@".equals(clazz) ? "" : clazz); + return studentMapper.findAll(page, name, grade, tel, institute, major, clazz); + } + + /** + * 通过学生id查询学生 + * + * @param studentId 学生id + * @return 学生 + */ + @Override + public Student findById(Integer studentId) { + return studentMapper.findById(studentId); + } + + /** + * 删除学生 + * + * @param studentId 学生id + * @return 结果 + */ + @Override + public Integer deleteById(Integer studentId) { + return studentMapper.deleteById(studentId); + } + + /** + * 更新学生 + * + * @param student 学生信息 + * @return 结果 + */ + @Override + public Integer update(Student student) { + return studentMapper.update(student); + } + + /** + * 添加学生 + * + * @param student 学生信息 + * @return 结果 + */ + @Override + public Integer add(Student student) { + return studentMapper.add(student); + } + + /** + * 更新密码 + * + * @param student 学生信息 + * @return 结果 + */ + @Override + public Integer updatePwd(Student student) { + return studentMapper.updatePwd(student); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/TeacherServiceImpl.java b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/TeacherServiceImpl.java new file mode 100644 index 0000000..64c858d --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/serviceimpl/TeacherServiceImpl.java @@ -0,0 +1,86 @@ +package com.shanzhu.oe.serviceimpl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.shanzhu.oe.entity.Teacher; +import com.shanzhu.oe.mapper.TeacherMapper; +import com.shanzhu.oe.service.TeacherService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 教师 服务层实现类 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Service +@RequiredArgsConstructor +public class TeacherServiceImpl implements TeacherService { + + private final TeacherMapper teacherMapper; + + /** + * 查询教师 分页 + * + * @param page 分页对象 + * @return 教师列表 + */ + @Override + public IPage findAll(Page page) { + return teacherMapper.findAll(page); + } + + @Override + public List findAll() { + Page teacherPage = new Page<>(0,9999); + return teacherMapper.findAll(teacherPage).getRecords(); + } + + /** + * 通过教师id查询 + * + * @param teacherId 教师id + * @return 教师 + */ + @Override + public Teacher findById(Integer teacherId) { + return teacherMapper.findById(teacherId); + } + + /** + * 删除教师 + * + * @param teacherId 教师id + * @return 结果 + */ + @Override + public Integer deleteById(Integer teacherId) { + return teacherMapper.deleteById(teacherId); + } + + /** + * 更新教师 + * + * @param teacher 教师信息 + * @return 结果 + */ + @Override + public Integer update(Teacher teacher) { + return teacherMapper.update(teacher); + } + + /** + * 添加教师 + * + * @param teacher 教师信息 + * @return 结果 + */ + @Override + public Integer add(Teacher teacher) { + teacher.setRole("1"); + return teacherMapper.add(teacher); + } +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/util/ApiResultHandler.java b/online-exam-backend/src/main/java/com/shanzhu/oe/util/ApiResultHandler.java new file mode 100644 index 0000000..f3785a8 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/util/ApiResultHandler.java @@ -0,0 +1,33 @@ +package com.shanzhu.oe.util; + +import com.shanzhu.oe.common.R; + +/** + * 对象 {@link R} 数据处理工具 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +public class ApiResultHandler { + + public static R success(Object object) { + R r = new R(); + r.setData(object); + r.setCode(200); + r.setMessage("请求成功"); + return r; + } + + public static R success() { + return success(null); + } + + public static R buildApiResult(Integer code, String message, T data) { + R r = new R(); + r.setCode(code); + r.setMessage(message); + r.setData(data); + return r; + } + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/vo/AnswerVO.java b/online-exam-backend/src/main/java/com/shanzhu/oe/vo/AnswerVO.java new file mode 100644 index 0000000..992b25d --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/vo/AnswerVO.java @@ -0,0 +1,51 @@ +package com.shanzhu.oe.vo; + +import lombok.Data; + + +/** + * 题库 接口返回对象 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class AnswerVO { + + /** + * 题目id + */ + private Long questionId; + + /** + * 题目 + */ + private String question; + + /** + * 科目 + */ + private String subject; + + /** + * 分数 + */ + private String score; + + /** + * 章节 + */ + private String section; + + /** + * 难度等级 + */ + private String level; + + /** + * 类型 + */ + private String type; + + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/vo/Item.java b/online-exam-backend/src/main/java/com/shanzhu/oe/vo/Item.java new file mode 100644 index 0000000..9d6b321 --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/vo/Item.java @@ -0,0 +1,39 @@ +package com.shanzhu.oe.vo; + +import lombok.Data; + +/** + * 组卷 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class Item { + + /** + * 科目 + */ + private String subject; + + /** + * 试卷编号 + */ + private Integer paperId; + + /** + * 选择题数量 + */ + private Integer changeNumber; + + /** + * 填空题数量 + */ + private Integer fillNumber; + + /** + * 判断题数量 + */ + private Integer judgeNumber; + +} diff --git a/online-exam-backend/src/main/java/com/shanzhu/oe/vo/QuestionVO.java b/online-exam-backend/src/main/java/com/shanzhu/oe/vo/QuestionVO.java new file mode 100644 index 0000000..99ebf8b --- /dev/null +++ b/online-exam-backend/src/main/java/com/shanzhu/oe/vo/QuestionVO.java @@ -0,0 +1,37 @@ +package com.shanzhu.oe.vo; + +import com.shanzhu.oe.entity.FillQuestion; +import com.shanzhu.oe.entity.JudgeQuestion; +import com.shanzhu.oe.entity.MultiQuestion; +import lombok.Data; + +/** + * 题目 接口返回对象 + * + * @author: ShanZhu + * @date: 2023-11-20 + */ +@Data +public class QuestionVO { + + /** + * 题目类型 + */ + private String type; + + /** + * 填空题 + */ + private FillQuestion fillQuestion; + + /** + * 判断题 + */ + private JudgeQuestion judgeQuestion; + + /** + * 选择题 + */ + private MultiQuestion multiQuestion; + +} diff --git a/online-exam-backend/src/main/resources/application.yml b/online-exam-backend/src/main/resources/application.yml new file mode 100644 index 0000000..a9ab9fd --- /dev/null +++ b/online-exam-backend/src/main/resources/application.yml @@ -0,0 +1,31 @@ +# YML是一种文件格式,全称为YAML(YAML Ain't Markup Language),SpringBoot通常使用YML作为项目配置。 +# 它是一种人类可读的、简洁明了的数据序列化格式。YAML文件格式通常用于配置文件、数据交换、消息传递和其他应用程序。 +# 可以通过文本编辑器进行编辑,也可以通过程序进行解析。YML文件格式是一种以层级缩进的方式表示程序数据结构的格式。 +# 在数据表示方面比XML等格式更加简洁清晰易读。YML文件格式通常以“.yml”为扩展名。 + +# 服务端口 +server: + port: 8087 + +# Spring配置 +spring: + + # 数据库配置 + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://localhost:3306/DB_OnlineExam?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true +# username: root +# password: 12345678 + # 线上库 + url: jdbc:mysql://124.223.95.146:3306/DB_OnlineExam?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true + username: root + password: f048fac128243533 +#mybatis配置 +mybatis: + configuration: + mapUnderscoreToCamelCase: true + +#mybatis-plus配置 +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl diff --git a/online-exam-backend/src/main/resources/banner.txt b/online-exam-backend/src/main/resources/banner.txt new file mode 100644 index 0000000..b983864 --- /dev/null +++ b/online-exam-backend/src/main/resources/banner.txt @@ -0,0 +1,8 @@ + ████████ ██ ████████ ██ + ██░░░░░░ ░██ ░░░░░░██ ░██ +░██ ░██ ██████ ███████ ██ ░██ ██ ██ +░█████████░██████ ░░░░░░██ ░░██░░░██ ██ ░██████ ░██ ░██ +░░░░░░░░██░██░░░██ ███████ ░██ ░██ ██ ░██░░░██░██ ░██ + ░██░██ ░██ ██░░░░██ ░██ ░██ ██ ░██ ░██░██ ░██ + ████████ ░██ ░██░░████████ ███ ░██ ████████░██ ░██░░██████ +░░░░░░░░ ░░ ░░ ░░░░░░░░ ░░░ ░░ ░░░░░░░░ ░░ ░░ ░░░░░░ \ No newline at end of file diff --git a/online-exam-frontend/.babelrc b/online-exam-frontend/.babelrc new file mode 100644 index 0000000..3a280ba --- /dev/null +++ b/online-exam-frontend/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + ["env", { + "modules": false, + "targets": { + "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] + } + }], + "stage-2" + ], + "plugins": ["transform-vue-jsx", "transform-runtime"] +} diff --git a/online-exam-frontend/.editorconfig b/online-exam-frontend/.editorconfig new file mode 100644 index 0000000..9d08a1a --- /dev/null +++ b/online-exam-frontend/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/online-exam-frontend/.gitignore b/online-exam-frontend/.gitignore new file mode 100644 index 0000000..3dfac44 --- /dev/null +++ b/online-exam-frontend/.gitignore @@ -0,0 +1,25 @@ +.DS_Store +node_modules +/dist + + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Editor directories and files` + ` + +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/online-exam-frontend/.npmrc b/online-exam-frontend/.npmrc new file mode 100644 index 0000000..a6ef790 --- /dev/null +++ b/online-exam-frontend/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npm.taobao.org/ diff --git a/online-exam-frontend/.postcssrc.js b/online-exam-frontend/.postcssrc.js new file mode 100644 index 0000000..eee3e92 --- /dev/null +++ b/online-exam-frontend/.postcssrc.js @@ -0,0 +1,10 @@ +// https://github.com/michael-ciniawsky/postcss-load-config + +module.exports = { + "plugins": { + "postcss-import": {}, + "postcss-url": {}, + // to edit target browsers: use "browserslist" field in package.json + "autoprefixer": {} + } +} diff --git a/online-exam-frontend/README.md b/online-exam-frontend/README.md new file mode 100644 index 0000000..f691033 --- /dev/null +++ b/online-exam-frontend/README.md @@ -0,0 +1,12 @@ +# 项目介绍及启动说明 + +### 启动项目 +``` bash +# 切换镜像 +npm config set registry https://registry.npm.taobao.org + +# 安装依赖,对应node的版本是16.13.2 +npm install --force + +# 启动项目 +npm run dev diff --git a/online-exam-frontend/build/build.js b/online-exam-frontend/build/build.js new file mode 100644 index 0000000..8f2ad8a --- /dev/null +++ b/online-exam-frontend/build/build.js @@ -0,0 +1,41 @@ +'use strict' +require('./check-versions')() + +process.env.NODE_ENV = 'production' + +const ora = require('ora') +const rm = require('rimraf') +const path = require('path') +const chalk = require('chalk') +const webpack = require('webpack') +const config = require('../config') +const webpackConfig = require('./webpack.prod.conf') + +const spinner = ora('building for production...') +spinner.start() + +rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { + if (err) throw err + webpack(webpackConfig, (err, stats) => { + spinner.stop() + if (err) throw err + process.stdout.write(stats.toString({ + colors: true, + modules: false, + children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build. + chunks: false, + chunkModules: false + }) + '\n\n') + + if (stats.hasErrors()) { + console.log(chalk.red(' Build failed with errors.\n')) + process.exit(1) + } + + console.log(chalk.cyan(' Build complete.\n')) + console.log(chalk.yellow( + ' Tip: built files are meant to be served over an HTTP server.\n' + + ' Opening index.html over file:// won\'t work.\n' + )) + }) +}) diff --git a/online-exam-frontend/build/check-versions.js b/online-exam-frontend/build/check-versions.js new file mode 100644 index 0000000..3ef972a --- /dev/null +++ b/online-exam-frontend/build/check-versions.js @@ -0,0 +1,54 @@ +'use strict' +const chalk = require('chalk') +const semver = require('semver') +const packageConfig = require('../package.json') +const shell = require('shelljs') + +function exec (cmd) { + return require('child_process').execSync(cmd).toString().trim() +} + +const versionRequirements = [ + { + name: 'node', + currentVersion: semver.clean(process.version), + versionRequirement: packageConfig.engines.node + } +] + +if (shell.which('npm')) { + versionRequirements.push({ + name: 'npm', + currentVersion: exec('npm --version'), + versionRequirement: packageConfig.engines.npm + }) +} + +module.exports = function () { + const warnings = [] + + for (let i = 0; i < versionRequirements.length; i++) { + const mod = versionRequirements[i] + + if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { + warnings.push(mod.name + ': ' + + chalk.red(mod.currentVersion) + ' should be ' + + chalk.green(mod.versionRequirement) + ) + } + } + + if (warnings.length) { + console.log('') + console.log(chalk.yellow('To use this template, you must update following to modules:')) + console.log() + + for (let i = 0; i < warnings.length; i++) { + const warning = warnings[i] + console.log(' ' + warning) + } + + console.log() + process.exit(1) + } +} diff --git a/online-exam-frontend/build/logo.png b/online-exam-frontend/build/logo.png new file mode 100644 index 0000000..4356b65 Binary files /dev/null and b/online-exam-frontend/build/logo.png differ diff --git a/online-exam-frontend/build/utils.js b/online-exam-frontend/build/utils.js new file mode 100644 index 0000000..a873f7d --- /dev/null +++ b/online-exam-frontend/build/utils.js @@ -0,0 +1,99 @@ +'use strict' +const path = require('path') +const config = require('../config') +const ExtractTextPlugin = require('extract-text-webpack-plugin') +const packageConfig = require('../package.json') + +exports.assetsPath = function (_path) { + const assetsSubDirectory = process.env.NODE_ENV === 'production' + ? config.build.assetsSubDirectory + : config.dev.assetsSubDirectory + + return path.posix.join(assetsSubDirectory, _path) +} + +exports.cssLoaders = function (options) { + options = options || {} + + const cssLoader = { + loader: 'css-loader', + options: { + sourceMap: options.sourceMap + } + } + + const postcssLoader = { + loader: 'postcss-loader', + options: { + sourceMap: options.sourceMap + } + } + + // generate loader string to be used with extract text plugin + function generateLoaders (loader, loaderOptions) { + const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] + + if (loader) { + loaders.push({ + loader: loader + '-loader', + options: Object.assign({}, loaderOptions, { + sourceMap: options.sourceMap + }) + }) + } + + // Extract CSS when that option is specified + // (which is the case during production build) + if (options.extract) { + return ExtractTextPlugin.extract({ + use: loaders, + fallback: 'vue-style-loader' + }) + } else { + return ['vue-style-loader'].concat(loaders) + } + } + + // https://vue-loader.vuejs.org/en/configurations/extract-css.html + return { + css: generateLoaders(), + postcss: generateLoaders(), + less: generateLoaders('less'), + stylus: generateLoaders('stylus'), + styl: generateLoaders('stylus') + } +} + +// Generate loaders for standalone style files (outside of .vue) +exports.styleLoaders = function (options) { + const output = [] + const loaders = exports.cssLoaders(options) + + for (const extension in loaders) { + const loader = loaders[extension] + output.push({ + test: new RegExp('\\.' + extension + '$'), + use: loader + }) + } + + return output +} + +exports.createNotifierCallback = () => { + const notifier = require('node-notifier') + + return (severity, errors) => { + if (severity !== 'error') return + + const error = errors[0] + const filename = error.file && error.file.split('!').pop() + + notifier.notify({ + title: packageConfig.name, + message: severity + ': ' + error.name, + subtitle: filename || '', + icon: path.join(__dirname, 'logo.png') + }) + } +} diff --git a/online-exam-frontend/build/vue-loader.conf.js b/online-exam-frontend/build/vue-loader.conf.js new file mode 100644 index 0000000..33ed58b --- /dev/null +++ b/online-exam-frontend/build/vue-loader.conf.js @@ -0,0 +1,22 @@ +'use strict' +const utils = require('./utils') +const config = require('../config') +const isProduction = process.env.NODE_ENV === 'production' +const sourceMapEnabled = isProduction + ? config.build.productionSourceMap + : config.dev.cssSourceMap + +module.exports = { + loaders: utils.cssLoaders({ + sourceMap: sourceMapEnabled, + extract: isProduction + }), + cssSourceMap: sourceMapEnabled, + cacheBusting: config.dev.cacheBusting, + transformToRequire: { + video: ['src', 'poster'], + source: 'src', + img: 'src', + image: 'xlink:href' + } +} diff --git a/online-exam-frontend/build/webpack.base.conf.js b/online-exam-frontend/build/webpack.base.conf.js new file mode 100644 index 0000000..e1cb26a --- /dev/null +++ b/online-exam-frontend/build/webpack.base.conf.js @@ -0,0 +1,99 @@ +'use strict' +const path = require('path') +const utils = require('./utils') +const config = require('../config') +const vueLoaderConfig = require('./vue-loader.conf') + +function resolve (dir) { + return path.join(__dirname, '..', dir) +} + + + +module.exports = { + context: path.resolve(__dirname, '../'), + entry: { + app: './src/main.js' + }, + output: { + path: config.build.assetsRoot, + filename: '[name].js', + publicPath: process.env.NODE_ENV === 'production' + ? config.build.assetsPublicPath + : config.dev.assetsPublicPath + }, + resolve: { + extensions: ['.js', '.vue', '.json'], + alias: { + 'vue$': 'vue/dist/vue.esm.js', + '@': resolve('src'), + } + }, + module: { + rules: [ + { + test: /\.less$/, + loader: "style-loader!css-loader!less-loader" + }, + { + test: /\.vue$/, + loader: 'vue-loader', + options: vueLoaderConfig + }, + { + test: /\.js$/, + loader: 'babel-loader', + include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] + }, + { + test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, + loader: 'url-loader', + options: { + limit: 10000, + name: utils.assetsPath('img/[name].[hash:7].[ext]') + } + }, + { + test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, + loader: 'url-loader', + options: { + limit: 10000, + name: utils.assetsPath('media/[name].[hash:7].[ext]') + } + }, + { + test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, + loader: 'url-loader', + options: { + limit: 10000, + name: utils.assetsPath('fonts/[name].[hash:7].[ext]') + } + }, + // { + // test: /node_modules[\\\/]vis[\\\/].*\.js$/, + // loader: 'babel-loader', + // query: { + // cacheDirectory: true, + // presets: [ "babel-preset-es2015" ].map(require.resolve), + // plugins: [ + // "transform-es3-property-literals", // #2452 + // "transform-es3-member-expression-literals", // #2566 + // "transform-runtime" // #2566 + // ] + // } + // } + ] + }, + node: { + // prevent webpack from injecting useless setImmediate polyfill because Vue + // source contains it (although only uses it if it's native). + setImmediate: false, + // prevent webpack from injecting mocks to Node native modules + // that does not make sense for the client + dgram: 'empty', + fs: 'empty', + net: 'empty', + tls: 'empty', + child_process: 'empty' + } +} diff --git a/online-exam-frontend/build/webpack.dev.conf.js b/online-exam-frontend/build/webpack.dev.conf.js new file mode 100644 index 0000000..070ae22 --- /dev/null +++ b/online-exam-frontend/build/webpack.dev.conf.js @@ -0,0 +1,95 @@ +'use strict' +const utils = require('./utils') +const webpack = require('webpack') +const config = require('../config') +const merge = require('webpack-merge') +const path = require('path') +const baseWebpackConfig = require('./webpack.base.conf') +const CopyWebpackPlugin = require('copy-webpack-plugin') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') +const portfinder = require('portfinder') + +const HOST = process.env.HOST +const PORT = process.env.PORT && Number(process.env.PORT) + +const devWebpackConfig = merge(baseWebpackConfig, { + module: { + rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) + }, + // cheap-module-eval-source-map is faster for development + devtool: config.dev.devtool, + + // these devServer options should be customized in /config/index.js + devServer: { + clientLogLevel: 'warning', + historyApiFallback: { + rewrites: [ + { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }, + ], + }, + hot: true, + contentBase: false, // since we use CopyWebpackPlugin. + compress: true, + host: HOST || config.dev.host, + port: PORT || config.dev.port, + open: config.dev.autoOpenBrowser, + overlay: config.dev.errorOverlay + ? { warnings: false, errors: true } + : false, + publicPath: config.dev.assetsPublicPath, + proxy: config.dev.proxyTable, + quiet: true, // necessary for FriendlyErrorsPlugin + watchOptions: { + poll: config.dev.poll, + } + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': require('../config/dev.env') + }), + new webpack.HotModuleReplacementPlugin(), + new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. + new webpack.NoEmitOnErrorsPlugin(), + // https://github.com/ampedandwired/html-webpack-plugin + new HtmlWebpackPlugin({ + filename: 'index.html', + template: 'index.html', + inject: true + }), + // copy custom static assets + new CopyWebpackPlugin([ + { + from: path.resolve(__dirname, '../static'), + to: config.dev.assetsSubDirectory, + ignore: ['.*'] + } + ]) + ] +}) + +module.exports = new Promise((resolve, reject) => { + portfinder.basePort = process.env.PORT || config.dev.port + portfinder.getPort((err, port) => { + if (err) { + reject(err) + } else { + // publish the new Port, necessary for e2e tests + process.env.PORT = port + // add port to devServer config + devWebpackConfig.devServer.port = port + + // Add FriendlyErrorsPlugin + devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ + compilationSuccessInfo: { + messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], + }, + onErrors: config.dev.notifyOnErrors + ? utils.createNotifierCallback() + : undefined + })) + + resolve(devWebpackConfig) + } + }) +}) diff --git a/online-exam-frontend/build/webpack.prod.conf.js b/online-exam-frontend/build/webpack.prod.conf.js new file mode 100644 index 0000000..d9f99f6 --- /dev/null +++ b/online-exam-frontend/build/webpack.prod.conf.js @@ -0,0 +1,145 @@ +'use strict' +const path = require('path') +const utils = require('./utils') +const webpack = require('webpack') +const config = require('../config') +const merge = require('webpack-merge') +const baseWebpackConfig = require('./webpack.base.conf') +const CopyWebpackPlugin = require('copy-webpack-plugin') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const ExtractTextPlugin = require('extract-text-webpack-plugin') +const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') +const UglifyJsPlugin = require('uglifyjs-webpack-plugin') + +const env = require('../config/prod.env') + +const webpackConfig = merge(baseWebpackConfig, { + module: { + rules: utils.styleLoaders({ + sourceMap: config.build.productionSourceMap, + extract: true, + usePostCSS: true + }) + }, + devtool: config.build.productionSourceMap ? config.build.devtool : false, + output: { + path: config.build.assetsRoot, + filename: utils.assetsPath('js/[name].[chunkhash].js'), + chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') + }, + plugins: [ + // http://vuejs.github.io/vue-loader/en/workflow/production.html + new webpack.DefinePlugin({ + 'process.env': env + }), + new UglifyJsPlugin({ + uglifyOptions: { + compress: { + warnings: false + } + }, + sourceMap: config.build.productionSourceMap, + parallel: true + }), + // extract css into its own file + new ExtractTextPlugin({ + filename: utils.assetsPath('css/[name].[contenthash].css'), + // Setting the following option to `false` will not extract CSS from codesplit chunks. + // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. + // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, + // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 + allChunks: true, + }), + // Compress extracted CSS. We are using this plugin so that possible + // duplicated CSS from different components can be deduped. + new OptimizeCSSPlugin({ + cssProcessorOptions: config.build.productionSourceMap + ? { safe: true, map: { inline: false } } + : { safe: true } + }), + // generate dist index.html with correct asset hash for caching. + // you can customize output by editing /index.html + // see https://github.com/ampedandwired/html-webpack-plugin + new HtmlWebpackPlugin({ + filename: config.build.index, + template: 'index.html', + inject: true, + minify: { + removeComments: true, + collapseWhitespace: true, + removeAttributeQuotes: true + // more options: + // https://github.com/kangax/html-minifier#options-quick-reference + }, + // necessary to consistently work with multiple chunks via CommonsChunkPlugin + chunksSortMode: 'dependency' + }), + // keep module.id stable when vendor modules does not change + new webpack.HashedModuleIdsPlugin(), + // enable scope hoisting + new webpack.optimize.ModuleConcatenationPlugin(), + // split vendor js into its own file + new webpack.optimize.CommonsChunkPlugin({ + name: 'vendor', + minChunks (module) { + // any required modules inside node_modules are extracted to vendor + return ( + module.resource && + /\.js$/.test(module.resource) && + module.resource.indexOf( + path.join(__dirname, '../node_modules') + ) === 0 + ) + } + }), + // extract webpack runtime and module manifest to its own file in order to + // prevent vendor hash from being updated whenever app bundle is updated + new webpack.optimize.CommonsChunkPlugin({ + name: 'manifest', + minChunks: Infinity + }), + // This instance extracts shared chunks from code splitted chunks and bundles them + // in a separate chunk, similar to the vendor chunk + // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk + new webpack.optimize.CommonsChunkPlugin({ + name: 'app', + async: 'vendor-async', + children: true, + minChunks: 3 + }), + + // copy custom static assets + new CopyWebpackPlugin([ + { + from: path.resolve(__dirname, '../static'), + to: config.build.assetsSubDirectory, + ignore: ['.*'] + } + ]) + ] +}) + +if (config.build.productionGzip) { + const CompressionWebpackPlugin = require('compression-webpack-plugin') + + webpackConfig.plugins.push( + new CompressionWebpackPlugin({ + asset: '[path].gz[query]', + algorithm: 'gzip', + test: new RegExp( + '\\.(' + + config.build.productionGzipExtensions.join('|') + + ')$' + ), + threshold: 10240, + minRatio: 0.8 + }) + ) +} + +if (config.build.bundleAnalyzerReport) { + const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin + webpackConfig.plugins.push(new BundleAnalyzerPlugin()) +} + +module.exports = webpackConfig diff --git a/online-exam-frontend/config/dev.env.js b/online-exam-frontend/config/dev.env.js new file mode 100644 index 0000000..1e22973 --- /dev/null +++ b/online-exam-frontend/config/dev.env.js @@ -0,0 +1,7 @@ +'use strict' +const merge = require('webpack-merge') +const prodEnv = require('./prod.env') + +module.exports = merge(prodEnv, { + NODE_ENV: '"development"' +}) diff --git a/online-exam-frontend/config/index.js b/online-exam-frontend/config/index.js new file mode 100644 index 0000000..463630c --- /dev/null +++ b/online-exam-frontend/config/index.js @@ -0,0 +1,54 @@ +/* + * index + * + * @Author: ShanZhu + * @Date: 2023-11-23 + */ +'use strict' +const path = require('path') + +module.exports = { + dev: { + + // Paths + assetsSubDirectory: 'static', + assetsPublicPath: '/', + proxyTable: { + '/api': { + target: 'http://localhost:8087',//本地地址 + changeOrigin: true, + pathRewrite: { + '^/api': ''//这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可 + } + } + }, + + host: 'localhost', + port: 8088, + autoOpenBrowser: false, + errorOverlay: true, + notifyOnErrors: true, + poll: false, + devtool: 'cheap-module-eval-source-map', + cacheBusting: true, + cssSourceMap: true + }, + + build: { + index: path.resolve(__dirname, '../dist/index.html'), + + // Paths + assetsRoot: path.resolve(__dirname, '../dist'), + assetsSubDirectory: 'static', + assetsPublicPath: '/', + + + productionSourceMap: true, + // https://webpack.js.org/configuration/devtool/#production + devtool: '#source-map', + + productionGzip: false, + productionGzipExtensions: ['js', 'css'], + bundleAnalyzerReport: process.env.npm_config_report + } +} diff --git a/online-exam-frontend/config/prod.env.js b/online-exam-frontend/config/prod.env.js new file mode 100644 index 0000000..a6f9976 --- /dev/null +++ b/online-exam-frontend/config/prod.env.js @@ -0,0 +1,4 @@ +'use strict' +module.exports = { + NODE_ENV: '"production"' +} diff --git a/online-exam-frontend/index.html b/online-exam-frontend/index.html new file mode 100644 index 0000000..c5af441 --- /dev/null +++ b/online-exam-frontend/index.html @@ -0,0 +1,15 @@ + + + + + + + 在线考试系统 + + + + +
+ + + diff --git a/online-exam-frontend/package.json b/online-exam-frontend/package.json new file mode 100644 index 0000000..3a61963 --- /dev/null +++ b/online-exam-frontend/package.json @@ -0,0 +1,75 @@ +{ + "name": "vue-init", + "version": "1.0.0", + "description": "vue demo", + "author": "", + "private": true, + "scripts": { + "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", + "start": "npm run dev", + "build": "node build/build.js" + }, + "dependencies": { + "@babel/preset-es2015": "^7.0.0-beta.53", + "axios": "^0.18.0", + "echarts": "^4.2.0-rc.2", + "element-ui": "^2.4.11", + "global": "^4.4.0", + "vis": "^4.21.0", + "vue": "^2.5.2", + "vue-cookies": "^1.5.12", + "vue-router": "^3.0.1", + "vuex": "^3.0.1", + "vuex-persistedstate": "^2.5.4" + }, + "devDependencies": { + "less": "^4.1.3", + "less-loader": "5.0.0", + "@babel/core": "^7.2.2", + "@babel/preset-env": "^7.2.3", + "autoprefixer": "^7.1.2", + "babel-core": "^6.22.1", + "babel-helper-vue-jsx-merge-props": "^2.0.3", + "babel-loader": "^7.1.5", + "babel-plugin-syntax-jsx": "^6.18.0", + "babel-plugin-transform-runtime": "^6.22.0", + "babel-plugin-transform-vue-jsx": "^3.5.0", + "babel-preset-env": "^1.3.2", + "babel-preset-stage-2": "^6.22.0", + "chalk": "^2.0.1", + "copy-webpack-plugin": "^4.0.1", + "css-loader": "^0.28.0", + "extract-text-webpack-plugin": "^3.0.0", + "file-loader": "^1.1.4", + "friendly-errors-webpack-plugin": "^1.6.1", + "html-webpack-plugin": "^2.30.1", + "node-notifier": "^5.1.2", + "optimize-css-assets-webpack-plugin": "^3.2.0", + "ora": "^1.2.0", + "portfinder": "^1.0.13", + "postcss-import": "^11.0.0", + "postcss-loader": "^2.0.8", + "postcss-url": "^7.2.1", + "rimraf": "^2.6.0", + "semver": "^5.3.0", + "shelljs": "^0.7.6", + "uglifyjs-webpack-plugin": "^1.1.1", + "url-loader": "^0.5.8", + "vue-loader": "^13.3.0", + "vue-style-loader": "^3.0.1", + "vue-template-compiler": "^2.5.2", + "webpack": "^3.12.0", + "webpack-bundle-analyzer": "^2.9.0", + "webpack-dev-server": "^2.9.1", + "webpack-merge": "^4.1.0" + }, + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 8" + ] +} diff --git a/online-exam-frontend/src/App.vue b/online-exam-frontend/src/App.vue new file mode 100644 index 0000000..e8f8c70 --- /dev/null +++ b/online-exam-frontend/src/App.vue @@ -0,0 +1,41 @@ + + + + + + diff --git a/online-exam-frontend/src/assets/homepage.png b/online-exam-frontend/src/assets/homepage.png new file mode 100644 index 0000000..643ff6f Binary files /dev/null and b/online-exam-frontend/src/assets/homepage.png differ diff --git a/online-exam-frontend/src/assets/img/evening.png b/online-exam-frontend/src/assets/img/evening.png new file mode 100644 index 0000000..4645b0d Binary files /dev/null and b/online-exam-frontend/src/assets/img/evening.png differ diff --git a/online-exam-frontend/src/assets/img/icon.png b/online-exam-frontend/src/assets/img/icon.png new file mode 100644 index 0000000..4356b65 Binary files /dev/null and b/online-exam-frontend/src/assets/img/icon.png differ diff --git a/online-exam-frontend/src/assets/img/loginbg.png b/online-exam-frontend/src/assets/img/loginbg.png new file mode 100644 index 0000000..2af181d Binary files /dev/null and b/online-exam-frontend/src/assets/img/loginbg.png differ diff --git a/online-exam-frontend/src/assets/img/loginicon.png b/online-exam-frontend/src/assets/img/loginicon.png new file mode 100644 index 0000000..2d0fcae Binary files /dev/null and b/online-exam-frontend/src/assets/img/loginicon.png differ diff --git a/online-exam-frontend/src/assets/img/userimg.png b/online-exam-frontend/src/assets/img/userimg.png new file mode 100644 index 0000000..2d0fcae Binary files /dev/null and b/online-exam-frontend/src/assets/img/userimg.png differ diff --git a/online-exam-frontend/src/assets/logo.png b/online-exam-frontend/src/assets/logo.png new file mode 100644 index 0000000..4356b65 Binary files /dev/null and b/online-exam-frontend/src/assets/logo.png differ diff --git a/online-exam-frontend/src/components/admin/addTeacher.vue b/online-exam-frontend/src/components/admin/addTeacher.vue new file mode 100644 index 0000000..bef28bc --- /dev/null +++ b/online-exam-frontend/src/components/admin/addTeacher.vue @@ -0,0 +1,89 @@ + + + + + + diff --git a/online-exam-frontend/src/components/admin/index.vue b/online-exam-frontend/src/components/admin/index.vue new file mode 100644 index 0000000..c052f17 --- /dev/null +++ b/online-exam-frontend/src/components/admin/index.vue @@ -0,0 +1,58 @@ + + + + + + + diff --git a/online-exam-frontend/src/components/admin/tacherManage.vue b/online-exam-frontend/src/components/admin/tacherManage.vue new file mode 100644 index 0000000..c2764bb --- /dev/null +++ b/online-exam-frontend/src/components/admin/tacherManage.vue @@ -0,0 +1,180 @@ + + + + + diff --git a/online-exam-frontend/src/components/charts/grade.vue b/online-exam-frontend/src/components/charts/grade.vue new file mode 100644 index 0000000..7af6a9b --- /dev/null +++ b/online-exam-frontend/src/components/charts/grade.vue @@ -0,0 +1,99 @@ + + + + + + diff --git a/online-exam-frontend/src/components/charts/scorePart.vue b/online-exam-frontend/src/components/charts/scorePart.vue new file mode 100644 index 0000000..97503d6 --- /dev/null +++ b/online-exam-frontend/src/components/charts/scorePart.vue @@ -0,0 +1,122 @@ + + + + + + + + diff --git a/online-exam-frontend/src/components/common/header.vue b/online-exam-frontend/src/components/common/header.vue new file mode 100644 index 0000000..d882683 --- /dev/null +++ b/online-exam-frontend/src/components/common/header.vue @@ -0,0 +1,234 @@ + + + + + + diff --git a/online-exam-frontend/src/components/common/hello.vue b/online-exam-frontend/src/components/common/hello.vue new file mode 100644 index 0000000..8739665 --- /dev/null +++ b/online-exam-frontend/src/components/common/hello.vue @@ -0,0 +1,84 @@ + + + + + + + + diff --git a/online-exam-frontend/src/components/common/login.vue b/online-exam-frontend/src/components/common/login.vue new file mode 100644 index 0000000..f99a044 --- /dev/null +++ b/online-exam-frontend/src/components/common/login.vue @@ -0,0 +1,226 @@ + + + + + + diff --git a/online-exam-frontend/src/components/common/mainLeft.vue b/online-exam-frontend/src/components/common/mainLeft.vue new file mode 100644 index 0000000..baecb87 --- /dev/null +++ b/online-exam-frontend/src/components/common/mainLeft.vue @@ -0,0 +1,109 @@ + + + + + + diff --git a/online-exam-frontend/src/components/common/mainTop.vue b/online-exam-frontend/src/components/common/mainTop.vue new file mode 100644 index 0000000..04dbbfc --- /dev/null +++ b/online-exam-frontend/src/components/common/mainTop.vue @@ -0,0 +1,11 @@ + + diff --git a/online-exam-frontend/src/components/common/navigator.vue b/online-exam-frontend/src/components/common/navigator.vue new file mode 100644 index 0000000..dbf6e77 --- /dev/null +++ b/online-exam-frontend/src/components/common/navigator.vue @@ -0,0 +1,55 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/answer.vue b/online-exam-frontend/src/components/student/answer.vue new file mode 100644 index 0000000..5701f3e --- /dev/null +++ b/online-exam-frontend/src/components/student/answer.vue @@ -0,0 +1,956 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/answerScore.vue b/online-exam-frontend/src/components/student/answerScore.vue new file mode 100644 index 0000000..ed9551f --- /dev/null +++ b/online-exam-frontend/src/components/student/answerScore.vue @@ -0,0 +1,170 @@ + + + + + + + diff --git a/online-exam-frontend/src/components/student/examMsg.vue b/online-exam-frontend/src/components/student/examMsg.vue new file mode 100644 index 0000000..931809b --- /dev/null +++ b/online-exam-frontend/src/components/student/examMsg.vue @@ -0,0 +1,274 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/index.vue b/online-exam-frontend/src/components/student/index.vue new file mode 100644 index 0000000..753ac5f --- /dev/null +++ b/online-exam-frontend/src/components/student/index.vue @@ -0,0 +1,152 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/manager.vue b/online-exam-frontend/src/components/student/manager.vue new file mode 100644 index 0000000..5f2baaf --- /dev/null +++ b/online-exam-frontend/src/components/student/manager.vue @@ -0,0 +1,111 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/message.vue b/online-exam-frontend/src/components/student/message.vue new file mode 100644 index 0000000..5762544 --- /dev/null +++ b/online-exam-frontend/src/components/student/message.vue @@ -0,0 +1,264 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/myExam.vue b/online-exam-frontend/src/components/student/myExam.vue new file mode 100644 index 0000000..16de009 --- /dev/null +++ b/online-exam-frontend/src/components/student/myExam.vue @@ -0,0 +1,218 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/myFooter.vue b/online-exam-frontend/src/components/student/myFooter.vue new file mode 100644 index 0000000..be7f22d --- /dev/null +++ b/online-exam-frontend/src/components/student/myFooter.vue @@ -0,0 +1,45 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/scoreTable.vue b/online-exam-frontend/src/components/student/scoreTable.vue new file mode 100644 index 0000000..509321a --- /dev/null +++ b/online-exam-frontend/src/components/student/scoreTable.vue @@ -0,0 +1,132 @@ + + + + + + diff --git a/online-exam-frontend/src/components/student/startExam.vue b/online-exam-frontend/src/components/student/startExam.vue new file mode 100644 index 0000000..19a0d46 --- /dev/null +++ b/online-exam-frontend/src/components/student/startExam.vue @@ -0,0 +1,313 @@ + + + + + + + diff --git a/online-exam-frontend/src/components/teacher/addAnswer.vue b/online-exam-frontend/src/components/teacher/addAnswer.vue new file mode 100644 index 0000000..b58b15b --- /dev/null +++ b/online-exam-frontend/src/components/teacher/addAnswer.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/online-exam-frontend/src/components/teacher/addAnswerChildren.vue b/online-exam-frontend/src/components/teacher/addAnswerChildren.vue new file mode 100644 index 0000000..ee99a9d --- /dev/null +++ b/online-exam-frontend/src/components/teacher/addAnswerChildren.vue @@ -0,0 +1,704 @@ + + + + + + + + diff --git a/online-exam-frontend/src/components/teacher/addExam.vue b/online-exam-frontend/src/components/teacher/addExam.vue new file mode 100644 index 0000000..bcd1eff --- /dev/null +++ b/online-exam-frontend/src/components/teacher/addExam.vue @@ -0,0 +1,115 @@ + + + + + + diff --git a/online-exam-frontend/src/components/teacher/addStudent.vue b/online-exam-frontend/src/components/teacher/addStudent.vue new file mode 100644 index 0000000..18c588f --- /dev/null +++ b/online-exam-frontend/src/components/teacher/addStudent.vue @@ -0,0 +1,98 @@ + + + + + + diff --git a/online-exam-frontend/src/components/teacher/allStudentsGrade.vue b/online-exam-frontend/src/components/teacher/allStudentsGrade.vue new file mode 100644 index 0000000..f903e09 --- /dev/null +++ b/online-exam-frontend/src/components/teacher/allStudentsGrade.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/online-exam-frontend/src/components/teacher/answerDescription.vue b/online-exam-frontend/src/components/teacher/answerDescription.vue new file mode 100644 index 0000000..5523e5d --- /dev/null +++ b/online-exam-frontend/src/components/teacher/answerDescription.vue @@ -0,0 +1,35 @@ + + + + diff --git a/online-exam-frontend/src/components/teacher/editAnswerChildren.vue b/online-exam-frontend/src/components/teacher/editAnswerChildren.vue new file mode 100644 index 0000000..abc9310 --- /dev/null +++ b/online-exam-frontend/src/components/teacher/editAnswerChildren.vue @@ -0,0 +1,583 @@ + + + + + + + + diff --git a/online-exam-frontend/src/components/teacher/examDescription.vue b/online-exam-frontend/src/components/teacher/examDescription.vue new file mode 100644 index 0000000..a1637ac --- /dev/null +++ b/online-exam-frontend/src/components/teacher/examDescription.vue @@ -0,0 +1,34 @@ + + + + diff --git a/online-exam-frontend/src/components/teacher/selectAnswer.vue b/online-exam-frontend/src/components/teacher/selectAnswer.vue new file mode 100644 index 0000000..f8c2499 --- /dev/null +++ b/online-exam-frontend/src/components/teacher/selectAnswer.vue @@ -0,0 +1,147 @@ + + + + + diff --git a/online-exam-frontend/src/components/teacher/selectExam.vue b/online-exam-frontend/src/components/teacher/selectExam.vue new file mode 100644 index 0000000..e4a2c87 --- /dev/null +++ b/online-exam-frontend/src/components/teacher/selectExam.vue @@ -0,0 +1,395 @@ + + + + + diff --git a/online-exam-frontend/src/components/teacher/selectExamToPart.vue b/online-exam-frontend/src/components/teacher/selectExamToPart.vue new file mode 100644 index 0000000..d7eb71b --- /dev/null +++ b/online-exam-frontend/src/components/teacher/selectExamToPart.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/online-exam-frontend/src/components/teacher/studentManage.vue b/online-exam-frontend/src/components/teacher/studentManage.vue new file mode 100644 index 0000000..f4f6e02 --- /dev/null +++ b/online-exam-frontend/src/components/teacher/studentManage.vue @@ -0,0 +1,218 @@ + + + + + diff --git a/online-exam-frontend/src/main.js b/online-exam-frontend/src/main.js new file mode 100644 index 0000000..89479e5 --- /dev/null +++ b/online-exam-frontend/src/main.js @@ -0,0 +1,32 @@ +/* + * 主函数 + * + * @Author: ShanZhu + * @Date: 2023-11-23 + */ +import Vue from 'vue' +import App from './App' +import router from './router' +import echarts from 'echarts' +import axios from 'axios' +import ElementUI from 'element-ui' +import 'element-ui/lib/theme-chalk/index.css' +import VueCookies from 'vue-cookies' +import store from '@/vuex/store' + +Vue.use(ElementUI) +Vue.use(VueCookies) + +Vue.config.productionTip = false +Vue.prototype.bus = new Vue() +Vue.prototype.$echarts = echarts +Vue.prototype.$axios = axios + +new Vue({ + el: '#app', + router, + store, + render: h => h(App), + components: { App }, + template: '' +}) diff --git a/online-exam-frontend/src/router/index.js b/online-exam-frontend/src/router/index.js new file mode 100644 index 0000000..0d36301 --- /dev/null +++ b/online-exam-frontend/src/router/index.js @@ -0,0 +1,109 @@ +import Vue from 'vue' +import Router from 'vue-router' +Vue.use(Router) + + + +const VueRouterPush = Router.prototype.push + +Router.prototype.push = function push (to) { + return VueRouterPush.call(this, to).catch(err => err) +} + +export default new Router({ + routes: [ + { + path: '/', + name: 'login', //登录界面 + component: () => import('@/components/common/login') + }, + { + path: '/index', //教师主页 + component: () => import('@/components/admin/index'), + children: [ + { + path: '/', //首页默认路由 + component: () => import('@/components/common/hello') + }, + { + path:'/grade', //学生成绩 + component: () => import('@/components/charts/grade') + }, + { + path: '/selectExamToPart', //学生分数段 + component: () => import('@/components/teacher/selectExamToPart') + }, + { + path: '/scorePart', + component: () => import('@/components/charts/scorePart') + }, + { + path: '/allStudentsGrade', //所有学生成绩统计 + component: () => import('@/components/teacher/allStudentsGrade') + }, + // { + // path: '/examDescription', //考试管理功能描述 + // component: () => import('@/components/teacher/examDescription') + // }, + { + path: '/selectExam', //查询所有考试 + component: () => import('@/components/teacher/selectExam') + }, + { + path: '/addExam', //添加考试 + component: () => import('@/components/teacher/addExam') + }, + // { + // path: '/answerDescription', //题库管理功能介绍 + // component: ()=> import('@/components/teacher/answerDescription') + // }, + { + path: '/selectAnswer', //查询所有题库 + component: () => import('@/components/teacher/selectAnswer') + }, + { + path: '/addAnswer', //增加题库主界面 + component: () => import('@/components/teacher/addAnswer') + }, + { + path: '/editAnswerChildren', //编辑题库主界面 + component: () => import('@/components/teacher/editAnswerChildren') + }, + { + path: '/addAnswerChildren', //点击试卷跳转到添加题库页面 + component: () => import('@/components/teacher/addAnswerChildren') + }, + { + path: '/studentManage', //学生管理界面 + component: () => import('@/components/teacher/studentManage') + }, + { + path: '/addStudent', //添加学生 + component: () => import('@/components/teacher/addStudent') + }, + { + path: '/teacherManage', + component: () => import('@/components/admin/tacherManage') + }, + { + path: '/addTeacher', + component: () => import ('@/components/admin/addTeacher') + } + ] + }, + { + path: '/student', + component: () => import('@/components/student/index'), + children: [ + {path:"/",component: ()=> import('@/components/student/myExam')}, + {path:'/startExam', component: () => import('@/components/student/startExam')}, + {path: '/manager', component: () => import('@/components/student/manager')}, + {path: '/examMsg', component: () => import('@/components/student/examMsg')}, + {path: '/message', component: () => import('@/components/student/message')}, + {path: '/studentScore', component: () => import("@/components/student/answerScore")}, + {path: '/scoreTable', component: () => import("@/components/student/scoreTable")} + ] + }, + {path: '/answer',component: () => import('@/components/student/answer')} + ] +}) diff --git a/online-exam-frontend/src/vuex/store.js b/online-exam-frontend/src/vuex/store.js new file mode 100644 index 0000000..2bb4f73 --- /dev/null +++ b/online-exam-frontend/src/vuex/store.js @@ -0,0 +1,64 @@ +import VUE from 'vue' +import VUEX from 'vuex' + +VUE.use(VUEX) + +const state = { + isPractice: false, //练习模式标志 + flag: false, //菜单栏左右滑动标志 + userInfo: null, + menu: [{ + index: '1', + title: '考试管理', + icon: 'icon-kechengbiao', + content: [{ item2: '考试查询', path: 'selectExam' }, { item3: '添加考试', path: '/addExam' }], + }, + { + index: '2', + title: '题库管理', + icon: 'icon-tiku', + content: [{ item2: '所有题库', path: '/selectAnswer' }, { item3: '增加题库', path: '/addAnswer' }, { path: '/addAnswerChildren' }], + }, + { + index: '3', + title: '成绩查询', + icon: 'icon-performance', + content: [{ item1: '学生成绩查询', path: '/allStudentsGrade' }, { path: '/grade' }, { item2: '成绩分段查询', path: '/selectExamToPart' }, { path: '/scorePart' }], + }, + { + index: '4', + title: '学生管理', + icon: 'icon-role', + content: [{ item1: '学生管理', path: '/studentManage' }, { item2: '添加学生', path: '/addStudent' }], + }, + ], +} +const mutations = { + practice(state, status) { + state.isPractice = status + }, + toggle(state) { + state.flag = !state.flag + }, + changeUserInfo(state, info) { + state.userInfo = info + } +} +const getters = { + +} +const actions = { + getUserInfo(context, info) { + context.commit('changeUserInfo', info) + }, + getPractice(context, status) { + context.commit('practice', status) + } +} +export default new VUEX.Store({ + state, + mutations, + getters, + actions, + // store +}) diff --git a/online-exam-frontend/static/img/icon.png b/online-exam-frontend/static/img/icon.png new file mode 100644 index 0000000..4356b65 Binary files /dev/null and b/online-exam-frontend/static/img/icon.png differ diff --git a/online-exam-frontend/static/img/userimg.png b/online-exam-frontend/static/img/userimg.png new file mode 100644 index 0000000..4356b65 Binary files /dev/null and b/online-exam-frontend/static/img/userimg.png differ