#Java Spring Boot - 1 endpoint with return 2 different entity product list based on pass in parameter

2 messages · Page 1 of 1 (latest)

knotty vortex
#

I still new in springboot java, can anyone assist if I want to achieve a result like if I have param pass in the controller which is A then it will go to AProductService return "A Product List", if the param is B then it will go to BProductService return "B Product List".

I have

  • 1 controller which is 1 endpoint "product/list"
  • 1 productservicefactory to control to access which services
  • 2 services which is AProductService (implements ProductService), BProductService (implements ProductService)
  • 1 interface which is ProductService
  • 2 entity (AProduct, BProduct)

May I ask if I using List<?> in controller to return as response it is good practice?

amber sinew
#

And how are you planning on deciding when to return productA or productB?