diff --git a/src/gaea.app/build.gradle b/src/gaea.app/build.gradle index 9af631c..e137186 100644 --- a/src/gaea.app/build.gradle +++ b/src/gaea.app/build.gradle @@ -11,7 +11,6 @@ dependencies { api project(":src:gaea.spring") api("org.springframework.boot:spring-boot-starter-web:$spring_version") - api("org.springframework.boot:spring-boot-starter-aop:$spring_version") api("org.springframework.boot:spring-boot-starter-mail:$spring_version") api("org.springframework.boot:spring-boot-starter-security:$spring_version") api group: 'net.sf.dozer', name: 'dozer', version: '5.5.1' diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/cmd/ICommandApp.kt b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/cmd/ICommandApp.kt index 8ac4982..b95d292 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/cmd/ICommandApp.kt +++ b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/cmd/ICommandApp.kt @@ -1,12 +1,12 @@ package com.synebula.gaea.app.cmd import com.synebula.gaea.app.IApplication -import com.synebula.gaea.app.component.aop.annotation.Method import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.data.serialization.json.IJsonSerializer import com.synebula.gaea.domain.service.ICommand import com.synebula.gaea.domain.service.IService +import com.synebula.gaea.spring.aop.annotation.Method import org.springframework.web.bind.annotation.* /** diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/cmd/ISimpleCommandApp.kt b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/cmd/ISimpleCommandApp.kt index 6c7b89c..fa7344c 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/cmd/ISimpleCommandApp.kt +++ b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/cmd/ISimpleCommandApp.kt @@ -1,12 +1,12 @@ package com.synebula.gaea.app.cmd import com.synebula.gaea.app.IApplication -import com.synebula.gaea.app.component.aop.annotation.Method import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.data.serialization.json.IJsonSerializer import com.synebula.gaea.domain.model.IAggregateRoot import com.synebula.gaea.domain.service.ISimpleService +import com.synebula.gaea.spring.aop.annotation.Method import org.springframework.web.bind.annotation.* /** diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/query/IQueryApp.kt b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/query/IQueryApp.kt index e06f38f..7557c9c 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/query/IQueryApp.kt +++ b/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/query/IQueryApp.kt @@ -1,10 +1,10 @@ package com.synebula.gaea.app.query import com.synebula.gaea.app.IApplication -import com.synebula.gaea.app.component.aop.annotation.Method import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.query.IQuery import com.synebula.gaea.query.Params +import com.synebula.gaea.spring.aop.annotation.Method import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.RequestParam diff --git a/src/gaea.mongodb/src/main/kotlin/com/synebula/gaea/mongodb/autoconfig/MongodbRepoProxy.kt b/src/gaea.mongodb/src/main/kotlin/com/synebula/gaea/mongodb/autoconfig/MongodbRepoProxy.kt index b4eb4a8..e1c64a3 100644 --- a/src/gaea.mongodb/src/main/kotlin/com/synebula/gaea/mongodb/autoconfig/MongodbRepoProxy.kt +++ b/src/gaea.mongodb/src/main/kotlin/com/synebula/gaea/mongodb/autoconfig/MongodbRepoProxy.kt @@ -71,7 +71,7 @@ class MongodbRepoProxy( } else if (this.query != null) { this.query!!.javaClass } else - throw InvalidClassException("class ${this.supertype.name} property repo and query are both null") + throw InvalidClassException("class [${this.supertype.name}] proxy object property [repo] and [query] are both null") try { val proxyMethod: Method = proxyClazz.getDeclaredMethod(method.name, *method.parameterTypes) diff --git a/src/gaea.spring/build.gradle b/src/gaea.spring/build.gradle index 95e297c..d283485 100644 --- a/src/gaea.spring/build.gradle +++ b/src/gaea.spring/build.gradle @@ -10,6 +10,8 @@ dependencies { implementation project(":src:gaea") implementation("org.springframework.boot:spring-boot-starter-web:$spring_version") implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' + + api("org.springframework.boot:spring-boot-starter-aop:$spring_version") } publishing { diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/AppAspect.kt b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/AppAspect.kt similarity index 73% rename from src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/AppAspect.kt rename to src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/AppAspect.kt index 1c696d8..ace1148 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/AppAspect.kt +++ b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/AppAspect.kt @@ -1,14 +1,13 @@ -package com.synebula.gaea.app.component.aop +package com.synebula.gaea.spring.aop import com.google.gson.Gson -import com.synebula.gaea.app.IApplication -import com.synebula.gaea.app.component.aop.annotation.Handler -import com.synebula.gaea.app.component.aop.annotation.Method -import com.synebula.gaea.app.component.aop.annotation.Module -import com.synebula.gaea.app.struct.HttpMessage +import com.synebula.gaea.data.message.DataMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.exception.NoticeUserException import com.synebula.gaea.log.ILogger +import com.synebula.gaea.spring.aop.annotation.Handler +import com.synebula.gaea.spring.aop.annotation.Method +import com.synebula.gaea.spring.aop.annotation.Module import org.aspectj.lang.ProceedingJoinPoint import org.aspectj.lang.annotation.Around import org.springframework.beans.factory.annotation.Autowired @@ -16,7 +15,7 @@ import org.springframework.context.ApplicationContext import org.springframework.core.DefaultParameterNameDiscoverer abstract class AppAspect { - private var paramDiscover = DefaultParameterNameDiscoverer() + private var parameterNameDiscoverer = DefaultParameterNameDiscoverer() private val gson = Gson() @@ -63,13 +62,9 @@ abstract class AppAspect { } catch (ex: Throwable) { //找到类的模块名称,否则使用类名 var moduleName = clazz.name - if (IApplication::class.java.isAssignableFrom(clazz)) { - moduleName = (point.`this` as IApplication).name - } else { - val name = clazz.annotations.find { it is Module } - if (name != null && name is Module) { - moduleName = name.name - } + val module = clazz.annotations.find { it is Module } + if (module != null && module is Module) { + moduleName = module.name } var message = "$moduleName - $funcName 异常" message = if (ex is NoticeUserException) { @@ -80,12 +75,12 @@ abstract class AppAspect { logger.error( ex, "$message。Method args ${ - paramDiscover.getParameterNames(func)?.contentToString() + parameterNameDiscoverer.getParameterNames(func)?.contentToString() } values is ${ gson.toJson(point.args) }" ) - return HttpMessage(Status.Error, message) + return gson.toJson(DataMessage(Status.Error, message)) } } } \ No newline at end of file diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/AccessLog.kt b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/AccessLog.kt similarity index 52% rename from src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/AccessLog.kt rename to src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/AccessLog.kt index 28015c6..8f87125 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/AccessLog.kt +++ b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/AccessLog.kt @@ -1,6 +1,6 @@ -package com.synebula.gaea.app.component.aop.annotation +package com.synebula.gaea.spring.aop.annotation -import com.synebula.gaea.app.component.aop.handler.AccessLogHandler +import com.synebula.gaea.spring.aop.handler.AccessLogHandler @Target(AnnotationTarget.FUNCTION) @Handler(AccessLogHandler::class) diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Handler.kt b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Handler.kt similarity index 68% rename from src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Handler.kt rename to src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Handler.kt index ff159f9..ea92224 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Handler.kt +++ b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Handler.kt @@ -1,6 +1,6 @@ -package com.synebula.gaea.app.component.aop.annotation +package com.synebula.gaea.spring.aop.annotation -import com.synebula.gaea.app.component.aop.handler.AnnotationHandler +import com.synebula.gaea.spring.aop.handler.AnnotationHandler import kotlin.reflect.KClass /** diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Method.kt b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Method.kt similarity index 83% rename from src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Method.kt rename to src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Method.kt index 3c198a3..aa3cb55 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Method.kt +++ b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Method.kt @@ -1,4 +1,4 @@ -package com.synebula.gaea.app.component.aop.annotation +package com.synebula.gaea.spring.aop.annotation import java.lang.annotation.Inherited diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Module.kt b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Module.kt similarity index 76% rename from src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Module.kt rename to src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Module.kt index 03ec88b..7202fbd 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/annotation/Module.kt +++ b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/annotation/Module.kt @@ -1,4 +1,4 @@ -package com.synebula.gaea.app.component.aop.annotation +package com.synebula.gaea.spring.aop.annotation /** * 模块的业务名称 diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/handler/AccessLogHandler.kt b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/handler/AccessLogHandler.kt similarity index 95% rename from src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/handler/AccessLogHandler.kt rename to src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/handler/AccessLogHandler.kt index 1898eb3..c2f70da 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/handler/AccessLogHandler.kt +++ b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/handler/AccessLogHandler.kt @@ -1,4 +1,4 @@ -package com.synebula.gaea.app.component.aop.handler +package com.synebula.gaea.spring.aop.handler import com.fasterxml.jackson.databind.ObjectMapper import com.synebula.gaea.log.ILogger diff --git a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/handler/AnnotationHandler.kt b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/handler/AnnotationHandler.kt similarity index 75% rename from src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/handler/AnnotationHandler.kt rename to src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/handler/AnnotationHandler.kt index fbd2a37..5f98788 100644 --- a/src/gaea.app/src/main/kotlin/com/synebula/gaea/app/component/aop/handler/AnnotationHandler.kt +++ b/src/gaea.spring/src/main/kotlin/com/synebula/gaea/spring/aop/handler/AnnotationHandler.kt @@ -1,4 +1,4 @@ -package com.synebula.gaea.app.component.aop.handler +package com.synebula.gaea.spring.aop.handler import java.lang.reflect.Method