From 4287d3f51194b76bd0e0fcf58554a90111cfd3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E9=87=91=E6=88=90?= <2693239786@qq.com> Date: Thu, 7 Sep 2023 08:52:23 +0800 Subject: [PATCH] update --- .../.idea/sonarlint/issuestore/index.pb | 24 ++++++++++----- .../sonarlint/securityhotspotstore/index.pb | 24 ++++++++++----- .../springboot/Control/WebHomeController.java | 25 ++++++++++++++++ .../com/xht/springboot/Dao/WebHomeMapper.java | 7 +++++ .../xht/springboot/Entity/UserComment.java | 1 - .../springboot/Service/WebHomeService.java | 29 +++++++++++++++++-- .../resources/mybatis/db1/WebHomeMapper.xml | 8 +++++ 7 files changed, 100 insertions(+), 18 deletions(-) diff --git a/src/medicine/.idea/sonarlint/issuestore/index.pb b/src/medicine/.idea/sonarlint/issuestore/index.pb index ec97fdab..c593fd92 100644 --- a/src/medicine/.idea/sonarlint/issuestore/index.pb +++ b/src/medicine/.idea/sonarlint/issuestore/index.pb @@ -1,14 +1,8 @@ -z -Jspringboot/src/main/java/com/xht/springboot/pythonspider/PythonSpider.java,8\2\82d065e13dbb46b69838db763af0105eec47337f -B -springboot/pom.xml,e\4\e46aee6c7c512a7b48980a296fca0acf004a1907 } Mspringboot/src/main/java/com/xht/springboot/Control/GetSpiderInformation.java,6\a\6ae8bd6e0b13a9d9272e5cd44460d2d0a72091d9 | Lspringboot/src/main/java/com/xht/springboot/Service/PersonalHomeService.java,7\6\762bc359bc75ba7b3073e784c826f31f6c989305 -s -Cspringboot/src/main/java/com/xht/springboot/Entity/UserComment.java,9\3\932ae6b8f9f42f924c25e69e48dc30fddd63ec28 q Aspringboot/src/main/java/com/xht/springboot/Entity/UserReply.java,0\5\051eaf551b928a8ccf651611c070ebb2b8155264 r @@ -24,4 +18,20 @@ Gspringboot/src/main/java/com/xht/springboot/Dao/PersonalHomeMapper.java,8\e\8e p @springboot/src/main/java/com/xht/springboot/Entity/UserHome.java,0\b\0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1 q -Aspringboot/src/main/java/com/xht/springboot/Entity/UserLogin.java,1\3\139a0da36daad8c438a5607ee212d1f38a505779 \ No newline at end of file +Aspringboot/src/main/java/com/xht/springboot/Entity/UserLogin.java,1\3\139a0da36daad8c438a5607ee212d1f38a505779 +z +Jspringboot/src/main/java/com/xht/springboot/pythonspider/PythonSpider.java,8\2\82d065e13dbb46b69838db763af0105eec47337f +p +@springboot/src/main/java/com/xht/springboot/Entity/UserText.java,4\0\40a2343a36c9747fa26c52f19f82c0a493b5c2e0 +z +Jspringboot/src/main/java/com/xht/springboot/Control/WebHomeController.java,e\d\edeacc9d294f3b307d4238fb3f381c6838218bb6 +v +Fspringboot/src/main/java/com/xht/springboot/SpringbootApplication.java,4\0\40324953a2003c0d6c6b3ceece38a620d48a0df7 +s +Cspringboot/src/main/java/com/xht/springboot/Entity/UserComment.java,9\3\932ae6b8f9f42f924c25e69e48dc30fddd63ec28 +w +Gspringboot/src/main/java/com/xht/springboot/Service/WebHomeService.java,5\f\5feb9f75e1bc678660918562fd0ce2745899be29 +B +springboot/pom.xml,e\4\e46aee6c7c512a7b48980a296fca0acf004a1907 +r +Bspringboot/src/main/java/com/xht/springboot/Dao/WebHomeMapper.java,2\a\2ad2a1260dac6c01c8b352bb0e2ca62f513676a9 \ No newline at end of file diff --git a/src/medicine/.idea/sonarlint/securityhotspotstore/index.pb b/src/medicine/.idea/sonarlint/securityhotspotstore/index.pb index 7c28c336..6f97e7d2 100644 --- a/src/medicine/.idea/sonarlint/securityhotspotstore/index.pb +++ b/src/medicine/.idea/sonarlint/securityhotspotstore/index.pb @@ -1,12 +1,6 @@ -z -Jspringboot/src/main/java/com/xht/springboot/pythonspider/PythonSpider.java,8\2\82d065e13dbb46b69838db763af0105eec47337f -B -springboot/pom.xml,e\4\e46aee6c7c512a7b48980a296fca0acf004a1907 } Mspringboot/src/main/java/com/xht/springboot/Control/GetSpiderInformation.java,6\a\6ae8bd6e0b13a9d9272e5cd44460d2d0a72091d9 -s -Cspringboot/src/main/java/com/xht/springboot/Entity/UserComment.java,9\3\932ae6b8f9f42f924c25e69e48dc30fddd63ec28 | Lspringboot/src/main/java/com/xht/springboot/Service/PersonalHomeService.java,7\6\762bc359bc75ba7b3073e784c826f31f6c989305 q @@ -24,4 +18,20 @@ Gspringboot/src/main/java/com/xht/springboot/Dao/PersonalHomeMapper.java,8\e\8e p @springboot/src/main/java/com/xht/springboot/Entity/UserHome.java,0\b\0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1 q -Aspringboot/src/main/java/com/xht/springboot/Entity/UserLogin.java,1\3\139a0da36daad8c438a5607ee212d1f38a505779 \ No newline at end of file +Aspringboot/src/main/java/com/xht/springboot/Entity/UserLogin.java,1\3\139a0da36daad8c438a5607ee212d1f38a505779 +p +@springboot/src/main/java/com/xht/springboot/Entity/UserText.java,4\0\40a2343a36c9747fa26c52f19f82c0a493b5c2e0 +v +Fspringboot/src/main/java/com/xht/springboot/SpringbootApplication.java,4\0\40324953a2003c0d6c6b3ceece38a620d48a0df7 +z +Jspringboot/src/main/java/com/xht/springboot/pythonspider/PythonSpider.java,8\2\82d065e13dbb46b69838db763af0105eec47337f +z +Jspringboot/src/main/java/com/xht/springboot/Control/WebHomeController.java,e\d\edeacc9d294f3b307d4238fb3f381c6838218bb6 +w +Gspringboot/src/main/java/com/xht/springboot/Service/WebHomeService.java,5\f\5feb9f75e1bc678660918562fd0ce2745899be29 +r +Bspringboot/src/main/java/com/xht/springboot/Dao/WebHomeMapper.java,2\a\2ad2a1260dac6c01c8b352bb0e2ca62f513676a9 +s +Cspringboot/src/main/java/com/xht/springboot/Entity/UserComment.java,9\3\932ae6b8f9f42f924c25e69e48dc30fddd63ec28 +B +springboot/pom.xml,e\4\e46aee6c7c512a7b48980a296fca0acf004a1907 \ No newline at end of file diff --git a/src/medicine/springboot/src/main/java/com/xht/springboot/Control/WebHomeController.java b/src/medicine/springboot/src/main/java/com/xht/springboot/Control/WebHomeController.java index 61df26c6..60f650a9 100644 --- a/src/medicine/springboot/src/main/java/com/xht/springboot/Control/WebHomeController.java +++ b/src/medicine/springboot/src/main/java/com/xht/springboot/Control/WebHomeController.java @@ -1,5 +1,6 @@ package com.xht.springboot.Control; +import com.xht.springboot.Entity.UserComment; import com.xht.springboot.Entity.UserReply; import com.xht.springboot.Entity.UserText; import com.xht.springboot.Service.WebHomeService; @@ -73,4 +74,28 @@ public class WebHomeController { public List findText(String token){ return webHomeService.findUserText(token); } + + @RequestMapping("/postcomment") + @ResponseBody + public RequestResult postComment(UserComment userComment){ + if(webHomeService.postUserComment(userComment)){ + requestResult.status = RequestResult.OK; + return requestResult; + }else { + requestResult.status = RequestResult.FAIL; + return requestResult; + } + } + + @RequestMapping("/postreply") + @ResponseBody + public RequestResult postReply(UserReply userReply){ + if(webHomeService.postUserReply(userReply)){ + requestResult.status = RequestResult.OK; + return requestResult; + }else { + requestResult.status = RequestResult.FAIL; + return requestResult; + } + } } diff --git a/src/medicine/springboot/src/main/java/com/xht/springboot/Dao/WebHomeMapper.java b/src/medicine/springboot/src/main/java/com/xht/springboot/Dao/WebHomeMapper.java index fce61b9d..88f4c241 100644 --- a/src/medicine/springboot/src/main/java/com/xht/springboot/Dao/WebHomeMapper.java +++ b/src/medicine/springboot/src/main/java/com/xht/springboot/Dao/WebHomeMapper.java @@ -1,5 +1,6 @@ package com.xht.springboot.Dao; +import com.xht.springboot.Entity.UserComment; import com.xht.springboot.Entity.UserReply; import com.xht.springboot.Entity.UserText; import org.apache.ibatis.annotations.Mapper; @@ -30,4 +31,10 @@ public interface WebHomeMapper { //查询文章-标题包含 public Collection findOfTitleContains(String string); + //上传对某文章的评论 + public int insertUserComment(UserComment userComment); + + //上传回复 + public int insertUserReply(UserReply userReply); + } diff --git a/src/medicine/springboot/src/main/java/com/xht/springboot/Entity/UserComment.java b/src/medicine/springboot/src/main/java/com/xht/springboot/Entity/UserComment.java index f37a14c4..071eea8d 100644 --- a/src/medicine/springboot/src/main/java/com/xht/springboot/Entity/UserComment.java +++ b/src/medicine/springboot/src/main/java/com/xht/springboot/Entity/UserComment.java @@ -6,7 +6,6 @@ import lombok.ToString; import org.springframework.stereotype.Component; import java.util.List; - @Data @ToString @Component diff --git a/src/medicine/springboot/src/main/java/com/xht/springboot/Service/WebHomeService.java b/src/medicine/springboot/src/main/java/com/xht/springboot/Service/WebHomeService.java index ac78c1a9..f56e330d 100644 --- a/src/medicine/springboot/src/main/java/com/xht/springboot/Service/WebHomeService.java +++ b/src/medicine/springboot/src/main/java/com/xht/springboot/Service/WebHomeService.java @@ -2,6 +2,7 @@ package com.xht.springboot.Service; import com.xht.springboot.Dao.WebHomeMapper; +import com.xht.springboot.Entity.UserComment; import com.xht.springboot.Entity.UserReply; import com.xht.springboot.Entity.UserText; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +28,7 @@ public class WebHomeService { int rows=0; rows = webHomeMapper.insertUserText(userText); if(rows >= 1){ - System.out.println("insert OK "+rows); + System.out.println("insert text OK "+rows); return true; }else{ return false; @@ -38,7 +39,7 @@ public class WebHomeService { int rows=0; rows = webHomeMapper.deleteUserText(userText); if(rows >= 1){ - System.out.println("delete OK "+rows); + System.out.println("delete text OK "+rows); return true; }else{ return false; @@ -49,7 +50,7 @@ public class WebHomeService { int rows=0; rows = webHomeMapper.updateUserText(userText); if(rows >= 1){ - System.out.println("update OK "+rows); + System.out.println("update text OK "+rows); return true; }else{ return false; @@ -62,4 +63,26 @@ public class WebHomeService { results.addAll(webHomeMapper.findOfTitleContains(token));//查询标题中是否包含 return results; } + + public boolean postUserComment(UserComment userComment){ + int rows=0; + rows = webHomeMapper.insertUserComment(userComment); + if(rows >= 1){ + System.out.println("insert comment OK "+rows); + return true; + }else{ + return false; + } + } + + public boolean postUserReply(UserReply userReply){ + int rows=0; + rows = webHomeMapper.insertUserReply(userReply); + if(rows >= 1){ + System.out.println("insert reply OK "+rows); + return true; + }else{ + return false; + } + } } diff --git a/src/medicine/springboot/src/main/resources/mybatis/db1/WebHomeMapper.xml b/src/medicine/springboot/src/main/resources/mybatis/db1/WebHomeMapper.xml index 2c0ad33f..39bbc0de 100644 --- a/src/medicine/springboot/src/main/resources/mybatis/db1/WebHomeMapper.xml +++ b/src/medicine/springboot/src/main/resources/mybatis/db1/WebHomeMapper.xml @@ -48,4 +48,12 @@ + + + insert into usercomments(textid,uid,comment) values(#{textid},#{uid},#{comment}) + + + + insert into userreplies(commentid,text) values(#{commentid},#{text}) + \ No newline at end of file