use of com.zyf.bean.User 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.bean.User 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.bean.User in project HeartWatchdogJsp by Viczyf.
the class RelaServlet method selectInfo.
public void selectInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
InfoDao infodao = new InfoDao();
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
int reid = MyTools.strToint(request.getParameter("para"));
List relainfolist = infodao.queryRelaInfo(uid, reid);
// request.setAttribute("relainfolist", relainfolist);
JsonArray array = new JsonArray();
for (int i = 0; i < relainfolist.size(); i++) {
Info single = (Info) relainfolist.get(i);
JsonObject ob = new JsonObject();
ob.addProperty("id", i + 1);
ob.addProperty("date", single.getDate());
ob.addProperty("read", "<a href=\"RelaServlet?action=RelaInfoSingle¶=" + single.getId() + "¶1=" + reid + " \"target=\"_blank\">查看记录</a>");
array.add(ob);
}
PrintWriter out = response.getWriter();
out.print(array);
System.out.println(array);
}
use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.
the class RelaServlet method relaTend.
private void relaTend(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
InfoDao infodao = new InfoDao();
int reid = MyTools.strToint(request.getParameter("para"));
String relaname = request.getParameter("para1");
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
List infoRelaList = infodao.queryRelaInfo(uid, reid);
request.setAttribute("infoRelaList", infoRelaList);
request.setAttribute("relaname", relaname);
String relaid = "";
relaid = String.valueOf(reid);
// 一个小细节,如果直接将int型传过去会报错
request.setAttribute("reid", relaid);
RequestDispatcher rd = request.getRequestDispatcher("relainfo.jsp");
rd.forward(request, response);
}
use of com.zyf.bean.User 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);
}
Aggregations