IAV-252/feat(custom-instructions): Add FAQ category support and refactor service layer
Summary
This MR introduces FAQ category association for custom instructions and refactors the service layer for improved consistency and maintainability.
Changes
New Features
-
FAQ Category Support: Custom instructions can now be linked to FAQ categories
- Required for
SUGGESTIONScategory instructions - Forbidden for
RESTRICTIONScategory instructions
- Required for
-
Bulk Deactivation: New
deactivateInstructionsByFaqCategory()method allows deactivating all instructions associated with a specific FAQ category (useful when a FAQ category is deleted or disabled)
Refactoring
- Unified agent lookup using
AgentValidationHelper.findAgentByUidOrThrow()across all methods - Extracted
getAgentCustomInstructionByUidOrThrow()helper to eliminate duplicated instruction lookup code - Added
resolveFaqCategory()helper for centralized FAQ category validation logic - Removed unused
CustomerCareAgentRepositorydependency
DTOs & Mapper Updates
- Added
faqCategoryUidto request DTO - Added
faqCategoryUidandfaqCategoryNameto response DTO - Updated mapper to use
ModelMapperwith manual field overrides for related entities
New Validations
| Error Code | Condition |
|---|---|
FAQ_CATEGORY_REQUIRED |
SUGGESTIONS instruction without FAQ category |
FAQ_CATEGORY_NOT_ALLOWED |
RESTRICTIONS instruction with FAQ category |
FAQ_CATEGORY_NOT_FOUND |
Provided FAQ category UID doesn't exist |
Testing
-
Create SUGGESTIONS instruction with valid FAQ category ✅ -
Create SUGGESTIONS instruction without FAQ category → Error ✅ -
Create RESTRICTIONS instruction without FAQ category ✅ -
Create RESTRICTIONS instruction with FAQ category → Error ✅ -
Update instruction with FAQ category change ✅ -
Bulk deactivate instructions by FAQ category ✅
Related Issues
Closes IAV-252