修改mongo查询集合名称由注解提供; 修改command app中throwExec为safeExec

This commit is contained in:
2020-05-26 00:46:16 +08:00
parent 6524ae97b5
commit 0bf9843a1f
3 changed files with 17 additions and 23 deletions

View File

@@ -22,7 +22,7 @@ interface ICommandApp<TCommand : ICommand, TKey> : IApplication {
@PostMapping
fun add(@RequestBody command: TCommand): HttpMessage {
return this.throwExecute("添加${this.name}数据失败 - ${if (jsonSerializer != null) jsonSerializer?.serialize(command) else ""}") {
return this.safeExecute("添加${this.name}数据失败 - ${if (jsonSerializer != null) jsonSerializer?.serialize(command) else ""}") {
if (this.service != null) {
val msg = this.service!!.add(command)
it.load(msg)
@@ -35,7 +35,7 @@ interface ICommandApp<TCommand : ICommand, TKey> : IApplication {
@DeleteMapping("/{key:.+}")
fun remove(@PathVariable key: TKey): HttpMessage {
return this.throwExecute("删除${this.name}失败[Key: $key]") {
return this.safeExecute("删除${this.name}失败[Key: $key]") {
if (this.service != null)
it.data = this.service!!.remove(key)
else {
@@ -47,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}失败 - ${if (jsonSerializer != null) jsonSerializer?.serialize(command) else ""}") {
return this.safeExecute("更新${this.name}失败 - ${if (jsonSerializer != null) jsonSerializer?.serialize(command) else ""}") {
if (this.service != null)
this.service!!.update(key, command)
else {