|
@@ -1,12 +1,66 @@
|
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import cn.com.qmth.examcloud.service.core.dao.ExamRepo;
|
|
|
+import cn.com.qmth.examcloud.service.core.entity.Exam;
|
|
|
+import cn.com.qmth.examcloud.service.core.service.ExamService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Example;
|
|
|
+import org.springframework.data.domain.ExampleMatcher;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
|
|
|
|
|
|
/**
|
|
|
* Created by songyue on 17/1/13.
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("${app.api.root}/exam")
|
|
|
+@RequestMapping("${app.api.root}")
|
|
|
public class ExamApi {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamRepo examRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamService examService;
|
|
|
+
|
|
|
+ @ApiOperation(value="查询所有考试批次",notes = "分页")
|
|
|
+ @GetMapping("/exam/all/{curPage}/{pageSize}")
|
|
|
+ public ResponseEntity getAllExam(@ModelAttribute Exam examCriteria, @PathVariable Integer curPage,@PathVariable Integer pageSize){
|
|
|
+ return examService.getAllExam(examCriteria,new PageRequest(curPage - 1,pageSize));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="查询所有考试批次",notes = "不分页")
|
|
|
+ @GetMapping("/exam/all")
|
|
|
+ public ResponseEntity getAllExam(@ModelAttribute Exam examCriteria){
|
|
|
+ return examService.getAllExam(examCriteria);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="按ID查询考试批次",notes = "ID查询")
|
|
|
+ @GetMapping("/exam/{examId}")
|
|
|
+ public ResponseEntity<Exam> getExamById(@PathVariable Long examId){
|
|
|
+ return examService.getExamById(examId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="新增考试批次",notes = "新增")
|
|
|
+ @PostMapping("/exam")
|
|
|
+ public ResponseEntity addExam(@ModelAttribute Exam exam){
|
|
|
+ return examService.saveExam(exam);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="更新考试批次",notes = "更新")
|
|
|
+ @PutMapping("/exam")
|
|
|
+ public ResponseEntity updateExam(@ModelAttribute Exam exam){
|
|
|
+ return examService.saveExam(exam);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="按ID删除考试批次",notes = "删除")
|
|
|
+ @DeleteMapping("/exam/{examId}")
|
|
|
+ public ResponseEntity deleteExam(@PathVariable Long examId){
|
|
|
+ return examService.deleteExam(examId);
|
|
|
+ }
|
|
|
}
|