优化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
}