From edfd36dde21a8ed47ae7ac10344e4c1a7b07fe75 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 18 May 2020 15:43:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86query=20typed=E4=B8=A4?= =?UTF-8?q?=E7=A7=8D=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.gradle | 2 +- .../com/synebula/gaea/app/IApplication.kt | 3 +- .../kotlin/com/synebula/gaea/app/IQueryApp.kt | 3 +- .../com/synebula/gaea/app/IQueryTypedApp.kt | 66 +++++++++++++++++++ .../com/synebula/gaea/app/QueryTypedApp.kt | 19 ++++++ .../com/synebula/gaea/app/UnionTypedApp.kt | 24 +++++++ .../synebula/gaea/query/mongo/IMongoQuery.kt | 14 ++-- .../synebula/gaea/query/mongo/MongoQuery.kt | 10 +-- ...{MongoTypedQuery.kt => MongoQueryTyped.kt} | 20 +++--- .../gaea/repository/mongo/IMongoRepository.kt | 14 ++++ .../gaea/repository/mongo/MongoRepository.kt | 65 ++++++++---------- .../repository/mongo/MongoRepositoryTyped.kt | 35 +++++----- .../gaea/domain/repository/IRepository.kt | 2 + .../domain/repository/IRepositoryTyped.kt | 4 ++ .../synebula/gaea/domain/service/IService.kt | 2 - .../synebula/gaea/domain/service/Service.kt | 4 -- .../gaea/domain/service/ServiceTyped.kt | 13 ++-- .../{IComplexQuery.kt => IQueryComplex.kt} | 2 +- .../query/{ITypedQuery.kt => IQueryTyped.kt} | 14 ++-- 19 files changed, 210 insertions(+), 106 deletions(-) create mode 100644 src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IQueryTypedApp.kt create mode 100644 src/gaea.app/src/main/kotlin/com/synebula/gaea/app/QueryTypedApp.kt create mode 100644 src/gaea.app/src/main/kotlin/com/synebula/gaea/app/UnionTypedApp.kt rename src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/{MongoTypedQuery.kt => MongoQueryTyped.kt} (64%) create mode 100644 src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/IMongoRepository.kt rename src/gaea/src/main/kotlin/com/synebula/gaea/query/{IComplexQuery.kt => IQueryComplex.kt} (94%) rename src/gaea/src/main/kotlin/com/synebula/gaea/query/{ITypedQuery.kt => IQueryTyped.kt} (58%) diff --git a/settings.gradle b/settings.gradle index f16550f..42a6a35 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -rootProject.name = 'greek.gaea' +rootProject.name = 'myths.gaea' include 'src:gaea' include 'src:gaea.app' include 'src:gaea.mongo' diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IApplication.kt b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IApplication.kt index 5a7954f..3966926 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IApplication.kt +++ b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IApplication.kt @@ -28,8 +28,7 @@ interface IApplication { } catch (ex: Exception) { msg.status = Status.Error msg.message = if (error.isEmpty()) ex.message ?: "" else error - msg.data = ex.message - logger.error(this, "$error: ${ex.message}") + logger.error(this, ex, "$error: ${ex.message}") } return msg } diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IQueryApp.kt b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IQueryApp.kt index 2e446fe..822cdcc 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IQueryApp.kt +++ b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IQueryApp.kt @@ -9,7 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.RequestParam /** - * 应用类接口,提供向Query服务的接口 + * 应用类接口,提供实现Query服务的接口 + * 依赖查询接口 @see IQuery * * @author alex * @version 0.1 diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IQueryTypedApp.kt b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IQueryTypedApp.kt new file mode 100644 index 0000000..bfbdc0a --- /dev/null +++ b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/IQueryTypedApp.kt @@ -0,0 +1,66 @@ +package com.synebula.gaea.app + +import com.synebula.gaea.app.component.HttpMessage +import com.synebula.gaea.data.message.Status +import com.synebula.gaea.query.IQuery +import com.synebula.gaea.query.IQueryTyped +import com.synebula.gaea.query.PagingParam +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestParam + +/** + * 应用类接口,提供实现Query服务的接口. + * 依赖查询接口 @see IQueryTyped + * + * @author alex + * @version 0.1 + * @since 2018 18-2-8 + */ +interface IQueryTypedApp : IApplication { + /** + * 查询服务 + */ + var query: IQueryTyped? + + var viewClass: Class + + @GetMapping("/{key:.+}") + fun get(@PathVariable key: TKey): HttpMessage { + return this.safeExecute("${this.name}获取数据失败") { + if (this.query != null) + it.data = this.query!!.get(key, viewClass) + else { + it.status = Status.Error + it.message = "没有对应服务,无法执行该操作" + } + } + } + + @GetMapping + fun list(@RequestParam parameters: MutableMap): HttpMessage { + return this.safeExecute("${this.name}获取数据失败") { + if (this.query != null) + it.data = this.query!!.list(parameters, viewClass) + else { + it.status = Status.Error + it.message = "没有对应服务,无法执行该操作" + } + } + } + + @GetMapping("/split/{size}/pages/{page}") + fun paging(@PathVariable page: Int, @PathVariable size: Int, @RequestParam parameters: MutableMap): HttpMessage { + return this.safeExecute("${this.name}获取分页数据失败") { + if (this.query != null) { + val params = PagingParam(page, size) + params.parameters = parameters + it.data = this.query!!.paging(params, viewClass) + } else { + it.status = Status.Error + it.message = "没有对应服务,无法执行该操作" + } + } + } + +} diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/QueryTypedApp.kt b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/QueryTypedApp.kt new file mode 100644 index 0000000..e7c4cec --- /dev/null +++ b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/QueryTypedApp.kt @@ -0,0 +1,19 @@ +package com.synebula.gaea.app + +import com.synebula.gaea.log.ILogger +import com.synebula.gaea.query.IQuery +import com.synebula.gaea.query.IQueryTyped + +/** + * 联合服务,同时实现了ICommandApp和IQueryApp接口 + * + * @param name 业务名称 + * @param query 业务查询服务 + * @param logger 日志组件 + */ +open class QueryTypedApp( + override var name: String, + override var viewClass: Class, + override var query: IQueryTyped?, + override var logger: ILogger) : IQueryTypedApp { +} diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/UnionTypedApp.kt b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/UnionTypedApp.kt new file mode 100644 index 0000000..5dd61a5 --- /dev/null +++ b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/UnionTypedApp.kt @@ -0,0 +1,24 @@ +package com.synebula.gaea.app + +import com.synebula.gaea.domain.service.ICommand +import com.synebula.gaea.domain.service.IService +import com.synebula.gaea.log.ILogger +import com.synebula.gaea.query.IQuery +import com.synebula.gaea.query.IQueryTyped + +/** + * 联合服务,同时实现了ICommandApp和IQueryApp接口 + * + * @param name 业务名称 + * @param service 业务domain服务 + * @param query 业务查询服务 + * @param logger 日志组件 + */ +open class UnionTypedApp( + override var name: String, + override var viewClass: Class, + override var service: IService?, + override var query: IQueryTyped?, + override var logger: ILogger) + : ICommandApp, IQueryTypedApp { +} \ No newline at end of file diff --git a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/IMongoQuery.kt b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/IMongoQuery.kt index 7083e42..68985ba 100644 --- a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/IMongoQuery.kt +++ b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/IMongoQuery.kt @@ -11,7 +11,7 @@ import java.lang.reflect.Field /** * 声明了Mongo查询的特有方法 */ -interface IMongoQuery { +interface IMongoQuery { /** * 日志组件 */ @@ -34,14 +34,14 @@ interface IMongoQuery { * * @param id 业务ID */ - fun idQuery(id: String): Query = Query(Criteria("_id").isEqualTo(id)) + fun idQuery(id: TKey): Query = Query(Criteria("_id").isEqualTo(id)) /** * 获取视图对象的字段列表 * * @param clazz 视图对象类型 */ - fun fields(clazz: Class): List { + fun fields(clazz: Class): List { return analyseFields(clazz.declaredFields) } @@ -65,7 +65,7 @@ interface IMongoQuery { * @param params 参数列表 * @param clazz 视图类对象 */ - fun where(query: Query, params: Map?, clazz: Class): Query { + fun where(query: Query, params: Map?, clazz: Class): Query { val criteria = Criteria() if (params != null) { for (param in params) { @@ -83,7 +83,7 @@ interface IMongoQuery { */ fun order(orders: Map?): Sort { val orderList = mutableListOf() - orders?.forEach() { + orders?.forEach { orderList.add(Sort.Order(Sort.Direction.valueOf(it.value.name), it.key)) } return if (orderList.size == 0) @@ -116,7 +116,7 @@ interface IMongoQuery { * @param value 字段值 * @param clazz 视图类对象 */ - fun changeFieldType(key: String, value: Any, clazz: Class): Any? { + fun changeFieldType(key: String, value: Any, clazz: Class): Any? { val getter = clazz.getMethod("get${key.substring(0, 1).toUpperCase()}${key.substring(1)}") return this.convertType(value.toString(), getter.returnType) } @@ -150,4 +150,4 @@ interface IMongoQuery { } } -} \ No newline at end of file +} diff --git a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoQuery.kt b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoQuery.kt index 13f4f4d..0b8835c 100644 --- a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoQuery.kt +++ b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoQuery.kt @@ -1,30 +1,32 @@ package com.synebula.gaea.query.mongo +import com.synebula.gaea.extension.firstCharLowerCase import com.synebula.gaea.log.ILogger import com.synebula.gaea.query.IQuery import com.synebula.gaea.query.PagingData import com.synebula.gaea.query.PagingParam import org.springframework.data.mongodb.core.MongoTemplate import org.springframework.data.mongodb.core.query.Query -import com.synebula.gaea.extension.* /** * 实现IQuery的Mongo查询类 * @param repo MongoRepo对象 */ -open class MongoQuery(var repo: MongoTemplate, override var logger: ILogger? = null) : IQuery, IMongoQuery { +open class MongoQuery(var repo: MongoTemplate, override var logger: ILogger? = null) : + IQuery, IMongoQuery { /** * 查询的对象类 */ var clazz: Class? = null private var _collection = "" + /** * 查询的集合名称 */ - var collection: String = "" + var collection: String set(value) { - field = value + this._collection = value } get() = if (this._collection.isNotEmpty()) this._collection diff --git a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoTypedQuery.kt b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoQueryTyped.kt similarity index 64% rename from src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoTypedQuery.kt rename to src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoQueryTyped.kt index fc62b2a..a011c19 100644 --- a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoTypedQuery.kt +++ b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/query/mongo/MongoQueryTyped.kt @@ -1,23 +1,20 @@ package com.synebula.gaea.query.mongo import com.synebula.gaea.log.ILogger -import com.synebula.gaea.query.* -import org.springframework.data.domain.Sort +import com.synebula.gaea.query.IQueryTyped +import com.synebula.gaea.query.PagingData +import com.synebula.gaea.query.PagingParam import org.springframework.data.mongodb.core.MongoTemplate -import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query -import org.springframework.data.mongodb.core.query.isEqualTo -import java.lang.reflect.Field /** * 实现IQuery的Mongo查询类 * @param repo MongoRepo对象 */ -open class MongoTypedQuery(var repo: MongoTemplate) : ITypedQuery, IMongoQuery { - override var logger: ILogger? = null +open class MongoQueryTyped(var repo: MongoTemplate, override var logger: ILogger? = null) : IQueryTyped, IMongoQuery { - override fun list(params: Map?, clazz: Class): List { + override fun list(params: Map?, clazz: Class): List { val viewFields = this.fields(clazz) val query = Query() this.where(query, params, clazz) @@ -25,12 +22,12 @@ open class MongoTypedQuery(var repo: MongoTemplate) : ITypedQuery?, clazz: Class): Int { + override fun count(params: Map?, clazz: Class): Int { val query = Query() return this.repo.count(this.where(query, params, clazz), clazz.simpleName).toInt() } - override fun paging(params: PagingParam, clazz: Class): PagingData { + override fun paging(params: PagingParam, clazz: Class): PagingData { val viewFields = this.fields(clazz) val result = PagingData(1, 10) result.size = params.size @@ -45,8 +42,7 @@ open class MongoTypedQuery(var repo: MongoTemplate) : ITypedQuery): TView? { + override fun get(key: TKey, clazz: Class): TView? { return this.repo.findOne(idQuery(key), clazz, clazz.simpleName) } - } diff --git a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/IMongoRepository.kt b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/IMongoRepository.kt new file mode 100644 index 0000000..0d8f9d0 --- /dev/null +++ b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/IMongoRepository.kt @@ -0,0 +1,14 @@ +package com.synebula.gaea.repository.mongo + +import org.springframework.data.mongodb.core.query.Criteria +import org.springframework.data.mongodb.core.query.Query +import org.springframework.data.mongodb.core.query.isEqualTo + +interface IMongoRepository { + /** + * 获取ID查询条件 + * + * @param id 业务ID + */ + fun idQuery(id: TKey): Query = Query(Criteria("_id").isEqualTo(id)) +} diff --git a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/MongoRepository.kt b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/MongoRepository.kt index 0813e7c..462b609 100644 --- a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/MongoRepository.kt +++ b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/MongoRepository.kt @@ -12,46 +12,39 @@ import org.springframework.data.mongodb.core.query.isEqualTo * @param repo MongoRepo对象 */ class MongoRepository>(private var repo: MongoTemplate) - : IRepository { + : IRepository, IMongoRepository { - /** - * 仓储的对象类 - */ - override var clazz: Class? = null + /** + * 仓储的对象类 + */ + override var clazz: Class? = null - /** - * 构造 - * @param clazz 仓储Domain对象 - * @param repo MongoRepo对象 - */ - constructor(clazz: Class, repo: MongoTemplate) : this(repo) { - this.clazz = clazz - } + /** + * 构造 + * @param clazz 仓储Domain对象 + * @param repo MongoRepo对象 + */ + constructor(clazz: Class, repo: MongoTemplate) : this(repo) { + this.clazz = clazz + } - override fun add(obj: TAggregateRoot) { - this.repo.save(obj) - } + override fun add(obj: TAggregateRoot) { + this.repo.save(obj) + } - override fun update(obj: TAggregateRoot) { - this.repo.save(obj) - } + override fun update(obj: TAggregateRoot) { + this.repo.save(obj) + } - override fun remove(id: String) { - this.repo.remove(idQuery(id), this.clazz!!) - } + override fun remove(id: String) { + this.repo.remove(idQuery(id), this.clazz!!) + } - override fun get(id: String): TAggregateRoot { - return this.repo.findOne(idQuery(id), clazz!!) as TAggregateRoot - } + override fun get(id: String): TAggregateRoot { + return this.repo.findOne(idQuery(id), clazz!!) as TAggregateRoot + } - override fun , TKey> get(id: TKey, clazz: Class): TAggregateRoot { - return this.repo.findOne(idQuery(id.toString()), clazz) as TAggregateRoot - } - - /** - * 获取ID查询条件 - * - * @param id 业务ID - */ - fun idQuery(id: String): Query = Query(Criteria("_id").isEqualTo(id)) -} \ No newline at end of file + override fun , TKey> get(id: TKey, clazz: Class): TAggregateRoot { + return this.repo.findOne(idQuery(id.toString()), clazz) as TAggregateRoot + } +} diff --git a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/MongoRepositoryTyped.kt b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/MongoRepositoryTyped.kt index 6b42e67..1aed41b 100644 --- a/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/MongoRepositoryTyped.kt +++ b/src/gaea.mongo/src/main/kotlin/com/synebula/gaea/repository/mongo/MongoRepositoryTyped.kt @@ -12,28 +12,23 @@ import org.springframework.data.mongodb.core.query.isEqualTo * @param repo MongoRepo对象 */ open class MongoRepositoryTyped(private var repo: MongoTemplate) - : IRepositoryTyped { + : IRepositoryTyped, IMongoRepository { - override fun , TKey> remove(id: TKey, clazz: Class) { - this.repo.remove(idQuery(id), clazz) - } + override fun , TKey> remove(id: TKey, clazz: Class) { + this.repo.remove(idQuery(id), clazz) + } - override fun , TKey> get(id: TKey, clazz: Class): TAggregateRoot { - return this.repo.findOne(idQuery(id), clazz) as TAggregateRoot - } + override fun , TKey> get(id: TKey, clazz: Class): TAggregateRoot { + return this.repo.findOne(idQuery(id), clazz) as TAggregateRoot + } - override fun , TKey> update(obj: TAggregateRoot, clazz: Class) { - this.repo.save(obj) - } + override fun , TKey> update(obj: TAggregateRoot, clazz: Class) { + this.repo.save(obj) + } - override fun , TKey> add(obj: TAggregateRoot, clazz: Class) { - this.repo.save(obj) - } + override fun , TKey> add(obj: TAggregateRoot, clazz: Class) { + this.repo.save(obj) + } - /** - * 获取ID查询条件 - * - * @param id 业务ID - */ - fun idQuery(id: TKey): Query = Query(Criteria("_id").isEqualTo(id)) -} \ No newline at end of file + +} diff --git a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/repository/IRepository.kt b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/repository/IRepository.kt index 196d2ad..ff7bd56 100644 --- a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/repository/IRepository.kt +++ b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/repository/IRepository.kt @@ -4,6 +4,8 @@ import com.synebula.gaea.domain.model.IAggregateRoot /** * 继承本接口表示对象为仓储类。 + * 定义了提供增删改的仓储接口。 + * 本接口泛型定义在类上,不需要显式提供聚合根的class对象,class对象作为类的成员变量声明。 * * @param this T is the parameter * @author alex diff --git a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/repository/IRepositoryTyped.kt b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/repository/IRepositoryTyped.kt index bd4660f..d00164d 100644 --- a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/repository/IRepositoryTyped.kt +++ b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/repository/IRepositoryTyped.kt @@ -2,6 +2,10 @@ package com.synebula.gaea.domain.repository import com.synebula.gaea.domain.model.IAggregateRoot +/** + * 定义了提供增删改的仓储接口。 + * 本接口泛型放置到方法上,并需要显式提供聚合根的class对象 + */ interface IRepositoryTyped { /** * 插入单个对象。 diff --git a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/IService.kt b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/IService.kt index b66ed12..8a56335 100644 --- a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/IService.kt +++ b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/IService.kt @@ -22,6 +22,4 @@ interface IService { fun update(key: TKey, command: ICommand) fun remove(key: TKey) - - fun > get(key: TKey, clazz: Class): TAggregateRoot } diff --git a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/Service.kt b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/Service.kt index 13eb12e..b41e75d 100644 --- a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/Service.kt +++ b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/Service.kt @@ -50,10 +50,6 @@ open class Service, TKey>( return this.repository.get(key) } - override fun > get(key: TKey, clazz: Class): T { - return this.repository.get(key, clazz) - } - /** * 转换ICommand类型到聚合根类型,默认实现,根据需要进行覆写。 * diff --git a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/ServiceTyped.kt b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/ServiceTyped.kt index 782c21f..2126c23 100644 --- a/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/ServiceTyped.kt +++ b/src/gaea/src/main/kotlin/com/synebula/gaea/domain/service/ServiceTyped.kt @@ -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, TKey>( protected var rootClass: Class, @@ -42,15 +43,11 @@ open class ServiceTyped, TKey>( this.repository.remove(key, rootClass) } - override fun > get(key: TKey, clazz: Class): TAggregateRoot { - return this.repository.get(key, clazz) - } - /** * 转换ICommand类型到聚合根类型,默认实现,根据需要进行覆写。 * - * @param command - * @return + * @param command 需要转换的命令 + * @return 聚合根 */ protected fun convert(command: ICommand): TAggregateRoot { try { diff --git a/src/gaea/src/main/kotlin/com/synebula/gaea/query/IComplexQuery.kt b/src/gaea/src/main/kotlin/com/synebula/gaea/query/IQueryComplex.kt similarity index 94% rename from src/gaea/src/main/kotlin/com/synebula/gaea/query/IComplexQuery.kt rename to src/gaea/src/main/kotlin/com/synebula/gaea/query/IQueryComplex.kt index 49ff1ad..f01e28d 100644 --- a/src/gaea/src/main/kotlin/com/synebula/gaea/query/IComplexQuery.kt +++ b/src/gaea/src/main/kotlin/com/synebula/gaea/query/IQueryComplex.kt @@ -5,7 +5,7 @@ package com.synebula.gaea.query * * @author wxf */ -interface IComplexQuery { +interface IQueryComplex { /** diff --git a/src/gaea/src/main/kotlin/com/synebula/gaea/query/ITypedQuery.kt b/src/gaea/src/main/kotlin/com/synebula/gaea/query/IQueryTyped.kt similarity index 58% rename from src/gaea/src/main/kotlin/com/synebula/gaea/query/ITypedQuery.kt rename to src/gaea/src/main/kotlin/com/synebula/gaea/query/IQueryTyped.kt index ad72df5..38412d9 100644 --- a/src/gaea/src/main/kotlin/com/synebula/gaea/query/ITypedQuery.kt +++ b/src/gaea/src/main/kotlin/com/synebula/gaea/query/IQueryTyped.kt @@ -1,20 +1,18 @@ package com.synebula.gaea.query /** - * 查询基接口。 + * 查询基接口, 其中方法都指定了查询的视图类型。 * * @author alex */ -interface ITypedQuery { - - +interface IQueryTyped { /** * 根据Key获取对象。 * * @param key 对象Key。 * @return */ - fun get(key: TKey, clazz: Class): TView? + fun get(key: TKey, clazz: Class): TView? /** * 根据实体类条件查询所有符合条件记录 @@ -22,7 +20,7 @@ interface ITypedQuery { * @param params 查询条件。 * @return list */ - fun list(params: Map?, clazz: Class): List + fun list(params: Map?, clazz: Class): List /** * 根据条件查询符合条件记录的数量 @@ -30,7 +28,7 @@ interface ITypedQuery { * @param params 查询条件。 * @return int */ - fun count(params: Map?, clazz: Class): Int + fun count(params: Map?, clazz: Class): Int /** * 根据实体类条件查询所有符合条件记录(分页查询) @@ -38,5 +36,5 @@ interface ITypedQuery { * @param params 分页条件 * @return 分页数据 */ - fun paging(params: PagingParam, clazz: Class): PagingData + fun paging(params: PagingParam, clazz: Class): PagingData }