use of com.zyf.bean.User 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.bean.User in project HeartWatchdogJsp by Viczyf.
the class SuggestionServlet method saveSuggestion.
public void saveSuggestion(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
Suggestion sugg = new Suggestion();
sugg.setUid(user.getUid());
sugg.setUname(user.getUname());
Date now = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
String date = format.format(now);
System.out.println(date);
sugg.setDate(date);
String info = request.getParameter("info");
sugg.setSuggsetion(info);
SuggestionDao suggestiondao = new SuggestionDao();
boolean rs = suggestiondao.saveSuggestion(sugg);
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=\"suggestion.jsp\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>3秒后自动返回。',\n" + " animation:\"slide-from-top\",\n" + " html: true,\n" + " timer: 3000,\n" + " showConfirmButton: false\n" + " });\n" + " })\n" + " window.onload = function(){\n" + " setTimeout(fun,3000);\n" + " }\n" + " function fun(){\n" + " window.location=\"suggestion.jsp\"\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=\"suggestion.jsp\" role=\"button\"><font size=\"5\" color=\"green\"> 点此返回</font></a>。<br>3秒后自动返回。',\n" + " animation:\"slide-from-top\",\n" + " html: true,\n" + " timer: 3000,\n" + " showConfirmButton: false\n" + " });\n" + " })\n" + " window.onload = function(){\n" + " setTimeout(fun,3000);\n" + " }\n" + " function fun(){\n" + " window.location=\"suggestion.jsp\"\n" + " }\n" + "</script>\n" + "</body>\n" + "</html>");
out.flush();
out.close();
}
}
use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.
the class TempServlet method tendTemp.
public void tendTemp(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
TempDao tempdao = new TempDao();
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
List tempList = tempdao.queryTemp(uid);
List tempMaxList = tempdao.queryMaxTemp(uid);
request.setAttribute("tempList", tempList);
request.setAttribute("tempMaxList", tempMaxList);
RequestDispatcher rd = request.getRequestDispatcher("temptend.jsp");
rd.forward(request, response);
}
use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.
the class UrineServlet method selectUrine.
public void selectUrine(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UrineDao urinedao = new UrineDao();
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int id = user.getUid();
List urineList = urinedao.queryUrine(id);
// request.setAttribute("urineList", urineList);
JsonArray array = new JsonArray();
for (int i = 0; i < urineList.size(); i++) {
Urine single = (Urine) urineList.get(i);
JsonObject ob = new JsonObject();
ob.addProperty("id", i + 1);
ob.addProperty("date", single.getDate());
ob.addProperty("read", "<a href=\"UrineServlet?action=single&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
ob.addProperty("del", "<a href=\"UrineServlet?action=delete&id=" + single.getId() + "\">删除记录</a>");
array.add(ob);
}
PrintWriter out = response.getWriter();
out.print(array);
System.out.println(array);
// RequestDispatcher rd = request.getRequestDispatcher("urinelist.jsp");
// request.setAttribute("listjson", array);
// rd.forward(request, response);
}
use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.
the class UrineServlet method singleUrine.
public void singleUrine(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UrineDao urinedao = new UrineDao();
int id = MyTools.strToint(request.getParameter("id"));
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
Urine urinesingle = urinedao.queryUrineSingle(id, uid);
request.setAttribute("urinesingle", urinesingle);
RequestDispatcher rd = request.getRequestDispatcher("urinesingle.jsp");
rd.forward(request, response);
}
Aggregations