-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f19704
commit 47d8583
Showing
8 changed files
with
227 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package account_v1 | ||
|
||
import ( | ||
"another_node/internal/web_server/pkg" | ||
"another_node/internal/web_server/pkg/response" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// Sync download accounts | ||
// @Tags Account | ||
// @Description download accounts | ||
// @Accept json | ||
// @Produce json | ||
// @Success 201 | ||
// @Router /api/account/v1/sync [GET] | ||
// @Param count query int true "how many accounts to download" | ||
// @Security JWT | ||
func Sync(ctx *gin.Context) { | ||
if count, err := pkg.GetUIntParamFromQueryOrPath("count", ctx, false); err != nil { | ||
response.BadRequest(ctx, err) | ||
return | ||
} else { | ||
_ = count | ||
//community.SyncAccounts(count) | ||
response.Created(ctx, nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package pkg | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func GetUIntParamFromQueryOrPath(paramKey string, ctx *gin.Context, allowNull bool) (uint, error) { | ||
|
||
keyStr := ctx.Param(paramKey) | ||
if len(keyStr) == 0 { | ||
keyStr = ctx.Query(paramKey) | ||
} | ||
if allowNull { | ||
if len(keyStr) == 0 { | ||
return 0, nil | ||
} | ||
} | ||
key, err := strconv.ParseUint(keyStr, 10, 64) | ||
if err != nil { | ||
return 0, err | ||
} else { | ||
return uint(key), nil | ||
} | ||
} | ||
|
||
func GetBoolParamFromQuery(paramKey string, ctx *gin.Context, defaultValue bool) bool { | ||
|
||
keyStr := ctx.Query(paramKey) | ||
if len(keyStr) == 0 { | ||
return defaultValue | ||
} | ||
|
||
return strings.EqualFold("true", keyStr) | ||
} |