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.*
|
||||||
import com.restapi.domain.Session.database
|
import com.restapi.domain.Session.database
|
||||||
import com.restapi.domain.Session.findDataModelByEntityAndUniqId
|
import com.restapi.domain.Session.findDataModelByEntityAndUniqId
|
||||||
|
import com.restapi.domain.Session.objectMapper
|
||||||
import com.restapi.integ.Scripting
|
import com.restapi.integ.Scripting
|
||||||
|
import io.ebean.RawSqlBuilder
|
||||||
import io.javalin.http.BadRequestResponse
|
import io.javalin.http.BadRequestResponse
|
||||||
import io.javalin.http.Context
|
import io.javalin.http.Context
|
||||||
import io.javalin.http.HttpStatus
|
import io.javalin.http.HttpStatus
|
||||||
@ -133,24 +135,42 @@ object Entities {
|
|||||||
verifyKeys(sql.params)
|
verifyKeys(sql.params)
|
||||||
|
|
||||||
val entity = ctx.pathParam("entity")
|
val entity = ctx.pathParam("entity")
|
||||||
ctx.json(
|
val fl = database.find(DataModel::class.java)
|
||||||
database.find(DataModel::class.java)
|
.setRawSql(
|
||||||
.where()
|
RawSqlBuilder.parse(
|
||||||
.eq("entityName", entity)
|
"""
|
||||||
.apply {
|
select sys_pk,
|
||||||
if (sql.dateRange.isNotEmpty()) {
|
deleted_on,
|
||||||
ge("createdAt", sql.dateRange.first())
|
current_approval_level,
|
||||||
if (sql.dateRange.size > 1) {
|
required_approval_levels,
|
||||||
lt("createdAt", sql.dateRange.last().plusDays(1))
|
deleted,
|
||||||
}
|
version,
|
||||||
}
|
created_at,
|
||||||
sql.params.forEach { (t, u) ->
|
modified_at,
|
||||||
|
deleted_by,
|
||||||
eq("data->>'$t'", u.getValue())
|
approval_status,
|
||||||
}
|
tags,
|
||||||
}
|
comments,
|
||||||
.findList()
|
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()
|
||||||
|
|
||||||
|
ctx.json(fl)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user