|
@@ -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;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|