diff --git a/src/main/kotlin/com/restapi/controllers/Entities.kt b/src/main/kotlin/com/restapi/controllers/Entities.kt index db61824..c3b544e 100644 --- a/src/main/kotlin/com/restapi/controllers/Entities.kt +++ b/src/main/kotlin/com/restapi/controllers/Entities.kt @@ -135,7 +135,7 @@ object Entities { val sql = ctx.bodyAsClass() verifyKeys(sql.params) - val entity = ctx.pathParam("entity") + val entity = ctx.pathParam("entity").lowercase() val searchJsonMap = sql.params.map { e -> Pair(e.key, e.value.getValue()) }.toMap() val fl = database.find(DataModel::class.java) .setRawSql( @@ -163,6 +163,7 @@ object Entities { where entity_name = :e and created_at between :from and :to and data @> cast(:search as jsonb) + order by sysPk """.trimIndent() ).create() ) @@ -188,6 +189,7 @@ object Entities { .eq("entityName", entity.lowercase()) .setFirstRow((pageNo - 1) * perPage) .setMaxRows(perPage) + .orderBy("sysPk") .findPagedList() ctx.json(cnt)