Преглед на файлове

Merge branch 'master' of http://47.100.37.243:10080/ZHOU/yunsu

преди 5 години
родител
ревизия
0a306770a0
променени са 1 файла, в които са добавени 39 реда и са изтрити 0 реда
  1. 39 0
      website/src/main/java/com/hssx/website/controller/UserController.java

+ 39 - 0
website/src/main/java/com/hssx/website/controller/UserController.java

@@ -0,0 +1,39 @@
+package com.hssx.website.controller;
+
+import com.hssx.website.entity.Comment;
+import com.hssx.website.service.ArticleService;
+import com.hssx.website.service.CommentService;
+import com.hssx.website.until.HttpRespMsg;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+public class UserController {
+
+    @Autowired
+    private ArticleService articleService;
+    @Autowired
+    private CommentService commentService;
+
+    @ApiOperation("案例")
+    @GetMapping("/index")
+    public String index(Model model) {
+        model = articleService.getList(model);
+        return "index";
+    }
+
+    @ApiOperation("添加留言")
+    @PostMapping("/add")
+    @ResponseBody
+    public HttpRespMsg addComment(Comment comment) {
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.data = commentService.save(comment);
+        return msg;
+    }
+}
+