首页>代码>vue+springboot2整合实现在线考试管理系统>/springboot/src/main/java/com/exam/controller/ExamManageController.java
package com.exam.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.exam.entity.ApiResult; import com.exam.entity.ExamManage; import com.exam.serviceimpl.ExamManageServiceImpl; import com.exam.util.ApiResultHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @RestController public class ExamManageController { @Autowired private ExamManageServiceImpl examManageService; @GetMapping("/exams") public ApiResult findAll(){ System.out.println("不分页查询所有试卷"); ApiResult apiResult; apiResult = ApiResultHandler.buildApiResult(200, "请求成功!", examManageService.findAll()); return apiResult; } @GetMapping("/exams/{page}/{size}") public ApiResult findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){ System.out.println("分页查询所有试卷"); ApiResult apiResult; Page<ExamManage> examManage = new Page<>(page,size); IPage<ExamManage> all = examManageService.findAll(examManage); apiResult = ApiResultHandler.buildApiResult(200, "请求成功!", all); return apiResult; } @GetMapping("/exam/{examCode}") public ApiResult findById(@PathVariable("examCode") Integer examCode){ System.out.println("根据ID查找"); ExamManage res = examManageService.findById(examCode); if(res == null) { return ApiResultHandler.buildApiResult(10000,"考试编号不存在",null); } return ApiResultHandler.buildApiResult(200,"请求成功!",res); } @DeleteMapping("/exam/{examCode}") public ApiResult deleteById(@PathVariable("examCode") Integer examCode){ int res = examManageService.delete(examCode); return ApiResultHandler.buildApiResult(200,"删除成功",res); } @PutMapping("/exam") public ApiResult update(@RequestBody ExamManage exammanage){ int res = examManageService.update(exammanage); // if (res == 0) { // return ApiResultHandler.buildApiResult(20000,"请求参数错误"); // } System.out.print("更新操作执行---"); return ApiResultHandler.buildApiResult(200,"更新成功",res); } @PostMapping("/exam") public ApiResult add(@RequestBody ExamManage exammanage){ int res = examManageService.add(exammanage); if (res ==1) { return ApiResultHandler.buildApiResult(200, "添加成功", res); } else { return ApiResultHandler.buildApiResult(400,"添加失败",res); } } @GetMapping("/examManagePaperId") public ApiResult findOnlyPaperId() { ExamManage res = examManageService.findOnlyPaperId(); if (res != null) { return ApiResultHandler.buildApiResult(200,"请求成功",res); } return ApiResultHandler.buildApiResult(400,"请求失败",res); } }

微信网友_7357533879193600 LV2
1月26日
yinxunyu12138 LV11
2024年12月29日
hrbylw LV9
2024年12月4日
pangzhihui LV14
2024年9月15日
樱花味小然子 LV5
2024年7月18日
wonderman LV5
2024年6月30日
JiangYing009 LV8
2024年4月27日
nyb4613 LV8
2024年4月15日
Boss绝 LV9
2024年3月25日
qqttuu LV3
2024年3月6日

gann2015 LV25
4月8日
329512801 LV28
3月24日
微信网友_7398626323435520 LV2
2月25日
ChanLain LV2
2月19日
微信网友_7357533879193600 LV2
1月26日
yinxunyu12138 LV11
2024年12月29日
ashuai123 LV4
2024年12月21日
hrbylw LV9
2024年12月4日
Daima000 LV4
2024年12月3日
citybird LV4
2024年11月18日