0.2.0 完善功能
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.*
|
||||
gradlew*
|
||||
build
|
||||
gradle
|
||||
|
||||
!.gitignore
|
||||
29
build.gradle
29
build.gradle
@@ -1,11 +1,11 @@
|
||||
buildscript {
|
||||
ext {
|
||||
kotlin_version = '1.2.10'
|
||||
kotlin_version = '1.3.41'
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
mavenLocal()
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
@@ -15,24 +15,27 @@ buildscript {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'idea'
|
||||
|
||||
group 'com.synebula'
|
||||
version '0.1'
|
||||
|
||||
repositories {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
ext {
|
||||
version '0.2.0'
|
||||
}
|
||||
|
||||
group 'com.synebula'
|
||||
version project.version
|
||||
|
||||
apply plugin: 'idea'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
mavenLocal()
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
@@ -44,7 +47,7 @@ subprojects {
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-reflect"
|
||||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
rootProject.name = 'gaea'
|
||||
include 'src:gaea.data'
|
||||
findProject(':src:gaea.data')?.name = 'gaea.data'
|
||||
include 'src:gaea'
|
||||
findProject(':src:gaea')?.name = 'gaea'
|
||||
include 'src:gaea.domain'
|
||||
findProject(':src:gaea.domain')?.name = 'gaea.domain'
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
dependencies {
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.synebula.gaea.data
|
||||
|
||||
import com.synebula.gaea.data.type.Status
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
*
|
||||
* @author reize
|
||||
* @version 0.0.1
|
||||
* @since 2016年9月6日 下午3:47:35
|
||||
*/
|
||||
open class StatusData<T> {
|
||||
var code: Status
|
||||
set(value) {
|
||||
field = value
|
||||
this.status = value.code
|
||||
}
|
||||
var status: Int
|
||||
var message: String = ""
|
||||
var data: T? = null
|
||||
val timestamp = Date().time
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*/
|
||||
constructor(code: Status) {
|
||||
this.code = code
|
||||
this.status = code.code
|
||||
}
|
||||
|
||||
constructor() : this(Status.success) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data 数据
|
||||
*/
|
||||
constructor(data: T) : this(Status.success) {
|
||||
this.data = data
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status 状态
|
||||
* @param message 消息
|
||||
*/
|
||||
constructor(status: Status, message: String) : this(status) {
|
||||
this.message = message
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status 状态
|
||||
* @param message 消息
|
||||
* @param data 数据
|
||||
*/
|
||||
constructor(status: Status, message: String, data: T) : this(status) {
|
||||
this.message = message
|
||||
this.data = data
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.synebula.gaea.data.type
|
||||
|
||||
/**
|
||||
* 状态类型。
|
||||
*
|
||||
* @author reize
|
||||
* @version 0.0.1
|
||||
* @since 2016年9月6日 下午3:27:55
|
||||
*/
|
||||
enum class Status(val code: Int) {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
success(200),
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
failure(400),
|
||||
|
||||
/**
|
||||
* 错误
|
||||
*/
|
||||
error(500);
|
||||
|
||||
companion object {
|
||||
fun valueOf(code: Int): Status {
|
||||
return when (code) {
|
||||
200 -> Status.success
|
||||
400 -> Status.failure
|
||||
else -> Status.error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
14
src/gaea.domain/build.gradle
Normal file
14
src/gaea.domain/build.gradle
Normal file
@@ -0,0 +1,14 @@
|
||||
dependencies {
|
||||
compile project(":src:gaea")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
group 'com.synebula'
|
||||
artifactId 'gaea.domain'
|
||||
version project.version
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.synebula.gaea.domain.model
|
||||
|
||||
abstract class AggregateRoot<TKey> : Entity<TKey>(), IAggregateRoot<TKey>
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.synebula.gaea.domain.model
|
||||
|
||||
abstract class Entity<TKey> : IEntity<TKey>
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.synebula.gaea.domain.model
|
||||
|
||||
/**
|
||||
* 继承本接口,说明对象为聚合根。
|
||||
*
|
||||
* @author alex
|
||||
**/
|
||||
interface IAggregateRoot<TKey> : IEntity<TKey>
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.synebula.gaea.domain.model
|
||||
|
||||
/**
|
||||
* 继承本接口,说明对象为实体类型。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <TKey> 主键的类型。
|
||||
**/
|
||||
interface IEntity<TKey> {
|
||||
|
||||
/**
|
||||
* 实体ID
|
||||
*/
|
||||
var id: TKey
|
||||
|
||||
/**
|
||||
* 实体对象是否有效。
|
||||
*/
|
||||
var alive: Boolean
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.synebula.gaea.domain.model
|
||||
|
||||
/**
|
||||
* 继承本接口,说明对象为值类型。
|
||||
* @author alex
|
||||
*/
|
||||
interface IValue
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.synebula.gaea.domain.model.complex
|
||||
|
||||
abstract class ComplexAggregateRoot<TKey, TSecond> : ComplexEntity<TKey, TSecond>(), IComplexAggregateRoot<TKey, TSecond>
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.synebula.gaea.domain.model.complex
|
||||
|
||||
|
||||
abstract class ComplexEntity<TKey, TSecond> : IComplexEntity<TKey, TSecond> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.synebula.gaea.domain.model.complex
|
||||
|
||||
/**
|
||||
* 继承本接口,说明对象为聚合根。
|
||||
*
|
||||
* @param <TKey> 主键的类型。
|
||||
* @author alex
|
||||
*/
|
||||
interface IComplexAggregateRoot<TKey, TSecond> : IComplexEntity<TKey, TSecond>
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.synebula.gaea.domain.model.complex
|
||||
|
||||
import com.synebula.gaea.domain.model.IEntity
|
||||
|
||||
interface IComplexEntity<TKey, TSecond> : IEntity<TKey> {
|
||||
var secondary: TSecond
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.synebula.gaea.domain.repository
|
||||
|
||||
import com.synebula.gaea.domain.model.complex.IComplexAggregateRoot
|
||||
|
||||
/**
|
||||
* 继承本接口表示对象为仓储类。
|
||||
*
|
||||
* @param <TAggregateRoot> this T is the parameter
|
||||
* @author alex
|
||||
*/
|
||||
interface IComplexRepository<TAggregateRoot : IComplexAggregateRoot<TKey, TSecond>, TKey, TSecond> {
|
||||
|
||||
/**
|
||||
* 插入单个对象。
|
||||
*
|
||||
* @param obj 需要插入的对象。
|
||||
* @return 返回原对象,如果对象ID为自增,则补充自增ID。
|
||||
*/
|
||||
fun add(obj: TAggregateRoot)
|
||||
|
||||
/**
|
||||
* 更新对象。
|
||||
*
|
||||
* @param obj 需要更新的对象。
|
||||
* @return
|
||||
*/
|
||||
fun update(obj: TAggregateRoot)
|
||||
|
||||
/**
|
||||
* 通过id删除该条数据
|
||||
*
|
||||
* @param key 对象ID。
|
||||
* @param secondary 对象副主键。
|
||||
* @return
|
||||
*/
|
||||
fun remove(key: TKey, secondary: TSecond)
|
||||
|
||||
/**
|
||||
* 根据ID获取对象。
|
||||
*
|
||||
* @param key 对象ID。
|
||||
* @return
|
||||
*/
|
||||
operator fun get(key: TKey, secondary: TSecond): TAggregateRoot
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.synebula.gaea.domain.repository
|
||||
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
/**
|
||||
* 继承本接口表示对象为仓储类。
|
||||
*
|
||||
* @param <TAggregateRoot> this T is the parameter
|
||||
* @author alex
|
||||
*/
|
||||
interface IRepository<TAggregateRoot : IAggregateRoot<TKey>, TKey> {
|
||||
|
||||
/**
|
||||
* 插入单个对象。
|
||||
*
|
||||
* @param obj 需要插入的对象。
|
||||
* @return 返回原对象,如果对象ID为自增,则补充自增ID。
|
||||
*/
|
||||
fun add(obj: TAggregateRoot)
|
||||
|
||||
/**
|
||||
* 更新对象。
|
||||
*
|
||||
* @param obj 需要更新的对象。
|
||||
* @return
|
||||
*/
|
||||
fun update(obj: TAggregateRoot)
|
||||
|
||||
/**
|
||||
* 通过id删除该条数据
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
fun remove(id: TKey)
|
||||
|
||||
/**
|
||||
* 根据ID获取对象。
|
||||
*
|
||||
* @param id 对象ID。
|
||||
* @return
|
||||
*/
|
||||
operator fun get(id: TKey): TAggregateRoot
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.synebula.gaea.domain.repository
|
||||
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
interface ITypedRepository<TAggregateRoot : IAggregateRoot<TKey>, TKey> {
|
||||
/**
|
||||
* 插入单个对象。
|
||||
*
|
||||
* @param obj 需要插入的对象。
|
||||
* @return 返回原对象,如果对象ID为自增,则补充自增ID。
|
||||
*/
|
||||
fun add(obj: TAggregateRoot): Unit
|
||||
|
||||
/**
|
||||
* 更新对象。
|
||||
*
|
||||
* @param obj 需要更新的对象。
|
||||
* @return
|
||||
*/
|
||||
fun update(obj: TAggregateRoot): Unit
|
||||
|
||||
/**
|
||||
* 通过id删除该条数据
|
||||
*
|
||||
* @param id id
|
||||
* @param clazz 操作数据的类型
|
||||
*/
|
||||
fun remove(id: TKey, clazz: Class<TAggregateRoot>): Unit
|
||||
|
||||
/**
|
||||
* 根据ID获取对象。
|
||||
*
|
||||
* @param id id
|
||||
* @param clazz 操作数据的类型
|
||||
* @return 聚合根
|
||||
*/
|
||||
fun get(id: TKey, clazz: Class<TAggregateRoot>): TAggregateRoot
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.synebula.gaea.domain.repository.context
|
||||
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
/**
|
||||
* 继承自IUnitOfWork,表示实现了工作单元模式的上下文接口。
|
||||
*
|
||||
* @author alex
|
||||
*/
|
||||
interface IContext : IUnitOfWork {
|
||||
/**
|
||||
* 将指定的聚合根标注为“新建”状态。
|
||||
* @param obj
|
||||
*/
|
||||
fun <TType : IAggregateRoot<TKey>, TKey> add(obj: TType)
|
||||
|
||||
/**
|
||||
* 将指定的聚合根标注为“更改”状态。
|
||||
*
|
||||
* @param obj
|
||||
*/
|
||||
fun <TType : IAggregateRoot<TKey>, TKey> update(obj: TType)
|
||||
|
||||
/**
|
||||
* 将指定的聚合根标注为“删除”状态。
|
||||
*
|
||||
* @param obj
|
||||
*/
|
||||
fun <TType : IAggregateRoot<TKey>, TKey> remove(obj: TType)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.synebula.gaea.domain.repository.context
|
||||
|
||||
/**
|
||||
* 表示所有继承于该接口的类型都是Unit Of Work的一种实现。
|
||||
*
|
||||
* @author alex
|
||||
*/
|
||||
interface IUnitOfWork {
|
||||
|
||||
/**
|
||||
* 获得一个boolean值,该值表述了当前的Unit Of Work事务是否已被提交。
|
||||
*
|
||||
* @return 返回Unit Of Work事务是否已被提交。
|
||||
*/
|
||||
val isCommitted: Boolean
|
||||
|
||||
/**
|
||||
* 提交当前的Unit Of Work事务。
|
||||
*/
|
||||
fun commit()
|
||||
|
||||
/**
|
||||
* 回滚当前的Unit Of Work事务。
|
||||
*/
|
||||
fun rollback()
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 表示第一个规约对象和第二个规约对象反转的结果取与。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
* 规约对象的类型。
|
||||
*/
|
||||
class AndNotSpecification<T>
|
||||
/**
|
||||
* 构造一个新的混合规约对象。
|
||||
*
|
||||
* @param left
|
||||
* 表达式左侧规约对象。
|
||||
* @param right
|
||||
* 表达式右侧规约对象。
|
||||
*/
|
||||
(left: ISpecification<T>, right: ISpecification<T>) : CompositeSpecification<T>(left, right) {
|
||||
|
||||
override fun isSatisfiedBy(obj: T): Boolean {
|
||||
return left.isSatisfiedBy(obj) && NotSpecification(right).isSatisfiedBy(obj)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 表示第一个规约对象和第二个规约对象取与。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
* 规约对象的类型。
|
||||
*/
|
||||
class AndSpecification<T>
|
||||
/**
|
||||
* 构造一个新的混合规约对象。
|
||||
*
|
||||
* @param left
|
||||
* 表达式左侧规约对象。
|
||||
* @param right
|
||||
* 表达式右侧规约对象。
|
||||
*/
|
||||
(left: ISpecification<T>, right: ISpecification<T>) : CompositeSpecification<T>(left, right) {
|
||||
|
||||
override fun isSatisfiedBy(obj: T): Boolean {
|
||||
return left.isSatisfiedBy(obj) && right.isSatisfiedBy(obj)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 任何对象都返回真。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
* 规约对象的类型。
|
||||
*/
|
||||
class AnySpecification<T> : Specification<T>() {
|
||||
|
||||
override fun isSatisfiedBy(obj: T): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 实现了接口ICompositeSpecification<T>,混合规约的基类。
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
</T> */
|
||||
abstract class CompositeSpecification<T>
|
||||
/**
|
||||
* 构造一个新的混合规约对象。
|
||||
*
|
||||
* @param left
|
||||
* 表达式左侧规约对象。
|
||||
* @param right
|
||||
* 表达式右侧规约对象。
|
||||
*/
|
||||
(
|
||||
/**
|
||||
* 表达式左侧规约对象。
|
||||
*/
|
||||
override val left: ISpecification<T>,
|
||||
/**
|
||||
* 表达式右侧规约对象。
|
||||
*/
|
||||
override val right: ISpecification<T>) : Specification<T>(), ICompositeSpecification<T>
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 定义一个有两个规约对象混合规约接口。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
* 规约对象的类型。
|
||||
*/
|
||||
interface ICompositeSpecification<T> : ISpecification<T> {
|
||||
|
||||
/**
|
||||
* 获取左侧规约对象。
|
||||
*
|
||||
* @return 返回左侧规约对象。
|
||||
*/
|
||||
val left: ISpecification<T>
|
||||
|
||||
/**
|
||||
* 获取右侧规约对象。
|
||||
*
|
||||
* @return 返回右侧规约对象。
|
||||
*/
|
||||
val right: ISpecification<T>
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 声明规约对象的公共接口。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
interface ISpecification<T> {
|
||||
/**
|
||||
* 判断是否符合条件。
|
||||
*
|
||||
* @param obj
|
||||
* 规约类型的对象。
|
||||
* @return 符合条件的返回True。
|
||||
*/
|
||||
fun isSatisfiedBy(obj: T): Boolean
|
||||
|
||||
/**
|
||||
* 结合当前规约对象和另一规约对象进行与判断。
|
||||
*
|
||||
* @param other
|
||||
* 需要进行与结合的另一个规约对象。
|
||||
* @return 结合后的规约对象。
|
||||
*/
|
||||
fun and(other: ISpecification<T>): ISpecification<T>
|
||||
|
||||
/**
|
||||
* 结合当前规约对象和另一规约对象进行或判断。
|
||||
*
|
||||
* @param other
|
||||
* 需要进行或结合的另一个规约对象。
|
||||
* @return 结合后的规约对象。
|
||||
*/
|
||||
fun or(other: ISpecification<T>): ISpecification<T>
|
||||
|
||||
/**
|
||||
* 结合当前规约对象和另一规约对象进行与且非判断
|
||||
*
|
||||
* @param other
|
||||
* 需要进行非结合的另一个规约对象。
|
||||
* @return 结合后的规约对象。
|
||||
*/
|
||||
fun andNot(other: ISpecification<T>): ISpecification<T>
|
||||
|
||||
/**
|
||||
* 结合当前规约对象和另一规约对象进行或非判断。
|
||||
*
|
||||
* @param other
|
||||
* 需要进行或非结合的另一个规约对象。
|
||||
* @return 结合后的规约对象。
|
||||
*/
|
||||
fun orNot(other: ISpecification<T>): ISpecification<T>
|
||||
|
||||
/**
|
||||
* 反转当前规约的判断结果。
|
||||
*
|
||||
* @return 反转后的规约对象。
|
||||
*/
|
||||
operator fun not(): ISpecification<T>
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 任何对象都返回假。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
* 规约对象的类型。
|
||||
*/
|
||||
class NoneSpecification<T> : Specification<T>() {
|
||||
|
||||
override fun isSatisfiedBy(obj: T): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 逆反规约。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
* 规约对象的类型。
|
||||
*/
|
||||
class NotSpecification<T>
|
||||
/**
|
||||
* 构造一个新的逆反规约对象。
|
||||
*
|
||||
* @param specification
|
||||
* 需要逆反的规约对象。
|
||||
*/
|
||||
(private val spec: ISpecification<T>) : Specification<T>() {
|
||||
|
||||
override fun isSatisfiedBy(obj: T): Boolean {
|
||||
return !spec.isSatisfiedBy(obj)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
/**
|
||||
* 表示第一个规约对象和第二个规约对象反转的结果取或。
|
||||
*
|
||||
* @author alex
|
||||
*
|
||||
* @param <T>
|
||||
* 规约对象的类型。
|
||||
*/
|
||||
class OrNotSpecification<T>
|
||||
/**
|
||||
* 构造一个新的混合规约对象。
|
||||
*
|
||||
* @param left
|
||||
* 表达式左侧规约对象。
|
||||
* @param right
|
||||
* 表达式右侧规约对象。
|
||||
*/
|
||||
(left: ISpecification<T>, right: ISpecification<T>) : CompositeSpecification<T>(left, right) {
|
||||
|
||||
override fun isSatisfiedBy(obj: T): Boolean {
|
||||
return left.isSatisfiedBy(obj) || NotSpecification(right).isSatisfiedBy(obj)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
class OrSpecification<T>
|
||||
/**
|
||||
* 构造一个新的混合规约对象。
|
||||
*
|
||||
* @param left
|
||||
* 表达式左侧规约对象。
|
||||
* @param right
|
||||
* 表达式右侧规约对象。
|
||||
*/
|
||||
(left: ISpecification<T>, right: ISpecification<T>) : CompositeSpecification<T>(left, right) {
|
||||
|
||||
override fun isSatisfiedBy(obj: T): Boolean {
|
||||
return left.isSatisfiedBy(obj) || right.isSatisfiedBy(obj)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.synebula.gaea.domain.repository.specifications
|
||||
|
||||
abstract class Specification<T> : ISpecification<T> {
|
||||
|
||||
abstract override fun isSatisfiedBy(obj: T): Boolean
|
||||
|
||||
override fun and(other: ISpecification<T>): ISpecification<T> {
|
||||
return AndSpecification(this, other)
|
||||
}
|
||||
|
||||
override fun or(other: ISpecification<T>): ISpecification<T> {
|
||||
return OrSpecification(this, other)
|
||||
}
|
||||
|
||||
override fun andNot(other: ISpecification<T>): ISpecification<T> {
|
||||
return AndNotSpecification(this, other)
|
||||
}
|
||||
|
||||
override fun orNot(other: ISpecification<T>): ISpecification<T> {
|
||||
return OrNotSpecification(this, other)
|
||||
}
|
||||
|
||||
override fun not(): ISpecification<T> {
|
||||
return NotSpecification(this)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.synebula.gaea.domain.service
|
||||
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 命令基础实现类,发给service的命令。
|
||||
*
|
||||
* @author alex
|
||||
* @version 0.1
|
||||
* @since 2018 18-2-8
|
||||
*/
|
||||
class Command : ICommand {
|
||||
override var timestamp = 0L
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.synebula.gaea.domain.service
|
||||
|
||||
import com.synebula.gaea.data.IObjectConverter
|
||||
import com.synebula.gaea.data.message.http.HttpMessage
|
||||
import com.synebula.gaea.domain.model.complex.IComplexAggregateRoot
|
||||
import com.synebula.gaea.domain.repository.IComplexRepository
|
||||
import com.synebula.gaea.log.ILogger
|
||||
|
||||
/**
|
||||
* 复合主键的服务基类
|
||||
*
|
||||
* @author alex
|
||||
* @version 0.1
|
||||
* @since 2018 18-2-8
|
||||
*/
|
||||
open class ComplexService<TAggregateRoot : IComplexAggregateRoot<TKey, TSecond>, TKey, TSecond>
|
||||
(var logger: ILogger, protected var repository: IComplexRepository<TAggregateRoot, TKey, TSecond>,
|
||||
protected var converter: IObjectConverter, protected var aggregateRootClass: Class<TAggregateRoot>)
|
||||
: IComplexService<TKey, TSecond> {
|
||||
|
||||
override fun add(command: ICommand): HttpMessage<Pair<TKey, TSecond>> {
|
||||
val msg = HttpMessage<Pair<TKey, TSecond>>()
|
||||
val root = this.convert(command)
|
||||
repository.add(root)
|
||||
msg.data = Pair<TKey, TSecond>(root.id, root.secondary)
|
||||
return msg
|
||||
}
|
||||
|
||||
override fun update(key: TKey, secondary: TSecond, command: ICommand) {
|
||||
val root = this.convert(command)
|
||||
root.id = key
|
||||
root.secondary = secondary
|
||||
repository.update(root)
|
||||
}
|
||||
|
||||
override fun remove(key: TKey, secondary: TSecond) {
|
||||
repository.remove(key, secondary)
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换ICommand类型到聚合根类型,默认实现,根据需要进行覆写。
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
protected fun convert(command: ICommand): TAggregateRoot {
|
||||
try {
|
||||
return converter.convert(command, aggregateRootClass)
|
||||
} catch (ex: Exception) {
|
||||
throw RuntimeException("command not match aggregate root", ex)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.synebula.gaea.domain.service
|
||||
|
||||
/**
|
||||
* 命令接口,发给service的命令。
|
||||
*
|
||||
* @author alex
|
||||
* @version 0.1
|
||||
* @since 2018 18-2-8
|
||||
*/
|
||||
interface ICommand {
|
||||
/**
|
||||
* 时间戳。
|
||||
*/
|
||||
var timestamp: Long
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.synebula.gaea.domain.service
|
||||
|
||||
import com.synebula.gaea.data.message.http.HttpMessage
|
||||
|
||||
/**
|
||||
* class IFlatService
|
||||
*
|
||||
* @author alex
|
||||
* @version 0.1
|
||||
* @since 2018 18-2-8
|
||||
*/
|
||||
interface IComplexService<TKey, TSecond> {
|
||||
|
||||
fun add(command: ICommand): HttpMessage<Pair<TKey, TSecond>>
|
||||
|
||||
fun update(key: TKey, secondary: TSecond, command: ICommand)
|
||||
|
||||
fun remove(key: TKey, secondary: TSecond)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.synebula.gaea.domain.service
|
||||
|
||||
import com.synebula.gaea.data.message.http.HttpMessage
|
||||
import com.synebula.gaea.log.ILogger
|
||||
|
||||
|
||||
/**
|
||||
* 继承该接口,表明对象为领域服务。
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年9月18日 下午2:23:15
|
||||
*/
|
||||
interface IService<TKey> {
|
||||
/**
|
||||
* 日志组件。若无日志组件则默认为NullLogger对象,不会为null。
|
||||
*/
|
||||
var logger: ILogger
|
||||
|
||||
fun add(command: ICommand): HttpMessage<TKey>
|
||||
|
||||
fun update(key: TKey, command: ICommand)
|
||||
|
||||
fun remove(key: TKey)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.synebula.gaea.domain.service
|
||||
|
||||
import com.synebula.gaea.data.IObjectConverter
|
||||
import com.synebula.gaea.data.message.http.HttpMessage
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
import com.synebula.gaea.domain.repository.IRepository
|
||||
import com.synebula.gaea.log.ILogger
|
||||
|
||||
|
||||
/**
|
||||
* class FlatService
|
||||
*
|
||||
* @author alex
|
||||
* @version 0.1
|
||||
* @since 2018 18-2-8
|
||||
*/
|
||||
open class Service<TAggregateRoot : IAggregateRoot<TKey>, TKey>
|
||||
(override var logger: ILogger,
|
||||
protected var repository: IRepository<TAggregateRoot, TKey>,
|
||||
protected var converter: IObjectConverter,
|
||||
protected var aggregateRootClass: Class<TAggregateRoot>) : IService<TKey> {
|
||||
|
||||
override fun add(command: ICommand): HttpMessage<TKey> {
|
||||
val msg = HttpMessage<TKey>()
|
||||
val root = this.convert(command)
|
||||
repository.add(root)
|
||||
msg.data = root.id
|
||||
return msg
|
||||
}
|
||||
|
||||
override fun update(key: TKey, command: ICommand) {
|
||||
val root = this.convert(command)
|
||||
root.id = key
|
||||
repository.update(root)
|
||||
}
|
||||
|
||||
override fun remove(key: TKey) {
|
||||
repository.remove(key)
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换ICommand类型到聚合根类型,默认实现,根据需要进行覆写。
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
protected fun convert(command: ICommand): TAggregateRoot {
|
||||
try {
|
||||
return converter.convert(command, aggregateRootClass)
|
||||
} catch (ex: Exception) {
|
||||
throw RuntimeException("command not match aggregate root", ex)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
10
src/gaea/build.gradle
Normal file
10
src/gaea/build.gradle
Normal file
@@ -0,0 +1,10 @@
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
group 'com.synebula'
|
||||
artifactId 'gaea.data'
|
||||
version project.version
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ package com.synebula.gaea.data
|
||||
* @version 0.1
|
||||
* @since 2018 18-2-2
|
||||
*/
|
||||
interface IObjectConvertor {
|
||||
interface IObjectConverter {
|
||||
|
||||
/**
|
||||
* 转换源对象到目标对象。
|
||||
@@ -16,6 +16,6 @@ interface IObjectConvertor {
|
||||
* @param dest 目标对象。
|
||||
* @param <T> 目标对象类型。
|
||||
* @return 目标对象
|
||||
</T> */
|
||||
*/
|
||||
fun <T> convert(src: Any, dest: Class<T>): T
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import java.util.Date
|
||||
|
||||
/**
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年9月29日 下午1:38:58
|
||||
*/
|
||||
@@ -3,7 +3,7 @@ package com.synebula.gaea.data.cache
|
||||
/**
|
||||
* 缓存接口。
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年8月15日 下午4:53:19
|
||||
*/
|
||||
@@ -3,7 +3,7 @@ package com.synebula.gaea.data.code
|
||||
/**
|
||||
* 组合编号,根据模板组合生成编号。
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年10月24日 下午2:53:50
|
||||
*/
|
||||
@@ -4,7 +4,7 @@ import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
/**
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年10月24日 下午3:42:47
|
||||
* @param pattern 时间格式化模式。不需要定制可以选择默认构造方法:"yyyyMMdd"。
|
||||
@@ -4,7 +4,7 @@ import java.util.Random
|
||||
|
||||
/**
|
||||
* 固定长度随机编号生成。
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年10月24日 上午10:58:05
|
||||
*/
|
||||
@@ -3,7 +3,7 @@ package com.synebula.gaea.data.code
|
||||
/**
|
||||
* 序列编号,自增的编号。
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年10月24日 下午3:17:36
|
||||
*/
|
||||
@@ -5,7 +5,7 @@ import java.util.UUID
|
||||
/**
|
||||
* 全球唯一编号生成。
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年10月24日 下午2:46:09
|
||||
*/
|
||||
@@ -3,7 +3,7 @@ package com.synebula.gaea.data.code
|
||||
/**
|
||||
* 继承本接口的类,都能实现编号生成工作。
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年10月24日 上午10:41:03
|
||||
*/
|
||||
@@ -3,7 +3,7 @@ package com.synebula.gaea.data.code
|
||||
/**
|
||||
* 默认值编号,返回默认值。
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年10月24日 下午4:07:10
|
||||
*/
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.synebula.gaea.data.message
|
||||
|
||||
import java.util.Date
|
||||
|
||||
open class Message<T> {
|
||||
/**
|
||||
* 传递的业务数据
|
||||
*/
|
||||
var data: T? = null
|
||||
|
||||
/**
|
||||
* 消息时间戳
|
||||
*/
|
||||
val timestamp: Long = Date().time
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.synebula.gaea.data.message.http
|
||||
|
||||
import com.synebula.gaea.data.message.Message
|
||||
|
||||
/**
|
||||
*
|
||||
* 用来统一Http返回消息类型,通常使用json格式传递
|
||||
*
|
||||
* @param status http编码。200成功,400错误,500异常
|
||||
* @tparam T 消息数据类型
|
||||
*/
|
||||
class HttpMessage<T>(var status: Int = HttpStatus.Success.code) : Message<T>() {
|
||||
/**
|
||||
* 附带提示消息
|
||||
*/
|
||||
var message = ""
|
||||
|
||||
constructor(data: T) : this(HttpStatus.Success.code) {
|
||||
this.data = data
|
||||
}
|
||||
|
||||
constructor(status: Int, message: String) : this(status) {
|
||||
this.message = message
|
||||
}
|
||||
|
||||
constructor(status: Int, data: T, message: String) : this(status) {
|
||||
this.data = data
|
||||
this.message = message
|
||||
}
|
||||
|
||||
fun from(other: HttpMessage<T>) {
|
||||
this.status = other.status
|
||||
this.data = other.data
|
||||
this.message = message
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.synebula.gaea.data.message.http
|
||||
|
||||
/**
|
||||
* 状态类型。
|
||||
*
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年9月6日 下午3:27:55
|
||||
*/
|
||||
enum class HttpStatus(val code: Int) {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
Success(200),
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
Failure(400),
|
||||
|
||||
/**
|
||||
* 错误
|
||||
*/
|
||||
Error(500);
|
||||
|
||||
companion object {
|
||||
fun valueOf(code: Int): HttpStatus {
|
||||
return when (code) {
|
||||
200 -> HttpStatus.Success
|
||||
400 -> HttpStatus.Failure
|
||||
else -> HttpStatus.Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.synebula.gaea.data.serializable
|
||||
|
||||
/**
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年9月6日 下午3:44:24
|
||||
*/
|
||||
@@ -3,7 +3,7 @@ package com.synebula.gaea.data.serializable
|
||||
/**
|
||||
* 继承该接口的类都可以序列号对象。
|
||||
*
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年9月6日 下午3:42:01
|
||||
*/
|
||||
@@ -2,7 +2,7 @@ package com.synebula.gaea.data.type
|
||||
|
||||
/**
|
||||
* 数据操作类型。包括创建、更新和删除。
|
||||
* @author reize
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年8月17日 下午2:48:29
|
||||
*/
|
||||
17
src/gaea/src/main/kotlin/com/synebula/gaea/log/ILogger.kt
Normal file
17
src/gaea/src/main/kotlin/com/synebula/gaea/log/ILogger.kt
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.synebula.gaea.log
|
||||
|
||||
import com.synebula.gaea.log.logger.*
|
||||
|
||||
/**
|
||||
* 定义日志记录的统一接口。
|
||||
*
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年8月15日 下午3:35:24
|
||||
*/
|
||||
interface ILogger : ITraceLogger, IDebugLogger, IInfoLogger, IWarnLogger, IErrorLogger {
|
||||
/**
|
||||
* @return 日志对象的Name
|
||||
*/
|
||||
val name: String
|
||||
}
|
||||
28
src/gaea/src/main/kotlin/com/synebula/gaea/log/Level.kt
Normal file
28
src/gaea/src/main/kotlin/com/synebula/gaea/log/Level.kt
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.synebula.gaea.log
|
||||
|
||||
/**
|
||||
* 日志等级
|
||||
* @author Looly
|
||||
*/
|
||||
enum class Level {
|
||||
/**
|
||||
* 'TRACE' log level.
|
||||
*/
|
||||
TRACE,
|
||||
/**
|
||||
* 'DEBUG' log level.
|
||||
*/
|
||||
DEBUG,
|
||||
/**
|
||||
* 'INFO' log level.
|
||||
*/
|
||||
INFO,
|
||||
/**
|
||||
* 'WARN' log level.
|
||||
*/
|
||||
WARN,
|
||||
/**
|
||||
* 'ERROR' log level.
|
||||
*/
|
||||
ERROR
|
||||
}
|
||||
69
src/gaea/src/main/kotlin/com/synebula/gaea/log/NullLogger.kt
Normal file
69
src/gaea/src/main/kotlin/com/synebula/gaea/log/NullLogger.kt
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.synebula.gaea.log
|
||||
|
||||
/**
|
||||
* 默认空日志对象,不会执行任何操作。可以让使用日志的时候可以不会为空(null)。
|
||||
*
|
||||
* @author alex
|
||||
* @version 0.0.1
|
||||
* @since 2016年9月18日 下午1:58:36
|
||||
*/
|
||||
class NullLogger : ILogger {
|
||||
|
||||
override val isTraceEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override val isDebugEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override val isInfoEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override val isWarnEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override val isErrorEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override val name: String
|
||||
get() = NullLogger::class.simpleName!!
|
||||
|
||||
override fun trace(t: Throwable) {}
|
||||
|
||||
override fun trace(format: String, vararg args: Any) {}
|
||||
|
||||
override fun trace(t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun trace(obj: Any, t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun debug(t: Throwable) {}
|
||||
|
||||
override fun debug(format: String, vararg args: Any) {}
|
||||
|
||||
override fun debug(t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun debug(obj: Any, t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun info(t: Throwable) {}
|
||||
|
||||
override fun info(format: String, vararg args: Any) {}
|
||||
|
||||
override fun info(t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun info(obj: Any, t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun warn(t: Throwable) {}
|
||||
|
||||
override fun warn(format: String, vararg args: Any) {}
|
||||
|
||||
override fun warn(t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun warn(obj: Any, t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun error(t: Throwable) {}
|
||||
|
||||
override fun error(format: String, vararg args: Any) {}
|
||||
|
||||
override fun error(t: Throwable, format: String, vararg args: Any) {}
|
||||
|
||||
override fun error(obj: Any, t: Throwable, format: String, vararg args: Any) {}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.synebula.gaea.log.logger
|
||||
|
||||
/**
|
||||
* DEBUG级别日志接口
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
interface IDebugLogger {
|
||||
/**
|
||||
* @return DEBUG 等级是否开启
|
||||
*/
|
||||
val isDebugEnabled: Boolean
|
||||
|
||||
/**
|
||||
* 打印 DEBUG 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
*/
|
||||
fun debug(t: Throwable)
|
||||
|
||||
/**
|
||||
* 打印 DEBUG 等级的日志
|
||||
*
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun debug(format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 DEBUG 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun debug(t: Throwable, format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 DEBUG 等级的日志
|
||||
*
|
||||
* @param obj 输出错误对象
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun debug(obj: Any, t: Throwable, format: String, vararg args: Any)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.synebula.gaea.log.logger
|
||||
|
||||
/**
|
||||
* ERROR级别日志接口
|
||||
* @author Looly
|
||||
*/
|
||||
interface IErrorLogger {
|
||||
/**
|
||||
* @return ERROR 等级是否开启
|
||||
*/
|
||||
val isErrorEnabled: Boolean
|
||||
|
||||
/**
|
||||
* 打印 ERROR 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
*/
|
||||
fun error(t: Throwable)
|
||||
|
||||
/**
|
||||
* 打印 ERROR 等级的日志
|
||||
*
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun error(format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 ERROR 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun error(t: Throwable, format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 ERROR 等级的日志
|
||||
*
|
||||
* @param obj 输出错误对象
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun error(obj: Any, t: Throwable, format: String, vararg args: Any)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.synebula.gaea.log.logger
|
||||
|
||||
/**
|
||||
* INFO级别日志接口
|
||||
* @author Looly
|
||||
*/
|
||||
interface IInfoLogger {
|
||||
/**
|
||||
* @return INFO 等级是否开启
|
||||
*/
|
||||
val isInfoEnabled: Boolean
|
||||
|
||||
/**
|
||||
* 打印 INFO 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
*/
|
||||
fun info(t: Throwable)
|
||||
|
||||
/**
|
||||
* 打印 INFO 等级的日志
|
||||
*
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun info(format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 INFO 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun info(t: Throwable, format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 INFO 等级的日志
|
||||
*
|
||||
* @param obj 输出错误对象
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun info(obj: Any, t: Throwable, format: String, vararg args: Any)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.synebula.gaea.log.logger
|
||||
|
||||
/**
|
||||
* TRACE级别日志接口
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
interface ITraceLogger {
|
||||
/**
|
||||
* @return TRACE 等级是否开启
|
||||
*/
|
||||
val isTraceEnabled: Boolean
|
||||
|
||||
/**
|
||||
* 打印 TRACE 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
*/
|
||||
fun trace(t: Throwable)
|
||||
|
||||
/**
|
||||
* 打印 TRACE 等级的日志
|
||||
*
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun trace(format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 TRACE 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun trace(t: Throwable, format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 TRACE 等级的日志
|
||||
*
|
||||
* @param obj 输出错误对象
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun trace(obj: Any, t: Throwable, format: String, vararg args: Any)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.synebula.gaea.log.logger
|
||||
|
||||
/**
|
||||
* WARN级别日志接口
|
||||
* @author Looly
|
||||
*/
|
||||
interface IWarnLogger {
|
||||
/**
|
||||
* @return WARN 等级是否开启
|
||||
*/
|
||||
val isWarnEnabled: Boolean
|
||||
|
||||
/**
|
||||
* 打印 WARN 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
*/
|
||||
fun warn(t: Throwable)
|
||||
|
||||
/**
|
||||
* 打印 WARN 等级的日志
|
||||
*
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun warn(format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 WARN 等级的日志
|
||||
*
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun warn(t: Throwable, format: String, vararg args: Any)
|
||||
|
||||
/**
|
||||
* 打印 WARN 等级的日志
|
||||
*
|
||||
* @param obj 输出错误对象
|
||||
* @param t 错误对象
|
||||
* @param format 消息模板
|
||||
* @param args 参数
|
||||
*/
|
||||
fun warn(obj: Any, t: Throwable, format: String, vararg args: Any)
|
||||
}
|
||||
Reference in New Issue
Block a user