Skip to content

Commit

Permalink
update Operator
Browse files Browse the repository at this point in the history
  • Loading branch information
cherry-yl-sh committed Mar 5, 2024
1 parent 93f39a8 commit 03b4fe9
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 38 deletions.
14 changes: 14 additions & 0 deletions common/model/api_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
32 changes: 18 additions & 14 deletions rpc_server/api/v1/get_support_entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)

}
16 changes: 13 additions & 3 deletions rpc_server/api/v1/get_support_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions rpc_server/api/v1/try_pay_user_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions service/executor/executor.go

This file was deleted.

7 changes: 7 additions & 0 deletions service/operator/get_support_entry_point_execute.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package operator

import "AAStarCommunity/EthPaymaster_BackService/common/model"

func GetSupportEntrypointExecute(request model.GetSupportEntrypointRequest) (model.Result, error) {
return model.Result{}, nil
}
9 changes: 9 additions & 0 deletions service/operator/get_support_strategy_execute.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package operator

import (
"AAStarCommunity/EthPaymaster_BackService/common/model"
)

func GetSupportStrategyExecute(request model.GetSupportStrategyRequest) (model.Result, error) {
return model.Result{}, nil
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package executor
package operator

import (
"AAStarCommunity/EthPaymaster_BackService/common/model"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package executor
package operator

import (
"AAStarCommunity/EthPaymaster_BackService/common/model"
Expand Down

0 comments on commit 03b4fe9

Please sign in to comment.