Design and Implementation of an Inventory Management System for Campus Supermarkets Using Java
Technology Stack
Backend with Spring Boot Framework
Spring Boot facilitates rapid development of applications based on the Spring framework through a philosophy prioritizing convention over configuration. It reduces setup complexity by offering sensible defaults, minimizing the need for extensive XML configurations or complex annotations. This framework streamlines project building using tools like Maven or Gradle, handling dependencies automatically. Projects can be initialized quickly using Spring Initializr, allowing developers to focus on core business logic.
Frontend Development with Vue.js
Vue.js emphasizes simplicity and ease of adoption. Its intuitive APIs enable straightforward creation of interactive interfaces. The framework supports two-way data binding via directives such as v-model, ensuring automatic synchronization between model and view without manual DOM manipulation. Component lifecycle hooks provide control at key stages including creation, mounting, updating, and destruction, enhancing flexibility during development.
Feasibility Assessment
Conducting a feasibility study is essential prior to system development. This analysis evaluates whether the proposed solution addresses inefficiencies in current manual processes and determines if benefits outweigh costs. For this inventory management system, technical viability was confirmed due to Java's maturity. Economic evaluation focused on cost-benefit alignmant, while operational feasibility ensured usability and practicality for end-users.
System Verification
The testing phase aims to identify defects across multiple scenarios to ensure robust functionality. Functional tests validate each module using black-box techniques, including boundary value analysis and requirement validation. Test cases are designed and executed systematically, followed by result documentation.
Login Module Testing
Authentication testing verifies correct credential handling and role-based access controls:
| Input Data | Expected Outcome | Actual Result | Analysis |
|---|---|---|---|
| Username: admin, Password: password123, Captcha: valid | Successful login | Logged in successfully | Matches expectation |
| Username: admin, Password: wrongpass, Captcha: valid | Authentication failure | Incorrect credentials message | As expected |
| Username: admin, Password: password123, Captcha: invalid | Invalid captcha error | Captcha verificasion failed | Correct behavior |
| Empty username, Password: password123, Captcha: valid | Prompt for username | Missing username warning | Expected outcome |
| Username: admin, Empty password, Captcha: valid | Authentication failure | Password required notice | Accurate response |
User Administration Testing
User management functionalities were evaluated for proper handling of CRUD operations:
| Scenario | Expected Behavior | Observed Outcome | Evaluation |
|---|---|---|---|
| Adding new user with complete info | Entry added to list | Appears in records | Successful |
| Updating existing user details | Changes reflected immediately | Details updated correctly | Working |
| Removing selected user | Confirmation prompt then deletion | Record removed after confirmation | Functions properly |
| Attempting to add user without name | Error indicating mandatory field | Name field flagged as required | Validation active |
| Entering duplicate username | Rejection with uniqueness alert | Duplicate entry prevented | Constraint enforced |
Database Schema Design
Structure of key tables used in the application:
| Column Name | Data Type | Length | Constraints |
|---|---|---|---|
| id | int | 11 | PRIMARY KEY |
| addtime | datetime | - | DEFAULT CURRENT_TIMESTAMP |
| itemCode | varchar | 64 | DEFAULT NULL |
| itemName | varchar | 12 | DEFAULT NULL |
| supplierInfo | varchar | 64 | DEFAULT NULL |
| penaltyNote | varchar | 64 | DEFAULT NULL |
| fineAmount | decimal | 10,2 | DEFAULT NULL |
| penaltyDate | date | - | DEFAULT NULL |
| customerName | varchar | 64 | DEFAULT NULL |
| contactPhone | varchar | 64 | DEFAULT NULL |
Sample Code Implementation
@RestController
public class SharedController {
@Autowired
private SharedService sharedService;
@Autowired
private SettingsService settingsService;
private static FaceClient baiduClient = null;
private static String MAP_API_KEY = null;
@GetMapping("/geolocation")
public ResponseEntity<Map<String, Object>> getGeolocation(
@RequestParam String longitude,
@RequestParam String latitude) {
if (MAP_API_KEY == null) {
ConfigEntity apiKeyConfig = settingsService.getConfigByName("map_api_key");
if (apiKeyConfig == null || apiKeyConfig.getValue() == null) {
return ResponseEntity.badRequest().body(Map.of("error", "Map API key not configured"));
}
MAP_API_KEY = apiKeyConfig.getValue();
}
Map<String, String> locationData = LocationUtil.fetchCityFromCoordinates(MAP_API_KEY, longitude, latitude);
return ResponseEntity.ok(Map.of("location", locationData));
}
@PostMapping("/compareFaces")
public ResponseEntity<Map<String, Object>> compareFaces(
@RequestParam String imageOne,
@RequestParam String imageTwo) throws IOException {
if (baiduClient == null) {
String apiKey = settingsService.getConfigByName("face_api_key").getValue();
String secretKey = settingsService.getConfigByName("face_secret_key").getValue();
String accessToken = AuthUtil.generateToken(apiKey, secretKey);
if (accessToken == null) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Map.of("error", "Invalid authentication keys"));
}
baiduClient = new FaceClient(apiKey, secretKey);
baiduClient.setTimeout(2000, 60000);
}
try {
byte[] imgBytes1 = Files.readAllBytes(Paths.get("uploads/" + imageOne));
byte[] imgBytes2 = Files.readAllBytes(Paths.get("uploads/" + imageTwo));
String encodedImg1 = Base64.getEncoder().encodeToString(imgBytes1);
String encodedImg2 = Base64.getEncoder().encodeToString(imgBytes2);
List<FaceMatchRequest> requests = Arrays.asList(
new FaceMatchRequest(encodedImg1, "BASE64"),
new FaceMatchRequest(encodedImg2, "BASE64")
);
JSONObject comparisonResult = baiduClient.performMatch(requests);
return ResponseEntity.ok(Map.of("matchResult", comparisonResult));
} catch (IOException ex) {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(Map.of("error", "Image files missing"));
}
}
}
SQL Script Examples
CREATE TABLE customer (
customerId BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique identifier',
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'Record creation time',
loginName VARCHAR(200) NOT NULL UNIQUE COMMENT 'Account name',
passcode VARCHAR(200) NOT NULL COMMENT 'Login password',
fullName VARCHAR(200) COMMENT 'Full name',
gender ENUM('Male', 'Female') COMMENT 'Gender specification',
avatarUrl VARCHAR(200) COMMENT 'Profile picture path',
phoneNumber VARCHAR(200) COMMENT 'Contact number',
nationalId VARCHAR(200) COMMENT 'National ID card'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE feedback (
messageId BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'Feedback ID',
submittedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'Submission timestamp',
userId BIGINT NOT NULL COMMENT 'Submitter reference',
userName VARCHAR(200) COMMENT 'Associated username',
messageContent TEXT NOT NULL COMMENT 'User comment',
replyContent TEXT COMMENT 'Admin response'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE sessionTokens (
tokenId BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'Token ID',
associatedUserId BIGINT NOT NULL COMMENT 'Linked account',
accountName VARCHAR(100) NOT NULL COMMENT 'Username linked',
sourceTable VARCHAR(100) COMMENT 'Originating table',
assignedRole VARCHAR(100) COMMENT 'Access level',
tokenValue VARCHAR(200) NOT NULL COMMENT 'Session key',
issuedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation timestamp',
expiresAt TIMESTAMP NOT NULL COMMENT 'Expiry moment'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;