基于javaweb+mysql的springboot+mybatis游泳馆会员管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Layui Ajax)

基于javaweb+mysql的springboot+mybatis游泳馆会员管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Layui Ajax)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

技术框架

JavaBean MVC JSP SpringBoot MyBatis MySQL CSS JavaScript Layui Ajax

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

登录、注册、退出、用户模块、公告模块、教练模块、设备模块、会员模块的增删改查管理

eclipse/MyEclipse运行:

idea运行:

        userService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取用户的详细信息(详情页面与编辑页面要显示该用户的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"userGet", "userEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        User vo = userService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("user_" + to + ".jsp");
    }

    /**
     * 根据条件查询用户的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(userService.list(params).get("list")));
    }
}


@Controller
public class AuthController extends HttpServlet {
    @Autowired
    private UserService userService;

    @RequestMapping("authLogin")
    public void login(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        String validationCode = request.getParameter("validationCode");
        if (validationCode != null && !validationCode.equals(request.getSession().getAttribute("validationCode"))) {//验证码不通过
            request.getSession().setAttribute("alert_msg", "错误:验证码不正确!");
            request.getRequestDispatcher("login.jsp").forward(request, response);
            return;
        }

        Map<String, Object> params = new HashMap();
        
        
        List<User> list = (List<User>) userService.list(params).get("list");
        for (User user : list) {
            if (user.getUsername().equals(username) && user.getPassword().equals(password)) {//找到这个管理员了
                request.getSession().setAttribute("loginUser", user);
				request.getSession().setMaxInactiveInterval(Integer.MAX_VALUE);
                request.getRequestDispatcher("user_list.jsp").forward(request, response);
                return;
            }
        }
        request.getSession().setAttribute("alert_msg", "错误:用户名或密码错误!");
        request.getRequestDispatcher("login.jsp").forward(request, response);
        OutputStream os = response.getOutputStream();
        ImageIO.write(image, "JPEG", os);// 以JPEG格式向客户端发送图形验证码
    }

    @RequestMapping("authResetPassword")
    public void resetPassword(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
        String msg;
        User loginUser = (User) request.getSession().getAttribute("loginUser");
        String oldPassword = request.getParameter("oldPassword");
        if (!loginUser.getPassword().equals(oldPassword)) {
            msg = "原密码错误!";
        } else {
            String newPassword = request.getParameter("newPassword");
            loginUser.setPassword(newPassword);
            this.userService.update(loginUser);
            msg = "修改成功!";
        }
        request.getSession().setAttribute("alert_msg", msg);
        request.getRequestDispatcher("reset_password.jsp").forward(request, response);
    }

    // 返回一个随机颜色(Color对象)
    private Color getRandomColor(int minColor, int maxColor) {
        Random random = new Random();
        // 保存minColor最大不会超过255
        if (minColor > 255)
            minColor = 255;
        //  保存minColor最大不会超过255
        if (maxColor > 255)
            maxColor = 255;
        //  获得红色的随机颜色值
        int red = minColor + random.nextInt(maxColor - minColor);
        //  获得绿色的随机颜色值
        int green = minColor + random.nextInt(maxColor - minColor);
        //  获得蓝色的随机颜色值
        int blue = minColor + random.nextInt(maxColor - minColor);
        return new Color(red, green, blue);
    }
}

        //调用Service层的增加(insert)方法
        userService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        userService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userEdit")
    public void edit(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        userService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取用户的详细信息(详情页面与编辑页面要显示该用户的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"userGet", "userEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        User vo = userService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("user_" + to + ".jsp");
    }
        Random random = new Random();
        // 保存minColor最大不会超过255
        if (minColor > 255)
            minColor = 255;
        //  保存minColor最大不会超过255
        if (maxColor > 255)
            maxColor = 255;
        //  获得红色的随机颜色值
        int red = minColor + random.nextInt(maxColor - minColor);
        //  获得绿色的随机颜色值
        int green = minColor + random.nextInt(maxColor - minColor);
        //  获得蓝色的随机颜色值
        int blue = minColor + random.nextInt(maxColor - minColor);
        return new Color(red, green, blue);
    }
}

@Controller
@RequestMapping
public class EquipmentController {

    @Autowired
    private EquipmentService equipmentService;

    /**
     * 增加设备
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("equipmentAdd")
     * 删除会员
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("memberDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        memberService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑会员
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("memberEdit")
    public void edit(Member vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        memberService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取会员的详细信息(详情页面与编辑页面要显示该会员的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"memberGet", "memberEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Member vo = memberService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("member_" + to + ".jsp");
     * @throws IOException
     */
    @RequestMapping("equipmentAdd")
    public void add(Equipment vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        equipmentService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除设备
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("equipmentDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        equipmentService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑设备
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("equipmentEdit")
    public void edit(Equipment vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        equipmentService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取设备的详细信息(详情页面与编辑页面要显示该设备的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException

@Controller
public class AuthController extends HttpServlet {
    @Autowired
    private UserService userService;

    @RequestMapping("authLogin")
    public void login(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        String validationCode = request.getParameter("validationCode");
        if (validationCode != null && !validationCode.equals(request.getSession().getAttribute("validationCode"))) {//验证码不通过
            request.getSession().setAttribute("alert_msg", "错误:验证码不正确!");
            request.getRequestDispatcher("login.jsp").forward(request, response);
            return;
        }

        Map<String, Object> params = new HashMap();
        
        
        List<User> list = (List<User>) userService.list(params).get("list");
        for (User user : list) {
            if (user.getUsername().equals(username) && user.getPassword().equals(password)) {//找到这个管理员了
                request.getSession().setAttribute("loginUser", user);
				request.getSession().setMaxInactiveInterval(Integer.MAX_VALUE);
                request.getRequestDispatcher("user_list.jsp").forward(request, response);
                return;
            }
        }
        request.getSession().setAttribute("alert_msg", "错误:用户名或密码错误!");
        request.getRequestDispatcher("login.jsp").forward(request, response);
    }

    @RequestMapping("authRegister")
    public void register(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println("username=" + username);
        System.out.println("password=" + password);

        Map<String, Object> params = new HashMap();
        
        
        params.put("startIndex", 0);
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(noticeService.list(params).get("list")));
    }
}

@Controller
@RequestMapping
public class CoachController {

    @Autowired
    private CoachService coachService;

    /**
     */
    @RequestMapping("equipmentEdit")
    public void edit(Equipment vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        equipmentService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取设备的详细信息(详情页面与编辑页面要显示该设备的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"equipmentGet", "equipmentEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Equipment vo = equipmentService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("equipment_" + to + ".jsp");
    }

    /**
     * 根据条件查询设备的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("equipmentList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
    private EquipmentService equipmentService;

    /**
     * 增加设备
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("equipmentAdd")
    public void add(Equipment vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        equipmentService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除设备
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("equipmentDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        equipmentService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑设备
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("equipmentEdit")
    public void edit(Equipment vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        equipmentService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取设备的详细信息(详情页面与编辑页面要显示该设备的详情)并跳转回页面
     *
     * @param response
     * @param request
    @Autowired
    private MemberService memberService;

    /**
     * 增加会员
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("memberAdd")
    public void add(Member vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        memberService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除会员
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("memberDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        memberService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑会员
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("memberEdit")
    public void edit(Member vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        memberService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取会员的详细信息(详情页面与编辑页面要显示该会员的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
     * @throws IOException
     */
    @RequestMapping("userAdd")
    public void add(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        userService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        userService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userEdit")
    public void edit(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        userService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取用户的详细信息(详情页面与编辑页面要显示该用户的详情)并跳转回页面
     *
     * @param response
     * @param request
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(coachService.list(params).get("list")));
    }
}

@Controller
@RequestMapping
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 增加用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userAdd")
    public void add(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        userService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除用户
     *
     * @param response
     * @param request
        //  获得绿色的随机颜色值
        int green = minColor + random.nextInt(maxColor - minColor);
        //  获得蓝色的随机颜色值
        int blue = minColor + random.nextInt(maxColor - minColor);
        return new Color(red, green, blue);
    }
}

@Controller
@RequestMapping
public class EquipmentController {

    @Autowired
    private EquipmentService equipmentService;

    /**
     * 增加设备
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("equipmentAdd")
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(userService.list(params).get("list")));
    }
}

@Configuration

public class CustomWebMvcConfigurer implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/*");
    }

    public class LoginInterceptor implements HandlerInterceptor {
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            HttpSession session = request.getSession();
            //移除错误提示
            session.removeAttribute("alert_msg");
            //登录拦截
            String uri = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/"));
            String[] access = new String[]{"login", "logout", "register", ".css", ".js", ".png", ".jpg", "validationCode"};
    }

    /**
     * 根据条件查询教练的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("coachList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(coachService.list(params).get("list")));
    }
}

     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("memberAdd")
    public void add(Member vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        memberService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除会员
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("memberDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        memberService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑会员
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("memberEdit")
    public void edit(Member vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        memberService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取会员的详细信息(详情页面与编辑页面要显示该会员的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"memberGet", "memberEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Member vo = memberService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("member_" + to + ".jsp");
    }

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值