|
@@ -1,5 +1,20 @@
|
|
package com.qmth.cqb.question.web;
|
|
package com.qmth.cqb.question.web;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.qmth.cqb.question.dao.QuesRepo;
|
|
import com.qmth.cqb.question.dao.QuesRepo;
|
|
import com.qmth.cqb.question.model.Question;
|
|
import com.qmth.cqb.question.model.Question;
|
|
@@ -8,13 +23,6 @@ import com.qmth.cqb.question.service.QuesService;
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Created by songyue on 16/12/28.
|
|
* Created by songyue on 16/12/28.
|
|
*/
|
|
*/
|
|
@@ -33,74 +41,81 @@ public class QuesController {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取试题
|
|
* 获取试题
|
|
|
|
+ *
|
|
* @param id
|
|
* @param id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="获取试题",notes="获取试题")
|
|
|
|
|
|
+ @ApiOperation(value = "获取试题", notes = "获取试题")
|
|
@GetMapping(value = "/question/{id}")
|
|
@GetMapping(value = "/question/{id}")
|
|
- public ResponseEntity getQuesById(@PathVariable String id){
|
|
|
|
- return new ResponseEntity(quesRepo.findOne(id),HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getQuesById(@PathVariable String id) {
|
|
|
|
+ Question ques = quesRepo.findOne(id);
|
|
|
|
+ quesService.formatQues(ques);
|
|
|
|
+ return new ResponseEntity(ques, HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 分页查询试题
|
|
* 分页查询试题
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="分页查询试题",notes="分页查询试题")
|
|
|
|
|
|
+ @ApiOperation(value = "分页查询试题", notes = "分页查询试题")
|
|
@GetMapping(value = "/question/{curPage}/{pageSize}")
|
|
@GetMapping(value = "/question/{curPage}/{pageSize}")
|
|
- public ResponseEntity getAllQuestion(@ModelAttribute QuestionSearchCondition searchCondition, @PathVariable int curPage,
|
|
|
|
- @PathVariable int pageSize){
|
|
|
|
- return new ResponseEntity(quesService.findAll(searchCondition, curPage, pageSize),
|
|
|
|
- HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getAllQuestion(@ModelAttribute QuestionSearchCondition searchCondition,
|
|
|
|
+ @PathVariable int curPage, @PathVariable int pageSize) {
|
|
|
|
+ return new ResponseEntity(quesService.findAll(searchCondition, curPage, pageSize), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 更新试题信息
|
|
* 更新试题信息
|
|
- * @param
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="更新试题",notes="更新试题")
|
|
|
|
|
|
+ @ApiOperation(value = "更新试题", notes = "更新试题")
|
|
@PutMapping(value = "/question")
|
|
@PutMapping(value = "/question")
|
|
- public ResponseEntity updateQuestion(@RequestBody Question question){
|
|
|
|
|
|
+ public ResponseEntity updateQuestion(@RequestBody Question question) {
|
|
quesService.saveQues(question);
|
|
quesService.saveQues(question);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增试题
|
|
* 新增试题
|
|
|
|
+ *
|
|
* @param question
|
|
* @param question
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="新增试题",notes="新增试题")
|
|
|
|
|
|
+ @ApiOperation(value = "新增试题", notes = "新增试题")
|
|
@PostMapping(value = "/question")
|
|
@PostMapping(value = "/question")
|
|
- public ResponseEntity addQuestion(@RequestBody Question question){
|
|
|
|
- return new ResponseEntity(quesRepo.save(question),HttpStatus.CREATED);
|
|
|
|
|
|
+ public ResponseEntity addQuestion(@RequestBody Question question) {
|
|
|
|
+ return new ResponseEntity(quesRepo.save(question), HttpStatus.CREATED);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除试题
|
|
* 删除试题
|
|
|
|
+ *
|
|
* @param id
|
|
* @param id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="删除试题",notes="删除试题")
|
|
|
|
|
|
+ @ApiOperation(value = "删除试题", notes = "删除试题")
|
|
@DeleteMapping(value = "/question/{id}")
|
|
@DeleteMapping(value = "/question/{id}")
|
|
- public ResponseEntity removeQuestion(@PathVariable String id){
|
|
|
|
- quesRepo.delete(id);
|
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity removeQuestion(@PathVariable String id) {
|
|
|
|
+ quesRepo.delete(id);
|
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除套题子题
|
|
* 删除套题子题
|
|
|
|
+ *
|
|
* @param id
|
|
* @param id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @ApiOperation(value="删除套题子题",notes="删除套题子题")
|
|
|
|
|
|
+ @ApiOperation(value = "删除套题子题", notes = "删除套题子题")
|
|
@PutMapping(value = "/question/{id}/{number}")
|
|
@PutMapping(value = "/question/{id}/{number}")
|
|
- public ResponseEntity removeQuestion(@PathVariable String id,@PathVariable String number){
|
|
|
|
|
|
+ public ResponseEntity removeQuestion(@PathVariable String id, @PathVariable String number) {
|
|
Question question = quesRepo.findOne(id);
|
|
Question question = quesRepo.findOne(id);
|
|
List<Question> subQuestions = question.getSubQuestions();
|
|
List<Question> subQuestions = question.getSubQuestions();
|
|
subQuestions.remove(Integer.parseInt(number));
|
|
subQuestions.remove(Integer.parseInt(number));
|
|
- return new ResponseEntity(quesRepo.save(question),HttpStatus.OK);
|
|
|
|
|
|
+ return new ResponseEntity(quesRepo.save(question), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|