1.4.0 增加jpa的代理模块
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
publishing {
|
||||
publications {
|
||||
publish(MavenPublication) {
|
||||
group "${project.group}"
|
||||
artifactId "${project.name}"
|
||||
version "$version"
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import java.util.logging.Logger
|
||||
* them together as a set ([Dagger](https://dagger.dev/dev-guide/multibindings), [Guice](https://github.com/google/guice/wiki/Multibindings), [Spring](https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-autowired-annotation)).
|
||||
*
|
||||
*
|
||||
* To react to messages, we recommend a reactive-streams framework like [RxJava](https://github.com/ReactiveX/RxJava/wiki) (supplemented with its [RxAndroid](https://github.com/ReactiveX/RxAndroid) extension if you are building for
|
||||
* To react to messages, we recommend a reactive-streams framework Like [RxJava](https://github.com/ReactiveX/RxJava/wiki) (supplemented with its [RxAndroid](https://github.com/ReactiveX/RxAndroid) extension if you are building for
|
||||
* Android) or [Project Reactor](https://projectreactor.io/). (For the basics of
|
||||
* translating code from using a message bus to using a reactive-streams framework, see these two
|
||||
* guides: [1](https://blog.jkl.gg/implementing-an-message-bus-with-rxjava-rxbus/), [2](https://lorentzos.com/rxjava-as-message-bus-the-right-way-10a36bdd49ba).) Some usages
|
||||
@@ -49,7 +49,7 @@ import java.util.logging.Logger
|
||||
* * It makes the cross-references between producer and subscriber harder to find. This can
|
||||
* complicate debugging, lead to unintentional reentrant calls, and force apps to eagerly
|
||||
* initialize all possible subscribers at startup time.
|
||||
* * It uses reflection in ways that break when code is processed by optimizers/minimizer like
|
||||
* * It uses reflection in ways that break when code is processed by optimizers/minimizer Like
|
||||
* [R8 and Proguard](https://developer.android.com/studio/build/shrink-code).
|
||||
* * It doesn't offer a way to wait for multiple messages before taking action. For example, it
|
||||
* doesn't offer a way to wait for multiple producers to all report that they're "ready," nor
|
||||
@@ -137,7 +137,7 @@ import java.util.logging.Logger
|
||||
* @author Cliff
|
||||
* @since 10.0
|
||||
* @param identifier a brief name for this bus, for logging purposes. Should/home/alex/privacy/project/myths/gaea be a valid Java
|
||||
* @param executor the default executor this event bus uses for dispatching events to subscribers.
|
||||
* @param executor the Default executor this event bus uses for dispatching events to subscribers.
|
||||
* @param dispatcher message dispatcher.
|
||||
* @param exceptionHandler Handler for subscriber exceptions.
|
||||
*/
|
||||
@@ -159,7 +159,7 @@ open class Bus<T : Any>(
|
||||
* identifier.
|
||||
*/
|
||||
@JvmOverloads
|
||||
constructor(identifier: String = "default") : this(
|
||||
constructor(identifier: String = "Default") : this(
|
||||
identifier,
|
||||
Executor { it.run() },
|
||||
Dispatcher.perThreadDispatchQueue(),
|
||||
@@ -173,7 +173,7 @@ open class Bus<T : Any>(
|
||||
* @since 16.0
|
||||
*/
|
||||
constructor(exceptionHandler: SubscriberExceptionHandler<T>) : this(
|
||||
"default",
|
||||
"Default",
|
||||
Executor { it.run() },
|
||||
Dispatcher.perThreadDispatchQueue(),
|
||||
exceptionHandler
|
||||
@@ -203,7 +203,7 @@ open class Bus<T : Any>(
|
||||
* @since 16.0
|
||||
*/
|
||||
constructor(executor: Executor, subscriberExceptionHandler: SubscriberExceptionHandler<T>) : this(
|
||||
"default",
|
||||
"Default",
|
||||
executor,
|
||||
Dispatcher.legacyAsync(),
|
||||
subscriberExceptionHandler
|
||||
@@ -216,7 +216,7 @@ open class Bus<T : Any>(
|
||||
* down the executor after the last message has been posted to this message bus.
|
||||
*/
|
||||
constructor(executor: Executor) : this(
|
||||
"default",
|
||||
"Default",
|
||||
executor,
|
||||
Dispatcher.legacyAsync(),
|
||||
LoggingHandler()
|
||||
|
||||
@@ -68,7 +68,7 @@ interface IRepository<TAggregateRoot : IAggregateRoot<ID>, ID> {
|
||||
* @param params 查询条件。
|
||||
* @return int
|
||||
*/
|
||||
fun count(params: Map<String, Any>?): Int
|
||||
fun count(params: Map<String, String>?): Int
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -61,5 +61,5 @@ interface IUniversalRepository {
|
||||
* @param params 查询条件。
|
||||
* @return int
|
||||
*/
|
||||
fun <TAggregateRoot> count(params: Map<String, Any>?, clazz: Class<TAggregateRoot>): Int
|
||||
fun <TAggregateRoot> count(params: Map<String, String>?, clazz: Class<TAggregateRoot>): Int
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ interface IQuery<TView, ID> {
|
||||
* @param params 查询条件。
|
||||
* @return 视图列表
|
||||
*/
|
||||
fun list(params: Map<String, Any>?): List<TView>
|
||||
fun list(params: Map<String, String>?): List<TView>
|
||||
|
||||
/**
|
||||
* 根据条件查询符合条件记录的数量
|
||||
@@ -33,7 +33,7 @@ interface IQuery<TView, ID> {
|
||||
* @param params 查询条件。
|
||||
* @return 数量
|
||||
*/
|
||||
fun count(params: Map<String, Any>?): Int
|
||||
fun count(params: Map<String, String>?): Int
|
||||
|
||||
/**
|
||||
* 根据实体类条件查询所有符合条件记录(分页查询)
|
||||
|
||||
@@ -20,7 +20,7 @@ interface IUniversalQuery {
|
||||
* @param params 查询条件。
|
||||
* @return 视图列表
|
||||
*/
|
||||
fun <TView> list(params: Map<String, Any>?, clazz: Class<TView>): List<TView>
|
||||
fun <TView> list(params: Map<String, String>?, clazz: Class<TView>): List<TView>
|
||||
|
||||
/**
|
||||
* 根据条件查询符合条件记录的数量
|
||||
@@ -28,7 +28,7 @@ interface IUniversalQuery {
|
||||
* @param params 查询条件。
|
||||
* @return 数量
|
||||
*/
|
||||
fun <TView> count(params: Map<String, Any>?, clazz: Class<TView>): Int
|
||||
fun <TView> count(params: Map<String, String>?, clazz: Class<TView>): Int
|
||||
|
||||
/**
|
||||
* 根据实体类条件查询所有符合条件记录(分页查询)
|
||||
|
||||
@@ -4,40 +4,45 @@ enum class Operator {
|
||||
/**
|
||||
* 等于
|
||||
*/
|
||||
eq,
|
||||
Eq,
|
||||
|
||||
/**
|
||||
* 不等于
|
||||
*/
|
||||
ne,
|
||||
Ne,
|
||||
|
||||
/**
|
||||
* 小于
|
||||
*/
|
||||
lt,
|
||||
Lt,
|
||||
|
||||
/**
|
||||
* 大于
|
||||
*/
|
||||
gt,
|
||||
Gt,
|
||||
|
||||
/**
|
||||
* 小于或等于
|
||||
*/
|
||||
lte,
|
||||
Lte,
|
||||
|
||||
/**
|
||||
* 大于或等于
|
||||
*/
|
||||
gte,
|
||||
Gte,
|
||||
|
||||
/**
|
||||
* 模糊匹配
|
||||
*/
|
||||
like,
|
||||
Like,
|
||||
|
||||
/**
|
||||
* 范围内
|
||||
*/
|
||||
Range,
|
||||
|
||||
/**
|
||||
* 默认查询, 未定义查询方式, 业务人员自己实现查询方式
|
||||
*/
|
||||
default
|
||||
Default
|
||||
}
|
||||
@@ -9,7 +9,7 @@ package com.synebula.gaea.query
|
||||
*/
|
||||
data class Params(var page: Int = 1, var size: Int = 10) {
|
||||
|
||||
private var _parameters = linkedMapOf<String, Any>()
|
||||
private var _parameters = linkedMapOf<String, String>()
|
||||
private var _orders = linkedMapOf<String, Order>()
|
||||
|
||||
/**
|
||||
@@ -27,41 +27,23 @@ data class Params(var page: Int = 1, var size: Int = 10) {
|
||||
this._orders = value
|
||||
}
|
||||
get() {
|
||||
if (this._parameters.keys.count { it.startsWith("@") } > 0) {
|
||||
val params = linkedMapOf<String, Any>()
|
||||
this._parameters.forEach {
|
||||
if (it.key.startsWith("@")) {
|
||||
this._orders[it.key.removePrefix("@")] = Order.valueOf(it.value.toString())
|
||||
} else
|
||||
params[it.key] = it.value
|
||||
}
|
||||
this._parameters = params
|
||||
}
|
||||
this.filterOrderParams()
|
||||
return this._orders
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询条件。
|
||||
*/
|
||||
var parameters: LinkedHashMap<String, Any>
|
||||
var parameters: LinkedHashMap<String, String>
|
||||
set(value) {
|
||||
this._parameters = value
|
||||
}
|
||||
get() {
|
||||
if (this._parameters.keys.count { it.startsWith("@") } > 0) {
|
||||
val params = linkedMapOf<String, Any>()
|
||||
this._parameters.forEach {
|
||||
if (it.key.startsWith("@")) {
|
||||
this._orders[it.key.removePrefix("@")] = Order.valueOf(it.value.toString())
|
||||
} else
|
||||
params[it.key] = it.value
|
||||
}
|
||||
this._parameters = params
|
||||
}
|
||||
this.filterOrderParams()
|
||||
return this._parameters
|
||||
}
|
||||
|
||||
constructor(page: Int, size: Int, parameters: LinkedHashMap<String, Any>) : this(page, size) {
|
||||
constructor(page: Int, size: Int, parameters: LinkedHashMap<String, String>) : this(page, size) {
|
||||
this.page = page
|
||||
this.size = size
|
||||
this._parameters = parameters
|
||||
@@ -70,7 +52,7 @@ data class Params(var page: Int = 1, var size: Int = 10) {
|
||||
/**
|
||||
* 添加查询条件
|
||||
*/
|
||||
fun where(field: String, value: Any): Params {
|
||||
fun where(field: String, value: String): Params {
|
||||
_parameters[field] = value
|
||||
return this
|
||||
}
|
||||
@@ -82,4 +64,20 @@ data class Params(var page: Int = 1, var size: Int = 10) {
|
||||
_orders[field] = order
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤参数中的排序字段
|
||||
*/
|
||||
private fun filterOrderParams() {
|
||||
if (this._parameters.keys.count { it.startsWith("@") } > 0) {
|
||||
val params = linkedMapOf<String, String>()
|
||||
this._parameters.forEach {
|
||||
if (it.key.startsWith("@")) {
|
||||
this._orders[it.key.removePrefix("@")] = Order.valueOf(it.value)
|
||||
} else
|
||||
params[it.key] = it.value
|
||||
}
|
||||
this._parameters = params
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.synebula.gaea.reflect
|
||||
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.ParameterizedType
|
||||
|
||||
/**
|
||||
@@ -24,5 +25,27 @@ fun Class<*>.getGenericInterface(interfaceClazz: Class<*>): ParameterizedType? {
|
||||
val type = this.genericInterfaces.find { it.typeName.startsWith(interfaceClazz.typeName) }
|
||||
return if (type == null) null
|
||||
else type as ParameterizedType
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找类字段, 可以查找包括继承类的私有字段
|
||||
*
|
||||
* @param name 字段名称
|
||||
* @return 字段类型
|
||||
*/
|
||||
fun Class<*>.findField(name: String): Field? {
|
||||
var field: Field? = null
|
||||
for (f in this.declaredFields) {
|
||||
if (f.name == name) {
|
||||
field = f
|
||||
}
|
||||
}
|
||||
if (field == null) {
|
||||
val superclass = this.superclass
|
||||
if (superclass != Any::class.java) {
|
||||
field = superclass.findField(name)
|
||||
}
|
||||
}
|
||||
return field
|
||||
}
|
||||
Reference in New Issue
Block a user