Implementing a Senior Living Management System with SSM and Vue.js

Technical Architecture

Backend Framework: Spring Boot

Spring Boot simplifies backend development with embedded servers (Tomcat, Jetty, Undertow) and auto-configuration capabilities. The framework automatically configures application components based on project dependencies, eliminating manual setup. It offers extensive out-of-the-box features including Spring Data, Spring Security, and Spring Cloud integration, enabling rapid development of high-quality applications with easy extensibility.

Frontend Framework: Vue.js

Vue.js employs virtual DOM technology for efficient DOM operations. Its reactive data binding system automatically updates the UI when data changes, allowing developers to focus on data processing rather than manual UI updates. The component-based architecture provides a flexible, efficient, and maintainable development pattern.

Persistence Layer: MyBatis Plus

MyBatis Plus enhances standard MyBatis functionality with simplified ORM operations. It supports multiple databases (MySQL, Oracle, SQL Server, PostgreSQL) and provides comprehensive APIs and annotations that reduce manual SQL writing. The framework includes code generation for entities, Mapper interfaces, and XML files, along with pagination, dynamic queries, optimistic locking, and performance analysis features.

System Testing Methodology

Testing focuses on identifying system defects through comprehensive functional validation. The process ensures the system meets requirements and addresses any discrepancies through iterative corrections.

Testing Objectives

System testing serves as the final quality assurance checkpoint in the development lifecycle. It validates system reliabliity and functionality from multiple perspectives, simulating real-user scenarios to identify and resolve potential issues before deployment.

Functional Testing Approach

Black-box testing methodologies validate system modules through boundary value analysis, required field validation, and user interaction simulations. Test cases are systematically executed to verify expected behaviors.

Authentication Test Cases:

Input Data Expected Result Actual Result Analysis
Valid credentials Successful login Login successful Matched expectation
Invalid password Authentication error Password error message Matched expectation
Empty username Validation prompt Username requierd message Matched expectation

User Management Test Cases:

Input Data Expected Result Actual Result Analysis
Add user with valid data User created successfully User appears in list Matched expectation
Edit user information Data updated correctly Information modified Matched expectation
Delete user with confirmation User removal User removed from system Matched expectation

Testing Conclusion

Comprehensive black-box testing validated all functional requirements and system logic. The testing process confirmed that the system meets design specifications with straightforward operational workflows suitable for end-users. All test scenarios aligned with user requirements, resulting in a functionally robust and performant system.

Code Implementation Examples

Authentication Service

@AuthenticationExempt
@PostMapping("/authenticate")
public ResponseResult login(String userIdentifier, String secretKey, String verificationCode, HttpServletRequest request) {
    SystemUser account = userService.queryOne(new QueryWrapper<SystemUser>().eq("user_identifier", userIdentifier));
    if(account == null || !account.getSecretKey().equals(secretKey)) {
        return ResponseResult.error("Invalid credentials");
    }
    String accessToken = tokenService.createToken(account.getId(), userIdentifier, "system_users", account.getAccessLevel());
    return ResponseResult.ok().set("accessToken", accessToken);
}

@Override
public String createToken(Long userId, String userIdentifier, String entityName, String accessLevel) {
    AuthenticationToken tokenRecord = this.queryOne(new QueryWrapper<AuthenticationToken>()
        .eq("user_id", userId).eq("access_level", accessLevel));
    String tokenValue = RandomUtil.generateString(32);
    Calendar expirationTime = Calendar.getInstance();
    expirationTime.setTime(new Date());
    expirationTime.add(Calendar.HOUR, 1);
    
    if(tokenRecord != null) {
        tokenRecord.setTokenValue(tokenValue);
        tokenRecord.setExpirationTime(expirationTime.getTime());
        this.updateById(tokenRecord);
    } else {
        this.insert(new AuthenticationToken(userId, userIdentifier, entityName, accessLevel, tokenValue, expirationTime.getTime()));
    }
    return tokenValue;
}

Authorization Interceptor

@Component
public class SecurityInterceptor implements HandlerInterceptor {
    
    public static final String AUTH_TOKEN_HEADER = "Authorization";
    
    @Autowired
    private TokenService tokenService;
    
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with,Token, Origin, Content-Type, Cookie, Accept, authorization");
        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
        
        if (request.getMethod().equals(RequestMethod.OPTIONS.name())) {
            response.setStatus(HttpStatus.OK.value());
            return false;
        }
        
        AuthenticationExempt exemption;
        if (handler instanceof HandlerMethod) {
            exemption = ((HandlerMethod) handler).getMethodAnnotation(AuthenticationExempt.class);
        } else {
            return true;
        }
        
        String token = request.getHeader(AUTH_TOKEN_HEADER);
        
        if(exemption != null) {
            return true;
        }
        
        AuthenticationToken tokenEntity = null;
        if(StringUtils.isNotBlank(token)) {
            tokenEntity = tokenService.getTokenEntity(token);
        }
        
        if(tokenEntity != null) {
            request.getSession().setAttribute("userId", tokenEntity.getUserId());
            request.getSession().setAttribute("accessLevel", tokenEntity.getAccessLevel());
            request.getSession().setAttribute("entityName", tokenEntity.getEntityName());
            request.getSession().setAttribute("userIdentifier", tokenEntity.getUserIdentifier());
            return true;
        }
        
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json; charset=utf-8");
        try (PrintWriter writer = response.getWriter()) {
            writer.print(JSONObject.toJSONString(ResponseResult.error(401, "Authentication required")));
        }
        return false;
    }
}

Database Schema

Authentication Token Table

CREATE TABLE authentication_tokens (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    user_id BIGINT NOT NULL,
    user_identifier VARCHAR(100) NOT NULL,
    entity_name VARCHAR(100),
    access_level VARCHAR(100),
    token_value VARCHAR(200) NOT NULL,
    created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    expiration_time TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO authentication_tokens VALUES 
(1, 23, 'user01', 'residents', 'admin', 'token123', '2023-02-23 21:46:45', '2023-03-15 14:01:36'),
(2, 11, 'user02', 'staff', 'manager', 'token456', '2023-02-27 18:33:52', '2023-03-17 18:27:42');

Tags: Spring Boot Vue.js MyBatis Plus System Architecture Authentication

Posted on Sun, 13 Sep 2026 16:47:23 +0000 by mechew