重构名称和注释内容
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.synebula.gaea.app.cmd
|
||||
|
||||
import com.synebula.gaea.app.IApplication
|
||||
import com.synebula.gaea.app.component.aop.annotation.MethodName
|
||||
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
|
||||
@@ -22,20 +22,20 @@ interface ICommandApp<TCommand : ICommand, ID> : IApplication {
|
||||
var service: IService<ID>
|
||||
|
||||
@PostMapping
|
||||
@MethodName("添加")
|
||||
@Method("添加")
|
||||
fun add(@RequestBody command: TCommand): HttpMessage {
|
||||
return HttpMessage(service.add(command))
|
||||
}
|
||||
|
||||
@PutMapping("/{id:.+}")
|
||||
@MethodName("更新")
|
||||
@Method("更新")
|
||||
fun update(@PathVariable id: ID, @RequestBody command: TCommand): HttpMessage {
|
||||
this.service.update(id, command)
|
||||
return HttpMessage()
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id:.+}")
|
||||
@MethodName("删除")
|
||||
@Method("删除")
|
||||
fun remove(@PathVariable id: ID): HttpMessage {
|
||||
val msg = HttpMessage()
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.gaea.app.cmd
|
||||
|
||||
import com.synebula.gaea.app.IApplication
|
||||
import com.synebula.gaea.app.component.aop.annotation.MethodName
|
||||
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
|
||||
@@ -22,20 +22,20 @@ interface ISimpleCommandApp<TRoot : IAggregateRoot<ID>, ID> : IApplication {
|
||||
var service: ISimpleService<TRoot, ID>
|
||||
|
||||
@PostMapping
|
||||
@MethodName("添加")
|
||||
@Method("添加")
|
||||
fun add(@RequestBody entity: TRoot): HttpMessage {
|
||||
return HttpMessage(service.add(entity))
|
||||
}
|
||||
|
||||
@PutMapping("/{id:.+}")
|
||||
@MethodName("更新")
|
||||
@Method("更新")
|
||||
fun update(@PathVariable id: ID, @RequestBody entity: TRoot): HttpMessage {
|
||||
this.service.update(id, entity)
|
||||
return HttpMessage()
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id:.+}")
|
||||
@MethodName("删除")
|
||||
@Method("删除")
|
||||
fun remove(@PathVariable id: ID): HttpMessage {
|
||||
val msg = HttpMessage()
|
||||
try {
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.synebula.gaea.app.component.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.MethodName
|
||||
import com.synebula.gaea.app.component.aop.annotation.ModuleName
|
||||
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.exception.NoticeUserException
|
||||
@@ -54,7 +54,7 @@ abstract class AppAspect {
|
||||
val handleClazz = applicationContext.getBean(handler.value.java)
|
||||
handleClazz.handle(clazz, func, point.args)
|
||||
}
|
||||
if (funcAnnotation is MethodName)
|
||||
if (funcAnnotation is Method)
|
||||
funcName = funcAnnotation.name
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ abstract class AppAspect {
|
||||
if (IApplication::class.java.isAssignableFrom(clazz)) {
|
||||
moduleName = (point.`this` as IApplication).name
|
||||
} else {
|
||||
val name = clazz.annotations.find { it is ModuleName }
|
||||
if (name != null && name is ModuleName) {
|
||||
moduleName = name.value
|
||||
val name = clazz.annotations.find { it is Module }
|
||||
if (name != null && name is Module) {
|
||||
moduleName = name.name
|
||||
}
|
||||
}
|
||||
var message = "$moduleName - $funcName 异常"
|
||||
|
||||
@@ -3,6 +3,11 @@ package com.synebula.gaea.app.component.aop.annotation
|
||||
import com.synebula.gaea.app.component.aop.handler.AnnotationHandler
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* 标注在注解,表明注解的处理方法
|
||||
*
|
||||
* @param value 注解处理方法
|
||||
*/
|
||||
@Target(AnnotationTarget.ANNOTATION_CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Handler(val value: KClass<out AnnotationHandler>)
|
||||
@@ -5,9 +5,9 @@ import java.lang.annotation.Inherited
|
||||
/**
|
||||
* 标记方法名称,由AOP负责记录异常时使用该名称
|
||||
*
|
||||
* @param name 异常消息
|
||||
* @param name 方法名称
|
||||
*/
|
||||
@Inherited
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class MethodName(val name: String)
|
||||
annotation class Method(val name: String)
|
||||
@@ -2,7 +2,8 @@ package com.synebula.gaea.app.component.aop.annotation
|
||||
|
||||
/**
|
||||
* 模块的业务名称
|
||||
* @param name 模块名称
|
||||
*/
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class ModuleName(val value: String)
|
||||
annotation class Module(val name: String)
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.gaea.app.query
|
||||
|
||||
import com.synebula.gaea.app.IApplication
|
||||
import com.synebula.gaea.app.component.aop.annotation.MethodName
|
||||
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
|
||||
@@ -20,7 +20,7 @@ interface IQueryApp<TView, ID> : IApplication {
|
||||
*/
|
||||
var clazz: Class<TView>
|
||||
|
||||
@MethodName("获取数据")
|
||||
@Method("获取数据")
|
||||
@GetMapping("/{id:.+}")
|
||||
fun get(@PathVariable id: ID): HttpMessage {
|
||||
val data = this.query.get(id, clazz)
|
||||
@@ -29,14 +29,14 @@ interface IQueryApp<TView, ID> : IApplication {
|
||||
return msg
|
||||
}
|
||||
|
||||
@MethodName("获取列表数据")
|
||||
@Method("获取列表数据")
|
||||
@GetMapping
|
||||
fun list(@RequestParam params: LinkedHashMap<String, Any>): HttpMessage {
|
||||
val data = this.query.list(params, clazz)
|
||||
return HttpMessage(data)
|
||||
}
|
||||
|
||||
@MethodName("获取分页数据")
|
||||
@Method("获取分页数据")
|
||||
@GetMapping("/segments/{size}/pages/{page}")
|
||||
fun paging(
|
||||
@PathVariable size: Int,
|
||||
|
||||
Reference in New Issue
Block a user