健身房管理系统 - 基于Spring Boot + MyBatis的Web项目实战(附图文+源码分析)

本项目为一款轻量级的健身房管理系统,前后端基于Spring Boot和Thymeleaf实现,功能涵盖会员管理、员工管理、课程管理、器材管理等,支持管理员和会员两类角色操作,是一次完整的Java Web实战项目开发案例,适合用于课程设计、毕业设计或项目练习。


🔧 一、项目背景与开发环境

随着健身行业的发展,线下管理方式逐渐转向系统化、数据化管理。本系统旨在解决健身房日常运营中的核心需求,实现信息数字化和流程自动化,提升管理效率。
开发者: 独立完成
开发工具与技术:

工具/框架说明
Spring Boot后端框架,简化配置与开发流程
MyBatisORM框架,简洁高效操作数据库
Thymeleaf模板引擎,动态HTML渲染
MySQL数据库系统,存储各类业务数据
sb-admin 模板前端UI框架,简洁美观
Maven构建工具,项目依赖管理
JDK & IDEJava 8 & IntelliJ IDEA

🧩 二、功能模块设计

系统整体分为两类用户:管理员会员用户,分别拥有不同的操作权限和页面视图。

🎯 管理员端功能:

  • 登录 / 退出系统

  • 查看健身房统计数据(会员总数、器材数量、员工数等)

  • 会员管理(新增、编辑、删除会员)

  • 员工管理(教练信息管理)

  • 器材管理(数量、名称登记)

  • 课程管理(课程安排、报名统计)

📷 图示:

  • 管理员登录页

  • 管理员首页 - 数据面板 + 图表展示

  • 添加会员页面

  • 编辑会员信息页面

  • 课程管理功能页(含报名查看、删除等)


🧑‍🤝‍🧑 会员端功能:

  • 登录个人账户

  • 查看个人信息

  • 报名课程、取消报名

📷 图示:

  • 会员报名选课页面


🗂 三、系统结构与数据库设计

结构参考自 [README.md] 文件说明,支持清晰的包分层管理。


数据库设计(主要表):

  • member:会员信息表

  • staff:员工信息表

  • equipment:器材信息表

  • course:课程信息表

  • apply_course:课程报名信息

  • admin_user / member_user:登录认证表

🗂 四、代码说明

1、src/main/java/com/milotnt/controller 页面跳转

ClassController.java

package com.milotnt.controller;

import com.milotnt.pojo.ClassOrder;
import com.milotnt.pojo.ClassTable;
import com.milotnt.service.ClassOrderService;
import com.milotnt.service.ClassTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("/class")
public class ClassController {

    @Autowired
    private ClassTableService classTableService;

    @Autowired
    private ClassOrderService classOrderService;

    //查询课程
    @RequestMapping("/selClass")
    public String selectClass(Model model) {
        List<ClassTable> classList = classTableService.findAll();
        model.addAttribute("classList", classList);
        return "selectClass";
    }

    //跳转新增课程页面
    @RequestMapping("/toAddClass")
    public String toAddClass() {
        return "addClass";
    }

    //新增课程
    @RequestMapping("/addClass")
    public String addClass(ClassTable classTable) {
        classTableService.insertClass(classTable);
        return "redirect:selClass";
    }

    //删除课程
    @RequestMapping("/delClass")
    public String deleteClass(Integer classId) {
        classTableService.deleteClassByClassId(classId);
        classTableService.deleteOrderByClassId(classId);
        return "redirect:selClass";
    }

    //查询课程报名信息
    @RequestMapping("/selClassOrder")
    public String selectClassOrder(Integer classId, Model model) {
        List<ClassOrder> classOrderList = classOrderService.selectMemberOrderList(classId);
        model.addAttribute("classOrderList", classOrderList);
        return "selectClassOrder";
    }

}

EmployeeController.java

package com.milotnt.controller;

import com.milotnt.pojo.Employee;
import com.milotnt.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;


@Controller
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    //查询员工
    @RequestMapping("/selEmployee")
    public String selectEmployee(Model model) {
        List<Employee> employeeList = employeeService.findAll();
        model.addAttribute("employeeList", employeeList);
        return "selectEmployee";
    }

    //跳转新增员工页面
    @RequestMapping("/toAddEmployee")
    public String toAddEmployee() {
        return "addEmployee";
    }

    //新增员工
    @RequestMapping("/addEmployee")
    public String addEmployee(Employee employee) {
        //工号随机生成
        Random random = new Random();
        String account1 = "1010";
        for (int i = 0; i < 5; i++) {
            account1 += random.nextInt(10);
        }
        Integer account = Integer.parseInt(account1);

        //获取当前日期
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String nowDay = simpleDateFormat.format(date);

        employee.setEmployeeAccount(account);
        employee.setEntryTime(nowDay);

        employeeService.insertEmployee(employee);

        return "redirect:selEmployee";

    }

    //删除员工
    @RequestMapping("/delEmployee")
    public String deleteEmployee(Integer employeeAccount) {
        employeeService.deleteByEmployeeAccount(employeeAccount);
        return "redirect:selEmployee";
    }

    //跳转员工修改页面
    @RequestMapping("/toUpdateEmployee")
    public String toUpdateEmployee(Integer employeeAccount, Model model) {
        List<Employee> employeeList = employeeService.selectByEmployeeAccount(employeeAccount);
        model.addAttribute("employeeList", employeeList);
        return "updateEmployee";
    }

    //修改员工信息
    @RequestMapping("/updateEmployee")
    public String updateEmployee(Employee employee) {
        employeeService.updateMemberByEmployeeAccount(employee);
        return "redirect:selEmployee";
    }

}

2、src/main/java/com/milotnt/mapper 数据库连接

AdminMapper.java

package com.milotnt.mapper;

import com.milotnt.pojo.Admin;
import org.apache.ibatis.annotations.Mapper;


@Mapper
public interface AdminMapper {

    Admin selectByAccountAndPassword(Admin admin);

}

ClassOrderMapper.java

package com.milotnt.mapper;

import com.milotnt.pojo.ClassOrder;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface ClassOrderMapper {

    //查询所有报名表信息
    List<ClassOrder> findAll();

    //添加报名信息
    Boolean insertClassOrder(ClassOrder classOrder);

    //根据会员账号查询个人报名课表
    List<ClassOrder> selectClassOrderByMemberAccount(Integer memberAccount);

    //删除已预约的课程
    Boolean deleteByClassOrderId(Integer classOrderId);

    //查询会员是否报名该课程
    ClassOrder selectMemberByClassIdAndMemberAccount(Integer classId, Integer memberAccount);

    //根据课程id查询所有报名的会员
    List<ClassOrder> selectMemberOrderList(Integer classId);

}

3、src/main/java/com/milotnt/pojo

Admin.java

package com.milotnt.pojo;


public class Admin {

    private Integer adminAccount;
    private String adminPassword;

    public Integer getAdminAccount() {
        return adminAccount;
    }

    public void setAdminAccount(Integer adminAccount) {
        this.adminAccount = adminAccount;
    }

    public String getAdminPassword() {
        return adminPassword;
    }

    public void setAdminPassword(String adminPassword) {
        this.adminPassword = adminPassword;
    }

    @Override
    public String toString() {
        return "Admin{" +
                "adminAccount=" + adminAccount +
                ", adminPassword='" + adminPassword + '\'' +
                '}';
    }
}

ClassOrder.java

package com.milotnt.pojo;

/**
 * @author ZhangMing [1157038410@qq.com]
 * @date 2021/8/10
 */
public class ClassOrder {

    private Integer classOrderId;
    private Integer classId;
    private String className;
    private String coach;
    private String memberName;
    private Integer memberAccount;
    private String classBegin;

    public ClassOrder() {
    }

    public ClassOrder(Integer classId, String className, String coach, String memberName, Integer memberAccount, String classBegin) {
        this.classId = classId;
        this.className = className;
        this.coach = coach;
        this.memberName = memberName;
        this.memberAccount = memberAccount;
        this.classBegin = classBegin;
    }

    public Integer getClassOrderId() {
        return classOrderId;
    }

    public void setClassOrderId(Integer classOrderId) {
        this.classOrderId = classOrderId;
    }

    public Integer getClassId() {
        return classId;
    }

    public void setClassId(Integer classId) {
        this.classId = classId;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getCoach() {
        return coach;
    }

    public void setCoach(String coach) {
        this.coach = coach;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public Integer getMemberAccount() {
        return memberAccount;
    }

    public void setMemberAccount(Integer memberAccount) {
        this.memberAccount = memberAccount;
    }

    public String getClassBegin() {
        return classBegin;
    }

    public void setClassBegin(String classBegin) {
        this.classBegin = classBegin;
    }

    @Override
    public String toString() {
        return "ClassOrder{" +
                "classOrderId=" + classOrderId +
                ", classId=" + classId +
                ", className='" + className + '\'' +
                ", coach='" + coach + '\'' +
                ", memberName='" + memberName + '\'' +
                ", memberAccount=" + memberAccount +
                ", classBegin='" + classBegin + '\'' +
                '}';
    }
}

4、src/main/java/com/milotnt/service

com/milotnt/service/AdminService.java

package com.milotnt.service;

import com.milotnt.pojo.Admin;



public interface AdminService {

    //管理员登录
    Admin adminLogin(Admin admin);

}

com/milotnt/service/impl/AdminServiceImpl.java

package com.milotnt.service.impl;

import com.milotnt.mapper.AdminMapper;
import com.milotnt.pojo.Admin;
import com.milotnt.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin adminLogin(Admin admin) {
        return adminMapper.selectByAccountAndPassword(admin);
    }
}

🚀 五、运行与部署说明

1. 本地运行流程

  1. 安装并启动 MySQL,创建数据库

  2. 导入 SQL 脚本初始化表结构

  3. 配置 application.yml 中数据库连接信息

  4. 使用 IntelliJ IDEA 打开项目并运行

  5. 浏览器访问:http://localhost:8080


✅ 六、项目总结

本健身房管理系统作为毕业设计项目,功能齐全、模块清晰,能够完整展示健身房在日常管理中的核心业务操作。通过本项目,开发者能全面了解:

  • Java Web 三层架构开发模式

  • Spring Boot + MyBatis 的整合使用

  • 前后端数据交互与动态页面渲染

  • 实用型图表、表格在管理系统中的应用


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值