use of com.zyf.dao.RelaDao in project HeartWatchdogJsp by Viczyf.
the class RelaServlet method relaAdd.
public void relaAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String relaname = request.getParameter("relaname");
String information = request.getParameter("info");
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
String uname = user.getUname();
UserDao userDao = new UserDao();
RelaDao reladao = new RelaDao();
if (userDao.userIsExist(relaname)) {
int reid = userDao.userQueryId(relaname);
if (reladao.relaIsExist(relaname, uid)) {
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + " <meta charset=\"UTF-8\">\n" + " <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + " $(document).ready(function(){\n" + " swal({\n" + " type:\"info\",\n" + " title: \"您已经提交了好友申请,请等待对方通过\",\n" + " text: '<a href=\"RelaServlet?action=RelaList#demoTab4\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>5秒后自动返回。',\n" + " animation:\"slide-from-top\",\n" + " html: true,\n" + " timer: 5000,\n" + " showConfirmButton: false\n" + " });\n" + " })\n" + " window.onload = function(){\n" + " setTimeout(fun,5000);\n" + " }\n" + " function fun(){\n" + " window.location=\"RelaServlet?action=RelaList#demoTab4\"\n" + " }\n" + "</script>\n" + "</body>\n" + "</html>\n");
out.flush();
out.close();
} else {
if (reladao.relaIsExist1(relaname, uid)) {
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + " <meta charset=\"UTF-8\">\n" + " <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + " $(document).ready(function(){\n" + " swal({\n" + " type:\"info\",\n" + " title: \"对方已经向您提交了好友申请,请到验证消息中通过即可\",\n" + " text: '<a href=\"RelaServlet?action=RelaList#demoTab4\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>5秒后自动返回。',\n" + " animation:\"slide-from-top\",\n" + " html: true,\n" + " timer: 5000,\n" + " showConfirmButton: false\n" + " });\n" + " })\n" + " window.onload = function(){\n" + " setTimeout(fun,5000);\n" + " }\n" + " function fun(){\n" + " window.location=\"RelaServlet?action=RelaList#demoTab4\"\n" + " }\n" + "</script>\n" + "</body>\n" + "</html>");
out.flush();
out.close();
} else {
boolean rs = reladao.sendRequest(uid, uname, reid, relaname, information);
if (rs) {
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + " <meta charset=\"UTF-8\">\n" + " <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + " $(document).ready(function(){\n" + " swal({\n" + " type:\"success\",\n" + " title: \"您已提交请求,请等待对方通过\",\n" + " text: '<a href=\"RelaServlet?action=RelaList#demoTab4\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>5秒后自动返回。',\n" + " animation:\"slide-from-top\",\n" + " html: true,\n" + " timer: 5000,\n" + " showConfirmButton: false\n" + " });\n" + " })\n" + " window.onload = function(){\n" + " setTimeout(fun,5000);\n" + " }\n" + " function fun(){\n" + " window.location=\"RelaServlet?action=RelaList#demoTab4\"\n" + " }\n" + "</script>\n" + "</body>\n" + "</html>");
out.flush();
out.close();
} else {
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + " <meta charset=\"UTF-8\">\n" + " <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + " $(document).ready(function(){\n" + " swal({\n" + " type:\"error\",\n" + " title: \"发送请求失败,请返回检查\",\n" + " text: '<a href=\"RelaServlet?action=RelaList#demoTab4\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>5秒后自动返回。',\n" + " animation:\"slide-from-top\",\n" + " html: true,\n" + " timer: 5000,\n" + " showConfirmButton: false\n" + " });\n" + " })\n" + " window.onload = function(){\n" + " setTimeout(fun,5000);\n" + " }\n" + " function fun(){\n" + " window.location=\"RelaServlet?action=RelaList#demoTab4\"\n" + " }\n" + "</script>\n" + "</body>\n" + "</html>");
out.flush();
out.close();
}
}
}
} else {
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + " <meta charset=\"UTF-8\">\n" + " <link href=\"css/sweet-alert.css\" rel=\"stylesheet\">\n" + "</head>\n" + "<body>\n" + "<script src=\"js/jquery-3.1.1.js\"></script>\n" + "<script src=\"js/sweet-alert.min.js\"></script>\n" + "<script type=\"text/javascript\">\n" + " $(document).ready(function(){\n" + " swal({\n" + " type:\"error\",\n" + " title: \"该用户不存在!\",\n" + " text: '<a href=\"RelaServlet?action=RelaList#demoTab4\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>5秒后自动返回。',\n" + " animation:\"slide-from-top\",\n" + " html: true,\n" + " timer: 5000,\n" + " showConfirmButton: false\n" + " });\n" + " })\n" + " window.onload = function(){\n" + " setTimeout(fun,5000);\n" + " }\n" + " function fun(){\n" + " window.location=\"RelaServlet?action=RelaList#demoTab4\"\n" + " }\n" + "</script>\n" + "</body>\n" + "</html");
out.flush();
out.close();
}
}
use of com.zyf.dao.RelaDao in project HeartWatchdogJsp by Viczyf.
the class RelaServlet method relaReject.
private void relaReject(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String messages = "";
String forward = "";
String href = "";
RelaDao reladao = new RelaDao();
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
int reid = user.getUid();
int id = MyTools.strToint(request.getParameter("id"));
boolean rs = reladao.relaReject(id, reid);
if (rs) {
messages = "您已拒绝该请求";
forward = "tishi.jsp";
href = "RelaServlet?action=RelaList";
} else {
// messages = "删除好友失败,请稍后重试或检查该用户是否已经删除";
messages = "操作失败,请返回检查";
forward = "tishi.jsp";
href = "RelaServlet?action=RelaList";
}
request.setAttribute("message", messages);
request.setAttribute("href", href);
RequestDispatcher requestDispatcher1 = request.getRequestDispatcher(forward);
requestDispatcher1.forward(request, response);
}
use of com.zyf.dao.RelaDao in project HeartWatchdogJsp by Viczyf.
the class RelaServlet method queryRela.
// if (action.equals('RelaInfo')){
// this.queryRelaInfo(request,response);
// }
public void queryRela(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RelaDao reladao = new RelaDao();
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
List relaList = reladao.queryRela(uid);
request.setAttribute("relaList", relaList);
List relaCheckList = reladao.checkRela(uid);
request.setAttribute("relaCheckList", relaCheckList);
List relaRequestList = reladao.requestRela(uid);
request.setAttribute("relaRequestList", relaRequestList);
RequestDispatcher rd = request.getRequestDispatcher("relamanage.jsp");
rd.forward(request, response);
}
use of com.zyf.dao.RelaDao in project HeartWatchdogJsp by Viczyf.
the class RelaServlet method relaCancel.
private void relaCancel(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String messages = "";
String forward = "";
String href = "";
RelaDao reladao = new RelaDao();
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
int uid = user.getUid();
int id = MyTools.strToint(request.getParameter("id"));
boolean rs = reladao.relaCancel(id, uid);
if (rs) {
messages = "您已撤回该申请";
forward = "tishi.jsp";
href = "RelaServlet?action=RelaList";
} else {
// messages = "删除好友失败,请稍后重试或检查该用户是否已经删除";
messages = "撤回申请失败,请返回检查";
forward = "tishi.jsp";
href = "RelaServlet?action=RelaList";
}
request.setAttribute("message", messages);
request.setAttribute("href", href);
RequestDispatcher requestDispatcher1 = request.getRequestDispatcher(forward);
requestDispatcher1.forward(request, response);
}
use of com.zyf.dao.RelaDao in project HeartWatchdogJsp by Viczyf.
the class RelaServlet method relaAgree.
private void relaAgree(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String messages = "";
String forward = "";
String href = "";
RelaDao reladao = new RelaDao();
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
int reid = user.getUid();
int id = MyTools.strToint(request.getParameter("id"));
boolean rs = reladao.relaAgree(id, reid);
if (rs) {
messages = "添加好友成功";
forward = "tishi.jsp";
href = "RelaServlet?action=RelaList";
} else {
messages = "添加好友失败,请检查该用户是否已经是您的好友";
forward = "tishi.jsp";
href = "RelaServlet?action=RelaList";
}
request.setAttribute("message", messages);
request.setAttribute("href", href);
RequestDispatcher requestDispatcher1 = request.getRequestDispatcher(forward);
requestDispatcher1.forward(request, response);
}
Aggregations