2.0 KiB
2.0 KiB
Backend Implementation - Quick Reference
Files to Create
-
app/Controllers/User/UserController.php
- Copy from:
code-templates/UserController.php - Creates: Full CRUD for users
- Copy from:
-
app/Models/User/UserModel.php
- Copy from:
code-templates/UserModel.php - Creates: User database model
- Copy from:
Files to Modify
-
app/Controllers/Specimen/SpecimenController.php
- Add method from:
code-templates/SpecimenController-delete-method.php - Adds: Delete specimen functionality
- Add method from:
-
app/Config/Routes.php
- Add routes from:
code-templates/Routes-additions.php - Adds: User routes + Specimen delete route
- Add routes from:
Database Migration
Run this SQL if users table doesn't exist:
CREATE TABLE IF NOT EXISTS users (
UserID INT AUTO_INCREMENT PRIMARY KEY,
Username VARCHAR(50) NOT NULL UNIQUE,
Email VARCHAR(100) NOT NULL,
Name VARCHAR(100),
Role VARCHAR(50),
Department VARCHAR(100),
IsActive BOOLEAN DEFAULT TRUE,
CreatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UpdatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
DelDate TIMESTAMP NULL,
INDEX idx_username (Username),
INDEX idx_email (Email)
);
Testing Commands
# Specimen Delete
curl -X DELETE http://localhost:8000/api/specimen/1
# Users API
curl http://localhost:8000/api/users
curl http://localhost:8000/api/users/1
curl -X POST http://localhost:8000/api/users \
-H "Content-Type: application/json" \
-d '{"Username":"test","Email":"test@test.com","Name":"Test User"}'
curl -X PATCH http://localhost:8000/api/users \
-H "Content-Type: application/json" \
-d '{"UserID":1,"Name":"Updated"}'
curl -X DELETE http://localhost:8000/api/users/1
Timeline Estimate
- Specimen Delete: 15 minutes (just add route + method)
- User API: 1-2 hours (new controller + model + routes)
- Testing: 30 minutes
Total: ~2-3 hours
Questions?
See the detailed specs:
specimen-delete.md- Full specimen delete specificationuser-api.md- Complete user API specification with examples