-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
716 additions
and
59 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package Controller; | ||
|
||
import java.io.IOException; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
|
||
import Service.BlogCommentReply2DBService; | ||
import domain.blog_holder; | ||
|
||
|
||
public class DeleteCommentReplyController extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
HttpSession session = request.getSession(false); | ||
if(session == null){ | ||
response.getWriter().write("对不起您未登录"); | ||
return; | ||
} | ||
blog_holder holder = (blog_holder) session.getAttribute("holder"); | ||
if(holder == null){ | ||
response.getWriter().write("对不起您未登录"); | ||
return; | ||
} | ||
String commentReplyID = request.getParameter("commentReplyID"); | ||
if (commentReplyID == null) { | ||
response.getWriter().write("参数传递错误"); | ||
return; | ||
} | ||
BlogCommentReply2DBService commentService = new BlogCommentReply2DBService(); | ||
if (commentService.deleteCommentReply(commentReplyID) == 1) { | ||
response.getWriter().write("删除成功"); | ||
}else { | ||
response.getWriter().write("删除失败"); | ||
} | ||
} | ||
|
||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
// TODO Auto-generated method stub | ||
doGet(request, response); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package Controller; | ||
|
||
import java.io.IOException; | ||
import java.util.Base64; | ||
import java.util.Base64.Decoder; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
|
||
import Service.BlogCommentReply2DBService; | ||
import Service.BlogVisitor2DBService; | ||
import domain.blog_comment_reply; | ||
import domain.blog_holder; | ||
import domain.blog_visitor; | ||
|
||
|
||
public class InsertCommentReplyForHolderController extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
HttpSession session = request.getSession(false); | ||
if(session == null){ | ||
response.getWriter().write("对不起您未登录"); | ||
return; | ||
} | ||
blog_holder holder = (blog_holder) session.getAttribute("holder"); | ||
if(holder == null){ | ||
response.getWriter().write("对不起您未登录"); | ||
return; | ||
} | ||
String commentID = request.getParameter("commentID"); | ||
String commentReplyContent = request.getParameter("commentReplyContent"); | ||
if (commentID == null || commentReplyContent == null) { | ||
response.getWriter().write("参数错误"); | ||
return; | ||
} | ||
BlogVisitor2DBService ser = new BlogVisitor2DBService(); | ||
blog_visitor visitor = ser.selectVisitor("IL MARE"); | ||
if (visitor == null) { | ||
visitor = new blog_visitor(); | ||
visitor.setVisitor_nickname("IL MARE"); | ||
visitor.setVisitor_gender("男"); | ||
visitor.setProvince(holder.getHolder_province_zh()); | ||
visitor.setCity(holder.getHolder_city_zh()); | ||
visitor.setFigureurl("/blog/" + holder.getHolder_img()); | ||
visitor.setFigureurl_1("/blog/" + holder.getHolder_img()); | ||
visitor.setFigureurl_2("/blog/" + holder.getHolder_img()); | ||
visitor.setFigureurl_qq("/blog/" + holder.getHolder_img()); | ||
visitor.setFigureurl_qq_1("/blog/" + holder.getHolder_img()); | ||
visitor.setFigureurl_qq_2("/blog/" + holder.getHolder_img()); | ||
if (ser.insertVisitor(visitor) != 1) { | ||
response.getWriter().write("visitor对象插入失败,错误"); | ||
return; | ||
} | ||
} | ||
String remoteAddr = request.getRemoteAddr(); | ||
blog_comment_reply reply = new blog_comment_reply(); | ||
reply.setComment_id(commentID); | ||
reply.setVisitor_id(visitor.getVisitor_id()); | ||
reply.setComment_reply_content(commentReplyContent); | ||
reply.setComment_reply_ip(remoteAddr); | ||
reply.setComment_reply_visibility(1); | ||
BlogCommentReply2DBService service = new BlogCommentReply2DBService(); | ||
if(service.insertCommentReply(reply) < 1) { | ||
response.getWriter().write("评论发布失败"); | ||
}else { | ||
response.getWriter().write("评论发布成功"); | ||
} | ||
} | ||
|
||
|
||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
// TODO Auto-generated method stub | ||
doGet(request, response); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package Controller; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import Service.BlogComment2DBService; | ||
import Service.BlogCommentReply2DBService; | ||
import domain.blog_comment; | ||
import domain.blog_comment_reply; | ||
import domain.blog_holder; | ||
import domain.blog_page; | ||
|
||
|
||
public class SelectCommentReplyController extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
HttpSession session = request.getSession(false); | ||
if(session == null){ | ||
response.getWriter().write("对不起您未登录"); | ||
return; | ||
} | ||
blog_holder holder = (blog_holder) session.getAttribute("holder"); | ||
if(holder == null){ | ||
response.getWriter().write("对不起您未登录"); | ||
return; | ||
} | ||
String pageIndex = request.getParameter("pageIndex"); | ||
if (pageIndex == null) { | ||
response.getWriter().write("参数传递错误"); | ||
return; | ||
} | ||
int index = Integer.parseInt(pageIndex); | ||
BlogCommentReply2DBService commentReplyService = new BlogCommentReply2DBService(); | ||
blog_page page = commentReplyService.selectCommentReplyForBackEnd(index, 10, 10); | ||
BlogComment2DBService commentService = new BlogComment2DBService(); | ||
Map<String, Integer> map = new HashMap<>(); | ||
for(int i = 0; i < page.getList().size(); i ++) { | ||
blog_comment_reply reply = (blog_comment_reply) page.getList().get(i); | ||
String commentID = reply.getComment_id(); | ||
if (map.get(commentID) == null) { | ||
map.put(commentID, i); | ||
blog_comment comment = commentService.selectCommentById(commentID); | ||
reply.setComment(comment); | ||
}else { | ||
blog_comment_reply tmp = (blog_comment_reply) page.getList().get(map.get(commentID)); | ||
reply.setComment(tmp.getComment()); | ||
} | ||
} | ||
ObjectMapper mapper = new ObjectMapper(); | ||
String returnStr = mapper.writeValueAsString(page); | ||
response.getWriter().write(returnStr); | ||
} | ||
|
||
|
||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
// TODO Auto-generated method stub | ||
doGet(request, response); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package Controller; | ||
|
||
import java.io.IOException; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
|
||
import Service.BlogCommentReply2DBService; | ||
import domain.blog_comment_reply; | ||
import domain.blog_holder; | ||
|
||
|
||
public class UpdateCommentReplyController extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
HttpSession session = request.getSession(false); | ||
if(session == null){ | ||
response.getWriter().write("对不起您未登录"); | ||
return; | ||
} | ||
blog_holder holder = (blog_holder) session.getAttribute("holder"); | ||
if(holder == null){ | ||
response.getWriter().write("对不起您未登录"); | ||
return; | ||
} | ||
String commentReplyID = request.getParameter("commentReplyID"); | ||
String commenReplytVisibility = request.getParameter("commenReplytVisibility"); | ||
if (commentReplyID == null) { | ||
response.getWriter().write("参数错误"); | ||
return; | ||
} | ||
BlogCommentReply2DBService service = new BlogCommentReply2DBService(); | ||
blog_comment_reply reply = service.selectCommentReplyById(commentReplyID); | ||
if (commenReplytVisibility == null) { | ||
Integer flag = reply.getComment_reply_visibility() == 0 ? 1 : 0; | ||
reply.setComment_reply_visibility(flag); | ||
}else { | ||
Integer flag = Integer.parseInt(commenReplytVisibility); | ||
reply.setComment_reply_visibility(flag); | ||
} | ||
if(service.updateCommentReply(reply) < 1) { | ||
response.getWriter().write("修改失败"); | ||
}else { | ||
response.getWriter().write("修改成功"); | ||
} | ||
} | ||
|
||
|
||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
// TODO Auto-generated method stub | ||
doGet(request, response); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.