import org.springframework.web.bind.annotation.PathVariable; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.beans.factory.annotation.Autowired; | |
@RestController | |
public class QueryController { | |
@Autowired | |
private QueryAdapter queryAdapter; | |
@RequestMapping("/{tableName}/avg/{field1}/by/{field2}") | |
public Graph avg(@PathVariable String tableName, | |
@PathVariable String field1, | |
@PathVariable String field2) { | |
return queryAdapter | |
.select(field1, field2) | |
.from(tableName) | |
.aggregate(new Average(field1, field2)); | |
} | |
// Endpoints for other aggregation functions: sum, count etc. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment