当前位置:   article > 正文

基于Springboot+vue前后端分离防作弊考试系统_前后端分离考试系统代码

前后端分离考试系统代码

作者主页:编程指南针

作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、Python项目、前端项目、人工智能与大数据、简历模板、学习资料、面试题库、技术互助

收藏点赞不迷路  关注作者有好处

文末获取源码 

项目编号:BS-XX-104

指南针考试系统是一个多角色在线培训考试系统,系统集成了用户管理、角色管理、题库管理、试题管理、考试管理、在线考试等功能,考试流程完善。实现一整套完整体系的考试系统,方便用户在此系统中进行练习并不断提升自己,在考试中不断进步。本系统采用前后端分离方式进行开发实现,使用springboot+vue来进行开发.考试时自动调用摄相头进行考试监控,以防止作弊。

技术栈

  1. SpringBoot
  2. Mybatis-plus
  3. MySQL 5.7
  4. Vue全家桶
  5. ElementUI
  6. Redis
  7. Swagger
  8. 阿里云OSS
  9. Log4j

主要功能

1. 权限控制

本系统存在三个不同的角色,教师,管理员,学生三种用户,此系统是基于vue+springboot实现的前后端分离,用户权限校验通过JWT生成token令牌发放到用户,并根据令牌对用户的身份合法性进行校验。

2. 在线考试

学生用户在注册登录之后,可以在本系统进行在线的考试,考试可由教师和管理员进行布置并设置考试权限(公开,密码),考试题型分为 单选、多选、判断、简答题,并支持题目附带配图。考试过程中需开启摄像头进行考试,系统会自动抓拍考生实时考试状态。

3. 成绩模块

参加考试后的学生用户,在提交试卷后进入考试结果页面,页面会自动核对学生用户的逻辑题的对错,对于简答题需要老师或者超级管理员进行批阅。对于学生用户参与的考试,学生用户可以查看到考试的详情并可以查看到自己所错的逻辑题。

4. 题库模块

学生用户在题库模块中可以进行题目的功能训练,训练模式分为,顺序练习,随机练习,也可以根据题型练习(单选,多选,判断)。用户答题时会实时判断正确与否,并有错题解析功能。

5. 题库管理

超级管理员和教师可以对本考试系统已有的题库进行管理,实现对题库信息的CRUD操作

6. 试题管理

教师和系统管理员用户有权限对本系统的所有试题进行操作,本系统试题支持复杂类型的题目,考试题目支持多插图,选项答案支持单插图功能。

7. 考试管理

教师和系统管理员用户有权限对系统存在的考试进行操作,本系统考试支持公开考试和密码口令考试,并可以对考试进行禁用也可以在设置考试时间段,对于考试可以进行很便利的进行组卷,系统内置两种组卷模式,题库组卷和自由选题组卷。

8. 考卷批阅

对于本系统中存在的复杂考试的题目,可以又对应的老师进行批阅,此系统的逻辑题无需老师用户进行批阅,老师的工作仅仅是批阅简答题这种无准确答案类型的题目,极大地减轻了老师用户的工作量

9. 考试统计

本系统针对每一次考试进行数据统计和报表,让使用本系统的老师用户能够直观的了解到每一次考试人员的进步。

10. 用户管理

超级管理员可以对注册本系统用户的进行授权,并拥有操作一切用户的权限。

下面展示一下系统的主要功能:

登陆:

后台管理首页

题库管理

试题管理

考试管理

阅卷管理

考试统计

公告管理

用户管理

教师登陆

学生登陆

在线考试:考试时要调出摄相头进行监控

查看个人成绩和错题:并为通过考试的生成证书

日常题库训练

部门核心代码:

  1. package com.wzz.controller;
  2. import com.wzz.dto.AddUserDto;
  3. import com.wzz.entity.Notice;
  4. import com.wzz.entity.UserRole;
  5. import com.wzz.service.NoticeService;
  6. import com.wzz.service.UserRoleService;
  7. import com.wzz.service.UserService;
  8. import com.wzz.vo.CommonResult;
  9. import com.wzz.vo.PageResponse;
  10. import com.wzz.vo.UserInfoVo;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiImplicitParam;
  13. import io.swagger.annotations.ApiImplicitParams;
  14. import io.swagger.annotations.ApiOperation;
  15. import lombok.RequiredArgsConstructor;
  16. import org.springframework.validation.annotation.Validated;
  17. import org.springframework.web.bind.annotation.*;
  18. import javax.validation.Valid;
  19. import java.util.List;
  20. /**
  21. * @author by znz
  22. * @implNote 2021/10/20 19:07
  23. */
  24. @Validated
  25. @RestController
  26. @RequiredArgsConstructor
  27. @Api(tags = "超级管理员权限相关的接口")
  28. @RequestMapping(value = "/admin")
  29. public class AdminController {
  30. private final UserService userService;
  31. private final UserRoleService userRoleService;
  32. private final NoticeService noticeService;
  33. @GetMapping("/getUser")
  34. @ApiOperation("获取用户信息,可分页 ----> 查询条件(可无)(username,trueName),必须有的(pageNo,pageSize)")
  35. public CommonResult<PageResponse<UserInfoVo>> getUser(@RequestParam(required = false) String loginName,
  36. @RequestParam(required = false) String trueName,
  37. Integer pageNo, Integer pageSize) {
  38. return CommonResult.<PageResponse<UserInfoVo>>builder()
  39. .data(userService.getUser(loginName, trueName, pageNo, pageSize))
  40. .build();
  41. }
  42. @GetMapping("/handleUser/{type}")
  43. @ApiOperation("管理员操作用户: type=1(启用) 2(禁用) 3(删除) userIds(需要操作的用户id)")
  44. public CommonResult<Void> handleUser(@PathVariable("type") Integer type, String userIds) {
  45. userService.handlerUser(type, userIds);
  46. return CommonResult.<Void>builder().build();
  47. }
  48. @PostMapping("/addUser")
  49. @ApiOperation("管理员用户新增用户")
  50. @ApiImplicitParams({
  51. @ApiImplicitParam(name = "user", value = "系统用户实体", required = true, dataType = "user", paramType = "body")
  52. })
  53. public CommonResult<Void> addUser(@RequestBody @Valid AddUserDto userDto) {
  54. userService.addUser(userDto);
  55. return CommonResult.<Void>builder().build();
  56. }
  57. @GetMapping("/getRole")
  58. @ApiOperation("查询系统存在的所有角色信息")
  59. public CommonResult<List<UserRole>> getRole() {
  60. return CommonResult.<List<UserRole>>builder()
  61. .data(userRoleService.getUserRole())
  62. .build();
  63. }
  64. @GetMapping("/getAllNotice")
  65. @ApiOperation("获取系统发布的所有公告(分页 条件查询 二合一接口)")
  66. @ApiImplicitParams({
  67. @ApiImplicitParam(name = "noticeContent", value = "搜索公告内容", dataType = "string", paramType = "query"),
  68. @ApiImplicitParam(name = "pageNo", value = "查询结果分页当前页面", required = true, dataType = "int", paramType = "query"),
  69. @ApiImplicitParam(name = "pageSize", value = "查询结果的页面条数大小", required = true, dataType = "int", paramType = "query")
  70. })
  71. public CommonResult<PageResponse<Notice>> getAllNotice(@RequestParam(required = false, name = "noticeContent") String content,
  72. Integer pageNo, Integer pageSize) {
  73. return CommonResult.<PageResponse<Notice>>builder()
  74. .data(noticeService.getAllNotices(content, pageNo, pageSize))
  75. .build();
  76. }
  77. @PostMapping("/publishNotice")
  78. @ApiOperation("发布新公告")
  79. @ApiImplicitParams({
  80. @ApiImplicitParam(name = "notice", value = "通知实体对象", required = true, dataType = "notice", paramType = "body")
  81. })
  82. public CommonResult<Void> publishNotice(@RequestBody Notice notice) {
  83. noticeService.publishNotice(notice);
  84. return CommonResult.<Void>builder()
  85. .build();
  86. }
  87. @GetMapping("/deleteNotice")
  88. @ApiOperation("批量删除公告")
  89. @ApiImplicitParams({
  90. @ApiImplicitParam(name = "noticeIds", value = "系统公告id", required = true, dataType = "string", paramType = "query")
  91. })
  92. public CommonResult<Void> deleteNotice(@RequestParam(name = "ids") String noticeIds) {
  93. noticeService.deleteNoticeByIds(noticeIds);
  94. return CommonResult.<Void>builder().build();
  95. }
  96. @PostMapping("/updateNotice")
  97. @ApiOperation("更新公告")
  98. @ApiImplicitParams({
  99. @ApiImplicitParam(name = "notice", value = "通知实体对象", required = true, dataType = "notice", paramType = "body")
  100. })
  101. public CommonResult<Void> updateNotice(@RequestBody Notice notice) {
  102. noticeService.updateNotice(notice);
  103. return CommonResult.<Void>builder().build();
  104. }
  105. }

  1. package com.wzz.controller;
  2. import com.wzz.entity.ExamQuestion;
  3. import com.wzz.entity.ExamRecord;
  4. import com.wzz.service.ExamQuestionService;
  5. import com.wzz.service.QuestionService;
  6. import com.wzz.service.impl.ExamRecordServiceImpl;
  7. import com.wzz.vo.CommonResult;
  8. import com.wzz.vo.PageResponse;
  9. import com.wzz.vo.QuestionVo;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiImplicitParam;
  12. import io.swagger.annotations.ApiImplicitParams;
  13. import io.swagger.annotations.ApiOperation;
  14. import lombok.RequiredArgsConstructor;
  15. import lombok.extern.slf4j.Slf4j;
  16. import org.springframework.web.bind.annotation.*;
  17. import javax.servlet.http.HttpServletRequest;
  18. import javax.servlet.http.HttpServletResponse;
  19. /**
  20. * @author by znz
  21. * @implNote 2021/11/7 19:44
  22. */
  23. @Slf4j
  24. @RestController
  25. @RequiredArgsConstructor
  26. @Api(tags = "学生权限相关的接口")
  27. @RequestMapping(value = "/student")
  28. public class StudentController {
  29. private final ExamRecordServiceImpl examRecordService;
  30. private final QuestionService questionService;
  31. private final ExamQuestionService examQuestionService;
  32. @GetMapping("/getMyGrade")
  33. @ApiOperation("获取个人成绩(分页 根据考试名查询)")
  34. @ApiImplicitParams({@ApiImplicitParam(name = "username", value = "系统唯一用户名", required = true, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "pageNo", value = "当前页面数", required = true, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "pageSize", value = "当前页面大小", required = true, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "examId", value = "考试唯一id", dataType = "int", paramType = "query")})
  35. public CommonResult<PageResponse<ExamRecord>> getMyGrade(String username, Integer pageNo, Integer pageSize, @RequestParam(required = false) Integer examId) {
  36. return CommonResult.<PageResponse<ExamRecord>>builder().data(examRecordService.getUserGrade(username, examId, pageNo, pageSize)).build();
  37. }
  38. @GetMapping("/getCertificate")
  39. @ApiOperation("生成证书接口")
  40. @ApiImplicitParams({@ApiImplicitParam(name = "examName", value = "考试名称", required = true, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "examRecordId", value = "考试记录id", required = true, dataType = "int", paramType = "query")})
  41. public void getCertificate(HttpServletResponse response, @RequestParam(name = "examName") String examName, @RequestParam(name = "examRecordId") Integer examRecordId) {
  42. examRecordService.createExamCertificate(response, examName, examRecordId);
  43. }
  44. @PostMapping("/addExamRecord")
  45. @ApiOperation("保存考试记录信息,返回保存记录的id")
  46. @ApiImplicitParams({@ApiImplicitParam(name = "examRecord", value = "考试记录实体对象", required = true, dataType = "examRecord", paramType = "body")})
  47. public CommonResult<Integer> addExamRecord(@RequestBody ExamRecord examRecord, HttpServletRequest request) {
  48. return CommonResult.<Integer>builder().data(examRecordService.addExamRecord(examRecord, request)).build();
  49. }
  50. // TODO 优化成多id一次查询
  51. @GetMapping("/getQuestionById/{id}")
  52. @ApiOperation("根据id获取题目信息")
  53. @ApiImplicitParams({
  54. @ApiImplicitParam(name = "id", value = "问题id", required = true, dataType = "int", paramType = "path")
  55. })
  56. public CommonResult<QuestionVo> getQuestionById(@PathVariable("id") Integer id) {
  57. return CommonResult.<QuestionVo>builder()
  58. .data(questionService.getQuestionVoById(id))
  59. .build();
  60. }
  61. @GetMapping("/getExamRecordById/{recordId}")
  62. @ApiOperation("根据考试的记录id查询用户考试的信息")
  63. @ApiImplicitParams({
  64. @ApiImplicitParam(name = "recordId", value = "考试记录id", required = true, dataType = "int", paramType = "query")
  65. })
  66. public CommonResult<ExamRecord> getExamRecordById(@PathVariable Integer recordId) {
  67. return CommonResult.<ExamRecord>builder()
  68. .data(examRecordService.getExamRecordById(recordId))
  69. .build();
  70. }
  71. @GetMapping("/getExamQuestionByExamId/{examId}")
  72. @ApiOperation("根据考试id查询考试中的每一道题目id和分值")
  73. @ApiImplicitParams({
  74. @ApiImplicitParam(name = "examId", value = "考试id", required = true, dataType = "int", paramType = "query")
  75. })
  76. public CommonResult<ExamQuestion> getExamQuestionByExamId(@PathVariable Integer examId) {
  77. return CommonResult.<ExamQuestion>builder()
  78. .data(examQuestionService.getExamQuestionByExamId(examId))
  79. .build();
  80. }
  81. }

  1. package com.wzz.controller;
  2. import com.wzz.entity.ExamRecord;
  3. import com.wzz.entity.Question;
  4. import com.wzz.entity.QuestionBank;
  5. import com.wzz.service.*;
  6. import com.wzz.utils.OSSUtil;
  7. import com.wzz.vo.*;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiImplicitParam;
  10. import io.swagger.annotations.ApiImplicitParams;
  11. import io.swagger.annotations.ApiOperation;
  12. import lombok.RequiredArgsConstructor;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.springframework.validation.annotation.Validated;
  15. import org.springframework.web.bind.annotation.*;
  16. import org.springframework.web.multipart.MultipartFile;
  17. import javax.validation.Valid;
  18. import java.util.List;
  19. /**
  20. * @author wzz
  21. * @implNote 2021/10/24 15:42
  22. */
  23. @Slf4j
  24. @Validated
  25. @RestController
  26. @RequiredArgsConstructor
  27. @Api(tags = "老师权限相关的接口")
  28. @RequestMapping(value = "/teacher")
  29. public class TeacherController {
  30. private final ExamService examService;
  31. private final UserService userService;
  32. private final QuestionService questionService;
  33. private final ExamRecordService examRecordService;
  34. private final QuestionBankService questionBankService;
  35. @GetMapping("/getQuestionBank")
  36. @ApiOperation("获取所有题库信息")
  37. public CommonResult<List<QuestionBank>> getQuestionBank() {
  38. return CommonResult.<List<QuestionBank>>builder()
  39. .data(questionBankService.getAllQuestionBanks())
  40. .build();
  41. }
  42. @GetMapping("/getQuestion")
  43. @ApiImplicitParams({
  44. @ApiImplicitParam(name = "questionType", value = "问题类型", dataType = "string", paramType = "query"),
  45. @ApiImplicitParam(name = "questionBank", value = "问题所属题库", dataType = "string", paramType = "query"),
  46. @ApiImplicitParam(name = "questionContent", value = "问题内容", dataType = "string", paramType = "query"),
  47. @ApiImplicitParam(name = "pageNo", value = "页面数", required = true, dataType = "int", paramType = "query"),
  48. @ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, dataType = "int", paramType = "query")
  49. })
  50. @ApiOperation("获取题目信息,可分页 ----> 查询条件(可无)(questionType,questionBank,questionContent),必须有的(pageNo,pageSize)")
  51. public CommonResult<PageResponse<Question>> getQuestion(@RequestParam(required = false) String questionType,
  52. @RequestParam(required = false) String questionBank,
  53. @RequestParam(required = false) String questionContent,
  54. Integer pageNo, Integer pageSize) {
  55. return CommonResult.<PageResponse<Question>>builder()
  56. .data(questionService.getQuestion(questionType, questionBank, questionContent, pageNo, pageSize))
  57. .build();
  58. }
  59. @GetMapping("/deleteQuestion")
  60. @ApiOperation("根据id批量删除")
  61. @ApiImplicitParams({
  62. @ApiImplicitParam(name = "questionIds", value = "问题id的字符串以逗号分隔", required = true, dataType = "string", paramType = "query")
  63. })
  64. public CommonResult<Void> deleteQuestion(String questionIds) {
  65. questionService.deleteQuestionByIds(questionIds);
  66. return CommonResult.<Void>builder()
  67. .build();
  68. }
  69. @GetMapping("/addBankQuestion")
  70. @ApiOperation("将问题加入题库")
  71. @ApiImplicitParams({
  72. @ApiImplicitParam(name = "questionIds", value = "问题id的字符串以逗号分隔", required = true, dataType = "string", paramType = "query"),
  73. @ApiImplicitParam(name = "banks", value = "题库id的字符串以逗号分隔", required = true, dataType = "string", paramType = "query")
  74. })
  75. public CommonResult<String> addBankQuestion(String questionIds, String banks) {
  76. questionBankService.addQuestionToBank(questionIds, banks);
  77. return CommonResult.<String>builder()
  78. .build();
  79. }
  80. @GetMapping("/removeBankQuestion")
  81. @ApiOperation("将问题从题库移除")
  82. @ApiImplicitParams({
  83. @ApiImplicitParam(name = "questionIds", value = "问题id的字符串以逗号分隔", required = true, dataType = "string", paramType = "query"),
  84. @ApiImplicitParam(name = "banks", value = "题库id的字符串以逗号分隔", required = true, dataType = "string", paramType = "query")
  85. })
  86. public CommonResult<Void> removeBankQuestion(String questionIds, String banks) {
  87. questionBankService.removeBankQuestion(questionIds, banks);
  88. return CommonResult.<Void>builder()
  89. .build();
  90. }
  91. @PostMapping("/uploadQuestionImage")
  92. @ApiOperation("接受前端上传的图片,返回上传图片地址")
  93. @ApiImplicitParams({
  94. @ApiImplicitParam(name = "file", value = "图片文件", required = true, dataType = "file", paramType = "body")
  95. })
  96. public CommonResult<String> uploadQuestionImage(MultipartFile file) throws Exception {
  97. log.info("开始上传文件: {}", file.getOriginalFilename());
  98. return CommonResult.<String>builder()
  99. .data(OSSUtil.picOSS(file))
  100. .message("上传成功")
  101. .build();
  102. }
  103. @PostMapping("/addQuestion")
  104. @ApiOperation("添加试题")
  105. @ApiImplicitParams({
  106. @ApiImplicitParam(name = "questionVo", value = "问题的vo视图对象", required = true, dataType = "questionVo", paramType = "body")
  107. })
  108. public CommonResult<Void> addQuestion(@RequestBody @Valid QuestionVo questionVo) {
  109. questionService.addQuestion(questionVo);
  110. return CommonResult.<Void>builder().build();
  111. }
  112. @PostMapping("/updateQuestion")
  113. @ApiOperation("更新试题")
  114. @ApiImplicitParams({
  115. @ApiImplicitParam(name = "questionVo", value = "问题的vo视图对象", required = true, dataType = "questionVo", paramType = "body")
  116. })
  117. public CommonResult<Void> updateQuestion(@RequestBody @Valid QuestionVo questionVo) {
  118. questionService.updateQuestion(questionVo);
  119. return CommonResult.<Void>builder()
  120. .build();
  121. }
  122. @GetMapping("/deleteQuestionBank")
  123. @ApiOperation("删除题库并去除所有题目中的包含此题库的信息")
  124. @ApiImplicitParams({
  125. @ApiImplicitParam(name = "ids", value = "删除题库的id字符串逗号分隔", required = true, dataType = "string", paramType = "query")
  126. })
  127. public CommonResult<Void> deleteQuestionBank(String ids) {
  128. questionBankService.deleteQuestionBank(ids);
  129. return CommonResult.<Void>builder()
  130. .build();
  131. }
  132. @PostMapping("/addQuestionBank")
  133. @ApiOperation("添加题库信息")
  134. @ApiImplicitParams({
  135. @ApiImplicitParam(name = "questionBank", value = "题库的实体对象", required = true, dataType = "questionBank", paramType = "body")
  136. })
  137. public CommonResult<Void> addQuestionBank(@RequestBody QuestionBank questionBank) {
  138. questionBankService.addQuestionBank(questionBank);
  139. return CommonResult.<Void>builder()
  140. .build();
  141. }
  142. @GetMapping("/operationExam/{type}")
  143. @ApiOperation("操作考试的信息表(type 1启用 2禁用 3删除)")
  144. @ApiImplicitParams({
  145. @ApiImplicitParam(name = "type", value = "操作类型", required = true, dataType = "int", paramType = "query"),
  146. @ApiImplicitParam(name = "ids", value = "操作的考试id集合", required = true, dataType = "string", paramType = "query")
  147. })
  148. public CommonResult<Void> operationExam(@PathVariable("type") Integer type, String ids) {
  149. examService.operationExam(type, ids);
  150. return CommonResult.<Void>builder()
  151. .build();
  152. }
  153. @PostMapping("/addExamByBank")
  154. @ApiOperation("根据题库添加考试")
  155. @ApiImplicitParams({
  156. @ApiImplicitParam(name = "addExamByBankVo", value = "根据题库添加考试vo对象", required = true, dataType = "addExamByBankVo", paramType = "body")
  157. })
  158. public CommonResult<Void> addExamByBank(@RequestBody @Valid AddExamByBankVo addExamByBankVo) {
  159. examService.addExamByBank(addExamByBankVo);
  160. return CommonResult.<Void>builder()
  161. .build();
  162. }
  163. @PostMapping("/addExamByQuestionList")
  164. @ApiOperation("根据题目列表添加考试")
  165. @ApiImplicitParams({
  166. @ApiImplicitParam(name = "addExamByQuestionVo", value = "通过题目列表添加考试的vo对象", required = true, dataType = "addExamByQuestionVo", paramType = "body")
  167. })
  168. public CommonResult<Void> addExamByQuestionList(@RequestBody @Valid AddExamByQuestionVo addExamByQuestionVo) {
  169. examService.addExamByQuestionList(addExamByQuestionVo);
  170. return CommonResult.<Void>builder()
  171. .build();
  172. }
  173. @PostMapping("/updateExamInfo")
  174. @ApiOperation("更新考试的信息")
  175. @ApiImplicitParams({
  176. @ApiImplicitParam(name = "addExamByQuestionVo", value = "通过题目列表添加考试的vo对象", required = true, dataType = "addExamByQuestionVo", paramType = "body")
  177. })
  178. public CommonResult<Void> updateExamInfo(@RequestBody AddExamByQuestionVo addExamByQuestionVo) {
  179. examService.updateExamInfo(addExamByQuestionVo);
  180. return CommonResult.<Void>builder()
  181. .build();
  182. }
  183. @GetMapping("/getExamRecord")
  184. @ApiOperation("获取考试记录信息,(pageNo,pageSize)")
  185. @ApiImplicitParams({
  186. @ApiImplicitParam(name = "examId", value = "考试id", required = true, dataType = "int", paramType = "query"),
  187. @ApiImplicitParam(name = "pageNo", value = "页面数", required = true, dataType = "int", paramType = "query"),
  188. @ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, dataType = "int", paramType = "query")
  189. })
  190. public CommonResult<PageResponse<ExamRecord>> getExamRecord(@RequestParam(required = false) Integer examId, Integer pageNo, Integer pageSize) {
  191. return CommonResult.<PageResponse<ExamRecord>>builder()
  192. .data(examRecordService.getExamRecord(examId, pageNo, pageSize))
  193. .build();
  194. }
  195. // TODO 改成ids查询
  196. @GetMapping("/getUserById/{userId}")
  197. @ApiOperation("根据用户id查询用户信息")
  198. @ApiImplicitParams({
  199. @ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "int", paramType = "query")
  200. })
  201. public CommonResult<UserInfoVo> getUserById(@PathVariable Integer userId) {
  202. return CommonResult.<UserInfoVo>builder()
  203. .data(userService.getUserInfoById(userId))
  204. .build();
  205. }
  206. @GetMapping("/setObjectQuestionScore")
  207. @ApiOperation("设置考试记录的客观题得分,设置总分为逻辑得分+客观题")
  208. @ApiImplicitParams({
  209. @ApiImplicitParam(name = "totalScore", value = "总成绩", required = true, dataType = "int", paramType = "query"),
  210. @ApiImplicitParam(name = "examRecordId", value = "考试记录id", required = true, dataType = "int", paramType = "query")
  211. })
  212. public CommonResult<Void> setObjectQuestionScore(Integer totalScore, Integer examRecordId) {
  213. examRecordService.setObjectQuestionScore(totalScore, examRecordId);
  214. return CommonResult.<Void>builder()
  215. .build();
  216. }
  217. @GetMapping("/getExamPassRate")
  218. @ApiOperation("提供每一门考试的通过率数据(echarts绘图)")
  219. public CommonResult<List<String>> getExamPassRate() {
  220. return CommonResult.<List<String>>builder()
  221. .data(examService.getExamPassRateEchartData())
  222. .build();
  223. }
  224. @GetMapping("/getExamNumbers")
  225. @ApiOperation("提供每一门考试的考试次数(echarts绘图)")
  226. public CommonResult<List<String>> getExamNumbers() {
  227. return CommonResult.<List<String>>builder()
  228. .data(examService.getExamNumbersEchartData())
  229. .build();
  230. }
  231. }

  1. package com.wzz.controller;
  2. import com.wzz.entity.Exam;
  3. import com.wzz.service.ExamService;
  4. import com.wzz.service.NoticeService;
  5. import com.wzz.service.QuestionBankService;
  6. import com.wzz.vo.*;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiImplicitParam;
  9. import io.swagger.annotations.ApiImplicitParams;
  10. import io.swagger.annotations.ApiOperation;
  11. import lombok.RequiredArgsConstructor;
  12. import org.springframework.web.bind.annotation.*;
  13. import java.util.List;
  14. @RestController
  15. @RequiredArgsConstructor
  16. @Api(tags = "三个角色公共的相关接口")
  17. @RequestMapping(value = "/public")
  18. public class PublicController {
  19. private final NoticeService noticeService;
  20. private final ExamService examService;
  21. private final QuestionBankService questionBankService;
  22. @PostMapping("/getExamInfo")
  23. @ApiOperation("根据信息查询考试的信息")
  24. @ApiImplicitParams({
  25. @ApiImplicitParam(name = "examQueryVo", value = "考试信息查询vo对象", required = true, dataType = "examQueryVo", paramType = "body")
  26. })
  27. public CommonResult<PageResponse<Exam>> getExamInfo(@RequestBody ExamQueryVo examQueryVo) {
  28. return CommonResult.<PageResponse<Exam>>builder()
  29. .data(examService.getExamPage(examQueryVo))
  30. .build();
  31. }
  32. @GetMapping("/getExamInfoById")
  33. @ApiOperation("根据考试id查询考试的信息和题目列表")
  34. @ApiImplicitParams({
  35. @ApiImplicitParam(name = "examId", value = "考试id", required = true, dataType = "int", paramType = "query")
  36. })
  37. public CommonResult<AddExamByQuestionVo> getExamInfoById(@RequestParam Integer examId) {
  38. return CommonResult.<AddExamByQuestionVo>builder()
  39. .data(examService.getExamInfoById(examId))
  40. .build();
  41. }
  42. @GetMapping("/allExamInfo")
  43. @ApiOperation("查询考试所有信息")
  44. public CommonResult<List<Exam>> allExamInfo() {
  45. return CommonResult.<List<Exam>>builder()
  46. .data(examService.list(null))
  47. .build();
  48. }
  49. @GetMapping("/getBankHaveQuestionSumByType")
  50. @ApiOperation("获取题库中所有题目类型的数量")
  51. @ApiImplicitParams({
  52. @ApiImplicitParam(name = "bankName", value = "题库名称", dataType = "string", paramType = "query"),
  53. @ApiImplicitParam(name = "pageNo", value = "页面数", required = true, dataType = "int", paramType = "query"),
  54. @ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, dataType = "int", paramType = "query"),
  55. })
  56. public CommonResult<PageResponse<BankHaveQuestionSum>> getBankHaveQuestionSumByType(@RequestParam(required = false) String bankName,
  57. Integer pageNo, Integer pageSize) {
  58. return CommonResult.<PageResponse<BankHaveQuestionSum>>builder()
  59. .data(questionBankService.getBankHaveQuestionSumByType(bankName, pageNo, pageSize))
  60. .build();
  61. }
  62. @GetMapping("/getQuestionByBankIdAndType")
  63. @ApiOperation("根据题库id和题目类型获取题目信息 type(1单选 2多选 3判断)")
  64. @ApiImplicitParams({
  65. @ApiImplicitParam(name = "bankId", value = "题库id", required = true, dataType = "int", paramType = "query"),
  66. @ApiImplicitParam(name = "type", value = "题目类型", required = true, dataType = "int", paramType = "query"),
  67. })
  68. public CommonResult<List<QuestionVo>> getQuestionByBankIdAndType(Integer bankId, Integer type) {
  69. return CommonResult.<List<QuestionVo>>builder()
  70. .data(questionBankService.getQuestionByBankIdAndType(bankId, type))
  71. .build();
  72. }
  73. @GetMapping("/getQuestionByBank")
  74. @ApiOperation("根据题库获取所有的题目信息(单选,多选,判断题)")
  75. @ApiImplicitParams({
  76. @ApiImplicitParam(name = "bankId", value = "题库id", required = true, dataType = "int", paramType = "query")
  77. })
  78. public CommonResult<List<QuestionVo>> getQuestionByBank(Integer bankId) {
  79. return CommonResult.<List<QuestionVo>>builder()
  80. .data(questionBankService.getQuestionsByBankId(bankId))
  81. .build();
  82. }
  83. @GetMapping("/getCurrentNewNotice")
  84. @ApiOperation("获取当前系统最新的公告")
  85. public CommonResult<String> getCurrentNewNotice() {
  86. return CommonResult.<String>builder()
  87. .data(noticeService.getCurrentNotice())
  88. .build();
  89. }
  90. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/210043
推荐阅读
相关标签
  

闽ICP备14008679号