拆分query typed两种类型
This commit is contained in:
@@ -4,6 +4,8 @@ import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
/**
|
||||
* 继承本接口表示对象为仓储类。
|
||||
* 定义了提供增删改的仓储接口。
|
||||
* 本接口泛型定义在类上,不需要显式提供聚合根的class对象,class对象作为类的成员变量声明。
|
||||
*
|
||||
* @param <TAggregateRoot> this T is the parameter
|
||||
* @author alex
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.synebula.gaea.domain.repository
|
||||
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
/**
|
||||
* 定义了提供增删改的仓储接口。
|
||||
* 本接口泛型放置到方法上,并需要显式提供聚合根的class对象
|
||||
*/
|
||||
interface IRepositoryTyped {
|
||||
/**
|
||||
* 插入单个对象。
|
||||
|
||||
@@ -22,6 +22,4 @@ interface IService<TKey> {
|
||||
fun update(key: TKey, command: ICommand)
|
||||
|
||||
fun remove(key: TKey)
|
||||
|
||||
fun <TAggregateRoot : IAggregateRoot<TKey>> get(key: TKey, clazz: Class<TAggregateRoot>): TAggregateRoot
|
||||
}
|
||||
|
||||
@@ -50,10 +50,6 @@ open class Service<TAggregateRoot : IAggregateRoot<TKey>, TKey>(
|
||||
return this.repository.get(key)
|
||||
}
|
||||
|
||||
override fun <T : IAggregateRoot<TKey>> get(key: TKey, clazz: Class<T>): T {
|
||||
return this.repository.get(key, clazz)
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换ICommand类型到聚合根类型,默认实现,根据需要进行覆写。
|
||||
*
|
||||
|
||||
@@ -8,7 +8,8 @@ import com.synebula.gaea.log.ILogger
|
||||
|
||||
|
||||
/**
|
||||
* class FlatService
|
||||
* 依赖了IRepositoryTyped仓储借口的服务实现类 ServiceTyped
|
||||
* 该类依赖仓储接口 @see IRepositoryTyped ,需要显式提供聚合根的class对象
|
||||
*
|
||||
* @param repository 仓储对象
|
||||
* @param rootClass 聚合根类对象
|
||||
@@ -16,7 +17,7 @@ import com.synebula.gaea.log.ILogger
|
||||
* @param logger 日志组件
|
||||
* @author alex
|
||||
* @version 0.1
|
||||
* @since 2018 18-2-8
|
||||
* @since 2020-05-17
|
||||
*/
|
||||
open class ServiceTyped<TAggregateRoot : IAggregateRoot<TKey>, TKey>(
|
||||
protected var rootClass: Class<TAggregateRoot>,
|
||||
@@ -42,15 +43,11 @@ open class ServiceTyped<TAggregateRoot : IAggregateRoot<TKey>, TKey>(
|
||||
this.repository.remove(key, rootClass)
|
||||
}
|
||||
|
||||
override fun <TAggregateRoot : IAggregateRoot<TKey>> get(key: TKey, clazz: Class<TAggregateRoot>): TAggregateRoot {
|
||||
return this.repository.get(key, clazz)
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换ICommand类型到聚合根类型,默认实现,根据需要进行覆写。
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
* @param command 需要转换的命令
|
||||
* @return 聚合根
|
||||
*/
|
||||
protected fun convert(command: ICommand): TAggregateRoot {
|
||||
try {
|
||||
|
||||
@@ -5,7 +5,7 @@ package com.synebula.gaea.query
|
||||
*
|
||||
* @author wxf
|
||||
*/
|
||||
interface IComplexQuery<TView, TKey, TSecond> {
|
||||
interface IQueryComplex<TView, TKey, TSecond> {
|
||||
|
||||
|
||||
/**
|
||||
@@ -1,20 +1,18 @@
|
||||
package com.synebula.gaea.query
|
||||
|
||||
/**
|
||||
* 查询基接口。
|
||||
* 查询基接口, 其中方法都指定了查询的视图类型。
|
||||
*
|
||||
* @author alex
|
||||
*/
|
||||
interface ITypedQuery<TView, TKey> {
|
||||
|
||||
|
||||
interface IQueryTyped {
|
||||
/**
|
||||
* 根据Key获取对象。
|
||||
*
|
||||
* @param key 对象Key。
|
||||
* @return
|
||||
*/
|
||||
fun get(key: TKey, clazz: Class<TView>): TView?
|
||||
fun <TView, TKey> get(key: TKey, clazz: Class<TView>): TView?
|
||||
|
||||
/**
|
||||
* 根据实体类条件查询所有符合条件记录
|
||||
@@ -22,7 +20,7 @@ interface ITypedQuery<TView, TKey> {
|
||||
* @param params 查询条件。
|
||||
* @return list
|
||||
*/
|
||||
fun list(params: Map<String, Any>?, clazz: Class<TView>): List<TView>
|
||||
fun <TView, TKey> list(params: Map<String, Any>?, clazz: Class<TView>): List<TView>
|
||||
|
||||
/**
|
||||
* 根据条件查询符合条件记录的数量
|
||||
@@ -30,7 +28,7 @@ interface ITypedQuery<TView, TKey> {
|
||||
* @param params 查询条件。
|
||||
* @return int
|
||||
*/
|
||||
fun count(params: Map<String, Any>?, clazz: Class<TView>): Int
|
||||
fun <TView, TKey> count(params: Map<String, Any>?, clazz: Class<TView>): Int
|
||||
|
||||
/**
|
||||
* 根据实体类条件查询所有符合条件记录(分页查询)
|
||||
@@ -38,5 +36,5 @@ interface ITypedQuery<TView, TKey> {
|
||||
* @param params 分页条件
|
||||
* @return 分页数据
|
||||
*/
|
||||
fun paging(params: PagingParam, clazz: Class<TView>): PagingData<TView>
|
||||
fun <TView, TKey> paging(params: PagingParam, clazz: Class<TView>): PagingData<TView>
|
||||
}
|
||||
Reference in New Issue
Block a user