优化APP异常提醒功能

This commit is contained in:
2020-05-18 17:15:31 +08:00
parent 28fd28b0f6
commit ddd4470b85
23 changed files with 112 additions and 45 deletions

View File

@@ -1,7 +1,6 @@
dependencies {
compile project(":src:gaea")
compile("org.springframework.boot:spring-boot-starter-web:$spring_version")
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
compile group: 'net.sf.dozer', name: 'dozer', version: '5.5.1'
}

View File

@@ -1,8 +1,10 @@
package com.synebula.gaea.app
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.log.ILogger
import javax.annotation.Resource
/**
* 指令服务同时实现ICommandApp
@@ -15,4 +17,6 @@ open class CommandApp<TCommand : ICommand, TKey>(
override var name: String,
override var service: IService<TKey>?,
override var logger: ILogger) : ICommandApp<TCommand, TKey> {
@Resource
override var jsonSerializer: IJsonSerializer? = null
}

View File

@@ -2,24 +2,27 @@ package com.synebula.gaea.app
import com.synebula.gaea.app.component.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 org.springframework.web.bind.annotation.*
import javax.annotation.Resource
/**
* 应用类接口提供向Command服务的接口
*
* @author alex
* @version 0.1
* @since 2018 18-2-8
* @since 2020-05-15
*/
interface ICommandApp<TCommand : ICommand, TKey> : IApplication {
var jsonSerializer: IJsonSerializer?
var service: IService<TKey>?
@PostMapping
fun add(@RequestBody command: TCommand): HttpMessage {
return this.throwExecute("${this.name}添加失败") {
return this.throwExecute("添加${this.name}数据失败 - ${if (jsonSerializer != null) jsonSerializer?.serialize(command) else ""}") {
if (this.service != null) {
val msg = this.service!!.add(command)
it.load(msg)
@@ -32,7 +35,7 @@ interface ICommandApp<TCommand : ICommand, TKey> : IApplication {
@DeleteMapping("/{key:.+}")
fun remove(@PathVariable key: TKey): HttpMessage {
return this.throwExecute("${this.name}删除失败") {
return this.throwExecute("删除${this.name}失败[Key: $key]") {
if (this.service != null)
it.data = this.service!!.remove(key)
else {
@@ -44,7 +47,7 @@ interface ICommandApp<TCommand : ICommand, TKey> : IApplication {
@PutMapping("/{key:.+}")
fun update(@PathVariable key: TKey, @RequestBody command: TCommand): HttpMessage {
return this.throwExecute("${this.name}更新失败") {
return this.throwExecute("更新${this.name}失败 - ${if (jsonSerializer != null) jsonSerializer?.serialize(command) else ""}") {
if (this.service != null)
this.service!!.update(key, command)
else {

View File

@@ -10,11 +10,12 @@ import org.springframework.web.bind.annotation.RequestParam
/**
* 应用类接口提供实现Query服务的接口
* 依赖查询接口 @see IQuery
* 依赖查询接 return this.safeExecute("获取${this.name}数据失败") {
口 @see IQuery
*
* @author alex
* @version 0.1
* @since 2018 18-2-8
* @since 2020-05-15
*/
interface IQueryApp<TView, TKey> : IApplication {
/**
@@ -24,7 +25,7 @@ interface IQueryApp<TView, TKey> : IApplication {
@GetMapping("/{key:.+}")
fun get(@PathVariable key: TKey): HttpMessage {
return this.safeExecute("${this.name}获取数据失败") {
return this.safeExecute("获取${this.name}数据失败") {
if (this.query != null)
it.data = this.query!!.get(key)
else {
@@ -36,7 +37,7 @@ interface IQueryApp<TView, TKey> : IApplication {
@GetMapping
fun list(@RequestParam parameters: MutableMap<String, Any>): HttpMessage {
return this.safeExecute("${this.name}获取数据失败") {
return this.safeExecute("获取${this.name}列表数据失败") {
if (this.query != null)
it.data = this.query!!.list(parameters)
else {
@@ -48,7 +49,7 @@ interface IQueryApp<TView, TKey> : IApplication {
@GetMapping("/split/{size}/pages/{page}")
fun paging(@PathVariable page: Int, @PathVariable size: Int, @RequestParam parameters: MutableMap<String, Any>): HttpMessage {
return this.safeExecute("${this.name}获取分页数据失败") {
return this.safeExecute("获取${this.name}分页数据[条数:$size,页码:$page]失败") {
if (this.query != null) {
val params = PagingParam(page, size)
params.parameters = parameters

View File

@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam
*
* @author alex
* @version 0.1
* @since 2018 18-2-8
* @since 2020-05-15
*/
interface IQueryTypedApp<TView, TKey> : IApplication {
/**
@@ -23,11 +23,14 @@ interface IQueryTypedApp<TView, TKey> : IApplication {
*/
var query: IQueryTyped?
/**
* 查询的View类型
*/
var viewClass: Class<TView>
@GetMapping("/{key:.+}")
fun get(@PathVariable key: TKey): HttpMessage {
return this.safeExecute("${this.name}获取数据失败") {
return this.safeExecute("获取${this.name}数据失败") {
if (this.query != null)
it.data = this.query!!.get(key, viewClass)
else {
@@ -39,7 +42,7 @@ interface IQueryTypedApp<TView, TKey> : IApplication {
@GetMapping
fun list(@RequestParam parameters: MutableMap<String, Any>): HttpMessage {
return this.safeExecute("${this.name}获取数据失败") {
return this.safeExecute("获取${this.name}列表数据失败") {
if (this.query != null)
it.data = this.query!!.list<TView, TKey>(parameters, viewClass)
else {
@@ -51,7 +54,7 @@ interface IQueryTypedApp<TView, TKey> : IApplication {
@GetMapping("/split/{size}/pages/{page}")
fun paging(@PathVariable page: Int, @PathVariable size: Int, @RequestParam parameters: MutableMap<String, Any>): HttpMessage {
return this.safeExecute("${this.name}获取分页数据失败") {
return this.safeExecute("获取${this.name}分页数据[条数:$size,页码:$page]失败") {
if (this.query != null) {
val params = PagingParam(page, size)
params.parameters = parameters

View File

@@ -1,9 +1,11 @@
package com.synebula.gaea.app
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.log.ILogger
import com.synebula.gaea.query.IQuery
import javax.annotation.Resource
/**
* 联合服务同时实现了ICommandApp和IQueryApp接口
@@ -19,4 +21,7 @@ open class UnionApp<TCommand : ICommand, TView, TKey>(
override var query: IQuery<TView, TKey>?,
override var logger: ILogger)
: ICommandApp<TCommand, TKey>, IQueryApp<TView, TKey> {
@Resource
override var jsonSerializer: IJsonSerializer? = null
}

View File

@@ -1,10 +1,12 @@
package com.synebula.gaea.app
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.log.ILogger
import com.synebula.gaea.query.IQuery
import com.synebula.gaea.query.IQueryTyped
import javax.annotation.Resource
/**
* 联合服务同时实现了ICommandApp和IQueryApp接口
@@ -21,4 +23,7 @@ open class UnionTypedApp<TCommand : ICommand, TView, TKey>(
override var query: IQueryTyped?,
override var logger: ILogger)
: ICommandApp<TCommand, TKey>, IQueryTypedApp<TView, TKey> {
@Resource
override var jsonSerializer: IJsonSerializer? = null
}

View File

@@ -5,7 +5,7 @@ package com.synebula.gaea.data
*
* @author alex
* @version 0.1
* @since 2018 18-2-2
* @since 2020-05-15
*/
interface IObjectConverter {

View File

@@ -5,7 +5,7 @@ package com.synebula.gaea.data.code
*
* @author alex
* @version 0.1
* @since 2018 18-2-1
* @since 2020-05-15
*
*
* Twitter_Snowflake<br></br>

View File

@@ -1,19 +0,0 @@
package com.synebula.gaea.data.serializable
abstract class AbstractJsonSerializer : IJsonSerializable {
protected lateinit var data: Any
/**
* 序列化data数据。
* 实现的serialize方法必须序列化data对象。
*
* @param data 需要序列号的数据。
* @return 序列化后的json数据。
*/
fun serialize(data: Any): String {
this.data = data
return this.serialize()
}
}

View File

@@ -0,0 +1,17 @@
package com.synebula.gaea.data.serialization
/**
* 序列化器
*/
interface IDeserializer {
/**
* 反序列化
*
* @param <S> 源数据类型
* @param <T> 目标数据类型
* @param src 源数据
* @return 目标数据
*/
fun <S, T> deserialize(src: S): T
}

View File

@@ -1,7 +1,7 @@
package com.synebula.gaea.data.serializable
package com.synebula.gaea.data.serialization
/**
* 继承该接口的类都可以序列对象
* 继承该接口的类都可以序列对象
*
* @author alex
* @version 0.0.1

View File

@@ -0,0 +1,17 @@
package com.synebula.gaea.data.serialization
/**
* 序列化器
*/
interface ISerializer {
/**
* 序列化
*
* @param <S> 源数据类型
* @param <T> 目标数据类型
* @param src 源数据
* @return 目标数据
*/
fun <S, T> serialize(src: S): T
}

View File

@@ -0,0 +1,15 @@
package com.synebula.gaea.data.serialization.json
/**
* 序列化器
*/
interface IJsonDeserializer {
/**
* 反序列化
*
* @param <T> 目标数据类型
* @param src Json字符串数据
* @return 目标数据
*/
fun <T> deserialize(src: String): T
}

View File

@@ -1,4 +1,6 @@
package com.synebula.gaea.data.serializable
package com.synebula.gaea.data.serialization.json
import com.synebula.gaea.data.serialization.ISerializable
/**
*

View File

@@ -0,0 +1,15 @@
package com.synebula.gaea.data.serialization.json
/**
* 序列化器
*/
interface IJsonSerializer {
/**
* 序列化
*
* @param <S> 源数据类型
* @param src 源数据
* @return Json字符串
*/
fun <S> serialize(src: S): String
}

View File

@@ -7,7 +7,7 @@ import java.util.*
*
* @author alex
* @version 0.1
* @since 2018 18-2-8
* @since 2020-05-15
*/
class Command : ICommand {
override var timestamp = 0L

View File

@@ -5,7 +5,7 @@ package com.synebula.gaea.domain.service
*
* @author alex
* @version 0.1
* @since 2018 18-2-8
* @since 2020-05-15
*/
interface ICommand {
/**

View File

@@ -7,7 +7,7 @@ import com.synebula.gaea.data.message.Message
*
* @author alex
* @version 0.1
* @since 2018 18-2-8
* @since 2020-05-15
*/
interface IServiceComplex<TKey, TSecond> {

View File

@@ -16,7 +16,7 @@ import com.synebula.gaea.log.ILogger
* @param logger 日志组件
* @author alex
* @version 0.1
* @since 2018 18-2-8
* @since 2020-05-15
*/
open class Service<TAggregateRoot : IAggregateRoot<TKey>, TKey>(
protected var rootClass: Class<TAggregateRoot>,

View File

@@ -11,7 +11,7 @@ import com.synebula.gaea.log.ILogger
*
* @author alex
* @version 0.1
* @since 2018 18-2-8
* @since 2020-05-15
*/
open class ServiceComplex<TAggregateRoot : IComplexAggregateRoot<TKey, TSecond>, TKey, TSecond>
(var logger: ILogger, protected var repository: IRepositoryComplex<TAggregateRoot, TKey, TSecond>,

View File

@@ -5,7 +5,7 @@ package com.synebula.gaea.query
*
* @author alex
* @version 0.1
* @since 2018 18-2-6
* @since 2020-05-15
*/
enum class OrderType {
/**

View File

@@ -5,7 +5,7 @@ package com.synebula.gaea.query
*
* @author alex
* @version 0.1
* @since 2018 18-2-5
* @since 2020-05-15
*/
data class PagingParam(var page: Int = 1, var size: Int = 10) {