- refactor.
This commit is contained in:
@@ -11,11 +11,9 @@ import (
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"github.com/satori/go.uuid"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -97,19 +95,7 @@ var (
|
||||
|
||||
type PageResultParser func(map[string]interface{}, int) ([]interface{}, int)
|
||||
|
||||
func getUUID() string {
|
||||
return strings.ToUpper(strings.Replace(uuid.Must(uuid.NewV1()).String(), "-", "", -1))
|
||||
}
|
||||
|
||||
func getJDOperator() string {
|
||||
return time.Now().Format("2006-01-02_15:04:05")
|
||||
}
|
||||
|
||||
func getCurTimeStr() string {
|
||||
return time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func SignParams(jdParams map[string]string) string {
|
||||
func signParams(jdParams map[string]string) string {
|
||||
var keys []string
|
||||
for k := range jdParams {
|
||||
if k != "app_secret" {
|
||||
@@ -166,8 +152,8 @@ func (j JDAPI) AccessJDQuery(apiStr string, jdParams map[string]string) (map[str
|
||||
return nil, ErrJdParam
|
||||
}
|
||||
|
||||
params["timestamp"] = getCurTimeStr()
|
||||
sign := SignParams(params)
|
||||
params["timestamp"] = utils.GetCurTimeStr()
|
||||
sign := signParams(params)
|
||||
params["sign"] = sign
|
||||
|
||||
exceedLimitRetryCount := 0
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -19,7 +20,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestTest(t *testing.T) {
|
||||
sugarLogger.Debug(getCurTimeStr())
|
||||
sugarLogger.Debug(utils.GetCurTimeStr())
|
||||
}
|
||||
|
||||
func TestAccessJDQuery(t *testing.T) {
|
||||
|
||||
@@ -76,7 +76,7 @@ func (j JDAPI) OrderAcceptOperate(orderId string, isAgreed bool) (interface{}, e
|
||||
jdParams := map[string]string{
|
||||
"orderId": orderId,
|
||||
"isAgreed": utils.Bool2String(isAgreed),
|
||||
"operator": getJDOperator(),
|
||||
"operator": utils.GetAPIOperator(),
|
||||
}
|
||||
return j.AccessJDQueryNoPage("ocs/orderAcceptOperate", jdParams, nil, nil)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
func GetConcretValue(value reflect.Value) reflect.Value {
|
||||
@@ -120,3 +124,20 @@ func Int64ToStr(value int64) string {
|
||||
func Int2Str(value int) string {
|
||||
return strconv.Itoa(value)
|
||||
}
|
||||
|
||||
// 去除-号,全部大写,比如:929ADB626EB911E893E452540009DAB3
|
||||
func GetUUID() string {
|
||||
return strings.ToUpper(strings.Replace(uuid.Must(uuid.NewV1()).String(), "-", "", -1))
|
||||
}
|
||||
|
||||
func GetCurTimeStr() string {
|
||||
return time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func GetCurTimestamp() int64 {
|
||||
return time.Now().Unix()
|
||||
}
|
||||
|
||||
func GetAPIOperator() string {
|
||||
return time.Now().Format("2006-01-02_15:04:05")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user