Skip to content

Commit 8ead0a8

Browse files
committed
#321 fix pagination
1 parent a96623f commit 8ead0a8

4 files changed

Lines changed: 27 additions & 5 deletions

File tree

src/main/kotlin/com/github/mgramin/sqlboot/model/connection/SimpleEndpoint.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ open class SimpleEndpoint(
6262
dataSourceNew.url = properties()["jdbc.url"].toString()
6363
dataSourceNew.username = properties()["jdbc.user"].toString()
6464
dataSourceNew.password = properties()["jdbc.password"].toString()
65+
dataSourceNew.minIdle = 1
66+
dataSourceNew.maxActive = 3
67+
dataSourceNew.maxIdle = 3
68+
dataSourceNew.maxWait = 3
6569
dataSource = dataSourceNew
6670
dataSourceNew
6771
}

src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/ApiController.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,27 @@ class ApiController {
123123
@RequestMapping(value = ["/api/{connection}/{type}"], method = [GET, POST])
124124
fun getResourcesHeadersJson(@PathVariable connection: String,
125125
@PathVariable type: String,
126-
request: HttpServletRequest) =
127-
getListResponseEntityHeaders(SqlPlaceholdersWrapper(DbUri("$connection/$type")))
126+
request: HttpServletRequest): ResponseEntity<List<Map<String, Any>>> {
127+
val uriString = if (request.queryString != null) {
128+
"$connection/$type?${request.queryString}"
129+
} else {
130+
"$connection/$type"
131+
}
132+
return getListResponseEntityHeaders(SqlPlaceholdersWrapper(DbUri(uriString)))
133+
}
128134

129135
@RequestMapping(value = ["/api/{connection}/{type}/{path}"], method = [GET, POST])
130136
fun getResourcesHeadersJson(@PathVariable connection: String,
131137
@PathVariable type: String,
132138
@PathVariable path: String,
133-
request: HttpServletRequest) =
134-
getListResponseEntityHeaders(SqlPlaceholdersWrapper(DbUri("$connection/$type/$path")))
139+
request: HttpServletRequest): ResponseEntity<List<Map<String, Any>>> {
140+
val uriString = if (request.queryString != null) {
141+
"$connection/$type/$path?${request.queryString}"
142+
} else {
143+
"$connection/$type/$path"
144+
}
145+
return getListResponseEntityHeaders(SqlPlaceholdersWrapper(DbUri(uriString)))
146+
}
135147

136148
private fun getListResponseEntityHeaders(uri: Uri): ResponseEntity<List<Map<String, Any>>> {
137149
val connections = endpointList.getByMask(uri.connection())

src/main/resources/application.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ conf:
3737
"jdbc.user": "postgres",
3838
"jdbc.password": "postgres",
3939
"os.query.rest.port": "8082",
40-
"visible": false,
4140
"description": "Embedded db for unit tests only"
4241
}
4342

src/test/kotlin/com/github/mgramin/sqlboot/template/generator/impl/GroovyTemplateGeneratorTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,11 @@ class GroovyTemplateGeneratorTest {
5454
assertEquals(templateGenerator.generate(maps), "create table persons ...")
5555
}
5656

57+
@Test
58+
fun test() {
59+
val maps = hashMapOf("column" to "id", "table" to "persons", "__timeFilter" to "public")
60+
val templateGenerator = GroovyTemplateGenerator("create table \${table.toLowerCase()} ... where \$__timeFilter(time)")
61+
assertEquals(templateGenerator.generate(maps), "create table persons ...")
62+
}
63+
5764
}

0 commit comments

Comments
 (0)