|
|
@@ -27,18 +27,37 @@ import org.springframework.web.bind.annotation.*;
|
|
|
* @Description //TODO
|
|
|
**/
|
|
|
@RepositoryRestController
|
|
|
-@RequestMapping("/api/question")
|
|
|
+@RequestMapping("/question")
|
|
|
public class QuestionController {
|
|
|
@Autowired
|
|
|
- @Qualifier("QuestionRepository") // inject Spring implementation here
|
|
|
+ @Qualifier("QuestionRepositoryImp") // inject Spring implementation here
|
|
|
private QuestionRepository questionRepository;
|
|
|
@Autowired
|
|
|
private PagedResourcesAssembler pagedAssembler;
|
|
|
@Autowired
|
|
|
private RepositoryEntityLinks entityLinks;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/{tqId}",method= RequestMethod.PUT, produces = "application/hal+json")
|
|
|
+ public @ResponseBody ResponseEntity<?> updateQuestion(@PathVariable String tqId, @RequestBody Question question, PersistentEntityResourceAssembler resourcesAssembler) {
|
|
|
+ final Question saved = questionRepository.save(question);
|
|
|
+ return new ResponseEntity(resourcesAssembler.toFullResource(saved), HttpStatus.OK);
|
|
|
+ }
|
|
|
+//
|
|
|
+// @GetMapping(value = "/{questionId}", produces = "application/hal+json")
|
|
|
+// public @ResponseBody ResponseEntity<?> getQuestion(@PathVariable String questionId, PersistentEntityResourceAssembler resourcesAssembler) {
|
|
|
+// final Question saved = questionRepository.findById(questionId)l
|
|
|
+// return new ResponseEntity(resourcesAssembler.toFullResource(saved), HttpStatus.OK);
|
|
|
+// }
|
|
|
+
|
|
|
@RequestMapping(value = "/search/findByStemLike",method= RequestMethod.GET, produces = "application/hal+json")
|
|
|
public @ResponseBody ResponseEntity<?> findByStem(String content,Pageable pageable) {
|
|
|
- final Page<Question> like = questionRepository.findByStemLike(content, pageable);
|
|
|
+ Page<Question> like;
|
|
|
+ if(content==null||content.length()==0){
|
|
|
+ like = questionRepository.findAll(pageable);
|
|
|
+ }else{
|
|
|
+ like = questionRepository.findByStemLike(content, pageable);
|
|
|
+ }
|
|
|
+
|
|
|
return new ResponseEntity(pagedAssembler.toModel(like), HttpStatus.OK);
|
|
|
}
|
|
|
|