Skip to content

Commit

Permalink
update at Oct 16th
Browse files Browse the repository at this point in the history
  • Loading branch information
yhilmare committed Oct 16, 2019
1 parent 4420e10 commit 576d946
Show file tree
Hide file tree
Showing 15 changed files with 716 additions and 59 deletions.
Binary file added WebContent/Images/blogComment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
331 changes: 324 additions & 7 deletions WebContent/WEB-INF/managementPage/blogManagement.html

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -727,4 +727,44 @@
<servlet-name>UpdateCommentController</servlet-name>
<url-pattern>/UpdateCommentController</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>InsertCommentReplyForHolderController</display-name>
<servlet-name>InsertCommentReplyForHolderController</servlet-name>
<servlet-class>Controller.InsertCommentReplyForHolderController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>InsertCommentReplyForHolderController</servlet-name>
<url-pattern>/InsertCommentReplyForHolderController</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>SelectCommentReplyController</display-name>
<servlet-name>SelectCommentReplyController</servlet-name>
<servlet-class>Controller.SelectCommentReplyController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SelectCommentReplyController</servlet-name>
<url-pattern>/SelectCommentReplyController</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>UpdateCommentReplyController</display-name>
<servlet-name>UpdateCommentReplyController</servlet-name>
<servlet-class>Controller.UpdateCommentReplyController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UpdateCommentReplyController</servlet-name>
<url-pattern>/UpdateCommentReplyController</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>DeleteCommentReplyController</display-name>
<servlet-name>DeleteCommentReplyController</servlet-name>
<servlet-class>Controller.DeleteCommentReplyController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DeleteCommentReplyController</servlet-name>
<url-pattern>/DeleteCommentReplyController</url-pattern>
</servlet-mapping>
</web-app>
45 changes: 45 additions & 0 deletions src/Controller/DeleteCommentReplyController.java
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);
}

}
79 changes: 79 additions & 0 deletions src/Controller/InsertCommentReplyForHolderController.java
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);
}

}
5 changes: 5 additions & 0 deletions src/Controller/RegisterVisitorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
e.printStackTrace();
}
}
if (visitor.getVisitor_nickname().trim().equalsIgnoreCase("IL MARE")
|| visitor.getVisitor_nickname().trim().equalsIgnoreCase("ILMARE")) {
response.getWriter().write("用户名ILMARE为保留字,注册失败");
return;
}
BlogVisitor2DBService service = new BlogVisitor2DBService();
String msg;
Login2DBThread thread = null;
Expand Down
69 changes: 69 additions & 0 deletions src/Controller/SelectCommentReplyController.java
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);
}

}
56 changes: 56 additions & 0 deletions src/Controller/UpdateCommentReplyController.java
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);
}

}
38 changes: 38 additions & 0 deletions src/Controller/UpdateProfileInfoController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.util.Base64;
import java.util.Enumeration;
import java.util.Base64.Decoder;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
Expand All @@ -11,8 +13,10 @@
import javax.servlet.http.HttpSession;

import Service.BlogHolder2DBService;
import Service.BlogVisitor2DBService;
import Utils.MD5Utils;
import domain.blog_holder;
import domain.blog_visitor;


public class UpdateProfileInfoController extends HttpServlet {
Expand Down Expand Up @@ -48,6 +52,40 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
holder_new.setHolder_id(holder.getHolder_id());
holder_new.setHolder_pwd(MD5Utils.getToken(holder_new.getHolder_pwd()));
holder_new.setHolder_img(holder.getHolder_img());

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_new.getHolder_province_zh());
visitor.setCity(holder_new.getHolder_city_zh());
visitor.setFigureurl("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_1("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_2("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_qq("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_qq_1("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_qq_2("/blog/" + holder_new.getHolder_img());
if (ser.insertVisitor(visitor) != 1) {
response.getWriter().write("visitor对象插入失败,错误");
return;
}
}else {
visitor.setProvince(holder_new.getHolder_province_zh());
visitor.setCity(holder_new.getHolder_city_zh());
visitor.setFigureurl("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_1("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_2("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_qq("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_qq_1("/blog/" + holder_new.getHolder_img());
visitor.setFigureurl_qq_2("/blog/" + holder_new.getHolder_img());
if (ser.updateVisitor(visitor) != 1) {
response.getWriter().write("visitor对象更新失败,错误");
return;
}
}

BlogHolder2DBService service = new BlogHolder2DBService();
if(service.updateHolder(holder_new) >= 1){
this.getServletContext().setAttribute("holder", holder_new);
Expand Down
Loading

0 comments on commit 576d946

Please sign in to comment.