In our organisation, we have a central service to raise tickets. Let's call this service MainService
. Agents log into this service directly and create raise tickets for various concerns.
A new requirement is to allow users to access this MainService
via a separate new application say MainServiceManagementService
. This new service will provide better user experience and will use APIs exposed by MainService
to perform actions such as fetching list of tickets, viewing details or a ticket, creating tickets and so on.
The MainServiceManagementService
is going to be a central service and will be used by other services to manage tickets pertaining to those specific services. Let's say we have 3 such services namely project A, project B and project C. For each of these services, we will create separate packages in MainServiceManagementService
and they are required to implement their own logic and own response formats.
Let's say I design a central interface like:
interface MainApplicationServiceInterface {
TicketViewResponse viewTicket(TicketViewRequest request);
TicketCreateResponse createTicket(TicketCreateRequest request);
TicketUpdateResponse updateTicket(TicketUpdateRequest request);
}
And then create implementations of above interface for each project such as:
class ProjectAService implements MainApplicationServiceInterface {
// methods implemented here
}
class ProjectBService implements MainApplicationServiceInterface {
// methods implemented here
}
My issue is for project A, I might want to generate a different type of response for view, create, update etc methods compared to project B and so on. The plan would be to take response like TicketViewResponse
and cast it to necessary response class. But I want to have different return types for my method implementations. Also different methods like view, create will have different type of response as shown in interface example. What would be the best way to achieve such a use case?
Aucun commentaire:
Enregistrer un commentaire