some changes for expense
This commit is contained in:
parent
0de3eb7142
commit
06637c21ee
@ -8,7 +8,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
||||
import com.restapi.domain.*
|
||||
import com.restapi.domain.Session.database
|
||||
import com.restapi.domain.Session.findDataModelByEntityAndUniqId
|
||||
import com.restapi.domain.Session.objectMapper
|
||||
import com.restapi.integ.Scripting
|
||||
import io.ebean.RawSqlBuilder
|
||||
import io.javalin.http.BadRequestResponse
|
||||
import io.javalin.http.Context
|
||||
import io.javalin.http.HttpStatus
|
||||
@ -133,24 +135,42 @@ object Entities {
|
||||
verifyKeys(sql.params)
|
||||
|
||||
val entity = ctx.pathParam("entity")
|
||||
ctx.json(
|
||||
database.find(DataModel::class.java)
|
||||
.where()
|
||||
.eq("entityName", entity)
|
||||
.apply {
|
||||
if (sql.dateRange.isNotEmpty()) {
|
||||
ge("createdAt", sql.dateRange.first())
|
||||
if (sql.dateRange.size > 1) {
|
||||
lt("createdAt", sql.dateRange.last().plusDays(1))
|
||||
}
|
||||
}
|
||||
sql.params.forEach { (t, u) ->
|
||||
val fl = database.find(DataModel::class.java)
|
||||
.setRawSql(
|
||||
RawSqlBuilder.parse(
|
||||
"""
|
||||
select sys_pk,
|
||||
deleted_on,
|
||||
current_approval_level,
|
||||
required_approval_levels,
|
||||
deleted,
|
||||
version,
|
||||
created_at,
|
||||
modified_at,
|
||||
deleted_by,
|
||||
approval_status,
|
||||
tags,
|
||||
comments,
|
||||
tenant_id,
|
||||
unique_identifier,
|
||||
entity_name,
|
||||
data,
|
||||
created_by,
|
||||
modified_by
|
||||
from data_model
|
||||
where entity_name = :e
|
||||
and created_at between :from and :to
|
||||
and data @> cast(:search as jsonb)
|
||||
""".trimIndent()
|
||||
).create()
|
||||
)
|
||||
.setParameter("from", sql.dateRange.first())
|
||||
.setParameter("to", sql.dateRange.last().plusDays(1))
|
||||
.setParameter("e", entity)
|
||||
.setParameter("search", objectMapper.writeValueAsString(sql.params.map { e -> Pair(e.key, e.value.getValue()) }.toMap()))
|
||||
.findList()
|
||||
|
||||
eq("data->>'$t'", u.getValue())
|
||||
}
|
||||
}
|
||||
.findList()
|
||||
)
|
||||
ctx.json(fl)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user