0.9.1 重命名ExceptionMessage注解为MethodName

This commit is contained in:
2021-04-07 11:05:30 +08:00
parent 3ea9b815b8
commit c047f7f5f8
5 changed files with 17 additions and 17 deletions

View File

@@ -21,7 +21,7 @@ allprojects {
subprojects {
ext {
version '0.9.0'
version '0.9.1'
spring_version = "2.3.0.RELEASE"
}

View File

@@ -2,7 +2,7 @@ package com.synebula.gaea.app.cmd
import com.synebula.gaea.app.IApplication
import com.synebula.gaea.app.struct.HttpMessage
import com.synebula.gaea.app.component.aop.annotation.ExceptionMessage
import com.synebula.gaea.app.component.aop.annotation.MethodName
import com.synebula.gaea.data.message.Status
import com.synebula.gaea.data.serialization.json.IJsonSerializer
import com.synebula.gaea.domain.service.ICommand
@@ -23,7 +23,7 @@ interface ICommandApp<TCommand : ICommand, TKey> : IApplication {
@PostMapping
@ExceptionMessage("添加异常")
@MethodName("添加")
fun add(@RequestBody command: TCommand): HttpMessage {
val msg = HttpMessage()
if (this.service != null) {
@@ -36,7 +36,7 @@ interface ICommandApp<TCommand : ICommand, TKey> : IApplication {
}
@PutMapping("/{id:.+}")
@ExceptionMessage("更新异常")
@MethodName("更新")
fun update(@PathVariable id: TKey, @RequestBody command: TCommand): HttpMessage {
val msg = HttpMessage()
if (this.service != null)
@@ -50,7 +50,7 @@ interface ICommandApp<TCommand : ICommand, TKey> : IApplication {
@DeleteMapping("/{id:.+}")
@ExceptionMessage("删除异常")
@MethodName("删除")
fun remove(@PathVariable id: TKey): HttpMessage {
val msg = HttpMessage()
if (this.service != null)

View File

@@ -3,7 +3,7 @@ package com.synebula.gaea.app.component.aop
import com.fasterxml.jackson.databind.ObjectMapper
import com.synebula.gaea.app.IApplication
import com.synebula.gaea.app.struct.HttpMessage
import com.synebula.gaea.app.component.aop.annotation.ExceptionMessage
import com.synebula.gaea.app.component.aop.annotation.MethodName
import com.synebula.gaea.app.component.aop.annotation.Handler
import com.synebula.gaea.app.component.aop.annotation.ModuleName
import com.synebula.gaea.data.message.Status
@@ -55,7 +55,7 @@ abstract class AppAspect {
}!!//获取声明类型中的方法信息
val funcAnnotations = func.annotations ?: arrayOf()
var exceptionMessage = func.name
var funcName = func.name
//遍历方法注解
for (funcAnnotation in funcAnnotations) {
val annotations = funcAnnotation.annotationClass.annotations
@@ -66,8 +66,8 @@ abstract class AppAspect {
val handleClazz = applicationContext.getBean(handler.value.java)
handleClazz.handle(clazz, func, point.args)
}
if (funcAnnotation is ExceptionMessage)
exceptionMessage = funcAnnotation.message
if (funcAnnotation is MethodName)
funcName = funcAnnotation.name
}
return try {
@@ -83,7 +83,7 @@ abstract class AppAspect {
moduleName = name.value
}
}
val message = "$moduleName - $exceptionMessage"
val message = "$moduleName - $funcName 异常"
logger.error(
ex,
"$message。Method args ${paramDiscover.getParameterNames(func)?.contentToString()} values is ${

View File

@@ -3,11 +3,11 @@ package com.synebula.gaea.app.component.aop.annotation
import java.lang.annotation.Inherited
/**
* 标记方法安全执行由AOP负责try catch异常
* 标记方法名称由AOP负责记录异常时使用该名称
*
* @param message 异常消息
* @param name 异常消息
*/
@Inherited
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
annotation class ExceptionMessage(val message: String)
annotation class MethodName(val name: String)

View File

@@ -2,7 +2,7 @@ package com.synebula.gaea.app.query
import com.synebula.gaea.app.IApplication
import com.synebula.gaea.app.struct.HttpMessage
import com.synebula.gaea.app.component.aop.annotation.ExceptionMessage
import com.synebula.gaea.app.component.aop.annotation.MethodName
import com.synebula.gaea.data.message.Status
import com.synebula.gaea.query.IQuery
import com.synebula.gaea.query.Params
@@ -21,24 +21,24 @@ interface IQueryApp<TView, TKey> : IApplication {
*/
var clazz: Class<TView>
@MethodName("获取数据")
@GetMapping("/{id:.+}")
@ExceptionMessage("获取数据失败")
fun get(@PathVariable id: TKey): HttpMessage {
return this.doQuery {
this.query!!.get(id, clazz)
}
}
@MethodName("获取列表数据")
@GetMapping
@ExceptionMessage("获取列表数据失败")
fun list(@RequestParam params: LinkedHashMap<String, Any>): HttpMessage {
return this.doQuery {
this.query!!.list(params, clazz)
}
}
@MethodName("获取分页数据")
@GetMapping("/segments/{size}/pages/{page}")
@ExceptionMessage("获取分页数据失败")
fun paging(
@PathVariable size: Int,
@PathVariable page: Int,