Search in sources :

Example 1 with BloodPressureDao

use of com.zyf.dao.BloodPressureDao in project HeartWatchdogJsp by Viczyf.

the class BloodpressureServlet method select_time_bloodpressure.

private void select_time_bloodpressure(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    BloodPressureDao bloodPressureDao = new BloodPressureDao();
    String startdate = request.getParameter("startdate");
    String enddate = request.getParameter("enddate");
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    System.out.println("uid" + uid);
    List bpList = bloodPressureDao.queryTimeBloodPressure(uid, startdate, enddate);
    System.out.println(bpList.size());
    JsonArray array = new JsonArray();
    for (int i = 0; i < bpList.size(); i++) {
        BloodPressure bp = (BloodPressure) bpList.get(i);
        JsonObject ob = new JsonObject();
        ob.addProperty("id", i + 1);
        ob.addProperty("date", bp.getDate());
        ob.addProperty("highPressure", bp.getHighpressure());
        ob.addProperty("lowPressure", bp.getLowpressure());
        ob.addProperty("xinlv", bp.getXinlv());
        array.add(ob);
    }
    System.out.println(array);
    PrintWriter out = response.getWriter();
    out.print(array);
}
Also used : JsonArray(com.google.gson.JsonArray) BloodPressure(com.zyf.bean.BloodPressure) User(com.zyf.bean.User) BloodPressureDao(com.zyf.dao.BloodPressureDao) HttpSession(javax.servlet.http.HttpSession) JsonObject(com.google.gson.JsonObject) List(java.util.List) PrintWriter(java.io.PrintWriter)

Example 2 with BloodPressureDao

use of com.zyf.dao.BloodPressureDao in project HeartWatchdogJsp by Viczyf.

the class BloodpressureServlet method tendBloodpressure.

public void tendBloodpressure(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    BloodPressureDao bloodPressureDao = new BloodPressureDao();
    HttpSession session = request.getSession();
    // 获取用户对象
    User user = (User) session.getAttribute("user");
    int id = user.getUid();
    List bpList = bloodPressureDao.queryBloodPressure(id);
    request.setAttribute("bpList", bpList);
    RequestDispatcher rd = request.getRequestDispatcher("bloodpressuretend.jsp");
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) BloodPressureDao(com.zyf.dao.BloodPressureDao) HttpSession(javax.servlet.http.HttpSession) List(java.util.List) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 3 with BloodPressureDao

use of com.zyf.dao.BloodPressureDao in project HeartWatchdogJsp by Viczyf.

the class BloodpressureServlet method selectBloodpressure.

private void selectBloodpressure(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    BloodPressureDao bloodPressureDao = new BloodPressureDao();
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    List bpList = bloodPressureDao.queryBloodPressure(uid);
    JsonArray array = new JsonArray();
    for (int i = 0; i < bpList.size(); i++) {
        BloodPressure bp = (BloodPressure) bpList.get(i);
        JsonObject ob = new JsonObject();
        ob.addProperty("id", i + 1);
        ob.addProperty("date", bp.getDate());
        ob.addProperty("highPressure", bp.getHighpressure());
        ob.addProperty("lowPressure", bp.getLowpressure());
        ob.addProperty("xinlv", bp.getXinlv());
        array.add(ob);
    }
    System.out.println(array);
    PrintWriter out = response.getWriter();
    out.print(array);
}
Also used : JsonArray(com.google.gson.JsonArray) BloodPressure(com.zyf.bean.BloodPressure) User(com.zyf.bean.User) BloodPressureDao(com.zyf.dao.BloodPressureDao) HttpSession(javax.servlet.http.HttpSession) JsonObject(com.google.gson.JsonObject) List(java.util.List) PrintWriter(java.io.PrintWriter)

Aggregations

User (com.zyf.bean.User)3 BloodPressureDao (com.zyf.dao.BloodPressureDao)3 List (java.util.List)3 HttpSession (javax.servlet.http.HttpSession)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 BloodPressure (com.zyf.bean.BloodPressure)2 PrintWriter (java.io.PrintWriter)2 RequestDispatcher (javax.servlet.RequestDispatcher)1