mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 09:44:26 +08:00
code refactor
This commit is contained in:
@@ -3,8 +3,6 @@ package api
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||||
@@ -233,7 +231,7 @@ func (a *ModelContextProtocolAPI) CallToolHandler(c *core.WebContext, jsonRPCReq
|
|||||||
|
|
||||||
// PingHandler return the ping response for model context protocol
|
// PingHandler return the ping response for model context protocol
|
||||||
func (a *ModelContextProtocolAPI) PingHandler(c *core.WebContext, jsonRPCRequest *core.JSONRPCRequest) (any, *errs.Error) {
|
func (a *ModelContextProtocolAPI) PingHandler(c *core.WebContext, jsonRPCRequest *core.JSONRPCRequest) (any, *errs.Error) {
|
||||||
return gin.H{}, nil
|
return core.O{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTransactionService implements the MCPAvailableServices interface
|
// GetTransactionService implements the MCPAvailableServices interface
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
// O is a shortcut for map[string]any
|
||||||
|
type O map[string]any
|
||||||
+3
-4
@@ -5,7 +5,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
|
|
||||||
"github.com/mayswind/ezbookkeeping/pkg/core"
|
"github.com/mayswind/ezbookkeeping/pkg/core"
|
||||||
@@ -14,7 +13,7 @@ import (
|
|||||||
|
|
||||||
// PrintJsonSuccessResult writes success response in json format to current http context
|
// PrintJsonSuccessResult writes success response in json format to current http context
|
||||||
func PrintJsonSuccessResult(c *core.WebContext, result any) {
|
func PrintJsonSuccessResult(c *core.WebContext, result any) {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, core.O{
|
||||||
"success": true,
|
"success": true,
|
||||||
"result": result,
|
"result": result,
|
||||||
})
|
})
|
||||||
@@ -46,7 +45,7 @@ func PrintJsonErrorResult(c *core.WebContext, err *errs.Error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result := gin.H{
|
result := core.O{
|
||||||
"success": false,
|
"success": false,
|
||||||
"errorCode": err.Code(),
|
"errorCode": err.Code(),
|
||||||
"errorMessage": errorMessage,
|
"errorMessage": errorMessage,
|
||||||
@@ -163,7 +162,7 @@ func WriteEventStreamJsonErrorResult(c *core.WebContext, originalErr *errs.Error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result := gin.H{
|
result := core.O{
|
||||||
"success": false,
|
"success": false,
|
||||||
"errorCode": originalErr.Code(),
|
"errorCode": originalErr.Code(),
|
||||||
"errorMessage": errorMessage,
|
"errorMessage": errorMessage,
|
||||||
|
|||||||
Reference in New Issue
Block a user