generate query controller