Split up Base and Query class

Base and Query class are duplicated in API controllers.
This fixes it.

Change-Id: Iccc9445747d00310d42ff904b572f7891cf8167f
Merge "Split up Base and Query class"