This commit is contained in:
邹宗楠
2023-01-30 11:26:21 +08:00
parent 0c0e640df2
commit eb8b84384e
4 changed files with 142 additions and 10 deletions

View File

@@ -16,20 +16,20 @@ const (
AuthTypeTiktokMini = "tiktokmini" // 抖音小程序
)
type TiktopMiniAuther struct {
type TiktokMiniAuther struct {
authprovider.DefAuther
}
var (
AutherObjMini *TiktopMiniAuther
AutherObjMini *TiktokMiniAuther
)
func init() {
AutherObjMini = new(TiktopMiniAuther)
AutherObjMini = new(TiktokMiniAuther)
auth2.RegisterAuther(AuthTypeTiktokMini, AutherObjMini)
}
func (a *TiktopMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
func (a *TiktokMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
//appID, realCode := splitCode(code)
//sessionInfo, err := getTikTokApp(appID).GetTiktokOauth(realCode)
sessionInfo, err := api.TiktokApi.GetTiktokOauth(code)
@@ -44,7 +44,7 @@ func (a *TiktopMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.A
}
// 特殊接口
func (a *TiktopMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
func (a *TiktokMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
var sessionKey string
appID, jsCode := weixin.SplitJsCode(jsCode)
if jsCode != "" {
@@ -74,7 +74,7 @@ func (a *TiktopMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encrypt
return string(decryptedData), nil
}
func (a *TiktopMiniAuther) GetUserType() (userType int8) {
func (a *TiktokMiniAuther) GetUserType() (userType int8) {
return model.UserTypeStoreBoss
}

View File

@@ -0,0 +1,109 @@
package kuaishou
//
//import (
// "git.rosy.net.cn/baseapi/platformapi/tiktok"
// "git.rosy.net.cn/baseapi/platformapi/weixinapi"
// "git.rosy.net.cn/jx-callback/business/auth2"
// "git.rosy.net.cn/jx-callback/business/auth2/authprovider"
// "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
// "git.rosy.net.cn/jx-callback/business/model"
// "git.rosy.net.cn/jx-callback/globals"
// "git.rosy.net.cn/jx-callback/globals/api"
// "strings"
//)
//
//const (
// AuthTypeKuaiShouMini = "kuaishoumini" // 快手小程序
//)
//
//type KuaiShouMiniAuther struct {
// authprovider.DefAuther
//}
//
//var (
// AutherObjMini *KuaiShouMiniAuther
//)
//
//func init() {
// AutherObjMini = new(KuaiShouMiniAuther)
// auth2.RegisterAuther(AuthTypeKuaiShouMini, AutherObjMini)
//}
//
//func (a *KuaiShouMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
// //appID, realCode := splitCode(code)
// //sessionInfo, err := getTikTokApp(appID).GetTiktokOauth(realCode)
// sessionInfo, err := api.TiktokApi.GetTiktokOauth(code)
// if err != nil {
// return nil, err
// }
// sessionKey := sessionInfo.Data.SessionKey
// if authBindEx, err = a.UnionFindAuthBind(AuthTypeKuaiShouMini, api.TiktokApi.GetAppID(), []string{AuthTypeKuaiShouMini}, sessionInfo.Data.OpenId, sessionInfo.Data.Unionid, sessionInfo); err == nil {
// authBindEx.UserData = sessionKey
// }
// return authBindEx, err
//}
//
//// 特殊接口
//func (a *KuaiShouMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
// var sessionKey string
// appID, jsCode := weixin.SplitJsCode(jsCode)
// if jsCode != "" {
// sessionInfo, err := getWxApp(appID).SNSCode2Session(jsCode)
// if err == nil {
// // if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, getWxApp(appID).GetAppID(), []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil {
// // if authBindEx.UserID != authInfo.GetID() {
// // return "", fmt.Errorf("jsCode与token不匹配")
// // }
// // } else {
// // return "", err
// // }
// sessionKey = sessionInfo.SessionKey
// } else {
// return "", err
// }
// } else {
// if authInfo.AuthBindInfo.Type != AuthTypeKuaiShouMini {
// // return "", ErrAuthTypeShouldBeMini
// }
// sessionKey = authInfo.AuthBindInfo.UserData.(string)
// }
// decryptedData, err := weixinapi.SNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
// if err != nil {
// return "", err
// }
// return string(decryptedData), nil
//}
//
//func (a *KuaiShouMiniAuther) GetUserType() (userType int8) {
// return model.UserTypeStoreBoss
//}
//
//func getWxApp(appID string) (miniApi *weixinapi.API) {
// miniApi = api.WeixinMiniAPI
// if len(appID) > 0 && appID == api.WeixinMiniAppID2 {
// miniApi = api.WeixinMiniAPI2
// }
// if len(appID) > 0 && appID == api.WeixinMiniAppIDsc {
// miniApi = api.WeixinMiniAPIsc
// }
// return miniApi
//}
//
//func getTikTokApp(appID string) (TikTokMini *tiktok.API) {
// TikTokMini = api.TiktokApi
// if len(appID) > 0 && appID == api.TiktokJXDJApiID {
// TikTokMini = api.TiktokJXDJApi
// }
// return TikTokMini
//}
//func splitCode(code string) (appID, realCode string) {
// str := strings.Split(code, "&")
// if len(str) == 2 {
// appID = str[1]
// realCode = str[0]
// } else {
// globals.SugarLogger.Warnf("splitCode abnormal code:%s", code)
// }
// return appID, realCode
//}

View File

@@ -6,12 +6,35 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
var enterpriseUserIdMap = map[string]string{
"15881105234": "WenShiQi",
"15928865396": "HeJiaMeng2",
"18981810340": "LiuLei",
"18048531223": "ShiFeng2",
"18080188338": "ShiFeng",
"18744776542": "WuTingQi",
"15729837802": "ZhangShuWei",
"17358644830": "ShengTianBanZi1376",
"18982250714": "LaoZhaoTongXue",
"15680070110": "LiRongWei",
"18780171617": "TianQinXin",
"17381914617": "TianQinXin2",
"18583684218": "JingXiCaiShi-YanXiaoKang18583684218",
}
// SendUserMessage 发送文本卡片
func SendUserMessage(phone, title, description, url string) error {
// 根据电话号码获取用户touserId
enterpriseUserId, err := api.EnterpriseChatMin.GetUserIdByMobile(phone)
if err != nil {
return err
var enterpriseUserId = ""
var err error = nil
if id, ok := enterpriseUserIdMap[phone]; ok {
enterpriseUserId = id
} else {
enterpriseUserId, err = api.EnterpriseChatMin.GetUserIdByMobile(phone)
if err != nil {
enterpriseUserId = enterpriseUserIdMap["18981810340"]
}
enterpriseUserIdMap[phone] = enterpriseUserId
}
err = api.EnterpriseChatMin.SendMsgToUserTypeText(&enterprise.SendTextMsgReq{

View File

@@ -104,7 +104,7 @@ func (c *Auth2Controller) TiktokDecrypt() {
// @Title 登录接口
// @Description 登录接口(微信与公众号登录不能直接调用此接口)
// @Param authType formData string true "登录类型,当前支持[localpass本地账号密码mobile手机短信wxqrcode:微信登录weixinsns微信公众号weixinmini小程序wxnative微信APPddstaff钉钉企业ddqrcode钉钉扫码alipaycode支付宝小程序]"
// @Param authType formData string true "登录类型,当前支持[kuaishou:快手授权登录,localpass本地账号密码mobile手机短信wxqrcode:微信登录weixinsns微信公众号weixinmini小程序wxnative微信APPddstaff钉钉企业ddqrcode钉钉扫码alipaycode支付宝小程序]"
// @Param authSecret formData string true "不同登录类型的登录秘密如果是localpass登录类型是md5后的值空串不要md5"
// @Param authID formData string false "登录ID登录类型为localpass时依赖于authIDType其它为相应登录类型的id"
// @Param authIDType formData string false "只有在登录类型为localpass时才有意义分别为userid2用户名emailmobile"