Architecture Overview
The poetry learning platform utilizes a modern web development stack combining Spring Boot, Vue.js, and MyBatis Plus for comprehensive educational resource management.
Backend Foundation - Spring Boot
Spring Boot provides an embedded server environment supporting Tomcat, Jetty, and Undertow without external configuration requirements. The framework's auto-configuration mechanism analyzes project dependencies to establish application settings automatically, eliminating manual configuration processes. Integrated components like Spring Data, Spring Security, and Spring Cloud offer extensive functionality out-of-the-box, enabling rapid application development with seamless integration capabilities.
Frontend Framework - Vue.js
Vue.js implements virtual DOM technology for efficient document manipulation through in-memory data structures. The framework incorporates reactive data binding, component architecture, and virtual DOM rendering to deliver flexible, maintainable development patterns. Automatic UI updates occur when underlying data changes, allowing developers to focus on business logic rather than manual interface modifications.
Data Persistence - MyBatis Plus
MyBatis Plus extends traditional MyBatis functionality with enhanced development tools supporting multiple database systems including MySQL, Oracle, SQL Server, and PostgreSQL. The framework offers comprehensive APIs and annotations for ORM operations, reducing manual SQL writing requirements. Built-in code generation capabilities create entity classes, mapper interfaces, and XML mapping files automatically, streamlining the development workflow. Additional features include pagination, dynamic queries, optimistic locking, and performance analysis tools.
System Testing Methodology
Copmrehensive testing ensures system reliability and functionality alignment with specified requirements.
Testing Objectives
System validation occurs during the final development phase to guarantee quality standards and operational stability. Testing prevents user experience issues by identifying potential problems through multi-perspective analysis. Quality assessment determines whether system functionality meets design specifications and identifies discrepancies between expected and actual behavior. User-centered testing approaches ensure realistic scenario evaluation without wasting resources on impractical test cases.
Functional Module Testing
Black-box testing methodology validates system modules through boundary value analysis, required field verification, and optional field validation. Test cases guide systematic functionality assessment.
Authentication Testing:
| Input Data | Expected Result | Actual Result | Analysis |
|---|---|---|---|
| Username: admin, Password: 123456, Valid Captcha | Successful Login | System Access Granted | Matches Expectation |
| Username: admin, Password: wrongpass, Valid Captcha | Authentication Failure | Invalid Credentials Message | Matches Expectation |
| Username: admin, Password: 123456, Invalid Captcha | Captcha Error | Incorrect Captcha Message | Matches Expectation |
| Empty Username, Password: 123456, Valid Captcha | Required Field Alert | Missing Username Prompt | Matches Expectation |
| Username: admin, Empty Password, Valid Captcha | Password Error | Invalid Password Message | Matches Expectation |
User Management Testing:
| Input Data | Expected Result | Actual Result | Analysis |
|---|---|---|---|
| Complete User Information | Creation Success | User Appears in List | Matches Expectation |
| Modified User Details | Update Success | Information Changed | Matches Expectation |
| Selected User Deletion | Removal Confirmation | User No Longer Available | Matches Expectation |
| Missing Username Field | Validation Error | Required Field Message | Matches Expectation |
| Duplicate Username Entry | Conflict Detection | Already Exists Message | Matches Expectation |
Testing Conclusions
Black-box testing methodology effectively validates system functionality through user simulation scenarios. The testing process ensures workflow accuracy and system completeness, improving overall usability. Function module verification confirms logical correctness without excessive complexity, maintaining user-friendly operation principles.
Implementation Code Examples
@AllowAnonymous
@PostMapping(value = "/authenticate")
public ResponseResult authenticate(String account, String passcode, String verificationCode, HttpServletRequest context) {
AccountEntity accountRecord = accountService.findUnique(new QueryWrapper<AccountEntity>().eq("account", account));
if(accountRecord == null || !accountRecord.getPasscode().equals(passcode)) {
return ResponseResult.failure("Invalid credentials");
}
String sessionToken = authenticationService.createSession(accountRecord.getId(), account, "accounts", accountRecord.getUserType());
return ResponseResult.success().data("sessionToken", sessionToken);
}
@Override
public String createSession(Long accountId, String accountName, String entityName, String userType) {
SessionEntity sessionRecord = this.findOne(new QueryWrapper<SessionEntity>().eq("accountId", accountId).eq("userType", userType));
String tokenValue = RandomUtil.generateRandomString(32);
Calendar calendarInstance = Calendar.getInstance();
calendarInstance.setTime(new Date());
calendarInstance.add(Calendar.HOUR_OF_DAY, 1);
if(sessionRecord != null) {
sessionRecord.setSessionToken(tokenValue);
sessionRecord.setExpirationTime(calendarInstance.getTime());
this.updateExisting(sessionRecord);
} else {
this.saveNew(new SessionEntity(accountId, accountName, entityName, userType, tokenValue, calendarInstance.getTime()));
}
return tokenValue;
}
/**
* Session Validation Interceptor
*/
@Component
public class SessionValidationInterceptor implements HandlerInterceptor {
public static final String SESSION_HEADER_KEY = "Authorization";
@Autowired
private SessionService sessionManager;
@Override
public boolean validateRequest(HttpServletRequest httpRequest, HttpServletResponse httpResponse, Object requestHandler) throws Exception {
httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
httpResponse.setHeader("Access-Control-Max-Age", "3600");
httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
httpResponse.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Authorization, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,access-control-allow-origin");
httpResponse.setHeader("Access-Control-Allow-Origin", httpRequest.getHeader("Origin"));
if (httpRequest.getMethod().equals(RequestMethod.OPTIONS.name())) {
httpResponse.setStatus(HttpStatus.OK.value());
return false;
}
AllowAnonymous anonymousAnnotation;
if (requestHandler instanceof HandlerMethod) {
anonymousAnnotation = ((HandlerMethod) requestHandler).getMethodAnnotation(AllowAnonymous.class);
} else {
return true;
}
String sessionToken = httpRequest.getHeader(SESSION_HEADER_KEY);
if(anonymousAnnotation != null) {
return true;
}
SessionEntity sessionData = null;
if(StringUtils.hasText(sessionToken)) {
sessionData = sessionManager.getSessionData(sessionToken);
}
if(sessionData != null) {
httpRequest.getSession().setAttribute("accountId", sessionData.getAccountId());
httpRequest.getSession().setAttribute("userType", sessionData.getUserType());
httpRequest.getSession().setAttribute("entityName", sessionData.getEntityName());
httpRequest.getSession().setAttribute("accountName", sessionData.getAccountName());
return true;
}
PrintWriter outputWriter = null;
httpResponse.setCharacterEncoding("UTF-8");
httpResponse.setContentType("application/json; charset=utf-8");
try {
outputWriter = httpResponse.getWriter();
outputWriter.print(JSONObject.toJSONString(ResponseResult.unauthorized("Authentication Required")));
} finally {
if(outputWriter != null){
outputWriter.close();
}
}
return false;
}
}
Database Schema Reference
-- ----------------------------
-- Session Management Table Structure
-- ----------------------------
DROP TABLE IF EXISTS `session_tokens`;
CREATE TABLE `session_tokens` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`accountId` bigint(20) NOT NULL COMMENT 'Account Identifier',
`accountName` varchar(100) NOT NULL COMMENT 'Account Name',
`entityName` varchar(100) DEFAULT NULL COMMENT 'Entity Type',
`userType` varchar(100) DEFAULT NULL COMMENT 'User Classification',
`sessionToken` varchar(200) NOT NULL COMMENT 'Authentication Token',
`creationTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation Timestamp',
`expirationTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Expiration Timestamp',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='Session Management';
-- ----------------------------
-- Sample Session Data
-- ----------------------------
INSERT INTO `session_tokens` VALUES ('9', '23', 'student01', 'learners', 'Student', 'tokenabc123def456ghi789jkl012mno345pqr', '2023-02-23 21:46:45', '2023-03-15 14:01:36');
INSERT INTO `session_tokens` VALUES ('10', '11', 'learner01', 'learners', 'Student', 'tokenxyz987wvu654tsr321qpo098nml765', '2023-02-27 18:33:52', '2023-03-17 18:27:42');
INSERT INTO `session_tokens` VALUES ('11', '17', 'member01', 'learners', 'Student', 'tokencat123dog456bird789fish012', '2023-02-27 18:46:19', '2023-02-27 19:48:58');
INSERT INTO `session_tokens` VALUES ('12', '1', 'administrator', 'administrators', 'Administrator', 'tokenadmin123secure456system789', '2023-02-27 19:37:01', '2023-03-17 18:23:02');
INSERT INTO `session_tokens` VALUES ('13', '21', 'clubleader', 'leaders', 'ClubLeader', 'tokensociety123group456team789', '2023-02-27 19:38:07', '2023-03-17 18:25:20');
INSERT INTO `session_tokens` VALUES ('14', '27', 'newuser01', 'learners', 'Student', 'tokenfresh123new456start789', '2023-03-15 12:56:17', '2023-03-15 14:00:16');
INSERT INTO `session_tokens` VALUES ('15', '29', 'president', 'leaders', 'ClubLeader', 'tokenchief123head456director789', '2023-03-15 12:58:08', '2023-03-15 14:03:48');