|
|
@@ -2,11 +2,17 @@ package com.seeckg.knowledgegraph_backend.controller;
|
|
|
|
|
|
|
|
|
import com.seeckg.knowledgegraph_backend.pojo.Knowledge;
|
|
|
+import com.seeckg.knowledgegraph_backend.pojo.KnowledgeVO;
|
|
|
+import com.seeckg.knowledgegraph_backend.pojo.Response;
|
|
|
import com.seeckg.knowledgegraph_backend.service.KnowledgeService;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@RestController
|
|
|
@@ -14,8 +20,25 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
public class KnowledgeController {
|
|
|
@Autowired
|
|
|
KnowledgeService knowledgeService;
|
|
|
+
|
|
|
@GetMapping("/{name}")
|
|
|
- public Knowledge findByName(@PathVariable("name") String name){
|
|
|
+ public Knowledge findByName(@PathVariable("name") String name) {
|
|
|
return knowledgeService.findByName(name);
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ public Response createKnowledge(@RequestBody KnowledgeVO knowledgeVO) {
|
|
|
+ return knowledgeService.addKnowledge(knowledgeVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/edit")
|
|
|
+ public Response editKnowledge(@RequestBody KnowledgeVO knowledgeVO, @RequestParam long userId) {
|
|
|
+ return knowledgeService.editKnowledge(knowledgeVO, userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete/{knowledgeId}")
|
|
|
+ public Response createKnowledge(@PathVariable("knowledgeId") long knowledgeId, @RequestParam long userId) {
|
|
|
+ return knowledgeService.deleteKnowledge(knowledgeId, userId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|