Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Implementing a Parking Space Short-Term Rental Billing System with Java SSM and Vue

Tech 1

Technical Architecture

Backend Framework: Spring Boot

Spring Boot simplifies the development of production-ready Spring applications through convention-over-configuration principles. It eliminates boilerplate code through auto-configuration while maintaining Spring's core functionality. The framework includes embedded web servers (Tomcat, Jetty, or Undertow), enabling deployment as executable JAR files. Spring Boot Actuator provides runtime monitoring capabilities, and starter dependencies facilitate integration with security, data access, messaging, and caching systems.

Frontend Framwork: Vue.js

Vue.js is a progressive JavaScript framework for building user interfaces and single-page applications. Its reactive data binding system simplifies view-data synchronization, while component-based architecture promotes code reusability and maintainability. Vue's intuitive API and active ecosystem provide extensive tooling and documentation support.

Core Implementation

Applicasion Entry Point

package com.parkingsystem;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
@MapperScan(basePackages = {"com.parkingsystem.mapper"})
public class ParkingApplication extends SpringBootServletInitializer {
    
    public static void main(String[] args) {
        SpringApplication.run(ParkingApplication.class, args);
    }
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ParkingApplication.class);
    }
}

User Management Controller

package com.parkingsystem.controller;

import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.parkingsystem.entity.UserAccount;
import com.parkingsystem.service.UserService;
import com.parkingsystem.service.AuthService;
import com.parkingsystem.utils.PageResult;
import com.parkingsystem.utils.ResponseData;

@RestController
@RequestMapping("/api/users")
public class UserController {
    
    @Autowired
    private UserService userService;
    
    @Autowired
    private AuthService authService;
    
    @PostMapping("/authenticate")
    public ResponseData login(@RequestParam String username, 
                             @RequestParam String password) {
        QueryWrapper<UserAccount> query = new QueryWrapper<>();
        query.eq("username", username);
        UserAccount user = userService.getOne(query);
        
        if(user == null || !user.getPassword().equals(password)) {
            return ResponseData.error("Invalid credentials");
        }
        
        String token = authService.generateToken(user.getId(), user.getRole());
        return ResponseData.success().put("token", token);
    }
    
    @PostMapping("/register")
    public ResponseData createUser(@RequestBody UserAccount newUser) {
        QueryWrapper<UserAccount> checkQuery = new QueryWrapper<>();
        checkQuery.eq("username", newUser.getUsername());
        if(userService.count(checkQuery) > 0) {
            return ResponseData.error("Username already exists");
        }
        
        newUser.setId(System.currentTimeMillis());
        userService.save(newUser);
        return ResponseData.success("Registration successful");
    }
    
    @GetMapping("/{id}")
    public ResponseData getUserProfile(@PathVariable Long id) {
        UserAccount user = userService.getById(id);
        return ResponseData.success().put("data", user);
    }
    
    @PutMapping("/{id}")
    @Transactional
    public ResponseData updateUser(@PathVariable Long id, 
                                  @RequestBody UserAccount updatedUser) {
        QueryWrapper<UserAccount> uniquenessCheck = new QueryWrapper<>();
        uniquenessCheck.ne("id", id).eq("username", updatedUser.getUsername());
        if(userService.count(uniquenessCheck) > 0) {
            return ResponseData.error("Username already taken");
        }
        
        updatedUser.setId(id);
        userService.updateById(updatedUser);
        return ResponseData.success("Update successful");
    }
    
    @DeleteMapping
    public ResponseData removeUsers(@RequestBody List<Long> userIds) {
        userService.removeByIds(userIds);
        return ResponseData.success("Users deleted");
    }
}

Testing Methodology

Functional Testing Approach

System validation employs black-box testing techniques including boundary value analysis, input validation, and mandatory field verification. Test cases simulate real-world usage scenarios to identify defects and ensure requirement compliance.

Authentication Test Cases

Login functionality testing verifies credential validation, role-based access control, and error handling. Test scenarios include valid/invalid credentials, role permistion checks, and session management.

Quality Assurance Outcomes

Comprehensive testing validates system functionality against design specifications. The process focuses on user experience, ensuring intuitive operation and logical consistency across all modules. Final testing confirms the system meets performance and functional requirements.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.