- 注释掉老user与auth相关的代码
This commit is contained in:
@@ -1,121 +1,110 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
// const (
|
||||||
"errors"
|
// DefTokenDuration = 7 * 24 * time.Hour // 7天
|
||||||
"time"
|
// )
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
// type IAuther interface {
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
// Login(id, secret string) (userID, loginType string, err error)
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
// Logout(loginInfo *LoginInfo) error
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
// }
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
// var (
|
||||||
DefTokenDuration = 7 * 24 * time.Hour // 7天
|
// authers map[string]IAuther
|
||||||
)
|
// )
|
||||||
|
|
||||||
type IAuther interface {
|
// var (
|
||||||
Login(id, secret string) (userID, loginType string, err error)
|
// ErrUserNotExist = errors.New("用户不存在,请联系运营创建")
|
||||||
Logout(loginInfo *LoginInfo) error
|
// ErrLoginTypeNotSupported = errors.New("不支持指定的登录类型")
|
||||||
}
|
// ErrUIDAndPassNotMatch = errors.New("用户与密码不匹配")
|
||||||
|
// ErrAPINeedRealLogin = errors.New("此API要求真正登录")
|
||||||
|
// ErrIllegalLoginType = errors.New("不支持的登录类型")
|
||||||
|
// )
|
||||||
|
|
||||||
var (
|
// type LoginInfo struct {
|
||||||
authers map[string]IAuther
|
// ID string
|
||||||
)
|
// LoginType string
|
||||||
|
// ExpiresIn int64
|
||||||
|
// Token string
|
||||||
|
// }
|
||||||
|
|
||||||
var (
|
// func init() {
|
||||||
ErrUserNotExist = errors.New("用户不存在,请联系运营创建")
|
// authers = make(map[string]IAuther)
|
||||||
ErrLoginTypeNotSupported = errors.New("不支持指定的登录类型")
|
// }
|
||||||
ErrUIDAndPassNotMatch = errors.New("用户与密码不匹配")
|
|
||||||
ErrAPINeedRealLogin = errors.New("此API要求真正登录")
|
|
||||||
ErrIllegalLoginType = errors.New("不支持的登录类型")
|
|
||||||
)
|
|
||||||
|
|
||||||
type LoginInfo struct {
|
// func RegisterAuther(loginType string, handler IAuther) {
|
||||||
ID string
|
// authers[loginType] = handler
|
||||||
LoginType string
|
// }
|
||||||
ExpiresIn int64
|
|
||||||
Token string
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
// func CreateLoginInfo(id, loginType string) (loginInfo *LoginInfo) {
|
||||||
authers = make(map[string]IAuther)
|
// token := utils.GetUUID()
|
||||||
}
|
// loginInfo = &LoginInfo{
|
||||||
|
// ID: id,
|
||||||
|
// LoginType: loginType,
|
||||||
|
// ExpiresIn: time.Now().Add(DefTokenDuration).Unix(),
|
||||||
|
// Token: token,
|
||||||
|
// }
|
||||||
|
// globals.SugarLogger.Debugf("CreateLoginInfo id:%s, loginType:%s, loginInfo:%s", id, loginType, utils.Format4Output(loginInfo, true))
|
||||||
|
// api.Cacher.Set(token, loginInfo, DefTokenDuration)
|
||||||
|
// return loginInfo
|
||||||
|
// }
|
||||||
|
|
||||||
func RegisterAuther(loginType string, handler IAuther) {
|
// func Login(id, loginType, secret string) (loginInfo *LoginInfo, err error) {
|
||||||
authers[loginType] = handler
|
// globals.SugarLogger.Debugf("Login id:%s, loginType:%s, secret:%s", id, loginType, secret)
|
||||||
}
|
// if handler := authers[loginType]; handler != nil {
|
||||||
|
// userID, loginType2, err2 := handler.Login(id, secret)
|
||||||
|
// if err = err2; err == nil {
|
||||||
|
// if userID != "" {
|
||||||
|
// globals.SugarLogger.Debugf("Login id:%s, loginType:%s, id changed to:%s", id, loginType, userID)
|
||||||
|
// id = userID
|
||||||
|
// }
|
||||||
|
// if loginType2 != "" {
|
||||||
|
// loginType = loginType2
|
||||||
|
// }
|
||||||
|
// return CreateLoginInfo(id, loginType), nil
|
||||||
|
// }
|
||||||
|
// err = ConvertErr2NoUser(err, "")
|
||||||
|
// } else {
|
||||||
|
// err = ErrLoginTypeNotSupported
|
||||||
|
// }
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
|
||||||
func CreateLoginInfo(id, loginType string) (loginInfo *LoginInfo) {
|
// func Logout(token string) (err error) {
|
||||||
token := utils.GetUUID()
|
// globals.SugarLogger.Debugf("Logout token:%s", token)
|
||||||
loginInfo = &LoginInfo{
|
// loginInfo := new(LoginInfo)
|
||||||
ID: id,
|
// if err = api.Cacher.GetAs(token, loginInfo); err == nil {
|
||||||
LoginType: loginType,
|
// if handler := authers[loginInfo.LoginType]; handler != nil {
|
||||||
ExpiresIn: time.Now().Add(DefTokenDuration).Unix(),
|
// err = handler.Logout(loginInfo)
|
||||||
Token: token,
|
// }
|
||||||
}
|
// api.Cacher.Del(token)
|
||||||
globals.SugarLogger.Debugf("CreateLoginInfo id:%s, loginType:%s, loginInfo:%s", id, loginType, utils.Format4Output(loginInfo, true))
|
// }
|
||||||
api.Cacher.Set(token, loginInfo, DefTokenDuration)
|
// return err
|
||||||
return loginInfo
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
func Login(id, loginType, secret string) (loginInfo *LoginInfo, err error) {
|
// func GetUserInfo(token string) (loginInfo *LoginInfo, err error) {
|
||||||
globals.SugarLogger.Debugf("Login id:%s, loginType:%s, secret:%s", id, loginType, secret)
|
// loginInfo = new(LoginInfo)
|
||||||
if handler := authers[loginType]; handler != nil {
|
// if err = api.Cacher.GetAs(token, loginInfo); err == nil {
|
||||||
userID, loginType2, err2 := handler.Login(id, secret)
|
// return loginInfo, nil
|
||||||
if err = err2; err == nil {
|
// }
|
||||||
if userID != "" {
|
// return nil, model.ErrTokenIsInvalid
|
||||||
globals.SugarLogger.Debugf("Login id:%s, loginType:%s, id changed to:%s", id, loginType, userID)
|
// }
|
||||||
id = userID
|
|
||||||
}
|
|
||||||
if loginType2 != "" {
|
|
||||||
loginType = loginType2
|
|
||||||
}
|
|
||||||
return CreateLoginInfo(id, loginType), nil
|
|
||||||
}
|
|
||||||
err = ConvertErr2NoUser(err, "")
|
|
||||||
} else {
|
|
||||||
err = ErrLoginTypeNotSupported
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func Logout(token string) (err error) {
|
// func ConvertErr2NoUser(err error, mobileNum string) error {
|
||||||
globals.SugarLogger.Debugf("Logout token:%s", token)
|
// if dao.IsNoRowsError(err) {
|
||||||
loginInfo := new(LoginInfo)
|
// err = ErrUserNotExist
|
||||||
if err = api.Cacher.GetAs(token, loginInfo); err == nil {
|
// }
|
||||||
if handler := authers[loginInfo.LoginType]; handler != nil {
|
// return err
|
||||||
err = handler.Logout(loginInfo)
|
// }
|
||||||
}
|
|
||||||
api.Cacher.Del(token)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUserInfo(token string) (loginInfo *LoginInfo, err error) {
|
// func (a *LoginInfo) GetAuthID() string {
|
||||||
loginInfo = new(LoginInfo)
|
// return a.ID
|
||||||
if err = api.Cacher.GetAs(token, loginInfo); err == nil {
|
// }
|
||||||
return loginInfo, nil
|
|
||||||
}
|
|
||||||
return nil, model.ErrTokenIsInvalid
|
|
||||||
}
|
|
||||||
|
|
||||||
func ConvertErr2NoUser(err error, mobileNum string) error {
|
// func (a *LoginInfo) GetAuthType() string {
|
||||||
if dao.IsNoRowsError(err) {
|
// return a.LoginType
|
||||||
err = ErrUserNotExist
|
// }
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *LoginInfo) GetAuthID() string {
|
// func (a *LoginInfo) GetUserTag() string {
|
||||||
return a.ID
|
// return a.ID
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (a *LoginInfo) GetAuthType() string {
|
|
||||||
return a.LoginType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *LoginInfo) GetUserTag() string {
|
|
||||||
return a.ID
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,104 +1,90 @@
|
|||||||
package mobile
|
package mobile
|
||||||
|
|
||||||
import (
|
// const (
|
||||||
"errors"
|
// DefVerifyCodeDuration = 5 * time.Minute
|
||||||
"fmt"
|
// TestMobile = "91112345678"
|
||||||
"math/rand"
|
// TestVerifyCode = "123456"
|
||||||
"time"
|
// )
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
// var (
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
// warningMap = map[string]int{
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
// "isv.AMOUNT_NOT_ENOUGH": 1,
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
// "isv.ACCOUNT_ABNORMAL": 1,
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
// "isv.OUT_OF_SERVICE": 1,
|
||||||
aliyunsmsclient "github.com/KenmyZhang/aliyun-communicate"
|
// "isv.DAY_LIMIT_CONTROL": 1,
|
||||||
)
|
// }
|
||||||
|
// )
|
||||||
|
|
||||||
const (
|
// const (
|
||||||
DefVerifyCodeDuration = 5 * time.Minute
|
// LoginType = "mobile"
|
||||||
TestMobile = "91112345678"
|
// )
|
||||||
TestVerifyCode = "123456"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
warningMap = map[string]int{
|
// ErrVerifyCodeIsWrong = errors.New("验证码错")
|
||||||
"isv.AMOUNT_NOT_ENOUGH": 1,
|
// )
|
||||||
"isv.ACCOUNT_ABNORMAL": 1,
|
|
||||||
"isv.OUT_OF_SERVICE": 1,
|
|
||||||
"isv.DAY_LIMIT_CONTROL": 1,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
// type Auther struct {
|
||||||
LoginType = "mobile"
|
// }
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
ErrVerifyCodeIsWrong = errors.New("验证码错")
|
// auther *Auther
|
||||||
)
|
// )
|
||||||
|
|
||||||
type Auther struct {
|
// func init() {
|
||||||
}
|
// auther = new(Auther)
|
||||||
|
// auth.RegisterAuther(LoginType, auther)
|
||||||
|
// }
|
||||||
|
|
||||||
var (
|
// func SendVerifyCode(mobileNumber string) error {
|
||||||
auther *Auther
|
// code := fmt.Sprintf("%06d", rand.Intn(1000000))
|
||||||
)
|
// globals.SugarLogger.Debugf("SendVerifyCode mobileNumber:%s, code:%s", mobileNumber, code)
|
||||||
|
|
||||||
func init() {
|
// smsClient := aliyunsmsclient.New("http://dysmsapi.aliyuncs.com/")
|
||||||
auther = new(Auther)
|
// response, err := smsClient.Execute(globals.AliKey, globals.AliSecret, mobileNumber, "京西菜市", "SMS_84655036", string(utils.MustMarshal(map[string]interface{}{
|
||||||
auth.RegisterAuther(LoginType, auther)
|
// "code": code,
|
||||||
}
|
// })))
|
||||||
|
// api.Cacher.Set(mobileNumber, code, DefVerifyCodeDuration)
|
||||||
|
// if err == nil && response.Code == aliyunsmsclient.ResponseCodeOk {
|
||||||
|
// } else {
|
||||||
|
// if err == nil {
|
||||||
|
// if warningMap[response.Code] == 1 {
|
||||||
|
// globals.SugarLogger.Warnf("SendVerifyCode mobileNumber:%s failed with response:%s", mobileNumber, utils.Format4Output(response, false))
|
||||||
|
// } else {
|
||||||
|
// globals.SugarLogger.Infof("SendVerifyCode mobileNumber:%s failed with response:%s", mobileNumber, utils.Format4Output(response, false))
|
||||||
|
// }
|
||||||
|
// err = fmt.Errorf("发送短信出错:%s", response.Message)
|
||||||
|
// } else {
|
||||||
|
// globals.SugarLogger.Warnf("SendVerifyCode mobileNumber:%s failed with error:%v", mobileNumber, err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
func SendVerifyCode(mobileNumber string) error {
|
// func VerifyCode(mobileNumber, code string) (err error) {
|
||||||
code := fmt.Sprintf("%06d", rand.Intn(1000000))
|
// globals.SugarLogger.Debugf("VerifyCode mobileNumber:%s, code:%s", mobileNumber, code)
|
||||||
globals.SugarLogger.Debugf("SendVerifyCode mobileNumber:%s, code:%s", mobileNumber, code)
|
|
||||||
|
|
||||||
smsClient := aliyunsmsclient.New("http://dysmsapi.aliyuncs.com/")
|
// err = ErrVerifyCodeIsWrong
|
||||||
response, err := smsClient.Execute(globals.AliKey, globals.AliSecret, mobileNumber, "京西菜市", "SMS_84655036", string(utils.MustMarshal(map[string]interface{}{
|
// if mobileNumber == TestMobile && code == TestVerifyCode {
|
||||||
"code": code,
|
// err = nil
|
||||||
})))
|
// } else {
|
||||||
api.Cacher.Set(mobileNumber, code, DefVerifyCodeDuration)
|
// if value := api.Cacher.Get(mobileNumber); value != nil {
|
||||||
if err == nil && response.Code == aliyunsmsclient.ResponseCodeOk {
|
// if code == value.(string) {
|
||||||
} else {
|
// api.Cacher.Del(mobileNumber)
|
||||||
if err == nil {
|
// err = nil
|
||||||
if warningMap[response.Code] == 1 {
|
// }
|
||||||
globals.SugarLogger.Warnf("SendVerifyCode mobileNumber:%s failed with response:%s", mobileNumber, utils.Format4Output(response, false))
|
// }
|
||||||
} else {
|
// }
|
||||||
globals.SugarLogger.Infof("SendVerifyCode mobileNumber:%s failed with response:%s", mobileNumber, utils.Format4Output(response, false))
|
// return err
|
||||||
}
|
// }
|
||||||
err = fmt.Errorf("发送短信出错:%s", response.Message)
|
|
||||||
} else {
|
|
||||||
globals.SugarLogger.Warnf("SendVerifyCode mobileNumber:%s failed with error:%v", mobileNumber, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func VerifyCode(mobileNumber, code string) (err error) {
|
// func (a *Auther) Login(mobileNum, verifyCode string) (userID, LoginType string, err error) {
|
||||||
globals.SugarLogger.Debugf("VerifyCode mobileNumber:%s, code:%s", mobileNumber, code)
|
// if err = VerifyCode(mobileNum, verifyCode); err == nil {
|
||||||
|
// _, err = dao.GetWeiXinUserByIDs(dao.GetDB(), mobileNum, "", "", "")
|
||||||
|
// err = auth.ConvertErr2NoUser(err, mobileNum)
|
||||||
|
// }
|
||||||
|
// return "", "", err
|
||||||
|
// }
|
||||||
|
|
||||||
err = ErrVerifyCodeIsWrong
|
// func (a *Auther) Logout(loginInfo *auth.LoginInfo) error {
|
||||||
if mobileNumber == TestMobile && code == TestVerifyCode {
|
// return nil
|
||||||
err = nil
|
// }
|
||||||
} else {
|
|
||||||
if value := api.Cacher.Get(mobileNumber); value != nil {
|
|
||||||
if code == value.(string) {
|
|
||||||
api.Cacher.Del(mobileNumber)
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Auther) Login(mobileNum, verifyCode string) (userID, LoginType string, err error) {
|
|
||||||
if err = VerifyCode(mobileNum, verifyCode); err == nil {
|
|
||||||
_, err = dao.GetWeiXinUserByIDs(dao.GetDB(), mobileNum, "", "", "")
|
|
||||||
err = auth.ConvertErr2NoUser(err, mobileNum)
|
|
||||||
}
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Auther) Logout(loginInfo *auth.LoginInfo) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package mobile
|
package mobile
|
||||||
|
|
||||||
import (
|
// func TestSendVerifyCode(t *testing.T) {
|
||||||
"testing"
|
// err := SendVerifyCode("18180948107")
|
||||||
)
|
// if err != nil {
|
||||||
|
// t.Fatal(err)
|
||||||
func TestSendVerifyCode(t *testing.T) {
|
// }
|
||||||
err := SendVerifyCode("18180948107")
|
// }
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,267 +1,249 @@
|
|||||||
package weixin
|
package weixin
|
||||||
|
|
||||||
import (
|
// const (
|
||||||
"encoding/base64"
|
// LoginType = "weixinsns"
|
||||||
"errors"
|
// LoginTypeMiniProgram = "weixinmini"
|
||||||
"fmt"
|
// DefTempPasswordDuration = 20 * time.Minute // 登录时间限制在5分钟内
|
||||||
"time"
|
// )
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
// const (
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
// CacheKeySeparator = "/"
|
||||||
weixin2 "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
// MiniVerifyCodePrefix = "MiniVerifyCode"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
// SessionKeyPrefix = "SessionKey"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
|
// )
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
// var (
|
||||||
LoginType = "weixinsns"
|
// StrStateIsWrong = "state:%s状态不对"
|
||||||
LoginTypeMiniProgram = "weixinmini"
|
// )
|
||||||
DefTempPasswordDuration = 20 * time.Minute // 登录时间限制在5分钟内
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
// var (
|
||||||
CacheKeySeparator = "/"
|
// auther *Auther
|
||||||
MiniVerifyCodePrefix = "MiniVerifyCode"
|
// AutherMini *AutherMiniProgram
|
||||||
SessionKeyPrefix = "SessionKey"
|
// )
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
StrStateIsWrong = "state:%s状态不对"
|
// ErrExceptionalLogin = errors.New("登录异常,超时,请重走绑定流程")
|
||||||
)
|
// )
|
||||||
|
|
||||||
var (
|
// type Auther struct {
|
||||||
auther *Auther
|
// }
|
||||||
AutherMini *AutherMiniProgram
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
// type AutherMiniProgram struct {
|
||||||
ErrExceptionalLogin = errors.New("登录异常,超时,请重走绑定流程")
|
// }
|
||||||
)
|
|
||||||
|
|
||||||
type Auther struct {
|
// type UserInfoExt struct {
|
||||||
}
|
// weixinapi.SNSUserInfo
|
||||||
|
// TempPassword string `json:"tempPassword"` // 一段时间有效的登录密码
|
||||||
|
// LoginInfo *auth.LoginInfo `json:"loginInfo"`
|
||||||
|
// }
|
||||||
|
|
||||||
type AutherMiniProgram struct {
|
// func init() {
|
||||||
}
|
// auther = new(Auther)
|
||||||
|
// auth.RegisterAuther(LoginType, auther)
|
||||||
|
|
||||||
type UserInfoExt struct {
|
// AutherMini = new(AutherMiniProgram)
|
||||||
weixinapi.SNSUserInfo
|
// auth.RegisterAuther(LoginTypeMiniProgram, AutherMini)
|
||||||
TempPassword string `json:"tempPassword"` // 一段时间有效的登录密码
|
// }
|
||||||
LoginInfo *auth.LoginInfo `json:"loginInfo"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
// func cacheSNSInfo(wxUserinfo *weixinapi.SNSUserInfo, password string, duration time.Duration) {
|
||||||
auther = new(Auther)
|
// api.Cacher.Set(wxUserinfo.OpenID, password, duration)
|
||||||
auth.RegisterAuther(LoginType, auther)
|
// api.Cacher.Set(wxUserinfo.OpenID+".sns", wxUserinfo, duration)
|
||||||
|
// }
|
||||||
|
|
||||||
AutherMini = new(AutherMiniProgram)
|
// func getSNSInfoFromCache(openID string) (wxUserinfo *weixinapi.SNSUserInfo, password string) {
|
||||||
auth.RegisterAuther(LoginTypeMiniProgram, AutherMini)
|
// password, _ = api.Cacher.Get(openID).(string)
|
||||||
}
|
// wxUserinfo = new(weixinapi.SNSUserInfo)
|
||||||
|
// if err := api.Cacher.GetAs(openID+".sns", wxUserinfo); err != nil {
|
||||||
|
// wxUserinfo = nil
|
||||||
|
// }
|
||||||
|
// return wxUserinfo, password
|
||||||
|
// }
|
||||||
|
|
||||||
func cacheSNSInfo(wxUserinfo *weixinapi.SNSUserInfo, password string, duration time.Duration) {
|
// func GetWeiXinUserInfo(code string, state string) (userInfo *UserInfoExt, err error) {
|
||||||
api.Cacher.Set(wxUserinfo.OpenID, password, duration)
|
// globals.SugarLogger.Debugf("GetUserInfo code:%s", code)
|
||||||
api.Cacher.Set(wxUserinfo.OpenID+".sns", wxUserinfo, duration)
|
// if state == "" {
|
||||||
}
|
// token, err2 := api.WeixinAPI.SNSRetrieveToken(code)
|
||||||
|
// if err = err2; err == nil {
|
||||||
|
// wxUserinfo, err2 := api.WeixinAPI.SNSGetUserInfo(token.AccessToken, token.OpenID)
|
||||||
|
// if err = err2; err == nil {
|
||||||
|
// userInfo = &UserInfoExt{
|
||||||
|
// SNSUserInfo: *wxUserinfo,
|
||||||
|
// TempPassword: utils.GetUUID(),
|
||||||
|
// }
|
||||||
|
// globals.SugarLogger.Debugf("GetUserInfo code:%s, userInfo:%s", code, utils.Format4Output(userInfo, true))
|
||||||
|
// cacheSNSInfo(wxUserinfo, userInfo.TempPassword, DefTempPasswordDuration)
|
||||||
|
// user, err2 := dao.GetWeiXinUserByIDs(dao.GetDB(), "", wxUserinfo.UnionID, wxUserinfo.OpenID, "")
|
||||||
|
// if err = err2; err == nil {
|
||||||
|
// userInfo.LoginInfo = auth.CreateLoginInfo(user.Tel, mobile.LoginType)
|
||||||
|
// } else if !dao.IsNoRowsError(err) { // 非用户不存在错误,报错
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// return userInfo, nil
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// err = fmt.Errorf(StrStateIsWrong, state)
|
||||||
|
// }
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
|
||||||
func getSNSInfoFromCache(openID string) (wxUserinfo *weixinapi.SNSUserInfo, password string) {
|
// // 此函数需要调整
|
||||||
password, _ = api.Cacher.Get(openID).(string)
|
// func (a *Auther) Login(openid, password string) (userID, LoginType string, err error) {
|
||||||
wxUserinfo = new(weixinapi.SNSUserInfo)
|
// globals.SugarLogger.Debugf("weixinsns Login openid:%s, password:%s", openid, password)
|
||||||
if err := api.Cacher.GetAs(openID+".sns", wxUserinfo); err != nil {
|
// _, cachedPwd := getSNSInfoFromCache(openid)
|
||||||
wxUserinfo = nil
|
// if cachedPwd != "" && password == cachedPwd {
|
||||||
}
|
// api.Cacher.Del(openid)
|
||||||
return wxUserinfo, password
|
// return "", "", nil
|
||||||
}
|
// }
|
||||||
|
// return "", "", ErrExceptionalLogin
|
||||||
|
// }
|
||||||
|
|
||||||
func GetWeiXinUserInfo(code string, state string) (userInfo *UserInfoExt, err error) {
|
// func (a *Auther) Logout(loginInfo *auth.LoginInfo) error {
|
||||||
globals.SugarLogger.Debugf("GetUserInfo code:%s", code)
|
// return nil
|
||||||
if state == "" {
|
// }
|
||||||
token, err2 := api.WeixinAPI.SNSRetrieveToken(code)
|
|
||||||
if err = err2; err == nil {
|
|
||||||
wxUserinfo, err2 := api.WeixinAPI.SNSGetUserInfo(token.AccessToken, token.OpenID)
|
|
||||||
if err = err2; err == nil {
|
|
||||||
userInfo = &UserInfoExt{
|
|
||||||
SNSUserInfo: *wxUserinfo,
|
|
||||||
TempPassword: utils.GetUUID(),
|
|
||||||
}
|
|
||||||
globals.SugarLogger.Debugf("GetUserInfo code:%s, userInfo:%s", code, utils.Format4Output(userInfo, true))
|
|
||||||
cacheSNSInfo(wxUserinfo, userInfo.TempPassword, DefTempPasswordDuration)
|
|
||||||
user, err2 := dao.GetWeiXinUserByIDs(dao.GetDB(), "", wxUserinfo.UnionID, wxUserinfo.OpenID, "")
|
|
||||||
if err = err2; err == nil {
|
|
||||||
userInfo.LoginInfo = auth.CreateLoginInfo(user.Tel, mobile.LoginType)
|
|
||||||
} else if !dao.IsNoRowsError(err) { // 非用户不存在错误,报错
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return userInfo, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err = fmt.Errorf(StrStateIsWrong, state)
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// 此函数需要调整
|
// func BindMobile(token, mobileNum, code, nickname string) (err error) {
|
||||||
func (a *Auther) Login(openid, password string) (userID, LoginType string, err error) {
|
// globals.SugarLogger.Debugf("BindMobile token:%s, mobileNum:%s, code:%s, nickname:%s", token, mobileNum, code, nickname)
|
||||||
globals.SugarLogger.Debugf("weixinsns Login openid:%s, password:%s", openid, password)
|
|
||||||
_, cachedPwd := getSNSInfoFromCache(openid)
|
|
||||||
if cachedPwd != "" && password == cachedPwd {
|
|
||||||
api.Cacher.Del(openid)
|
|
||||||
return "", "", nil
|
|
||||||
}
|
|
||||||
return "", "", ErrExceptionalLogin
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Auther) Logout(loginInfo *auth.LoginInfo) error {
|
// loginInfo := new(auth.LoginInfo)
|
||||||
return nil
|
// if err = api.Cacher.GetAs(token, loginInfo); err == nil {
|
||||||
}
|
// if err = mobile.VerifyCode(mobileNum, code); err == nil {
|
||||||
|
// wxUserinfo, _ := getSNSInfoFromCache(loginInfo.ID)
|
||||||
|
// if wxUserinfo == nil {
|
||||||
|
// return fmt.Errorf("绑定超时,请重新绑定")
|
||||||
|
// }
|
||||||
|
// if nickname == "" {
|
||||||
|
// nickname = wxUserinfo.NickName
|
||||||
|
// }
|
||||||
|
// err = auth.ConvertErr2NoUser(dao.UpdateWeiXinUser(dao.GetDB(), mobileNum, nickname, wxUserinfo.UnionID, wxUserinfo.OpenID, ""), mobileNum)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// jxutils.HandleUserWXRemark(nil, mobileNum, false)
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
func BindMobile(token, mobileNum, code, nickname string) (err error) {
|
// // 绑定手机加登录
|
||||||
globals.SugarLogger.Debugf("BindMobile token:%s, mobileNum:%s, code:%s, nickname:%s", token, mobileNum, code, nickname)
|
// func BindMobile2(openid, secret, mobileNum, verifyCode, nickname string) (loginInfo *auth.LoginInfo, err error) {
|
||||||
|
// globals.SugarLogger.Debugf("BindMobile2 openid:%s, secret:%s, mobileNum:%s, verifyCode:%s, nickname:%s", openid, secret, mobileNum, verifyCode, nickname)
|
||||||
|
|
||||||
loginInfo := new(auth.LoginInfo)
|
// err = ErrExceptionalLogin
|
||||||
if err = api.Cacher.GetAs(token, loginInfo); err == nil {
|
// if value := api.Cacher.Get(openid); value != nil {
|
||||||
if err = mobile.VerifyCode(mobileNum, code); err == nil {
|
// wxUserinfo, cachedSecret := getSNSInfoFromCache(openid)
|
||||||
wxUserinfo, _ := getSNSInfoFromCache(loginInfo.ID)
|
// if wxUserinfo == nil {
|
||||||
if wxUserinfo == nil {
|
// return nil, fmt.Errorf("绑定超时,请重新绑定")
|
||||||
return fmt.Errorf("绑定超时,请重新绑定")
|
// }
|
||||||
}
|
// if secret == cachedSecret {
|
||||||
if nickname == "" {
|
// if err = mobile.VerifyCode(mobileNum, verifyCode); err == nil {
|
||||||
nickname = wxUserinfo.NickName
|
// api.Cacher.Del(openid)
|
||||||
}
|
// err = nil
|
||||||
err = auth.ConvertErr2NoUser(dao.UpdateWeiXinUser(dao.GetDB(), mobileNum, nickname, wxUserinfo.UnionID, wxUserinfo.OpenID, ""), mobileNum)
|
// if nickname == "" {
|
||||||
}
|
// nickname = wxUserinfo.NickName
|
||||||
}
|
// }
|
||||||
jxutils.HandleUserWXRemark(nil, mobileNum, false)
|
// if err = dao.UpdateWeiXinUser(dao.GetDB(), mobileNum, nickname, wxUserinfo.UnionID, wxUserinfo.OpenID, ""); err == nil {
|
||||||
return err
|
// loginInfo = auth.CreateLoginInfo(mobileNum, mobile.LoginType)
|
||||||
}
|
// } else {
|
||||||
|
// err = auth.ConvertErr2NoUser(err, mobileNum)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// jxutils.HandleUserWXRemark(nil, mobileNum, false)
|
||||||
|
// return loginInfo, err
|
||||||
|
// }
|
||||||
|
|
||||||
// 绑定手机加登录
|
// // 此函数已废弃
|
||||||
func BindMobile2(openid, secret, mobileNum, verifyCode, nickname string) (loginInfo *auth.LoginInfo, err error) {
|
// // 对于小程序来说,
|
||||||
globals.SugarLogger.Debugf("BindMobile2 openid:%s, secret:%s, mobileNum:%s, verifyCode:%s, nickname:%s", openid, secret, mobileNum, verifyCode, nickname)
|
// // 1,用户必须先在后台创建(手机号标识)
|
||||||
|
// // 2,用户必须先绑定微信
|
||||||
|
// // 先以短信方式登录:
|
||||||
|
// // SendMobileVerifyCode
|
||||||
|
// // Login use type mobile
|
||||||
|
// // MiniBindWeiXin
|
||||||
|
// // 3,用户以CODE来登录(Login use type weixinmini)
|
||||||
|
// // Login
|
||||||
|
|
||||||
err = ErrExceptionalLogin
|
// func (a *AutherMiniProgram) BindWeiXin(ctx *jxcontext.Context, code, nickName string) (err error) {
|
||||||
if value := api.Cacher.Get(openid); value != nil {
|
// globals.SugarLogger.Debugf("AutherMiniProgram BindWeiXin code:%s, nickName:%s", code, nickName)
|
||||||
wxUserinfo, cachedSecret := getSNSInfoFromCache(openid)
|
// loginInfo := ctx.GetLoginInfo()
|
||||||
if wxUserinfo == nil {
|
// if loginInfo == nil || loginInfo.GetAuthType() != mobile.LoginType {
|
||||||
return nil, fmt.Errorf("绑定超时,请重新绑定")
|
// return fmt.Errorf("调用AutherMiniProgram BindWeiXin时,必须以手机验证方式登录")
|
||||||
}
|
// }
|
||||||
if secret == cachedSecret {
|
// sessionInfo, err := weixin2.ProxySNSCode2Session(code)
|
||||||
if err = mobile.VerifyCode(mobileNum, verifyCode); err == nil {
|
// if err != nil {
|
||||||
api.Cacher.Del(openid)
|
// return err
|
||||||
err = nil
|
// }
|
||||||
if nickname == "" {
|
// err = dao.UpdateWeiXinUser(dao.GetDB(), loginInfo.GetAuthID(), nickName, sessionInfo.UnionID, "", sessionInfo.OpenID)
|
||||||
nickname = wxUserinfo.NickName
|
// return auth.ConvertErr2NoUser(err, "")
|
||||||
}
|
// }
|
||||||
if err = dao.UpdateWeiXinUser(dao.GetDB(), mobileNum, nickname, wxUserinfo.UnionID, wxUserinfo.OpenID, ""); err == nil {
|
|
||||||
loginInfo = auth.CreateLoginInfo(mobileNum, mobile.LoginType)
|
|
||||||
} else {
|
|
||||||
err = auth.ConvertErr2NoUser(err, mobileNum)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jxutils.HandleUserWXRemark(nil, mobileNum, false)
|
|
||||||
return loginInfo, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// 此函数已废弃
|
// // 绑定小程序
|
||||||
// 对于小程序来说,
|
// func (a *AutherMiniProgram) BindMiniProgram(ctx *jxcontext.Context, code string) (err error) {
|
||||||
// 1,用户必须先在后台创建(手机号标识)
|
// globals.SugarLogger.Debugf("BindMiniProgram code:%s", code)
|
||||||
// 2,用户必须先绑定微信
|
// if ctx.GetLoginType() != mobile.LoginType {
|
||||||
// 先以短信方式登录:
|
// return errors.New("登录方式应该为手机")
|
||||||
// SendMobileVerifyCode
|
// }
|
||||||
// Login use type mobile
|
// sessionInfo, err := weixin2.ProxySNSCode2Session(code)
|
||||||
// MiniBindWeiXin
|
// if err != nil {
|
||||||
// 3,用户以CODE来登录(Login use type weixinmini)
|
// return err
|
||||||
// Login
|
// }
|
||||||
|
// db := dao.GetDB()
|
||||||
|
// user, err := dao.GetWeiXinUserByIDs(db, ctx.GetLoginID(), "", "", "")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// // if user.OpenIDUnion != sessionInfo.UnionID {
|
||||||
|
// // return errors.New("绑定用户不匹配")
|
||||||
|
// // }
|
||||||
|
// err = auth.ConvertErr2NoUser(dao.UpdateWeiXinUser(db, user.Tel, "", sessionInfo.UnionID, "", sessionInfo.OpenID), user.Tel)
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
func (a *AutherMiniProgram) BindWeiXin(ctx *jxcontext.Context, code, nickName string) (err error) {
|
// func (a *AutherMiniProgram) Login(mobileNum, code string) (userID, LoginType string, err error) {
|
||||||
globals.SugarLogger.Debugf("AutherMiniProgram BindWeiXin code:%s, nickName:%s", code, nickName)
|
// globals.SugarLogger.Debugf("AutherMiniProgram Login mobileNum:%s, code:%s", mobileNum, code)
|
||||||
loginInfo := ctx.GetLoginInfo()
|
// sessionInfo, err := weixin2.ProxySNSCode2Session(code)
|
||||||
if loginInfo == nil || loginInfo.GetAuthType() != mobile.LoginType {
|
// if err != nil {
|
||||||
return fmt.Errorf("调用AutherMiniProgram BindWeiXin时,必须以手机验证方式登录")
|
// return "", "", err
|
||||||
}
|
// }
|
||||||
sessionInfo, err := weixin2.ProxySNSCode2Session(code)
|
// globals.SugarLogger.Debugf("AutherMiniProgram Login code:%s, unionID:%s, openID:%s", code, sessionInfo.UnionID, sessionInfo.OpenID)
|
||||||
if err != nil {
|
// db := dao.GetDB()
|
||||||
return err
|
// user, err := dao.GetWeiXinUserByIDs(db, "", sessionInfo.UnionID, "", sessionInfo.OpenID)
|
||||||
}
|
// if err != nil {
|
||||||
err = dao.UpdateWeiXinUser(dao.GetDB(), loginInfo.GetAuthID(), nickName, sessionInfo.UnionID, "", sessionInfo.OpenID)
|
// return "", "", auth.ConvertErr2NoUser(err, mobileNum)
|
||||||
return auth.ConvertErr2NoUser(err, "")
|
// }
|
||||||
}
|
// if user.OpenIDMini != sessionInfo.OpenID {
|
||||||
|
// user.OpenIDMini = sessionInfo.OpenID
|
||||||
|
// dao.UpdateEntity(db, user, "OpenIDMini")
|
||||||
|
// }
|
||||||
|
// globals.SugarLogger.Debugf("AutherMiniProgram Login user.Tel:%s, code:%s, openID:%s", user.Tel, code, sessionInfo.OpenID)
|
||||||
|
// if mobileNum != user.Tel {
|
||||||
|
|
||||||
// 绑定小程序
|
// }
|
||||||
func (a *AutherMiniProgram) BindMiniProgram(ctx *jxcontext.Context, code string) (err error) {
|
// api.Cacher.Set(composeSessionKeyCacheKey(user.Tel), sessionInfo.SessionKey, auth.DefTokenDuration)
|
||||||
globals.SugarLogger.Debugf("BindMiniProgram code:%s", code)
|
// return user.Tel, mobile.LoginType, err
|
||||||
if ctx.GetLoginType() != mobile.LoginType {
|
// }
|
||||||
return errors.New("登录方式应该为手机")
|
|
||||||
}
|
|
||||||
sessionInfo, err := weixin2.ProxySNSCode2Session(code)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
db := dao.GetDB()
|
|
||||||
user, err := dao.GetWeiXinUserByIDs(db, ctx.GetLoginID(), "", "", "")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// if user.OpenIDUnion != sessionInfo.UnionID {
|
|
||||||
// return errors.New("绑定用户不匹配")
|
|
||||||
// }
|
|
||||||
err = auth.ConvertErr2NoUser(dao.UpdateWeiXinUser(db, user.Tel, "", sessionInfo.UnionID, "", sessionInfo.OpenID), user.Tel)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *AutherMiniProgram) Login(mobileNum, code string) (userID, LoginType string, err error) {
|
// func (a *AutherMiniProgram) Logout(loginInfo *auth.LoginInfo) error {
|
||||||
globals.SugarLogger.Debugf("AutherMiniProgram Login mobileNum:%s, code:%s", mobileNum, code)
|
// globals.SugarLogger.Debugf("AutherMiniProgram Logout openid:%s", utils.Format4Output(loginInfo, false))
|
||||||
sessionInfo, err := weixin2.ProxySNSCode2Session(code)
|
// return api.Cacher.Del(composeSessionKeyCacheKey(loginInfo.GetAuthID()))
|
||||||
if err != nil {
|
// }
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
globals.SugarLogger.Debugf("AutherMiniProgram Login code:%s, unionID:%s, openID:%s", code, sessionInfo.UnionID, sessionInfo.OpenID)
|
|
||||||
db := dao.GetDB()
|
|
||||||
user, err := dao.GetWeiXinUserByIDs(db, "", sessionInfo.UnionID, "", sessionInfo.OpenID)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", auth.ConvertErr2NoUser(err, mobileNum)
|
|
||||||
}
|
|
||||||
if user.OpenIDMini != sessionInfo.OpenID {
|
|
||||||
user.OpenIDMini = sessionInfo.OpenID
|
|
||||||
dao.UpdateEntity(db, user, "OpenIDMini")
|
|
||||||
}
|
|
||||||
globals.SugarLogger.Debugf("AutherMiniProgram Login user.Tel:%s, code:%s, openID:%s", user.Tel, code, sessionInfo.OpenID)
|
|
||||||
if mobileNum != user.Tel {
|
|
||||||
|
|
||||||
}
|
// func (a *AutherMiniProgram) DecryptData(ctx *jxcontext.Context, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
||||||
api.Cacher.Set(composeSessionKeyCacheKey(user.Tel), sessionInfo.SessionKey, auth.DefTokenDuration)
|
// globals.SugarLogger.Debugf("AutherMiniProgram DecryptData encryptedData:%s, iv:%s", encryptedData, iv)
|
||||||
return user.Tel, mobile.LoginType, err
|
// var sessionKey string
|
||||||
}
|
// if err = api.Cacher.GetAs(composeSessionKeyCacheKey(ctx.GetLoginInfo().GetAuthID()), &sessionKey); err != nil {
|
||||||
|
// return "", err
|
||||||
|
// }
|
||||||
|
// decryptedData, err := weixin2.ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
|
||||||
|
// if err != nil {
|
||||||
|
// return "", err
|
||||||
|
// }
|
||||||
|
// return base64.StdEncoding.EncodeToString(decryptedData), nil
|
||||||
|
// }
|
||||||
|
|
||||||
func (a *AutherMiniProgram) Logout(loginInfo *auth.LoginInfo) error {
|
// func composeMiniVerifiyCacheKey(key string) string {
|
||||||
globals.SugarLogger.Debugf("AutherMiniProgram Logout openid:%s", utils.Format4Output(loginInfo, false))
|
// return MiniVerifyCodePrefix + CacheKeySeparator + key
|
||||||
return api.Cacher.Del(composeSessionKeyCacheKey(loginInfo.GetAuthID()))
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
func (a *AutherMiniProgram) DecryptData(ctx *jxcontext.Context, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
// func composeSessionKeyCacheKey(key string) string {
|
||||||
globals.SugarLogger.Debugf("AutherMiniProgram DecryptData encryptedData:%s, iv:%s", encryptedData, iv)
|
// return SessionKeyPrefix + CacheKeySeparator + key
|
||||||
var sessionKey string
|
// }
|
||||||
if err = api.Cacher.GetAs(composeSessionKeyCacheKey(ctx.GetLoginInfo().GetAuthID()), &sessionKey); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
decryptedData, err := weixin2.ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return base64.StdEncoding.EncodeToString(decryptedData), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func composeMiniVerifiyCacheKey(key string) string {
|
|
||||||
return MiniVerifyCodePrefix + CacheKeySeparator + key
|
|
||||||
}
|
|
||||||
|
|
||||||
func composeSessionKeyCacheKey(key string) string {
|
|
||||||
return SessionKeyPrefix + CacheKeySeparator + key
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -179,15 +179,15 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
|
|||||||
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||||
|
|
||||||
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
|
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
|
||||||
if !globals.DisableWXAuth1 && jxutils.IsLegalMobileNumber(keywordInt64) {
|
// if !globals.DisableWXAuth1 && jxutils.IsLegalMobileNumber(keywordInt64) {
|
||||||
sql += `
|
// sql += `
|
||||||
LEFT JOIN weixins wx1 ON t1.id = wx1.jxstoreid AND wx1.parentid = -1 AND wx1.tel = ?
|
// LEFT JOIN weixins wx1 ON t1.id = wx1.jxstoreid AND wx1.parentid = -1 AND wx1.tel = ?
|
||||||
LEFT JOIN weixins wx2 ON t1.id = wx2.jxstoreid AND wx2.parentid = -1
|
// LEFT JOIN weixins wx2 ON t1.id = wx2.jxstoreid AND wx2.parentid = -1
|
||||||
LEFT JOIN weixins wx3 ON wx3.parentid = wx2.id AND wx3.tel = ?
|
// LEFT JOIN weixins wx3 ON wx3.parentid = wx2.id AND wx3.tel = ?
|
||||||
`
|
// `
|
||||||
sqlParams = append(sqlParams, keywordInt64, keywordInt64)
|
// sqlParams = append(sqlParams, keywordInt64, keywordInt64)
|
||||||
sqlWhere += " OR wx1.id IS NOT NULL OR wx3.id IS NOT NULL"
|
// sqlWhere += " OR wx1.id IS NOT NULL OR wx3.id IS NOT NULL"
|
||||||
}
|
// }
|
||||||
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?"
|
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?"
|
||||||
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64)
|
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64)
|
||||||
if jxutils.GuessVendorIDFromVendorStoreID(keywordInt64) != model.VendorIDUnknown {
|
if jxutils.GuessVendorIDFromVendorStoreID(keywordInt64) != model.VendorIDUnknown {
|
||||||
|
|||||||
@@ -1,226 +1,210 @@
|
|||||||
package cms
|
package cms
|
||||||
|
|
||||||
import (
|
// var (
|
||||||
"fmt"
|
// LoginTypeFieldMap = map[string]string{
|
||||||
|
// mobile.LoginType: "tel",
|
||||||
|
// weixin.LoginType: "openid",
|
||||||
|
// weixin.LoginTypeMiniProgram: "openid_mini",
|
||||||
|
// }
|
||||||
|
// )
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
// func GetStoreUsers(ctx *jxcontext.Context, storeID int) (storeUserInfos []*dao.StoreUserInfo, err error) {
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
// sql := `
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
|
// SELECT t1.id, t1.jxstoreid, t1.openid, t1.tel, t1.nickname, t1.parentid, t3.tel parent_mobile,
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/weixin"
|
// CONCAT("[", GROUP_CONCAT(CONCAT('{"id":', t2.id, ',"parentID":', t2.parentid, ',"tel":"', t2.tel, '","nickname":"', IF(t2.nickname IS NULL, "", t2.nickname), '"}')), "]") members_str
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
// FROM weixins t1
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
// LEFT JOIN weixins t2 ON t2.parentid = t1.id
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
// LEFT JOIN weixins t3 ON t1.parentid = t3.id
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
// WHERE t1.parentid = -1 AND t1.jxstoreid = ?
|
||||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
// GROUP BY 1,2,3,4,5,6,7;
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
// `
|
||||||
"github.com/astaxie/beego/orm"
|
// // globals.SugarLogger.Debug(sql)
|
||||||
)
|
// if err = dao.GetRows(nil, &storeUserInfos, sql, storeID); err == nil {
|
||||||
|
// for _, storeUserInfo := range storeUserInfos {
|
||||||
|
// if storeUserInfo.MembersStr != "" {
|
||||||
|
// err = utils.UnmarshalUseNumber([]byte(storeUserInfo.MembersStr), &storeUserInfo.Members)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return storeUserInfos, err
|
||||||
|
// }
|
||||||
|
|
||||||
var (
|
// func GetUserInfo(ctx *jxcontext.Context, mobile string) (storeUserInfo *dao.StoreUserInfo, err error) {
|
||||||
LoginTypeFieldMap = map[string]string{
|
// storeUserInfo, err = dao.GetUserStoreInfo(dao.GetDB(), "tel", mobile)
|
||||||
mobile.LoginType: "tel",
|
// globals.SugarLogger.Debugf("GetUserInfo:%s, token:%s, mobile:%s, storeUserInfo:%s, err:%v", ctx.GetTrackInfo(), ctx.GetToken(), mobile, utils.Format4Output(storeUserInfo, true), err)
|
||||||
weixin.LoginType: "openid",
|
// return storeUserInfo, err
|
||||||
weixin.LoginTypeMiniProgram: "openid_mini",
|
// }
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetStoreUsers(ctx *jxcontext.Context, storeID int) (storeUserInfos []*dao.StoreUserInfo, err error) {
|
// func GetSelfInfo(ctx *jxcontext.Context) (storeUserInfo *dao.StoreUserInfo, err error) {
|
||||||
sql := `
|
// loginInfo := ctx.GetLoginInfo()
|
||||||
SELECT t1.id, t1.jxstoreid, t1.openid, t1.tel, t1.nickname, t1.parentid, t3.tel parent_mobile,
|
// if loginInfo == nil {
|
||||||
CONCAT("[", GROUP_CONCAT(CONCAT('{"id":', t2.id, ',"parentID":', t2.parentid, ',"tel":"', t2.tel, '","nickname":"', IF(t2.nickname IS NULL, "", t2.nickname), '"}')), "]") members_str
|
// return nil, auth.ErrAPINeedRealLogin
|
||||||
FROM weixins t1
|
// }
|
||||||
LEFT JOIN weixins t2 ON t2.parentid = t1.id
|
// fieldName := LoginTypeFieldMap[loginInfo.GetAuthType()]
|
||||||
LEFT JOIN weixins t3 ON t1.parentid = t3.id
|
// if fieldName == "" {
|
||||||
WHERE t1.parentid = -1 AND t1.jxstoreid = ?
|
// return nil, auth.ErrIllegalLoginType
|
||||||
GROUP BY 1,2,3,4,5,6,7;
|
// }
|
||||||
`
|
// storeUserInfo, err = dao.GetUserStoreInfo(dao.GetDB(), fieldName, loginInfo.GetAuthID())
|
||||||
// globals.SugarLogger.Debug(sql)
|
// globals.SugarLogger.Debugf("GetSelfInfo:%s, token:%s, storeUserInfo:%s, err:%v", ctx.GetTrackInfo(), ctx.GetToken(), utils.Format4Output(storeUserInfo, true), err)
|
||||||
if err = dao.GetRows(nil, &storeUserInfos, sql, storeID); err == nil {
|
// return storeUserInfo, err
|
||||||
for _, storeUserInfo := range storeUserInfos {
|
// }
|
||||||
if storeUserInfo.MembersStr != "" {
|
|
||||||
err = utils.UnmarshalUseNumber([]byte(storeUserInfo.MembersStr), &storeUserInfo.Members)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return storeUserInfos, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUserInfo(ctx *jxcontext.Context, mobile string) (storeUserInfo *dao.StoreUserInfo, err error) {
|
// func GetMyStoreList(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityName, err error) {
|
||||||
storeUserInfo, err = dao.GetUserStoreInfo(dao.GetDB(), "tel", mobile)
|
// mobileNum, _ := ctx.GetMobileAndUserID()
|
||||||
globals.SugarLogger.Debugf("GetUserInfo:%s, token:%s, mobile:%s, storeUserInfo:%s, err:%v", ctx.GetTrackInfo(), ctx.GetToken(), mobile, utils.Format4Output(storeUserInfo, true), err)
|
// if mobileNum == "" {
|
||||||
return storeUserInfo, err
|
// return nil, fmt.Errorf("不能得到用户手机号")
|
||||||
}
|
// }
|
||||||
|
// storeList, err = dao.GetStoreListByMobile(dao.GetDB(), mobileNum)
|
||||||
|
// return storeList, err
|
||||||
|
// }
|
||||||
|
|
||||||
func GetSelfInfo(ctx *jxcontext.Context) (storeUserInfo *dao.StoreUserInfo, err error) {
|
// func UnbindMobile(ctx *jxcontext.Context, mobile string) (num int64, err error) {
|
||||||
loginInfo := ctx.GetLoginInfo()
|
// db := dao.GetDB()
|
||||||
if loginInfo == nil {
|
// num, err = dao.UpdateEntityByKV(db, &legacymodel.WeiXins{}, map[string]interface{}{
|
||||||
return nil, auth.ErrAPINeedRealLogin
|
// "JxStoreID": 0,
|
||||||
}
|
// "ParentID": -1,
|
||||||
fieldName := LoginTypeFieldMap[loginInfo.GetAuthType()]
|
// }, map[string]interface{}{
|
||||||
if fieldName == "" {
|
// "Tel": mobile,
|
||||||
return nil, auth.ErrIllegalLoginType
|
// })
|
||||||
}
|
// if err == nil {
|
||||||
storeUserInfo, err = dao.GetUserStoreInfo(dao.GetDB(), fieldName, loginInfo.GetAuthID())
|
// jxutils.HandleUserWXRemark(db, mobile, false)
|
||||||
globals.SugarLogger.Debugf("GetSelfInfo:%s, token:%s, storeUserInfo:%s, err:%v", ctx.GetTrackInfo(), ctx.GetToken(), utils.Format4Output(storeUserInfo, true), err)
|
// TransferLegacyWeixins(mobile)
|
||||||
return storeUserInfo, err
|
// }
|
||||||
}
|
// return num, err
|
||||||
|
// }
|
||||||
|
|
||||||
func GetMyStoreList(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityName, err error) {
|
// func BindMobile2Store(ctx *jxcontext.Context, mobile string, storeID int) (num int64, err error) {
|
||||||
mobileNum, _ := ctx.GetMobileAndUserID()
|
// db := dao.GetDB()
|
||||||
if mobileNum == "" {
|
// user, err2 := verifyMobileIsBlank(db, mobile)
|
||||||
return nil, fmt.Errorf("不能得到用户手机号")
|
// if err = err2; err == nil || err == orm.ErrNoRows {
|
||||||
}
|
// user.JxStoreID = storeID
|
||||||
storeList, err = dao.GetStoreListByMobile(dao.GetDB(), mobileNum)
|
// if err == nil {
|
||||||
return storeList, err
|
// dao.Begin(db)
|
||||||
}
|
// defer func() {
|
||||||
|
// if r := recover(); r != nil {
|
||||||
|
// dao.Rollback(db)
|
||||||
|
// panic(r)
|
||||||
|
// }
|
||||||
|
// }()
|
||||||
|
// if num, err = dao.UpdateEntity(db, user, "JxStoreID"); err == nil {
|
||||||
|
// err = dao.SetWeiXinsEmpty2Null(db, user)
|
||||||
|
// }
|
||||||
|
// if err != nil {
|
||||||
|
// dao.Rollback(db)
|
||||||
|
// } else {
|
||||||
|
// dao.Commit(db)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // globals.SugarLogger.Debug(utils.Format4Output(user, false))
|
||||||
|
// dao.WrapAddIDCULEntity(user, ctx.GetUserName())
|
||||||
|
// user.ParentID = -1
|
||||||
|
// if err = dao.CreateWeiXins(db, user); err == nil {
|
||||||
|
// num = 1
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if err == nil {
|
||||||
|
// jxutils.HandleUserWXRemark(db, mobile, false)
|
||||||
|
// TransferLegacyWeixins(mobile)
|
||||||
|
// }
|
||||||
|
// return num, err
|
||||||
|
// }
|
||||||
|
|
||||||
func UnbindMobile(ctx *jxcontext.Context, mobile string) (num int64, err error) {
|
// func AddMobile2Mobile(ctx *jxcontext.Context, parentMobile, mobile string) (num int64, err error) {
|
||||||
db := dao.GetDB()
|
// db := dao.GetDB()
|
||||||
num, err = dao.UpdateEntityByKV(db, &legacymodel.WeiXins{}, map[string]interface{}{
|
// parentUser := &legacymodel.WeiXins{}
|
||||||
"JxStoreID": 0,
|
// parentUser.Tel = parentMobile
|
||||||
"ParentID": -1,
|
// if err = dao.GetEntity(db, parentUser, "Tel"); err == nil {
|
||||||
}, map[string]interface{}{
|
// if parentUser.ParentID == -1 {
|
||||||
"Tel": mobile,
|
// globals.SugarLogger.Debug(parentUser)
|
||||||
})
|
// if err = verifyMobileHasNoMembers(db, mobile); err == nil {
|
||||||
if err == nil {
|
// user, err2 := verifyMobileIsBlank(db, mobile)
|
||||||
jxutils.HandleUserWXRemark(db, mobile, false)
|
// if err = err2; err == nil || err == orm.ErrNoRows {
|
||||||
TransferLegacyWeixins(mobile)
|
// user.ParentID = parentUser.ID
|
||||||
}
|
// if err == nil {
|
||||||
return num, err
|
// // todo transaction
|
||||||
}
|
// if num, err = dao.UpdateEntity(db, user, "ParentID"); err == nil {
|
||||||
|
// err = dao.SetWeiXinsEmpty2Null(db, user)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// dao.WrapAddIDCULEntity(user, ctx.GetUserName())
|
||||||
|
// if err = dao.CreateWeiXins(db, user); err == nil {
|
||||||
|
// num = 1
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// err = fmt.Errorf("%s本身是成员", parentMobile)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if err == nil {
|
||||||
|
// jxutils.HandleUserWXRemark(db, mobile, false)
|
||||||
|
// TransferLegacyWeixins(mobile)
|
||||||
|
// }
|
||||||
|
// return num, err
|
||||||
|
// }
|
||||||
|
|
||||||
func BindMobile2Store(ctx *jxcontext.Context, mobile string, storeID int) (num int64, err error) {
|
// func ChangeMobile(ctx *jxcontext.Context, curMobile, expectedMobile string) (num int64, err error) {
|
||||||
db := dao.GetDB()
|
// num, err = dao.UpdateEntityByKV(nil, &legacymodel.WeiXins{}, map[string]interface{}{
|
||||||
user, err2 := verifyMobileIsBlank(db, mobile)
|
// "Tel": expectedMobile,
|
||||||
if err = err2; err == nil || err == orm.ErrNoRows {
|
// }, map[string]interface{}{
|
||||||
user.JxStoreID = storeID
|
// "Tel": curMobile,
|
||||||
if err == nil {
|
// })
|
||||||
dao.Begin(db)
|
// if err == nil {
|
||||||
defer func() {
|
// TransferLegacyWeixins(curMobile)
|
||||||
if r := recover(); r != nil {
|
// TransferLegacyWeixins(expectedMobile)
|
||||||
dao.Rollback(db)
|
// }
|
||||||
panic(r)
|
// return num, err
|
||||||
}
|
// }
|
||||||
}()
|
|
||||||
if num, err = dao.UpdateEntity(db, user, "JxStoreID"); err == nil {
|
|
||||||
err = dao.SetWeiXinsEmpty2Null(db, user)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
dao.Rollback(db)
|
|
||||||
} else {
|
|
||||||
dao.Commit(db)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// globals.SugarLogger.Debug(utils.Format4Output(user, false))
|
|
||||||
dao.WrapAddIDCULEntity(user, ctx.GetUserName())
|
|
||||||
user.ParentID = -1
|
|
||||||
if err = dao.CreateWeiXins(db, user); err == nil {
|
|
||||||
num = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
jxutils.HandleUserWXRemark(db, mobile, false)
|
|
||||||
TransferLegacyWeixins(mobile)
|
|
||||||
}
|
|
||||||
return num, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddMobile2Mobile(ctx *jxcontext.Context, parentMobile, mobile string) (num int64, err error) {
|
// func verifyMobileIsBlank(db *dao.DaoDB, mobile string) (user *legacymodel.WeiXins, err error) {
|
||||||
db := dao.GetDB()
|
// if !jxutils.IsStringLikeMobile(mobile) {
|
||||||
parentUser := &legacymodel.WeiXins{}
|
// return nil, fmt.Errorf("%s看起来不像是一个手机号", mobile)
|
||||||
parentUser.Tel = parentMobile
|
// }
|
||||||
if err = dao.GetEntity(db, parentUser, "Tel"); err == nil {
|
// user = &legacymodel.WeiXins{
|
||||||
if parentUser.ParentID == -1 {
|
// Tel: mobile,
|
||||||
globals.SugarLogger.Debug(parentUser)
|
// }
|
||||||
if err = verifyMobileHasNoMembers(db, mobile); err == nil {
|
// if err = dao.GetEntity(db, user, "Tel"); err == nil {
|
||||||
user, err2 := verifyMobileIsBlank(db, mobile)
|
// if user.ParentID != -1 && user.ParentID != 0 {
|
||||||
if err = err2; err == nil || err == orm.ErrNoRows {
|
// userParent := &legacymodel.WeiXins{
|
||||||
user.ParentID = parentUser.ID
|
// ID: user.ParentID,
|
||||||
if err == nil {
|
// }
|
||||||
// todo transaction
|
// if err = dao.GetEntity(db, userParent); err != nil && err != orm.ErrNoRows {
|
||||||
if num, err = dao.UpdateEntity(db, user, "ParentID"); err == nil {
|
// return nil, err
|
||||||
err = dao.SetWeiXinsEmpty2Null(db, user)
|
// }
|
||||||
}
|
// if err != orm.ErrNoRows {
|
||||||
} else {
|
// err = fmt.Errorf("%s已经是组长:%s,门店:%d的小组成员", mobile, userParent.Tel, userParent.JxStoreID)
|
||||||
dao.WrapAddIDCULEntity(user, ctx.GetUserName())
|
// } else {
|
||||||
if err = dao.CreateWeiXins(db, user); err == nil {
|
// err = nil
|
||||||
num = 1
|
// }
|
||||||
}
|
// } else if user.JxStoreID != 0 {
|
||||||
}
|
// store := &model.Store{}
|
||||||
}
|
// store.ID = user.JxStoreID
|
||||||
}
|
// if err = dao.GetEntity(db, store); err == nil {
|
||||||
} else {
|
// err = fmt.Errorf("%s本身已经是门店:%d的组长", mobile, user.JxStoreID)
|
||||||
err = fmt.Errorf("%s本身是成员", parentMobile)
|
// } else if dao.IsNoRowsError(err) {
|
||||||
}
|
// err = nil
|
||||||
}
|
// }
|
||||||
if err == nil {
|
// }
|
||||||
jxutils.HandleUserWXRemark(db, mobile, false)
|
// }
|
||||||
TransferLegacyWeixins(mobile)
|
// return user, err
|
||||||
}
|
// }
|
||||||
return num, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func ChangeMobile(ctx *jxcontext.Context, curMobile, expectedMobile string) (num int64, err error) {
|
// func verifyMobileHasNoMembers(db *dao.DaoDB, mobile string) (err error) {
|
||||||
num, err = dao.UpdateEntityByKV(nil, &legacymodel.WeiXins{}, map[string]interface{}{
|
// countInfo := &struct{ Ct int }{}
|
||||||
"Tel": expectedMobile,
|
// if err = dao.GetRow(db, countInfo, `
|
||||||
}, map[string]interface{}{
|
// SELECT COUNT(*) ct
|
||||||
"Tel": curMobile,
|
// FROM weixins t1
|
||||||
})
|
// JOIN weixins t2 ON t1.parentid = t2.id AND t2.tel = ?
|
||||||
if err == nil {
|
// `, mobile); err == nil {
|
||||||
TransferLegacyWeixins(curMobile)
|
// if countInfo.Ct > 0 {
|
||||||
TransferLegacyWeixins(expectedMobile)
|
// user := &legacymodel.WeiXins{
|
||||||
}
|
// Tel: mobile,
|
||||||
return num, err
|
// }
|
||||||
}
|
// dao.GetEntity(db, user, "Tel")
|
||||||
|
// err = fmt.Errorf("%s本身已经是门店:%d组长", mobile, user.JxStoreID)
|
||||||
func verifyMobileIsBlank(db *dao.DaoDB, mobile string) (user *legacymodel.WeiXins, err error) {
|
// }
|
||||||
if !jxutils.IsStringLikeMobile(mobile) {
|
// }
|
||||||
return nil, fmt.Errorf("%s看起来不像是一个手机号", mobile)
|
// return err
|
||||||
}
|
// }
|
||||||
user = &legacymodel.WeiXins{
|
|
||||||
Tel: mobile,
|
|
||||||
}
|
|
||||||
if err = dao.GetEntity(db, user, "Tel"); err == nil {
|
|
||||||
if user.ParentID != -1 && user.ParentID != 0 {
|
|
||||||
userParent := &legacymodel.WeiXins{
|
|
||||||
ID: user.ParentID,
|
|
||||||
}
|
|
||||||
if err = dao.GetEntity(db, userParent); err != nil && err != orm.ErrNoRows {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err != orm.ErrNoRows {
|
|
||||||
err = fmt.Errorf("%s已经是组长:%s,门店:%d的小组成员", mobile, userParent.Tel, userParent.JxStoreID)
|
|
||||||
} else {
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
} else if user.JxStoreID != 0 {
|
|
||||||
store := &model.Store{}
|
|
||||||
store.ID = user.JxStoreID
|
|
||||||
if err = dao.GetEntity(db, store); err == nil {
|
|
||||||
err = fmt.Errorf("%s本身已经是门店:%d的组长", mobile, user.JxStoreID)
|
|
||||||
} else if dao.IsNoRowsError(err) {
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return user, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func verifyMobileHasNoMembers(db *dao.DaoDB, mobile string) (err error) {
|
|
||||||
countInfo := &struct{ Ct int }{}
|
|
||||||
if err = dao.GetRow(db, countInfo, `
|
|
||||||
SELECT COUNT(*) ct
|
|
||||||
FROM weixins t1
|
|
||||||
JOIN weixins t2 ON t1.parentid = t2.id AND t2.tel = ?
|
|
||||||
`, mobile); err == nil {
|
|
||||||
if countInfo.Ct > 0 {
|
|
||||||
user := &legacymodel.WeiXins{
|
|
||||||
Tel: mobile,
|
|
||||||
}
|
|
||||||
dao.GetEntity(db, user, "Tel")
|
|
||||||
err = fmt.Errorf("%s本身已经是门店:%d组长", mobile, user.JxStoreID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -63,11 +61,13 @@ func New(notUsed interface{}, token string, w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
userInfo, err2 := auth.GetUserInfo(token)
|
globals.SugarLogger.Warnf("jxcontext wrong token:%s", token)
|
||||||
if err = err2; err == nil {
|
errCode = model.ErrCodeTokenIsInvalid
|
||||||
// globals.SugarLogger.Debugf("jxcontext New, V1 authInfo:%s", utils.Format4Output(userInfo, true))
|
// userInfo, err2 := auth.GetUserInfo(token)
|
||||||
ctx.userInfo = userInfo
|
// if err = err2; err == nil {
|
||||||
}
|
// // globals.SugarLogger.Debugf("jxcontext New, V1 authInfo:%s", utils.Format4Output(userInfo, true))
|
||||||
|
// ctx.userInfo = userInfo
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
if err == model.ErrTokenIsInvalid {
|
if err == model.ErrTokenIsInvalid {
|
||||||
if !globals.IsProductEnv() {
|
if !globals.IsProductEnv() {
|
||||||
@@ -142,14 +142,6 @@ func (ctx *Context) GetMobileAndUserID() (mobile, userID string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
userInfo, err2 := auth.GetUserInfo(token)
|
|
||||||
if err2 == nil {
|
|
||||||
if mobile = userInfo.GetAuthID(); mobile != "" {
|
|
||||||
if user, err := dao.GetUserByID(dao.GetDB(), "mobile", mobile); err == nil {
|
|
||||||
userID = user.UserID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return mobile, userID
|
return mobile, userID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,13 +448,13 @@ func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err e
|
|||||||
storeID := 0
|
storeID := 0
|
||||||
remark := ""
|
remark := ""
|
||||||
|
|
||||||
if !globals.DisableWXAuth1 {
|
// if !globals.DisableWXAuth1 {
|
||||||
wxinfo, err := dao.GetUserStoreInfo(db, "tel", mobile)
|
// wxinfo, err := dao.GetUserStoreInfo(db, "tel", mobile)
|
||||||
if err == nil {
|
// if err == nil {
|
||||||
openIDs = []string{wxinfo.OpenID}
|
// openIDs = []string{wxinfo.OpenID}
|
||||||
storeID = wxinfo.JxStoreID
|
// storeID = wxinfo.JxStoreID
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if globals.EnableWXAuth2 {
|
if globals.EnableWXAuth2 {
|
||||||
userID := ""
|
userID := ""
|
||||||
if mobileIsUerID {
|
if mobileIsUerID {
|
||||||
|
|||||||
@@ -89,33 +89,33 @@ var (
|
|||||||
func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) {
|
func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
openIDMap := make(map[string]int)
|
openIDMap := make(map[string]int)
|
||||||
if !globals.DisableWXAuth1 {
|
// if !globals.DisableWXAuth1 {
|
||||||
var openIDList []string
|
// var openIDList []string
|
||||||
sql := `
|
// sql := `
|
||||||
SELECT openid
|
// SELECT openid
|
||||||
FROM weixins t1
|
// FROM weixins t1
|
||||||
JOIN
|
// JOIN
|
||||||
(SELECT id
|
// (SELECT id
|
||||||
FROM weixins
|
// FROM weixins
|
||||||
WHERE jxstoreid = ? AND parentid = -1) t2 ON t2.id = t1.parentid
|
// WHERE jxstoreid = ? AND parentid = -1) t2 ON t2.id = t1.parentid
|
||||||
WHERE openid IS NOT NULL
|
// WHERE openid IS NOT NULL
|
||||||
UNION
|
// UNION
|
||||||
SELECT openid
|
// SELECT openid
|
||||||
FROM weixins
|
// FROM weixins
|
||||||
WHERE jxstoreid = ? AND parentid = -1 AND openid IS NOT NULL`
|
// WHERE jxstoreid = ? AND parentid = -1 AND openid IS NOT NULL`
|
||||||
sqlParams := []interface{}{
|
// sqlParams := []interface{}{
|
||||||
storeID,
|
// storeID,
|
||||||
storeID,
|
// storeID,
|
||||||
}
|
// }
|
||||||
err := dao.GetRows(db, &openIDList, sql, sqlParams...)
|
// err := dao.GetRows(db, &openIDList, sql, sqlParams...)
|
||||||
if err != nil || len(openIDList) == 0 {
|
// if err != nil || len(openIDList) == 0 {
|
||||||
globals.SugarLogger.Infof("GetWeixinOpenIDsFromStoreID can not find openid for store:%d, num:%d, error:%v", storeID, len(openIDList), err)
|
// globals.SugarLogger.Infof("GetWeixinOpenIDsFromStoreID can not find openid for store:%d, num:%d, error:%v", storeID, len(openIDList), err)
|
||||||
return retVal
|
// return retVal
|
||||||
}
|
// }
|
||||||
for _, v := range openIDList {
|
// for _, v := range openIDList {
|
||||||
openIDMap[v] = 1
|
// openIDMap[v] = 1
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if globals.EnableWXAuth2 {
|
if globals.EnableWXAuth2 {
|
||||||
if userIDList, err2 := api2.RoleMan.GetRoleUserList(autils.NewStoreBossRole(storeID)); err2 == nil {
|
if userIDList, err2 := api2.RoleMan.GetRoleUserList(autils.NewStoreBossRole(storeID)); err2 == nil {
|
||||||
for _, v := range userIDList {
|
for _, v := range userIDList {
|
||||||
|
|||||||
@@ -1,182 +1,111 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
// type StoreUserInfo struct {
|
||||||
"fmt"
|
// legacymodel.WeiXins
|
||||||
|
// ParentMobile string `json:"parentMobile"`
|
||||||
|
// Members []*legacymodel.WeiXins `orm:"-" json:"members"`
|
||||||
|
// MembersStr string `json:"-"`
|
||||||
|
// }
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
// func CreateWeiXins(db *DaoDB, user *legacymodel.WeiXins) (err error) {
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
// Begin(db)
|
||||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
// if err = CreateEntity(db, user); err != nil {
|
||||||
)
|
// Rollback(db)
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// if err = SetWeiXinsEmpty2Null(db, user); err != nil {
|
||||||
|
// Rollback(db)
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// Commit(db)
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
type StoreUserInfo struct {
|
// func SetWeiXinsEmpty2Null(db *DaoDB, user *legacymodel.WeiXins) (err error) {
|
||||||
legacymodel.WeiXins
|
// _, err = ExecuteSQL(db, `
|
||||||
ParentMobile string `json:"parentMobile"`
|
// UPDATE weixins
|
||||||
Members []*legacymodel.WeiXins `orm:"-" json:"members"`
|
// SET
|
||||||
MembersStr string `json:"-"`
|
// openid = IF(openid = '', NULL, openid),
|
||||||
}
|
// openid_mini = IF(openid_mini = '', NULL, openid_mini),
|
||||||
|
// openid_union = IF(openid_union = '', NULL, openid_union),
|
||||||
|
// tel = IF(tel = '', NULL, tel),
|
||||||
|
// parentid = IF(parentid = 0, -1, parentid)
|
||||||
|
// WHERE id = ?
|
||||||
|
// `, user.ID)
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
type StoreWithCityName struct {
|
// func GetWeiXinUserByIDs(db *DaoDB, tel, unionID, openID, miniOpenID string) (user *legacymodel.WeiXins, err error) {
|
||||||
model.Store
|
// fieldList := []string{
|
||||||
CityName string `json:"cityName"`
|
// "Tel",
|
||||||
}
|
// "OpenIDUnion",
|
||||||
|
// "OpenID",
|
||||||
|
// "OpenIDMini",
|
||||||
|
// }
|
||||||
|
// valueList := []string{
|
||||||
|
// tel,
|
||||||
|
// unionID,
|
||||||
|
// openID,
|
||||||
|
// miniOpenID,
|
||||||
|
// }
|
||||||
|
// user = &legacymodel.WeiXins{
|
||||||
|
// Tel: tel,
|
||||||
|
// OpenIDUnion: unionID,
|
||||||
|
// OpenID: openID,
|
||||||
|
// OpenIDMini: miniOpenID,
|
||||||
|
// }
|
||||||
|
// for index := range valueList {
|
||||||
|
// if valueList[index] != "" {
|
||||||
|
// if err = GetEntity(db, user, fieldList[index]); err == nil {
|
||||||
|
// return user, nil
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
|
||||||
func CreateWeiXins(db *DaoDB, user *legacymodel.WeiXins) (err error) {
|
// func UpdateWeiXinUser(db *DaoDB, tel, nickname, unionID, openID, miniOpenID string) (err error) {
|
||||||
Begin(db)
|
// user := &legacymodel.WeiXins{
|
||||||
if err = CreateEntity(db, user); err != nil {
|
// Tel: tel,
|
||||||
Rollback(db)
|
// }
|
||||||
return err
|
// if err = GetEntity(db, user, "Tel"); err == nil {
|
||||||
}
|
// updateFields := []string{}
|
||||||
if err = SetWeiXinsEmpty2Null(db, user); err != nil {
|
// if openID != "" {
|
||||||
Rollback(db)
|
// user.OpenID = openID
|
||||||
return err
|
// updateFields = append(updateFields, "OpenID")
|
||||||
}
|
// }
|
||||||
Commit(db)
|
// if unionID != "" {
|
||||||
return err
|
// user.OpenIDUnion = unionID
|
||||||
}
|
// updateFields = append(updateFields, "OpenIDUnion")
|
||||||
|
// }
|
||||||
|
// if miniOpenID != "" {
|
||||||
|
// user.OpenIDMini = miniOpenID
|
||||||
|
// updateFields = append(updateFields, "OpenIDMini")
|
||||||
|
// }
|
||||||
|
// if nickname != "" {
|
||||||
|
// user.NickName = nickname
|
||||||
|
// updateFields = append(updateFields, "NickName")
|
||||||
|
// }
|
||||||
|
// _, err = UpdateEntity(db, user, updateFields...)
|
||||||
|
// }
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
func SetWeiXinsEmpty2Null(db *DaoDB, user *legacymodel.WeiXins) (err error) {
|
// func GetUserStoreInfo(db *DaoDB, fieldName, fieldValue string) (storeUserInfo *StoreUserInfo, err error) {
|
||||||
_, err = ExecuteSQL(db, `
|
// sql := fmt.Sprintf(`
|
||||||
UPDATE weixins
|
// 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,
|
||||||
SET
|
// CONCAT("[", GROUP_CONCAT(CONCAT('{"id":', t2.id, ',"tel":"', t2.tel, '","nickname":"', IF(t2.nickname IS NULL, "", t2.nickname), '"}')), "]") members_str
|
||||||
openid = IF(openid = '', NULL, openid),
|
// FROM weixins t1
|
||||||
openid_mini = IF(openid_mini = '', NULL, openid_mini),
|
// LEFT JOIN weixins t2 ON t2.parentid = t1.id
|
||||||
openid_union = IF(openid_union = '', NULL, openid_union),
|
// LEFT JOIN weixins t3 ON t1.parentid = t3.id
|
||||||
tel = IF(tel = '', NULL, tel),
|
// WHERE t1.%s = ?
|
||||||
parentid = IF(parentid = 0, -1, parentid)
|
// GROUP BY 1,2,3,4,5,6,7;
|
||||||
WHERE id = ?
|
// `, fieldName)
|
||||||
`, user.ID)
|
// if err = GetRow(db, &storeUserInfo, sql, fieldValue); err == nil { // todo
|
||||||
return err
|
// err = nil
|
||||||
}
|
// if storeUserInfo.MembersStr != "" {
|
||||||
|
// err = utils.UnmarshalUseNumber([]byte(storeUserInfo.MembersStr), &storeUserInfo.Members)
|
||||||
func GetWeiXinUserByIDs(db *DaoDB, tel, unionID, openID, miniOpenID string) (user *legacymodel.WeiXins, err error) {
|
// }
|
||||||
fieldList := []string{
|
// }
|
||||||
"Tel",
|
// return storeUserInfo, err
|
||||||
"OpenIDUnion",
|
// }
|
||||||
"OpenID",
|
|
||||||
"OpenIDMini",
|
|
||||||
}
|
|
||||||
valueList := []string{
|
|
||||||
tel,
|
|
||||||
unionID,
|
|
||||||
openID,
|
|
||||||
miniOpenID,
|
|
||||||
}
|
|
||||||
user = &legacymodel.WeiXins{
|
|
||||||
Tel: tel,
|
|
||||||
OpenIDUnion: unionID,
|
|
||||||
OpenID: openID,
|
|
||||||
OpenIDMini: miniOpenID,
|
|
||||||
}
|
|
||||||
for index := range valueList {
|
|
||||||
if valueList[index] != "" {
|
|
||||||
if err = GetEntity(db, user, fieldList[index]); err == nil {
|
|
||||||
return user, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func UpdateWeiXinUser(db *DaoDB, tel, nickname, unionID, openID, miniOpenID string) (err error) {
|
|
||||||
user := &legacymodel.WeiXins{
|
|
||||||
Tel: tel,
|
|
||||||
}
|
|
||||||
if err = GetEntity(db, user, "Tel"); err == nil {
|
|
||||||
updateFields := []string{}
|
|
||||||
if openID != "" {
|
|
||||||
user.OpenID = openID
|
|
||||||
updateFields = append(updateFields, "OpenID")
|
|
||||||
}
|
|
||||||
if unionID != "" {
|
|
||||||
user.OpenIDUnion = unionID
|
|
||||||
updateFields = append(updateFields, "OpenIDUnion")
|
|
||||||
}
|
|
||||||
if miniOpenID != "" {
|
|
||||||
user.OpenIDMini = miniOpenID
|
|
||||||
updateFields = append(updateFields, "OpenIDMini")
|
|
||||||
}
|
|
||||||
if nickname != "" {
|
|
||||||
user.NickName = nickname
|
|
||||||
updateFields = append(updateFields, "NickName")
|
|
||||||
}
|
|
||||||
_, err = UpdateEntity(db, user, updateFields...)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUserStoreInfo(db *DaoDB, fieldName, fieldValue string) (storeUserInfo *StoreUserInfo, err error) {
|
|
||||||
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,
|
|
||||||
CONCAT("[", GROUP_CONCAT(CONCAT('{"id":', t2.id, ',"tel":"', t2.tel, '","nickname":"', IF(t2.nickname IS NULL, "", t2.nickname), '"}')), "]") members_str
|
|
||||||
FROM weixins t1
|
|
||||||
LEFT JOIN weixins t2 ON t2.parentid = t1.id
|
|
||||||
LEFT JOIN weixins t3 ON t1.parentid = t3.id
|
|
||||||
WHERE t1.%s = ?
|
|
||||||
GROUP BY 1,2,3,4,5,6,7;
|
|
||||||
`, fieldName)
|
|
||||||
if err = GetRow(db, &storeUserInfo, sql, fieldValue); err == nil { // todo
|
|
||||||
err = nil
|
|
||||||
if storeUserInfo.MembersStr != "" {
|
|
||||||
err = utils.UnmarshalUseNumber([]byte(storeUserInfo.MembersStr), &storeUserInfo.Members)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return storeUserInfo, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityName, err error) {
|
|
||||||
if mobile != "" {
|
|
||||||
sql := `
|
|
||||||
SELECT
|
|
||||||
DISTINCT t1.*, t2.name city_name
|
|
||||||
FROM (
|
|
||||||
SELECT *
|
|
||||||
FROM store t1
|
|
||||||
WHERE (t1.market_man_phone = ? OR t1.operator_phone = ?)
|
|
||||||
UNION DISTINCT
|
|
||||||
SELECT t1.*
|
|
||||||
FROM store t1
|
|
||||||
JOIN weixins t2 ON t2.jxstoreid = t1.id AND t2.parentid = -1
|
|
||||||
LEFT JOIN weixins t3 ON t3.parentid = t2.id
|
|
||||||
WHERE (t2.tel = ? OR t3.tel = ?)
|
|
||||||
) t1
|
|
||||||
LEFT JOIN place t2 ON t2.code = t1.city_code
|
|
||||||
WHERE t1.deleted_at = ?
|
|
||||||
ORDER BY t1.name`
|
|
||||||
sqlParams := []interface{}{
|
|
||||||
mobile,
|
|
||||||
mobile,
|
|
||||||
mobile,
|
|
||||||
mobile,
|
|
||||||
utils.DefaultTimeValue,
|
|
||||||
}
|
|
||||||
err = GetRows(db, &storeList, sql, sqlParams...)
|
|
||||||
}
|
|
||||||
return storeList, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList []string, storeIDs []int) (storeList []*StoreWithCityName, err error) {
|
|
||||||
sql := `
|
|
||||||
SELECT t1.*, t2.name city_name
|
|
||||||
FROM store t1
|
|
||||||
LEFT JOIN place t2 ON t2.code = t1.city_code
|
|
||||||
WHERE t1.deleted_at = ? AND ( 1 = 0`
|
|
||||||
sqlParams := []interface{}{
|
|
||||||
utils.DefaultTimeValue,
|
|
||||||
}
|
|
||||||
if mobile != "" {
|
|
||||||
sql += " OR t1.market_man_phone = ? OR t1.operator_phone = ?"
|
|
||||||
sqlParams = append(sqlParams, mobile, mobile)
|
|
||||||
}
|
|
||||||
if len(shortRoleNameList) > 0 {
|
|
||||||
questionMarks := GenQuestionMarks(len(shortRoleNameList))
|
|
||||||
sql += " OR t1.market_man_role IN (" + questionMarks + ") OR t1.operator_role IN (" + questionMarks + ") OR t1.operator_role2 IN (" + questionMarks + ")"
|
|
||||||
sqlParams = append(sqlParams, shortRoleNameList, shortRoleNameList, shortRoleNameList)
|
|
||||||
}
|
|
||||||
if len(storeIDs) > 0 {
|
|
||||||
sql += " OR t1.id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
|
||||||
sqlParams = append(sqlParams, storeIDs)
|
|
||||||
}
|
|
||||||
sql += ")"
|
|
||||||
err = GetRows(db, &storeList, sql, sqlParams...)
|
|
||||||
return storeList, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type StoreWithCityName struct {
|
||||||
|
model.Store
|
||||||
|
CityName string `json:"cityName"`
|
||||||
|
}
|
||||||
|
|
||||||
func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err error) {
|
func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err error) {
|
||||||
sql := fmt.Sprintf(`
|
sql := fmt.Sprintf(`
|
||||||
SELECT *
|
SELECT *
|
||||||
@@ -85,3 +90,61 @@ func DeleteUsers(db *DaoDB, userIDs []string) (num int64, err error) {
|
|||||||
}
|
}
|
||||||
return num, err
|
return num, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityName, err error) {
|
||||||
|
if mobile != "" {
|
||||||
|
sql := `
|
||||||
|
SELECT
|
||||||
|
DISTINCT t1.*, t2.name city_name
|
||||||
|
FROM (
|
||||||
|
SELECT *
|
||||||
|
FROM store t1
|
||||||
|
WHERE (t1.market_man_phone = ? OR t1.operator_phone = ?)
|
||||||
|
UNION DISTINCT
|
||||||
|
SELECT t1.*
|
||||||
|
FROM store t1
|
||||||
|
JOIN weixins t2 ON t2.jxstoreid = t1.id AND t2.parentid = -1
|
||||||
|
LEFT JOIN weixins t3 ON t3.parentid = t2.id
|
||||||
|
WHERE (t2.tel = ? OR t3.tel = ?)
|
||||||
|
) t1
|
||||||
|
LEFT JOIN place t2 ON t2.code = t1.city_code
|
||||||
|
WHERE t1.deleted_at = ?
|
||||||
|
ORDER BY t1.name`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
mobile,
|
||||||
|
mobile,
|
||||||
|
mobile,
|
||||||
|
mobile,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
err = GetRows(db, &storeList, sql, sqlParams...)
|
||||||
|
}
|
||||||
|
return storeList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList []string, storeIDs []int) (storeList []*StoreWithCityName, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT t1.*, t2.name city_name
|
||||||
|
FROM store t1
|
||||||
|
LEFT JOIN place t2 ON t2.code = t1.city_code
|
||||||
|
WHERE t1.deleted_at = ? AND ( 1 = 0`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if mobile != "" {
|
||||||
|
sql += " OR t1.market_man_phone = ? OR t1.operator_phone = ?"
|
||||||
|
sqlParams = append(sqlParams, mobile, mobile)
|
||||||
|
}
|
||||||
|
if len(shortRoleNameList) > 0 {
|
||||||
|
questionMarks := GenQuestionMarks(len(shortRoleNameList))
|
||||||
|
sql += " OR t1.market_man_role IN (" + questionMarks + ") OR t1.operator_role IN (" + questionMarks + ") OR t1.operator_role2 IN (" + questionMarks + ")"
|
||||||
|
sqlParams = append(sqlParams, shortRoleNameList, shortRoleNameList, shortRoleNameList)
|
||||||
|
}
|
||||||
|
if len(storeIDs) > 0 {
|
||||||
|
sql += " OR t1.id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
|
}
|
||||||
|
sql += ")"
|
||||||
|
err = GetRows(db, &storeList, sql, sqlParams...)
|
||||||
|
return storeList, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,41 +1,33 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
// func TestCreateWeiXins(t *testing.T) {
|
||||||
"testing"
|
// err := CreateWeiXins(GetDB(), &legacymodel.WeiXins{
|
||||||
|
// Tel: "12345",
|
||||||
|
// })
|
||||||
|
// if err != nil {
|
||||||
|
// t.Fatal(err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
// func TestGetWeiXinUserByIDs(t *testing.T) {
|
||||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
// user, err := GetWeiXinUserByIDs(GetDB(), "", "unionid", "", "")
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
// if err != nil {
|
||||||
)
|
// t.Fatal(err)
|
||||||
|
// }
|
||||||
|
// globals.SugarLogger.Debug(utils.Format4Output(user, false))
|
||||||
|
// }
|
||||||
|
|
||||||
func TestCreateWeiXins(t *testing.T) {
|
// func TestUpdateWeiXinUser(t *testing.T) {
|
||||||
err := CreateWeiXins(GetDB(), &legacymodel.WeiXins{
|
// err := UpdateWeiXinUser(GetDB(), "12345", "nickname", "unionid", "openid", "miniid")
|
||||||
Tel: "12345",
|
// if err != nil {
|
||||||
})
|
// t.Fatal(err)
|
||||||
if err != nil {
|
// }
|
||||||
t.Fatal(err)
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetWeiXinUserByIDs(t *testing.T) {
|
// func TestGetUserStoreInfo(t *testing.T) {
|
||||||
user, err := GetWeiXinUserByIDs(GetDB(), "", "unionid", "", "")
|
// user, err := GetUserStoreInfo(GetDB(), "tel", "18180948107")
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(user, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(user, false))
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestUpdateWeiXinUser(t *testing.T) {
|
|
||||||
err := UpdateWeiXinUser(GetDB(), "12345", "nickname", "unionid", "openid", "miniid")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetUserStoreInfo(t *testing.T) {
|
|
||||||
user, err := GetUserStoreInfo(GetDB(), "tel", "18180948107")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(user, false))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||||
@@ -11,12 +12,28 @@ import (
|
|||||||
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile" // 强制导入mobile认证方式
|
_ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile" // 强制导入mobile认证方式
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetComposedCode(c *beego.Controller, code string) (composedCode string) {
|
||||||
|
composedCode = code
|
||||||
|
referer := c.Ctx.Request.Referer()
|
||||||
|
globals.SugarLogger.Debugf("GetComposedCode referer:%s", referer)
|
||||||
|
index := strings.Index(referer, "//")
|
||||||
|
if index > 0 {
|
||||||
|
list := strings.Split(referer[index+2:], "/")
|
||||||
|
if len(list) >= 2 {
|
||||||
|
composedCode = strings.Join([]string{
|
||||||
|
list[1],
|
||||||
|
code,
|
||||||
|
}, ",")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return composedCode
|
||||||
|
}
|
||||||
|
|
||||||
type Auth2Controller struct {
|
type Auth2Controller struct {
|
||||||
beego.Controller
|
beego.Controller
|
||||||
}
|
}
|
||||||
@@ -84,10 +101,10 @@ func (c *Auth2Controller) Login() {
|
|||||||
// @router /GetTokenInfo [get]
|
// @router /GetTokenInfo [get]
|
||||||
func (c *Auth2Controller) GetTokenInfo() {
|
func (c *Auth2Controller) GetTokenInfo() {
|
||||||
c.callGetTokenInfo(func(params *tAuth2GetTokenInfoParams) (retVal interface{}, errCode string, err error) {
|
c.callGetTokenInfo(func(params *tAuth2GetTokenInfoParams) (retVal interface{}, errCode string, err error) {
|
||||||
if auth2.IsV2Token(params.Token) {
|
if true { //auth2.IsV2Token(params.Token) {
|
||||||
retVal, err = auth2.GetTokenInfo(params.Token)
|
retVal, err = auth2.GetTokenInfo(params.Token)
|
||||||
} else {
|
} else {
|
||||||
retVal, err = auth.GetUserInfo(params.Token)
|
// retVal, err = auth.GetUserInfo(params.Token)
|
||||||
}
|
}
|
||||||
if err == model.ErrTokenIsInvalid {
|
if err == model.ErrTokenIsInvalid {
|
||||||
errCode = model.ErrCodeTokenIsInvalid
|
errCode = model.ErrCodeTokenIsInvalid
|
||||||
@@ -214,7 +231,7 @@ func (c *Auth2Controller) Logout() {
|
|||||||
if authInfo, ok := params.Ctx.GetLoginInfo().(*auth2.AuthInfo); ok {
|
if authInfo, ok := params.Ctx.GetLoginInfo().(*auth2.AuthInfo); ok {
|
||||||
err = auth2.Logout(authInfo)
|
err = auth2.Logout(authInfo)
|
||||||
} else {
|
} else {
|
||||||
err = auth.Logout(params.Token)
|
// err = auth.Logout(params.Token)
|
||||||
}
|
}
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,238 +1,205 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
// type WeixinCallbackResult struct {
|
||||||
"encoding/base64"
|
// Code int `json:"code"`
|
||||||
"fmt"
|
// Msg string `json:"msg"`
|
||||||
"net/http"
|
// Data interface{} `json:"data"`
|
||||||
"strings"
|
// }
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
// // 认证相关API
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
// type AuthController struct {
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
|
// beego.Controller
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/weixin"
|
// }
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"github.com/astaxie/beego"
|
|
||||||
)
|
|
||||||
|
|
||||||
type WeixinCallbackResult struct {
|
// var (
|
||||||
Code int `json:"code"`
|
// ErrParameterIsIllegal = "参数不全或不合法"
|
||||||
Msg string `json:"msg"`
|
// )
|
||||||
Data interface{} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 认证相关API
|
// // @Title 给微信用的回调接口
|
||||||
type AuthController struct {
|
// // @Description 给微信用的回调接口,自己不能直接调用
|
||||||
beego.Controller
|
// // @Param code query string true "客户同意后得到的code"
|
||||||
}
|
// // @Param block query string true "回调地址"
|
||||||
|
// // @Param state query string false "微信回调的登录状态"
|
||||||
|
// // @Success 200 {object} controllers.CallResult
|
||||||
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
|
// // @router /GetWeiXinUserInfo [get]
|
||||||
|
// func (c *AuthController) GetWeiXinUserInfo() {
|
||||||
|
// retVal := &WeixinCallbackResult{}
|
||||||
|
// var err error
|
||||||
|
// code := c.GetString("code")
|
||||||
|
// block := c.GetString("block")
|
||||||
|
// state := c.GetString("state")
|
||||||
|
// if block != "" {
|
||||||
|
// if code != "" {
|
||||||
|
// result, err2 := weixin.GetWeiXinUserInfo(code, state)
|
||||||
|
// if err = err2; err == nil {
|
||||||
|
// retVal.Code = 1
|
||||||
|
// retVal.Msg = "微信登录成功"
|
||||||
|
// retVal.Data = result
|
||||||
|
// } else {
|
||||||
|
// retVal.Msg = err.Error()
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// retVal.Msg = "code为空"
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// retVal.Msg = "没有block"
|
||||||
|
// }
|
||||||
|
// redirectURL := fmt.Sprintf("%s?info=%s", block, base64.StdEncoding.EncodeToString(utils.MustMarshal(retVal)))
|
||||||
|
// globals.SugarLogger.Debugf("auth GetWeiXinUserInfo retVal:%s, redirectURL:%s", utils.Format4Output(retVal, true), redirectURL)
|
||||||
|
// c.Redirect(redirectURL, http.StatusTemporaryRedirect)
|
||||||
|
// }
|
||||||
|
|
||||||
var (
|
// // @Title 登录接口
|
||||||
ErrParameterIsIllegal = "参数不全或不合法"
|
// // @Description 登录接口
|
||||||
)
|
// // @Param id formData string false "登录ID"
|
||||||
|
// // @Param type formData string true "登录类型,当前支持[weixinsns:微信公众号登录,localpass:本地账号密码,mobile:手机短信,weixinmini;小程序code登录]"
|
||||||
|
// // @Param secret formData string true "不同登录类型的登录秘密"
|
||||||
|
// // @Success 200 {object} controllers.CallResult
|
||||||
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
|
// // @router /Login [post]
|
||||||
|
// func (c *AuthController) Login() {
|
||||||
|
// c.callLogin(func(params *tAuthLoginParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
// if params.Type == weixin.LoginTypeMiniProgram {
|
||||||
|
// params.Secret = GetComposedCode(&c.Controller, params.Secret)
|
||||||
|
// }
|
||||||
|
// retVal, err = auth.Login(params.Id, params.Type, params.Secret)
|
||||||
|
// if err == auth.ErrUserNotExist {
|
||||||
|
// return retVal, model.ErrCodeUserNotExist, err
|
||||||
|
// }
|
||||||
|
// return retVal, "", err
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
// @Title 给微信用的回调接口
|
// // @Title 登出接口
|
||||||
// @Description 给微信用的回调接口,自己不能直接调用
|
// // @Description 登出接口
|
||||||
// @Param code query string true "客户同意后得到的code"
|
// // @Param token header string true "认证token"
|
||||||
// @Param block query string true "回调地址"
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Param state query string false "微信回调的登录状态"
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @router /Logout [delete]
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// func (c *AuthController) Logout() {
|
||||||
// @router /GetWeiXinUserInfo [get]
|
// c.callLogout(func(params *tAuthLogoutParams) (retVal interface{}, errCode string, err error) {
|
||||||
func (c *AuthController) GetWeiXinUserInfo() {
|
// err = auth.Logout(params.Token)
|
||||||
retVal := &WeixinCallbackResult{}
|
// globals.SugarLogger.Debug(err)
|
||||||
var err error
|
// return nil, "", err
|
||||||
code := c.GetString("code")
|
// })
|
||||||
block := c.GetString("block")
|
// }
|
||||||
state := c.GetString("state")
|
|
||||||
if block != "" {
|
|
||||||
if code != "" {
|
|
||||||
result, err2 := weixin.GetWeiXinUserInfo(code, state)
|
|
||||||
if err = err2; err == nil {
|
|
||||||
retVal.Code = 1
|
|
||||||
retVal.Msg = "微信登录成功"
|
|
||||||
retVal.Data = result
|
|
||||||
} else {
|
|
||||||
retVal.Msg = err.Error()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
retVal.Msg = "code为空"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
retVal.Msg = "没有block"
|
|
||||||
}
|
|
||||||
redirectURL := fmt.Sprintf("%s?info=%s", block, base64.StdEncoding.EncodeToString(utils.MustMarshal(retVal)))
|
|
||||||
globals.SugarLogger.Debugf("auth GetWeiXinUserInfo retVal:%s, redirectURL:%s", utils.Format4Output(retVal, true), redirectURL)
|
|
||||||
c.Redirect(redirectURL, http.StatusTemporaryRedirect)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 登录接口
|
// // @Title 得到用户信息
|
||||||
// @Description 登录接口
|
// // @Description 得到用户信息(从token中)
|
||||||
// @Param id formData string false "登录ID"
|
// // @Param token header string true "认证token"
|
||||||
// @Param type formData string true "登录类型,当前支持[weixinsns:微信公众号登录,localpass:本地账号密码,mobile:手机短信,weixinmini;小程序code登录]"
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Param secret formData string true "不同登录类型的登录秘密"
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @router /GetUserInfo [get]
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// func (c *AuthController) GetUserInfo() {
|
||||||
// @router /Login [post]
|
// c.callGetUserInfo(func(params *tAuthGetUserInfoParams) (retVal interface{}, errCode string, err error) {
|
||||||
func (c *AuthController) Login() {
|
// retVal, err = auth.GetUserInfo(params.Token)
|
||||||
c.callLogin(func(params *tAuthLoginParams) (retVal interface{}, errCode string, err error) {
|
// return retVal, "", err
|
||||||
if params.Type == weixin.LoginTypeMiniProgram {
|
// })
|
||||||
params.Secret = GetComposedCode(&c.Controller, params.Secret)
|
// }
|
||||||
}
|
|
||||||
retVal, err = auth.Login(params.Id, params.Type, params.Secret)
|
|
||||||
if err == auth.ErrUserNotExist {
|
|
||||||
return retVal, model.ErrCodeUserNotExist, err
|
|
||||||
}
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 登出接口
|
// // @Title 发送验证码
|
||||||
// @Description 登出接口
|
// // @Description 发送验证码
|
||||||
// @Param token header string true "认证token"
|
// // @Param mobile formData string true "手机号"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @router /Logout [delete]
|
// // @router /SendMobileVerifyCode [post]
|
||||||
func (c *AuthController) Logout() {
|
// func (c *AuthController) SendMobileVerifyCode() {
|
||||||
c.callLogout(func(params *tAuthLogoutParams) (retVal interface{}, errCode string, err error) {
|
// c.callSendMobileVerifyCode(func(params *tAuthSendMobileVerifyCodeParams) (retVal interface{}, errCode string, err error) {
|
||||||
err = auth.Logout(params.Token)
|
// err = mobile.SendVerifyCode(params.Mobile)
|
||||||
globals.SugarLogger.Debug(err)
|
// return retVal, "", err
|
||||||
return nil, "", err
|
// })
|
||||||
})
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 得到用户信息
|
// // @Title 绑定手机
|
||||||
// @Description 得到用户信息(从token中)
|
// // @Description 绑定手机,待删除
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Param mobile formData string true "手机号"
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Param code formData string true "验证码"
|
||||||
// @router /GetUserInfo [get]
|
// // @Param nickname formData string false "用户名"
|
||||||
func (c *AuthController) GetUserInfo() {
|
// // @Success 200 {object} controllers.CallResult
|
||||||
c.callGetUserInfo(func(params *tAuthGetUserInfoParams) (retVal interface{}, errCode string, err error) {
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
retVal, err = auth.GetUserInfo(params.Token)
|
// // @router /BindMobile [post]
|
||||||
return retVal, "", err
|
// func (c *AuthController) BindMobile() {
|
||||||
})
|
// c.callBindMobile(func(params *tAuthBindMobileParams) (retVal interface{}, errCode string, err error) {
|
||||||
}
|
// err = weixin.BindMobile(params.Token, params.Mobile, params.Code, params.Nickname)
|
||||||
|
// if err == auth.ErrUserNotExist {
|
||||||
|
// return retVal, model.ErrCodeUserNotExist, err
|
||||||
|
// }
|
||||||
|
// return retVal, "", err
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
// @Title 发送验证码
|
// // @Title 微信公众号绑定手机2
|
||||||
// @Description 发送验证码
|
// // @Description 微信公众号绑定手机2
|
||||||
// @Param mobile formData string true "手机号"
|
// // @Param openID formData string true "微信公众号ID"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Param secret formData string true "后台之前返回的secret"
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Param nickname formData string false "用户名"
|
||||||
// @router /SendMobileVerifyCode [post]
|
// // @Param mobile formData string true "手机号"
|
||||||
func (c *AuthController) SendMobileVerifyCode() {
|
// // @Param verifyCode formData string true "手机验证码"
|
||||||
c.callSendMobileVerifyCode(func(params *tAuthSendMobileVerifyCodeParams) (retVal interface{}, errCode string, err error) {
|
// // @Success 200 {object} controllers.CallResult
|
||||||
err = mobile.SendVerifyCode(params.Mobile)
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
return retVal, "", err
|
// // @router /BindMobile2 [post]
|
||||||
})
|
// func (c *AuthController) BindMobile2() {
|
||||||
}
|
// c.callBindMobile2(func(params *tAuthBindMobile2Params) (retVal interface{}, errCode string, err error) {
|
||||||
|
// if retVal, err = weixin.BindMobile2(params.OpenID, params.Secret, params.Mobile, params.VerifyCode, params.Nickname); err == nil {
|
||||||
|
// cms.TransferLegacyWeixins(params.Mobile)
|
||||||
|
// } else if err == auth.ErrUserNotExist {
|
||||||
|
// return retVal, model.ErrCodeUserNotExist, err
|
||||||
|
// }
|
||||||
|
// return retVal, "", err
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
// @Title 绑定手机
|
// // @Title 绑定手机
|
||||||
// @Description 绑定手机,待删除
|
// // @Description 绑定手机(调用此方法前先需要以短信方式登录),待删除
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param mobile formData string true "手机号"
|
// // @Param code formData string true "小程序用户code"
|
||||||
// @Param code formData string true "验证码"
|
// // @Param nickname formData string false "用户名"
|
||||||
// @Param nickname formData string false "用户名"
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @router /MiniBindWeiXin [post]
|
||||||
// @router /BindMobile [post]
|
// func (c *AuthController) MiniBindWeiXin() {
|
||||||
func (c *AuthController) BindMobile() {
|
// c.callMiniBindWeiXin(func(params *tAuthMiniBindWeiXinParams) (retVal interface{}, errCode string, err error) {
|
||||||
c.callBindMobile(func(params *tAuthBindMobileParams) (retVal interface{}, errCode string, err error) {
|
// err = weixin.AutherMini.BindWeiXin(params.Ctx, GetComposedCode(&c.Controller, params.Code), params.Nickname)
|
||||||
err = weixin.BindMobile(params.Token, params.Mobile, params.Code, params.Nickname)
|
// if err == auth.ErrUserNotExist {
|
||||||
if err == auth.ErrUserNotExist {
|
// return retVal, model.ErrCodeUserNotExist, err
|
||||||
return retVal, model.ErrCodeUserNotExist, err
|
// }
|
||||||
}
|
// return retVal, "", err
|
||||||
return retVal, "", err
|
// })
|
||||||
})
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 微信公众号绑定手机2
|
// // @Title 绑定小程序
|
||||||
// @Description 微信公众号绑定手机2
|
// // @Description 绑定小程序
|
||||||
// @Param openID formData string true "微信公众号ID"
|
// // @Param token header string true "认证token"
|
||||||
// @Param secret formData string true "后台之前返回的secret"
|
// // @Param code formData string true "小程序用户code"
|
||||||
// @Param nickname formData string false "用户名"
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Param mobile formData string true "手机号"
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @Param verifyCode formData string true "手机验证码"
|
// // @router /BindMiniProgram [post]
|
||||||
// @Success 200 {object} controllers.CallResult
|
// func (c *AuthController) BindMiniProgram() {
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// c.callBindMiniProgram(func(params *tAuthBindMiniProgramParams) (retVal interface{}, errCode string, err error) {
|
||||||
// @router /BindMobile2 [post]
|
// err = weixin.AutherMini.BindMiniProgram(params.Ctx, GetComposedCode(&c.Controller, params.Code))
|
||||||
func (c *AuthController) BindMobile2() {
|
// if err == nil {
|
||||||
c.callBindMobile2(func(params *tAuthBindMobile2Params) (retVal interface{}, errCode string, err error) {
|
// cms.TransferLegacyWeixins(params.Ctx.GetLoginID())
|
||||||
if retVal, err = weixin.BindMobile2(params.OpenID, params.Secret, params.Mobile, params.VerifyCode, params.Nickname); err == nil {
|
// }
|
||||||
cms.TransferLegacyWeixins(params.Mobile)
|
// if err == auth.ErrUserNotExist {
|
||||||
} else if err == auth.ErrUserNotExist {
|
// return retVal, model.ErrCodeUserNotExist, err
|
||||||
return retVal, model.ErrCodeUserNotExist, err
|
// }
|
||||||
}
|
// return retVal, "", err
|
||||||
return retVal, "", err
|
// })
|
||||||
})
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 绑定手机
|
// // @Title 解密小程序数据
|
||||||
// @Description 绑定手机(调用此方法前先需要以短信方式登录),待删除
|
// // @Description 解密小程序数据
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param code formData string true "小程序用户code"
|
// // @Param data formData string true "加密数据"
|
||||||
// @Param nickname formData string false "用户名"
|
// // @Param iv formData string true "iv"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @router /MiniBindWeiXin [post]
|
// // @router /MiniDecryptData [post]
|
||||||
func (c *AuthController) MiniBindWeiXin() {
|
// func (c *AuthController) MiniDecryptData() {
|
||||||
c.callMiniBindWeiXin(func(params *tAuthMiniBindWeiXinParams) (retVal interface{}, errCode string, err error) {
|
// c.callMiniDecryptData(func(params *tAuthMiniDecryptDataParams) (retVal interface{}, errCode string, err error) {
|
||||||
err = weixin.AutherMini.BindWeiXin(params.Ctx, GetComposedCode(&c.Controller, params.Code), params.Nickname)
|
// retVal, err = weixin.AutherMini.DecryptData(params.Ctx, params.Data, params.Iv)
|
||||||
if err == auth.ErrUserNotExist {
|
// return retVal, "", err
|
||||||
return retVal, model.ErrCodeUserNotExist, err
|
// })
|
||||||
}
|
// }
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 绑定小程序
|
|
||||||
// @Description 绑定小程序
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param code formData string true "小程序用户code"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /BindMiniProgram [post]
|
|
||||||
func (c *AuthController) BindMiniProgram() {
|
|
||||||
c.callBindMiniProgram(func(params *tAuthBindMiniProgramParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
err = weixin.AutherMini.BindMiniProgram(params.Ctx, GetComposedCode(&c.Controller, params.Code))
|
|
||||||
if err == nil {
|
|
||||||
cms.TransferLegacyWeixins(params.Ctx.GetLoginID())
|
|
||||||
}
|
|
||||||
if err == auth.ErrUserNotExist {
|
|
||||||
return retVal, model.ErrCodeUserNotExist, err
|
|
||||||
}
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 解密小程序数据
|
|
||||||
// @Description 解密小程序数据
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param data formData string true "加密数据"
|
|
||||||
// @Param iv formData string true "iv"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /MiniDecryptData [post]
|
|
||||||
func (c *AuthController) MiniDecryptData() {
|
|
||||||
c.callMiniDecryptData(func(params *tAuthMiniDecryptDataParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
retVal, err = weixin.AutherMini.DecryptData(params.Ctx, params.Data, params.Iv)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetComposedCode(c *beego.Controller, code string) (composedCode string) {
|
|
||||||
composedCode = code
|
|
||||||
referer := c.Ctx.Request.Referer()
|
|
||||||
globals.SugarLogger.Debugf("GetComposedCode referer:%s", referer)
|
|
||||||
index := strings.Index(referer, "//")
|
|
||||||
if index > 0 {
|
|
||||||
list := strings.Split(referer[index+2:], "/")
|
|
||||||
if len(list) >= 2 {
|
|
||||||
composedCode = strings.Join([]string{
|
|
||||||
list[1],
|
|
||||||
code,
|
|
||||||
}, ",")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return composedCode
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,123 +1,118 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
// type UserController struct {
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
// beego.Controller
|
||||||
"github.com/astaxie/beego"
|
// }
|
||||||
)
|
|
||||||
|
|
||||||
type UserController struct {
|
// // @Title 得到门店用户信息
|
||||||
beego.Controller
|
// // @Description 得到门店用户信息
|
||||||
}
|
// // @Param token header string true "认证token"
|
||||||
|
// // @Param storeID query int true "门店号"
|
||||||
|
// // @Success 200 {object} controllers.CallResult
|
||||||
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
|
// // @router /TmpGetStoreUsers [get]
|
||||||
|
// func (c *UserController) TmpGetStoreUsers() {
|
||||||
|
// c.callTmpGetStoreUsers(func(params *tUserTmpGetStoreUsersParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
// retVal, err = cms.GetStoreUsers(params.Ctx, params.StoreID)
|
||||||
|
// return retVal, "", err
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
// @Title 得到门店用户信息
|
// // @Title 得到用户门店及成员信息
|
||||||
// @Description 得到门店用户信息
|
// // @Description 得到用户门店及成员信息
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param storeID query int true "门店号"
|
// // @Param mobile query string true "手机号"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @router /TmpGetStoreUsers [get]
|
// // @router /TmpGetUserInfo [get]
|
||||||
func (c *UserController) TmpGetStoreUsers() {
|
// func (c *UserController) TmpGetUserInfo() {
|
||||||
c.callTmpGetStoreUsers(func(params *tUserTmpGetStoreUsersParams) (retVal interface{}, errCode string, err error) {
|
// c.callTmpGetUserInfo(func(params *tUserTmpGetUserInfoParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = cms.GetStoreUsers(params.Ctx, params.StoreID)
|
// retVal, err = cms.GetUserInfo(params.Ctx, params.Mobile)
|
||||||
return retVal, "", err
|
// return retVal, "", err
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Title 得到用户门店及成员信息
|
// // @Title 得到用户自己的门店及成员信息
|
||||||
// @Description 得到用户门店及成员信息
|
// // @Description 得到用户自己的门店及成员信息
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param mobile query string true "手机号"
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @router /TmpGetSelfInfo [get]
|
||||||
// @router /TmpGetUserInfo [get]
|
// func (c *UserController) TmpGetSelfInfo() {
|
||||||
func (c *UserController) TmpGetUserInfo() {
|
// c.callTmpGetSelfInfo(func(params *tUserTmpGetSelfInfoParams) (retVal interface{}, errCode string, err error) {
|
||||||
c.callTmpGetUserInfo(func(params *tUserTmpGetUserInfoParams) (retVal interface{}, errCode string, err error) {
|
// retVal, err = cms.GetSelfInfo(params.Ctx)
|
||||||
retVal, err = cms.GetUserInfo(params.Ctx, params.Mobile)
|
// return retVal, "", err
|
||||||
return retVal, "", err
|
// })
|
||||||
})
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 得到用户自己的门店及成员信息
|
// // @Title 得到用户自己的门店列表
|
||||||
// @Description 得到用户自己的门店及成员信息
|
// // @Description 得到用户自己的门店列表
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @router /TmpGetSelfInfo [get]
|
// // @router /TmpGetMyStoreList [get]
|
||||||
func (c *UserController) TmpGetSelfInfo() {
|
// func (c *UserController) TmpGetMyStoreList() {
|
||||||
c.callTmpGetSelfInfo(func(params *tUserTmpGetSelfInfoParams) (retVal interface{}, errCode string, err error) {
|
// c.callTmpGetSelfInfo(func(params *tUserTmpGetSelfInfoParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = cms.GetSelfInfo(params.Ctx)
|
// retVal, err = cms.GetMyStoreList(params.Ctx)
|
||||||
return retVal, "", err
|
// return retVal, "", err
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Title 得到用户自己的门店列表
|
// // @Title 取消手机门店绑定
|
||||||
// @Description 得到用户自己的门店列表
|
// // @Description 此操作会将此手机关联的所有门店信息清除(取消组长,取消自己为他组组员),如果此人为组长,取消后组员也相应会取消门店绑定(但组员的成员关系还在)
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Param mobile formData string true "手机号"
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @router /TmpGetMyStoreList [get]
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
func (c *UserController) TmpGetMyStoreList() {
|
// // @router /TmpUnbindMobile [put]
|
||||||
c.callTmpGetSelfInfo(func(params *tUserTmpGetSelfInfoParams) (retVal interface{}, errCode string, err error) {
|
// func (c *UserController) TmpUnbindMobile() {
|
||||||
retVal, err = cms.GetMyStoreList(params.Ctx)
|
// c.callTmpUnbindMobile(func(params *tUserTmpUnbindMobileParams) (retVal interface{}, errCode string, err error) {
|
||||||
return retVal, "", err
|
// retVal, err = cms.UnbindMobile(params.Ctx, params.Mobile)
|
||||||
})
|
// return retVal, "", err
|
||||||
}
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
// @Title 取消手机门店绑定
|
// // @Title 手机门店绑定
|
||||||
// @Description 此操作会将此手机关联的所有门店信息清除(取消组长,取消自己为他组组员),如果此人为组长,取消后组员也相应会取消门店绑定(但组员的成员关系还在)
|
// // @Description 此操作会将此手机设置成为相应门的组长,如果之前有组员关系,则此操作后,组员也会自动与门店绑定
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param mobile formData string true "手机号"
|
// // @Param mobile formData string true "手机号"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Param storeID formData int true "门店ID"
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @router /TmpUnbindMobile [put]
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
func (c *UserController) TmpUnbindMobile() {
|
// // @router /TmpBindMobile2Store [put]
|
||||||
c.callTmpUnbindMobile(func(params *tUserTmpUnbindMobileParams) (retVal interface{}, errCode string, err error) {
|
// func (c *UserController) TmpBindMobile2Store() {
|
||||||
retVal, err = cms.UnbindMobile(params.Ctx, params.Mobile)
|
// c.callTmpBindMobile2Store(func(params *tUserTmpBindMobile2StoreParams) (retVal interface{}, errCode string, err error) {
|
||||||
return retVal, "", err
|
// retVal, err = cms.BindMobile2Store(params.Ctx, params.Mobile, params.StoreID)
|
||||||
})
|
// return retVal, "", err
|
||||||
}
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
// @Title 手机门店绑定
|
// // @Title 将手机加到另一手机上
|
||||||
// @Description 此操作会将此手机设置成为相应门的组长,如果之前有组员关系,则此操作后,组员也会自动与门店绑定
|
// // @Description 将手机加到另一手机上
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param mobile formData string true "手机号"
|
// // @Param parentMobile formData string true "父手机号"
|
||||||
// @Param storeID formData int true "门店ID"
|
// // @Param mobile formData string true "手机号"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @router /TmpBindMobile2Store [put]
|
// // @router /TmpAddMobile2Mobile [put]
|
||||||
func (c *UserController) TmpBindMobile2Store() {
|
// func (c *UserController) TmpAddMobile2Mobile() {
|
||||||
c.callTmpBindMobile2Store(func(params *tUserTmpBindMobile2StoreParams) (retVal interface{}, errCode string, err error) {
|
// c.callTmpAddMobile2Mobile(func(params *tUserTmpAddMobile2MobileParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = cms.BindMobile2Store(params.Ctx, params.Mobile, params.StoreID)
|
// retVal, err = cms.AddMobile2Mobile(params.Ctx, params.ParentMobile, params.Mobile)
|
||||||
return retVal, "", err
|
// return retVal, "", err
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Title 将手机加到另一手机上
|
// // @Title 变更手机号
|
||||||
// @Description 将手机加到另一手机上
|
// // @Description 变更手机号
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param parentMobile formData string true "父手机号"
|
// // @Param curMobile formData string true "当前手机号"
|
||||||
// @Param mobile formData string true "手机号"
|
// // @Param expectedMobile formData string true "手机号"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @router /TmpAddMobile2Mobile [put]
|
// // @router /TmpChangeMobile [put]
|
||||||
func (c *UserController) TmpAddMobile2Mobile() {
|
// func (c *UserController) TmpChangeMobile() {
|
||||||
c.callTmpAddMobile2Mobile(func(params *tUserTmpAddMobile2MobileParams) (retVal interface{}, errCode string, err error) {
|
// c.callTmpChangeMobile(func(params *tUserTmpChangeMobileParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = cms.AddMobile2Mobile(params.Ctx, params.ParentMobile, params.Mobile)
|
// retVal, err = cms.ChangeMobile(params.Ctx, params.CurMobile, params.ExpectedMobile)
|
||||||
return retVal, "", err
|
// return retVal, "", err
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Title 变更手机号
|
|
||||||
// @Description 变更手机号
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param curMobile formData string true "当前手机号"
|
|
||||||
// @Param expectedMobile formData string true "手机号"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /TmpChangeMobile [put]
|
|
||||||
func (c *UserController) TmpChangeMobile() {
|
|
||||||
c.callTmpChangeMobile(func(params *tUserTmpChangeMobileParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
retVal, err = cms.ChangeMobile(params.Ctx, params.CurMobile, params.ExpectedMobile)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ func Init() {
|
|||||||
orm.RegisterModel(new(legacymodel.BlackClient))
|
orm.RegisterModel(new(legacymodel.BlackClient))
|
||||||
orm.RegisterModel(new(legacymodel.JxBadComments))
|
orm.RegisterModel(new(legacymodel.JxBadComments))
|
||||||
orm.RegisterModel(new(legacymodel.StoreBill))
|
orm.RegisterModel(new(legacymodel.StoreBill))
|
||||||
if !globals.DisableWXAuth1 {
|
// if !globals.DisableWXAuth1 {
|
||||||
orm.RegisterModel(new(legacymodel.WeiXins))
|
// orm.RegisterModel(new(legacymodel.WeiXins))
|
||||||
}
|
// }
|
||||||
orm.RegisterModel(new(model.GoodsOrder))
|
orm.RegisterModel(new(model.GoodsOrder))
|
||||||
orm.RegisterModel(new(model.GoodsOrderOriginal))
|
orm.RegisterModel(new(model.GoodsOrderOriginal))
|
||||||
orm.RegisterModel(new(model.TempGoodsOrderMobile))
|
orm.RegisterModel(new(model.TempGoodsOrderMobile))
|
||||||
|
|||||||
@@ -187,96 +187,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "BindMiniProgram",
|
|
||||||
Router: `/BindMiniProgram`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "BindMobile",
|
|
||||||
Router: `/BindMobile`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "BindMobile2",
|
|
||||||
Router: `/BindMobile2`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "GetUserInfo",
|
|
||||||
Router: `/GetUserInfo`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "GetWeiXinUserInfo",
|
|
||||||
Router: `/GetWeiXinUserInfo`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "Login",
|
|
||||||
Router: `/Login`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "Logout",
|
|
||||||
Router: `/Logout`,
|
|
||||||
AllowHTTPMethods: []string{"delete"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "MiniBindWeiXin",
|
|
||||||
Router: `/MiniBindWeiXin`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "MiniDecryptData",
|
|
||||||
Router: `/MiniDecryptData`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:AuthController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "SendMobileVerifyCode",
|
|
||||||
Router: `/SendMobileVerifyCode`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:CmsController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "CreateQrOrBarCode",
|
Method: "CreateQrOrBarCode",
|
||||||
@@ -1926,76 +1836,4 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TmpAddMobile2Mobile",
|
|
||||||
Router: `/TmpAddMobile2Mobile`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TmpBindMobile2Store",
|
|
||||||
Router: `/TmpBindMobile2Store`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TmpChangeMobile",
|
|
||||||
Router: `/TmpChangeMobile`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TmpGetMyStoreList",
|
|
||||||
Router: `/TmpGetMyStoreList`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TmpGetSelfInfo",
|
|
||||||
Router: `/TmpGetSelfInfo`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TmpGetStoreUsers",
|
|
||||||
Router: `/TmpGetStoreUsers`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TmpGetUserInfo",
|
|
||||||
Router: `/TmpGetUserInfo`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TmpUnbindMobile",
|
|
||||||
Router: `/TmpUnbindMobile`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,21 +31,21 @@ func init() {
|
|||||||
&controllers.StoreController{},
|
&controllers.StoreController{},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
beego.NSNamespace("/auth",
|
// beego.NSNamespace("/auth",
|
||||||
beego.NSInclude(
|
// beego.NSInclude(
|
||||||
&controllers.AuthController{},
|
// &controllers.AuthController{},
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
beego.NSNamespace("/cms",
|
beego.NSNamespace("/cms",
|
||||||
beego.NSInclude(
|
beego.NSInclude(
|
||||||
&controllers.CmsController{},
|
&controllers.CmsController{},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
beego.NSNamespace("/user",
|
// beego.NSNamespace("/user",
|
||||||
beego.NSInclude(
|
// beego.NSInclude(
|
||||||
&controllers.UserController{},
|
// &controllers.UserController{},
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
beego.NSNamespace("/store/sku",
|
beego.NSNamespace("/store/sku",
|
||||||
beego.NSInclude(
|
beego.NSInclude(
|
||||||
&controllers.StoreSkuController{},
|
&controllers.StoreSkuController{},
|
||||||
|
|||||||
Reference in New Issue
Block a user