Commit 3dafaf3a authored by Ghitha Dinan's avatar Ghitha Dinan

add param in

parent 3c50d2a0
......@@ -12,7 +12,11 @@ class Pagination2Request(
var paramLike: List<ParamSearch>? = emptyList(),
var paramIs: List<ParamSearch>? = emptyList()
var paramIs: List<ParamSearch>? = emptyList(),
var paramIn: List<ParamArray>? = emptyList(),
var paramNotIn: List<ParamArray>? = emptyList()
)
class Sort(
......@@ -26,3 +30,8 @@ class ParamSearch(
var value: String? = null
)
class ParamArray(
var field: String? = null,
var dataType: String? = null,
var value: List<String>? = null
)
......@@ -48,6 +48,34 @@ open class BaseRepositoryNative<T>(_class: Class<T>?) {
queryStr += ")"
}
if (!req.paramIn.isNullOrEmpty()) {
queryStr += " AND ("
req.paramIn?.forEachIndexed { index, element ->
queryStr += "s.${element.field} IN(:${element.field})"
if ((index + 1) < req.paramIs!!.size) {
queryStr += " AND "
}
}
queryStr += ")"
}
if (!req.paramNotIn.isNullOrEmpty()) {
queryStr += " AND ("
req.paramNotIn?.forEachIndexed { index, element ->
queryStr += "s.${element.field} NOT IN(:${element.field})"
if ((index + 1) < req.paramIs!!.size) {
queryStr += " AND "
}
}
queryStr += ")"
}
if (!req.sort.isNullOrEmpty()) {
queryStr += " ORDER BY "
......@@ -70,6 +98,14 @@ open class BaseRepositoryNative<T>(_class: Class<T>?) {
query.setParameter(it.field, it.value)
}
req.paramIn?.forEach {
query.setParameter(it.field, it.value)
}
req.paramNotIn?.forEach {
query.setParameter(it.field, it.value)
}
if (req.enablePage == true) {
query.firstResult = req.page!! * req.size!!
query.maxResults = req.size!!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment