From 9ed917593842f4016e4c03e9c4fbe445ce6a2dc3 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 29 Jan 2019 09:36:58 +0800 Subject: [PATCH] - tiny refactor --- business/jxcallback/auth/auth.go | 2 ++ business/jxcallback/auth/weixin/weixin.go | 2 +- business/jxstore/cms/user.go | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/business/jxcallback/auth/auth.go b/business/jxcallback/auth/auth.go index e3cf77038..27a4b6aad 100644 --- a/business/jxcallback/auth/auth.go +++ b/business/jxcallback/auth/auth.go @@ -28,6 +28,8 @@ var ( ErrUserNotExist = errors.New("用户不存在,请联系运营创建") ErrLoginTypeNotSupported = errors.New("不支持指定的登录类型") ErrUIDAndPassNotMatch = errors.New("用户与密码不匹配") + ErrAPINeedRealLogin = errors.New("此API要求真正登录") + ErrIllegalLoginType = errors.New("不支持的登录类型") ) type LoginInfo struct { diff --git a/business/jxcallback/auth/weixin/weixin.go b/business/jxcallback/auth/weixin/weixin.go index d109f9d03..10f6976a6 100644 --- a/business/jxcallback/auth/weixin/weixin.go +++ b/business/jxcallback/auth/weixin/weixin.go @@ -139,7 +139,7 @@ func BindMobile(token, mobileNum, code, nickname string) (err error) { // 绑定手机加登录 func BindMobile2(openid, secret, mobileNum, verifyCode, nickname string) (loginInfo *auth.LoginInfo, err error) { - globals.SugarLogger.Debugf("BindMobileEx openid:%s, secret:%s, mobileNum:%s, verifyCode:%s, nickname:%s", openid, secret, mobileNum, verifyCode, nickname) + globals.SugarLogger.Debugf("BindMobile2 openid:%s, secret:%s, mobileNum:%s, verifyCode:%s, nickname:%s", openid, secret, mobileNum, verifyCode, nickname) err = ErrExceptionalLogin if value := api.Cacher.Get(openid); value != nil { diff --git a/business/jxstore/cms/user.go b/business/jxstore/cms/user.go index 8bfa1498f..ab954ed57 100644 --- a/business/jxstore/cms/user.go +++ b/business/jxstore/cms/user.go @@ -4,6 +4,7 @@ import ( "fmt" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/jxcallback/auth" "git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile" "git.rosy.net.cn/jx-callback/business/jxcallback/auth/weixin" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" @@ -72,12 +73,12 @@ func GetUserInfo(ctx *jxcontext.Context, mobile string) (storeUserInfo *StoreUse func GetSelfInfo(ctx *jxcontext.Context) (storeUserInfo *StoreUserInfo, err error) { loginInfo := ctx.GetLoginInfo() if loginInfo == nil { - return nil, fmt.Errorf("此API要求真正登录") + return nil, auth.ErrAPINeedRealLogin } fieldName := LoginTypeFieldMap[loginInfo.LoginType] if fieldName == "" { - return nil, fmt.Errorf("不支持的登录类型") + return nil, auth.ErrIllegalLoginType } sql := fmt.Sprintf(` SELECT t1.id, IF(t3.id IS NULL, t1.jxstoreid, t3.jxstoreid) jxstoreid, t1.openid, t1.tel, t1.nickname, t1.parentid, t3.tel parent_mobile,