Category Entity Structure
TheCategory entity (defined in Category.java:22) contains the following fields:
| Field | Type | Validation | Description |
|---|---|---|---|
id | Long | Auto-generated | Unique category identifier |
name | String | Required, 2-100 chars, unique | Category name |
description | String | Optional, max 200 chars | Category description |
active | Boolean | Required, default: true | Whether category is active |
Validation Rules
Category Management Endpoints
All category management operations are handled through theCategoryController (CategoryController.java:17) at the /admin base path.
View Categories
GET
/admin/categoriesDisplays all categories ordered by ID. Accessible from CategoryController.java:36.Create/Update Category
POST
/admin/categoriesSaves a new category or updates an existing one. See CategoryController.java:46.Edit Category
GET
/admin/edit/{id}Prepares a category for editing by loading its data. See CategoryController.java:80.Delete Category
GET
/admin/delete/{id}Removes a category from the system. See CategoryController.java:109.Toggle Category Status
GET/admin/toggle/{id} (CategoryController.java:132)
Changes a category’s active status between enabled and disabled without deleting it.
CRUD Operations
TheCategoryService (CategoryService.java:22) handles all business logic for category management.
Creating a Category
The service validates that no duplicate category names exist before saving:Retrieving Categories
Get all categories ordered by ID:Updating a Category
Updating uses the samesave() method. The service checks if the ID exists to determine whether to create or update.
Deleting a Category
Deleting a category that has associated service requests or professionals may fail due to database constraints. Consider using the toggle status feature to deactivate categories instead.
Best Practices
Use Descriptive Names
Choose clear, concise category names that professionals and clients will easily understand (e.g., “Plumbing”, “Electrical”, “Cleaning”).
Add Helpful Descriptions
Provide a brief description (up to 200 characters) to clarify what services belong in each category.
Deactivate Instead of Delete
Use the toggle status feature to deactivate categories rather than deleting them to preserve historical data.
Related Resources
- User Oversight - Managing users and their roles
- Admin Dashboard - Overview of admin dashboard features
