diff --git a/common/model/api_request.go b/common/model/api_request.go index c23fac63..b7d7966f 100644 --- a/common/model/api_request.go +++ b/common/model/api_request.go @@ -25,3 +25,17 @@ func (sender *TryPayUserOpRequest) Validate() error { return nil } + +type GetSupportEntrypointRequest struct { +} + +func (request *GetSupportEntrypointRequest) Validate() error { + return nil +} + +type GetSupportStrategyRequest struct { +} + +func (request *GetSupportStrategyRequest) Validate() error { + return nil +} diff --git a/rpc_server/api/v1/get_support_entrypoint.go b/rpc_server/api/v1/get_support_entrypoint.go index 7ef0b1ff..40200590 100644 --- a/rpc_server/api/v1/get_support_entrypoint.go +++ b/rpc_server/api/v1/get_support_entrypoint.go @@ -2,8 +2,7 @@ package v1 import ( "AAStarCommunity/EthPaymaster_BackService/common/model" - "AAStarCommunity/EthPaymaster_BackService/rpc_server/api/utils" - "AAStarCommunity/EthPaymaster_BackService/service/executor" + "AAStarCommunity/EthPaymaster_BackService/service/operator" "fmt" "github.com/gin-gonic/gin" "net/http" @@ -18,19 +17,24 @@ import ( // @Success 200 // @Security JWT func GetSupportEntrypoint(c *gin.Context) { + request := model.GetSupportEntrypointRequest{} response := model.GetResponse() - if ok, apiKey := utils.CurrentUser(c); ok { - _ = apiKey + //1. API validate + if err := c.ShouldBindJSON(&request); err != nil { + errStr := fmt.Sprintf("Request Error [%v]", err) + response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr) + } + if err := request.Validate(); err != nil { + errStr := fmt.Sprintf("Request Error [%v]", err) + response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr) + } - //1.TODO API validate - //2. recall service - result, err := executor.GetSupportEntrypointExecute() - if err != nil { - errStr := fmt.Sprintf("%v", err) - response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr) - } - response.WithData(result).Success(c) - } else { - response.SetHttpCode(http.StatusUnauthorized) + //2. recall service + result, err := operator.GetSupportEntrypointExecute(request) + if err != nil { + errStr := fmt.Sprintf("%v", err) + response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr) } + response.WithData(result).Success(c) + } diff --git a/rpc_server/api/v1/get_support_strategy.go b/rpc_server/api/v1/get_support_strategy.go index 07272918..3f0bab8c 100644 --- a/rpc_server/api/v1/get_support_strategy.go +++ b/rpc_server/api/v1/get_support_strategy.go @@ -2,7 +2,7 @@ package v1 import ( "AAStarCommunity/EthPaymaster_BackService/common/model" - "AAStarCommunity/EthPaymaster_BackService/service/executor" + "AAStarCommunity/EthPaymaster_BackService/service/operator" "fmt" "github.com/gin-gonic/gin" "net/http" @@ -17,10 +17,20 @@ import ( // @Router /api/v1/get-support-strategy [GET] // @Security JWT func GetSupportStrategy(c *gin.Context) { - //1.TODO API validate //2. recall service - result, err := executor.GetSupportStrategyExecute() + request := model.GetSupportStrategyRequest{} response := model.GetResponse() + + //1. API validate + if err := c.ShouldBindJSON(&request); err != nil { + errStr := fmt.Sprintf("Request Error [%v]", err) + response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr) + } + if err := request.Validate(); err != nil { + errStr := fmt.Sprintf("Request Error [%v]", err) + response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr) + } + result, err := operator.GetSupportStrategyExecute(request) if err != nil { errStr := fmt.Sprintf("%v", err) response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr) diff --git a/rpc_server/api/v1/try_pay_user_operation.go b/rpc_server/api/v1/try_pay_user_operation.go index c2f9dfd6..ecca7ed3 100644 --- a/rpc_server/api/v1/try_pay_user_operation.go +++ b/rpc_server/api/v1/try_pay_user_operation.go @@ -2,7 +2,7 @@ package v1 import ( "AAStarCommunity/EthPaymaster_BackService/common/model" - "AAStarCommunity/EthPaymaster_BackService/service/executor" + "AAStarCommunity/EthPaymaster_BackService/service/operator" "fmt" "github.com/gin-gonic/gin" "net/http" @@ -18,11 +18,9 @@ import ( // @Success 200 // @Security JWT func TryPayUserOperation(c *gin.Context) { - //1.TODO API validate - //2. recall service request := model.TryPayUserOpRequest{} response := model.GetResponse() - + //1. API validate if err := c.ShouldBindJSON(&request); err != nil { errStr := fmt.Sprintf("Request Error [%v]", err) response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr) @@ -32,9 +30,8 @@ func TryPayUserOperation(c *gin.Context) { errStr := fmt.Sprintf("Request Error [%v]", err) response.SetHttpCode(http.StatusBadRequest).FailCode(c, http.StatusBadRequest, errStr) } - - result, err := executor.TryPayUserOpExecute(request) - //TODO paramValidate + //2. recall service + result, err := operator.TryPayUserOpExecute(request) if err != nil { errStr := fmt.Sprintf("TryPayUserOpExecute ERROR [%v]", err) response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr) diff --git a/service/executor/executor.go b/service/executor/executor.go deleted file mode 100644 index 8cd52808..00000000 --- a/service/executor/executor.go +++ /dev/null @@ -1,12 +0,0 @@ -package executor - -import ( - "AAStarCommunity/EthPaymaster_BackService/common/model" -) - -func GetSupportEntrypointExecute() (model.Result, error) { - return model.Result{}, nil -} -func GetSupportStrategyExecute() (model.Result, error) { - return model.Result{}, nil -} diff --git a/service/operator/get_support_entry_point_execute.go b/service/operator/get_support_entry_point_execute.go new file mode 100644 index 00000000..2a03206e --- /dev/null +++ b/service/operator/get_support_entry_point_execute.go @@ -0,0 +1,7 @@ +package operator + +import "AAStarCommunity/EthPaymaster_BackService/common/model" + +func GetSupportEntrypointExecute(request model.GetSupportEntrypointRequest) (model.Result, error) { + return model.Result{}, nil +} diff --git a/service/operator/get_support_strategy_execute.go b/service/operator/get_support_strategy_execute.go new file mode 100644 index 00000000..ba50edc4 --- /dev/null +++ b/service/operator/get_support_strategy_execute.go @@ -0,0 +1,9 @@ +package operator + +import ( + "AAStarCommunity/EthPaymaster_BackService/common/model" +) + +func GetSupportStrategyExecute(request model.GetSupportStrategyRequest) (model.Result, error) { + return model.Result{}, nil +} diff --git a/service/executor/try_pay_user_op_execute.go b/service/operator/try_pay_user_op_execute.go similarity index 99% rename from service/executor/try_pay_user_op_execute.go rename to service/operator/try_pay_user_op_execute.go index 0b7f5508..30fbfff5 100644 --- a/service/executor/try_pay_user_op_execute.go +++ b/service/operator/try_pay_user_op_execute.go @@ -1,4 +1,4 @@ -package executor +package operator import ( "AAStarCommunity/EthPaymaster_BackService/common/model" diff --git a/service/executor/try_pay_user_op_test.go b/service/operator/try_pay_user_op_test.go similarity index 97% rename from service/executor/try_pay_user_op_test.go rename to service/operator/try_pay_user_op_test.go index 4a41b057..e6d03af2 100644 --- a/service/executor/try_pay_user_op_test.go +++ b/service/operator/try_pay_user_op_test.go @@ -1,4 +1,4 @@ -package executor +package operator import ( "AAStarCommunity/EthPaymaster_BackService/common/model"