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