Hệ Thống Quản Lý Thông Tin Phòng Gym Sử Dụng Spring Boot

Công Nghệ Sử Dụng

Hệ thống được phát triển dựa trên nền tảng Spring Boot kết hợp với cơ sở dữ liệu MySQL. Môi trường triển khai sử dụng máy chủ Tomcat và công cụ phát triển Eclipse. Kiến trúc hệ thống được thiết kế với các đặc điểm: khả năng bảo trì tốt, dễ dàng mở rộng, giao diện thân thiện và hiệu suất ổn định.

Tính Năng Hệ Thống

Module Người Dùng

Người dùng sau khi đăng nhập có thể truy cập các chức năng: trang chủ, quản lý thông tin cá nhân, mua thẻ thành viên, đăng ký khóa học và đặt chỗ sân tập.

  • Quản lý thẻ thành viên: Hiển thị thông tin mã số, tên thẻ, loại thẻ, giá, thời hạn, tên người dùng, họ tên, số điện thoại và trạng thái thanh toán
  • Quản lý đặt sân: Cung cấp thông tin tên phòng gym, mã nhân viên, giá theo giờ, số người, nội dung đặt, thời gian đặt, thông tin người dùng và trạng thái xét duyệt

Module Quản Trị Viên

Quản trị viên có quyền truy cập toàn bộ hệ thống với các chức năng quản lý người dùng, huấn luyện viên, thẻ thành viên, khóa học và sân tập.

  • Quản lý người dùng: Cho phép chỉnh sửa và xóa thông tin tài khoản, họ tên, giới tính, ảnh đại diện, tuổi, CMND, số điện thoại
  • Quản lý thẻ thành viên: Thao tác với thông tin mã số, tên, hình ảnh, loại thẻ, giá trị và thời hạn sử dụng
  • Quản lý khóa học: Điều chỉnh thông tin tên khóa học, phân loại, video giảng dạy, thời lượng, thông tin huấn luyện viên
  • Quản lý sân tập: Xử lý thông tin địa điểm, hình ảnh, giờ mở cửa, giá thuê, số lượng người, tiện ích hồ bơi

Module Huấn Luyện Viên

Huấn luyện viên có thể quản lý thông tin khóa học, lịch đăng ký của học viên và tình trạng đặt sân tập.

  • Quản lý khóa học: Cập nhật nội dung giảng dạy, video, thời lượng và thông tin liên quan
  • Quản lý sân tập: Theo dõi tình trạng đặt chỗ và thông tin cơ sở vật chất
  • Quản lý đặt sân: Duyệt và xử lý các yêu cầu đặt chỗ từ người dùng

Module Trang Chủ

Giao diện chính hệ thống cung cấp các mục: trang chủ, thẻ thành viên, thông tin khóa học, sân tập, tài khoản cá nhân và khu vực quản trị. Người dùng có thể đăng ký tài khoản mới, đăng nhập và cập nhật thông tin cá nhân.

Đoạn Mã Quan Trọng

Module Xác Thực


package com.gym.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.gym.entity.UserAccount;
import com.gym.service.AuthService;
import com.gym.service.TokenHandler;
import com.gym.utils.ResponseWrapper;

@RestController
@RequestMapping("/api/auth")
public class AuthController {

    @Autowired
    private AuthService authService;
    
    @Autowired
    private TokenHandler tokenHandler;

    @PostMapping("/signin")
    public ResponseWrapper authenticate(@RequestParam String username, 
                                      @RequestParam String password) {
        UserAccount account = authService.findByUsername(username);
        if(account == null || !account.getPassword().equals(password)) {
            return ResponseWrapper.error("Thông tin đăng nhập không chính xác");
        }
        String accessToken = tokenHandler.createToken(account.getId(), 
                                                     username, 
                                                     account.getRole());
        return ResponseWrapper.success().addData("token", accessToken);
    }

    @PostMapping("/signup")
    public ResponseWrapper register(@RequestBody UserAccount newUser) {
        if(authService.existsByUsername(newUser.getUsername())) {
            return ResponseWrapper.error("Tên người dùng đã tồn tại");
        }
        authService.createUser(newUser);
        return ResponseWrapper.success();
    }
}

Module Tải Lên Tệp


package com.gym.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.gym.service.FileStorageService;
import com.gym.utils.ResponseWrapper;
import java.io.IOException;

@RestController
@RequestMapping("/api/files")
public class FileController {

    @Autowired
    private FileStorageService fileService;

    @PostMapping("/upload")
    public ResponseWrapper handleUpload(@RequestParam("file") MultipartFile file) {
        if(file.isEmpty()) {
            return ResponseWrapper.error("Tệp tin không được để trống");
        }
        try {
            String storedName = fileService.storeFile(file);
            return ResponseWrapper.success().addData("filename", storedName);
        } catch (IOException e) {
            return ResponseWrapper.error("Lỗi khi lưu tệp tin");
        }
    }

    @GetMapping("/download/{filename}")
    public ResponseEntity downloadFile(@PathVariable String filename) {
        return fileService.loadFileAsResource(filename);
    }
}

Lớp Bao Bọc Phản Hồi


package com.gym.utils;

import java.util.HashMap;

public class ResponseWrapper extends HashMap {
    
    private ResponseWrapper(int code, String message) {
        this.put("status", code);
        this.put("message", message);
    }
    
    public static ResponseWrapper success() {
        return new ResponseWrapper(200, "Thành công");
    }
    
    public static ResponseWrapper success(String message) {
        return new ResponseWrapper(200, message);
    }
    
    public static ResponseWrapper error(String message) {
        return new ResponseWrapper(500, message);
    }
    
    public static ResponseWrapper error(int code, String message) {
        return new ResponseWrapper(code, message);
    }
    
    public ResponseWrapper addData(String key, Object value) {
        this.put(key, value);
        return this;
    }
}

Thẻ: Spring Boot mysql Quản Lý Phòng Gym Java Web Spring MVC

Đăng vào ngày 18 tháng 8 lúc 15:12