首页>代码>基于SpringBoot+Vue实现的在线考试系统>/OnlineExamSystem/OnlineExamSystemApi/src/main/java/com/rabbiter/oes/controller/ExamManageController.java
package com.rabbiter.oes.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.rabbiter.oes.entity.ApiResult; import com.rabbiter.oes.entity.ExamManage; import com.rabbiter.oes.serviceimpl.ExamManageServiceImpl; import com.rabbiter.oes.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); } }
最近下载更多
dapeng0011 LV13
4月6日
微信网友_6927932988952576 LV12
3月30日
zolscy LV12
3月24日
2206371875 LV7
3月14日
3263394665 LV9
3月10日
wanglinddad LV55
3月7日
qqttuu LV3
3月6日
gnnhka LV10
3月4日
haozhilang LV8
2月27日
Boss绝 LV9
2月26日
最近浏览更多
chirsbey2
5月10日
暂无贡献等级
kenhomeliu LV29
4月30日
JiangYing009 LV8
4月27日
1230123 LV1
4月21日
qianhui1 LV3
4月18日
做自己的太阳 LV11
4月17日
dhcpsl LV2
4月10日
wmxhahah LV7
4月8日
dapeng0011 LV13
4月6日
微信网友_6927932988952576 LV12
3月30日