Search in sources :

Example 21 with User

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();
    }
}
Also used : User(com.zyf.bean.User) UserDao(com.zyf.dao.UserDao) HttpSession(javax.servlet.http.HttpSession) RelaDao(com.zyf.dao.RelaDao) PrintWriter(java.io.PrintWriter)

Example 22 with User

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);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) RelaDao(com.zyf.dao.RelaDao) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 23 with User

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&para=" + single.getId() + "&para1=" + reid + " \"target=\"_blank\">查看记录</a>");
        array.add(ob);
    }
    PrintWriter out = response.getWriter();
    out.print(array);
    System.out.println(array);
}
Also used : JsonArray(com.google.gson.JsonArray) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) JsonObject(com.google.gson.JsonObject) List(java.util.List) Info(com.zyf.bean.Info) PrintWriter(java.io.PrintWriter)

Example 24 with User

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);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) List(java.util.List) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 25 with User

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);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) List(java.util.List) RelaDao(com.zyf.dao.RelaDao) RequestDispatcher(javax.servlet.RequestDispatcher)

Aggregations

User (com.zyf.bean.User)53 HttpSession (javax.servlet.http.HttpSession)51 RequestDispatcher (javax.servlet.RequestDispatcher)28 List (java.util.List)18 PrintWriter (java.io.PrintWriter)17 JsonObject (com.google.gson.JsonObject)12 JsonArray (com.google.gson.JsonArray)11 InfoDao (com.zyf.dao.InfoDao)9 Info (com.zyf.bean.Info)7 ExaminationDao (com.zyf.dao.ExaminationDao)7 Info24 (com.zyf.bean.Info24)6 Info24Dao (com.zyf.dao.Info24Dao)6 RelaDao (com.zyf.dao.RelaDao)6 UserDao (com.zyf.dao.UserDao)6 Examination (com.zyf.bean.Examination)5 MedicalhistoryDao (com.zyf.dao.MedicalhistoryDao)5 Medicalhistory (com.zyf.bean.Medicalhistory)4 Urine (com.zyf.bean.Urine)4 FileDao (com.zyf.dao.FileDao)4 UrineDao (com.zyf.dao.UrineDao)4