From aaa3d926c945642c39f44f8f2d8df1aa1eaac84c Mon Sep 17 00:00:00 2001 From: Yun Date: Sun, 12 Oct 2025 20:45:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=85=88=E5=8E=BB=E6=8E=89=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.go | 7 ++++--- platform.go | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/api.go b/api.go index a79c802..25e4d3a 100644 --- a/api.go +++ b/api.go @@ -39,14 +39,15 @@ func (l *apix) GetSign(ctx context.Context, signKey string, params map[string]an if signKey == "" { return "", ErrorSignKeyIsEmpty } - if len(params) == 0 { - return "", ErrorSignParamIsEmpty - } for _, val := range l.ignoreKeys { delete(params, val) } + if len(params) == 0 { + return "", ErrorSignParamIsEmpty + } + // 排序 keys := make([]string, len(params)) i := 0 diff --git a/platform.go b/platform.go index 6becc7b..b6c8ee0 100644 --- a/platform.go +++ b/platform.go @@ -13,14 +13,14 @@ import ( ) type platform struct { - ingoreKeys []string + ignoreKeys []string logger loggerx.LoggerInterface } func NewPlatform(opts ...Option) *platform { options := newOptions(opts...) return &platform{ - ingoreKeys: options.ignoreKeys, + ignoreKeys: options.ignoreKeys, logger: options.logger, } } @@ -30,12 +30,13 @@ func (l *platform) GetSign(ctx context.Context, signKey string, params map[strin if signKey == "" { return "", ErrorSignKeyIsEmpty } - if len(params) == 0 { - return "", ErrorSignParamIsEmpty + + for _, val := range l.ignoreKeys { + delete(params, val) } - for _, val := range l.ingoreKeys { - delete(params, val) + if len(params) == 0 { + return "", ErrorSignParamIsEmpty } // 排序