Supplier Service
Purpose
Manage supplier lifecycle (create, read, update, delete with validation). Suppliers represent goods providers in the inventory system.
Key Responsibilities
- Create new suppliers with uniqueness validation
- Retrieve suppliers by ID or list all
- Search suppliers by name (partial matching)
- Update supplier information
- Delete suppliers with constraint validation (e.g., cannot delete if used in inventory)
- Count suppliers for KPIs
Interface Methods
List<SupplierDTO> findAll();
long countSuppliers();
Optional<SupplierDTO> findById(String id);
List<SupplierDTO> search(String name);
SupplierDTO create(CreateSupplierDTO dto);
SupplierDTO update(String id, UpdateSupplierDTO dto);
void delete(String id);Business Rules
- Unique Names - Supplier names must be unique (case-insensitive)
- Required Fields - All required fields (name, contact) must be provided
- Deletion Constraint - Supplier can only be deleted if no items are sourced from them
- Audit Preservation - Update preserves audit fields (createdBy, createdAt)
Exception Handling
DuplicateResourceException(409 Conflict) - Name already existsNoSuchElementException(404 Not Found) - Supplier not foundIllegalStateException(409 Conflict) - Cannot delete (has items)