1.2.0 增加 IRepository IQuery的工厂方法,避免无用的空白接口编写
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.synebula.gaea.domain.repository
|
||||
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
/**
|
||||
* Repository 工厂接口。 定义了Repository的创建方法。
|
||||
*/
|
||||
interface IRepositoryFactory {
|
||||
|
||||
/**
|
||||
* 创建原始类型的IRepository接口类型
|
||||
*/
|
||||
fun createRawRepository(clazz: Class<*>): IRepository<*, *>
|
||||
|
||||
/**
|
||||
* 创建指定类型的IRepository接口类型
|
||||
*/
|
||||
fun <T : IAggregateRoot<I>, I> createRepository(clazz: Class<T>): IRepository<T, I>
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.synebula.gaea.domain.service
|
||||
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* 声明服务依赖的聚合根,若服务没有实现类则可以根据依赖项自动组装服务。
|
||||
*
|
||||
* @param clazz 依赖的聚合根类型
|
||||
*/
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Domain(val clazz: KClass<out IAggregateRoot<*>>)
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.synebula.gaea.domain.service
|
||||
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
import com.synebula.gaea.domain.repository.IRepository
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* 声明服务的依赖项,若服务没有实现类则可以根据依赖项自动组装服务。
|
||||
*
|
||||
* @param clazz 依赖的聚合根类型
|
||||
* @param repo 依赖的[IRepository]类型
|
||||
*/
|
||||
annotation class ServiceDependency(
|
||||
val clazz: KClass<out IAggregateRoot<*>>,
|
||||
val repo: KClass<out IRepository<*, *>>,
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.synebula.gaea.query
|
||||
|
||||
|
||||
/**
|
||||
* Query 工厂接口。 定义了Query的创建方法。
|
||||
*/
|
||||
interface IQueryFactory {
|
||||
|
||||
/**
|
||||
* 创建原始类型的IQuery接口类型
|
||||
*/
|
||||
fun createRawQuery(clazz: Class<*>): IQuery<*, *>
|
||||
|
||||
/**
|
||||
* 创建指定类型的IQuery接口类型
|
||||
*/
|
||||
fun <T, I> createQuery(clazz: Class<T>): IQuery<T, I>
|
||||
}
|
||||
Reference in New Issue
Block a user