From 27da0e4c57b97ba50ff5212be256e279753bf4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 5 Jan 2024 16:24:27 +0800 Subject: [PATCH] 1 --- controllers/api_controller_ex.go | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 controllers/api_controller_ex.go diff --git a/controllers/api_controller_ex.go b/controllers/api_controller_ex.go new file mode 100644 index 000000000..692a1e7bc --- /dev/null +++ b/controllers/api_controller_ex.go @@ -0,0 +1,45 @@ +package controllers + +import ( + "fmt" + "git.rosy.net.cn/jx-callback/business/model" +) + +type CallResult2 struct { + Code string `json:"code"` + Desc string `json:"desc"` + Data interface{} `json:"data"` +} + +func buildParamRequiredErr(str []string) (err error) { + msg := "缺少参数[" + for k, v := range str { + if k != 0 { + msg += "," + v + } else { + msg += v + } + } + msg += "],请传入正确的值!" + return fmt.Errorf(msg) +} + +func buildParamErrCodeAndErr(str string) (data, errCode string, err error) { + return data, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", str) +} + +func buildParamErr(str string) (err error) { + return fmt.Errorf("参数[%s]错误,请传入正确的值!", str) +} + +func buildMethodParamSign() (err error) { + return fmt.Errorf("参数['sign']校验失败,请传入正确的值!") +} + +func buildMethodParamErr() (err error) { + return fmt.Errorf("参数['method']错误,请传入正确的值!") +} + +func buildTimestampParamErr() (err error) { + return fmt.Errorf("参数['timestamp']和服务器时间差距过大,请传入正确的值!") +}