1.1.1 move aop to package gaea.spring
This commit is contained in:
@@ -11,7 +11,6 @@ dependencies {
|
|||||||
api project(":src:gaea.spring")
|
api project(":src:gaea.spring")
|
||||||
|
|
||||||
api("org.springframework.boot:spring-boot-starter-web:$spring_version")
|
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-mail:$spring_version")
|
||||||
api("org.springframework.boot:spring-boot-starter-security:$spring_version")
|
api("org.springframework.boot:spring-boot-starter-security:$spring_version")
|
||||||
api group: 'net.sf.dozer', name: 'dozer', version: '5.5.1'
|
api group: 'net.sf.dozer', name: 'dozer', version: '5.5.1'
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.synebula.gaea.app.cmd
|
package com.synebula.gaea.app.cmd
|
||||||
|
|
||||||
import com.synebula.gaea.app.IApplication
|
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.app.struct.HttpMessage
|
||||||
import com.synebula.gaea.data.message.Status
|
import com.synebula.gaea.data.message.Status
|
||||||
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
||||||
import com.synebula.gaea.domain.service.ICommand
|
import com.synebula.gaea.domain.service.ICommand
|
||||||
import com.synebula.gaea.domain.service.IService
|
import com.synebula.gaea.domain.service.IService
|
||||||
|
import com.synebula.gaea.spring.aop.annotation.Method
|
||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.synebula.gaea.app.cmd
|
package com.synebula.gaea.app.cmd
|
||||||
|
|
||||||
import com.synebula.gaea.app.IApplication
|
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.app.struct.HttpMessage
|
||||||
import com.synebula.gaea.data.message.Status
|
import com.synebula.gaea.data.message.Status
|
||||||
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
||||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||||
import com.synebula.gaea.domain.service.ISimpleService
|
import com.synebula.gaea.domain.service.ISimpleService
|
||||||
|
import com.synebula.gaea.spring.aop.annotation.Method
|
||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.synebula.gaea.app.query
|
package com.synebula.gaea.app.query
|
||||||
|
|
||||||
import com.synebula.gaea.app.IApplication
|
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.app.struct.HttpMessage
|
||||||
import com.synebula.gaea.query.IQuery
|
import com.synebula.gaea.query.IQuery
|
||||||
import com.synebula.gaea.query.Params
|
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.GetMapping
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
import org.springframework.web.bind.annotation.RequestParam
|
import org.springframework.web.bind.annotation.RequestParam
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class MongodbRepoProxy(
|
|||||||
} else if (this.query != null) {
|
} else if (this.query != null) {
|
||||||
this.query!!.javaClass
|
this.query!!.javaClass
|
||||||
} else
|
} 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 {
|
try {
|
||||||
val proxyMethod: Method = proxyClazz.getDeclaredMethod(method.name, *method.parameterTypes)
|
val proxyMethod: Method = proxyClazz.getDeclaredMethod(method.name, *method.parameterTypes)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ dependencies {
|
|||||||
implementation project(":src:gaea")
|
implementation project(":src:gaea")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-web:$spring_version")
|
implementation("org.springframework.boot:spring-boot-starter-web:$spring_version")
|
||||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
|
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
|
||||||
|
|
||||||
|
api("org.springframework.boot:spring-boot-starter-aop:$spring_version")
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package com.synebula.gaea.app.component.aop
|
package com.synebula.gaea.spring.aop
|
||||||
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.synebula.gaea.app.IApplication
|
import com.synebula.gaea.data.message.DataMessage
|
||||||
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.Status
|
import com.synebula.gaea.data.message.Status
|
||||||
import com.synebula.gaea.exception.NoticeUserException
|
import com.synebula.gaea.exception.NoticeUserException
|
||||||
import com.synebula.gaea.log.ILogger
|
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.ProceedingJoinPoint
|
||||||
import org.aspectj.lang.annotation.Around
|
import org.aspectj.lang.annotation.Around
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
@@ -16,7 +15,7 @@ import org.springframework.context.ApplicationContext
|
|||||||
import org.springframework.core.DefaultParameterNameDiscoverer
|
import org.springframework.core.DefaultParameterNameDiscoverer
|
||||||
|
|
||||||
abstract class AppAspect {
|
abstract class AppAspect {
|
||||||
private var paramDiscover = DefaultParameterNameDiscoverer()
|
private var parameterNameDiscoverer = DefaultParameterNameDiscoverer()
|
||||||
|
|
||||||
private val gson = Gson()
|
private val gson = Gson()
|
||||||
|
|
||||||
@@ -63,13 +62,9 @@ abstract class AppAspect {
|
|||||||
} catch (ex: Throwable) {
|
} catch (ex: Throwable) {
|
||||||
//找到类的模块名称,否则使用类名
|
//找到类的模块名称,否则使用类名
|
||||||
var moduleName = clazz.name
|
var moduleName = clazz.name
|
||||||
if (IApplication::class.java.isAssignableFrom(clazz)) {
|
val module = clazz.annotations.find { it is Module }
|
||||||
moduleName = (point.`this` as IApplication).name
|
if (module != null && module is Module) {
|
||||||
} else {
|
moduleName = module.name
|
||||||
val name = clazz.annotations.find { it is Module }
|
|
||||||
if (name != null && name is Module) {
|
|
||||||
moduleName = name.name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var message = "$moduleName - $funcName 异常"
|
var message = "$moduleName - $funcName 异常"
|
||||||
message = if (ex is NoticeUserException) {
|
message = if (ex is NoticeUserException) {
|
||||||
@@ -80,12 +75,12 @@ abstract class AppAspect {
|
|||||||
logger.error(
|
logger.error(
|
||||||
ex,
|
ex,
|
||||||
"$message。Method args ${
|
"$message。Method args ${
|
||||||
paramDiscover.getParameterNames(func)?.contentToString()
|
parameterNameDiscoverer.getParameterNames(func)?.contentToString()
|
||||||
} values is ${
|
} values is ${
|
||||||
gson.toJson(point.args)
|
gson.toJson(point.args)
|
||||||
}"
|
}"
|
||||||
)
|
)
|
||||||
return HttpMessage(Status.Error, message)
|
return gson.toJson(DataMessage<Any>(Status.Error, message))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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)
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
@Handler(AccessLogHandler::class)
|
@Handler(AccessLogHandler::class)
|
||||||
@@ -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
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.synebula.gaea.app.component.aop.annotation
|
package com.synebula.gaea.spring.aop.annotation
|
||||||
|
|
||||||
import java.lang.annotation.Inherited
|
import java.lang.annotation.Inherited
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.synebula.gaea.app.component.aop.annotation
|
package com.synebula.gaea.spring.aop.annotation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模块的业务名称
|
* 模块的业务名称
|
||||||
@@ -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.fasterxml.jackson.databind.ObjectMapper
|
||||||
import com.synebula.gaea.log.ILogger
|
import com.synebula.gaea.log.ILogger
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.synebula.gaea.app.component.aop.handler
|
package com.synebula.gaea.spring.aop.handler
|
||||||
|
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
Reference in New Issue
Block a user