zoukankan      html  css  js  c++  java
  • 需求分析大作业 功能实现进度一

    一、今日完成

    1.增加管理员登录功能

    package com.me.web;
    
    import com.me.dao.UserDao;
    import com.me.domain.AdminUser;
    import com.me.domain.User;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.sql.SQLException;
    
    @WebServlet("/loginServlet")
    public class dengluServlet extends HttpServlet {
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setContentType("text/html;charset=utf-8");
            String rand = (String) request.getSession().getAttribute("rand");
            String username = request.getParameter("user");
            String pwd = request.getParameter("pwd");
            String randcode = request.getParameter("randcode");
            UserDao dao = new UserDao();
            int num_user = 0,num_admin = 0;
            User user = null;
            AdminUser adminUser = null;
            if (!randcode.equals(rand)){
                response.getWriter().write("<script>alert('验证码错误!');window.location.href='"+request.getContextPath()+"/login.html'</script>");
            }
    
            //查找是否有账号、以及登录
            try {
                num_user= dao.ajaxUsername(username);
                num_admin = dao.ajaxAdminUser(username);
                user = dao.login(username,pwd);
                adminUser = dao.adminLogin(username,pwd);
            } catch (SQLException e) {
                e.printStackTrace();
                response.getWriter().write("<script>alert('登录失败!');window.location.href='"+request.getContextPath()+"/login.html'</script>");
            }
    
            if (num_user == 0){
                //查找管理员账号
                if (num_admin == 0){
                    //未找到
                    response.getWriter().write("<script>alert('该用户不存在,请注册!');window.location.href='"+request.getContextPath()+"/register.html'</script>");
                }else {
                    if (adminUser != null){
                        //登录成功
                      request.getSession().setAttribute("user",adminUser);
                        request.getSession().setAttribute("who","admin");
                        response.getWriter().write("<script>alert('登录成功!');window.location.href='"+request.getContextPath()+"/main.html'</script>");
                    }else if (adminUser == null){
                        //管理员账号或密码错误
                        response.getWriter().write("<script>alert('用户名或密码错误!');window.location.href='"+request.getContextPath()+"/register.html'</script>");
                    }
                }
            }else {
                if (user != null){
                    //账号密码正确
                    request.getSession().setAttribute("user",user);
                    request.getSession().setAttribute("who","user");
                    response.getWriter().write("<script>alert('登录成功!');window.location.href='"+request.getContextPath()+"/main.html'</script>");
                }else if (user == null ){
                    //账号密码错误
                    response.getWriter().write("<script>alert('用户名或密码错误!');window.location.href='"+request.getContextPath()+"/register.html'</script>");
                }
            }
        }
    }

    2.增加需求审核界面

    二、明日计划

    1.完成用户管理界面以及功能

    2.完成新增用户的功能

    3.完成权限管理界面及部分功能

  • 相关阅读:
    简单马周游问题1152siicly
    Sicily 1155. Can I Post the lette
    POJ 1007
    给定2个大小分别为n, m的整数集合,分别存放在两个数组中 int A[n],B[m],输出两个集合的交集。
    算法1--
    GAN
    为什么ConcurrentHashMap是弱一致的
    手写HASHMAP
    千万级规模高性能、高并发的网络架构经验分享
    Web 通信 之 长连接、长轮询(转)
  • 原文地址:https://www.cnblogs.com/best-hym/p/13843303.html
Copyright © 2011-2022 走看看