use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.
the class InfoServlet method singleInfo.
public void singleInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
InfoDao infodao = new InfoDao();
int id = MyTools.strToint(request.getParameter("id"));
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
Info infosingle = infodao.queryInfoSingle(id, uid);
request.setAttribute("infosingle", infosingle);
RequestDispatcher rd = request.getRequestDispatcher("infosingle.jsp");
rd.forward(request, response);
}
use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.
the class InfoServlet method select_time_info.
public void select_time_info(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
InfoDao infodao = new InfoDao();
String startdate = request.getParameter("startdate");
String enddate = request.getParameter("enddate");
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int id = user.getUid();
List infoList = infodao.queryTimeInfo(id, startdate, enddate);
JsonArray array = new JsonArray();
for (int i = 0; i < infoList.size(); i++) {
Info single = (Info) infoList.get(i);
JsonObject ob = new JsonObject();
ob.addProperty("id", i + 1);
ob.addProperty("date", single.getDate());
ob.addProperty("read", "<a href=\"InfoServlet?action=single&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
ob.addProperty("read1", "<a href=\"InfoServlet?action=singlepot&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
ob.addProperty("del", "<a href=\"InfoServlet?action=delete&id=" + single.getId() + "\">删除记录</a>");
array.add(ob);
}
PrintWriter out = response.getWriter();
out.print(array);
System.out.println(array);
}
use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.
the class InfoServlet method deleteInfo.
public void deleteInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String message = "";
String forward = "";
String href = "";
InfoDao infodao = new InfoDao();
int id = MyTools.strToint(request.getParameter("id"));
Info info = new Info();
info.setId(id);
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
int uid = user.getUid();
boolean mark = infodao.delInfo(info, uid);
if (mark) {
message = message + "<li>删除记录成功!</li>";
forward = "tishi.jsp";
href = href + "infotime.jsp";
} else {
message = message + "<li>删除记录失败!</li>";
forward = "tishi.jsp";
href = href + "infotime.jsp";
}
request.setAttribute("message", message);
request.setAttribute("href", href);
RequestDispatcher rd = request.getRequestDispatcher(forward);
rd.forward(request, response);
}
use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.
the class RelaServlet method relaInfoSingle.
public void relaInfoSingle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
InfoDao infodao = new InfoDao();
int id = MyTools.strToint(request.getParameter("para"));
HttpSession session = request.getSession();
// 获取用户对象
User user = (User) session.getAttribute("user");
int uid = user.getUid();
int reid = MyTools.strToint(request.getParameter("para1"));
Info infosingle = infodao.queryRelaInfoSingle(id, uid, reid);
request.setAttribute("infosingle", infosingle);
String relaid = String.valueOf(reid);
request.setAttribute("reid", relaid);
RequestDispatcher rd = request.getRequestDispatcher("relainfosingle.jsp");
rd.forward(request, response);
}
use of com.zyf.dao.InfoDao in project HeartWatchdogJsp by Viczyf.
the class TestJson method doPost.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
InfoDao infodao = new InfoDao();
int id = 1;
List infoList = infodao.queryInfo(id);
request.setAttribute("infoList", infoList);
JsonArray array = new JsonArray();
for (int i = 0; i < infoList.size(); i++) {
Info single = (Info) infoList.get(i);
JsonObject ob = new JsonObject();
ob.addProperty("id", i + 1);
ob.addProperty("date", single.getDate());
ob.addProperty("read", "<a href=\"InfoServlet?action=single&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
ob.addProperty("del", "<a href=\"InfoServlet?action=delete&id=" + single.getId() + "\">删除记录</a>");
array.add(ob);
}
PrintWriter out = response.getWriter();
out.print(array);
System.out.println(array);
}
Aggregations