From 7c0ad28e96a396910e7643e2545f1419afd9d2dd Mon Sep 17 00:00:00 2001 From: Yangtao Date: Tue, 18 Nov 2025 18:33:22 +0800 Subject: [PATCH] feat(app): update --- README.md | 4 + pkg/authmeta/rbac.go | 2 - pkg/cache/redis_client.go | 2 +- pkg/cache/redis_lock.go | 6 +- pkg/cache/user/user.go | 4 +- pkg/client/configs/mail-template-reset.html | 15 -- pkg/client/game/wz/wz_client.go | 225 -------------------- pkg/client/netease/captcha.go | 6 +- pkg/client/netease/live_person_test.go | 78 ------- pkg/client/shengwang_client_test.go | 11 - pkg/client/sms_client.go | 38 +--- pkg/client/tencent.go | 11 +- pkg/client/tencent_test.go | 74 ------- pkg/common/CmdTools/AliyunCloudClient.go | 6 +- pkg/common/CmdTools/ExcelTool.go | 2 +- pkg/common/CmdTools/TencentCloudClient.go | 4 +- pkg/common/ConstVar.go | 3 - pkg/common/app_const.go | 3 - pkg/common/netease/ImClient.go | 4 - pkg/common/netease/ImClient_test.go | 124 ----------- pkg/common/pinyin/pinyin_test.go | 9 - pkg/constant/p_vars.go | 1 - pkg/helper/AliAudio_test.go | 11 - pkg/helper/Helper.go | 1 - pkg/partner/Apple/AppleClient_test.go | 32 --- pkg/partner/submail/submail_client.go | 12 -- pkg/utils/p_tools.go | 5 +- 27 files changed, 20 insertions(+), 673 deletions(-) delete mode 100644 pkg/client/configs/mail-template-reset.html delete mode 100644 pkg/client/game/wz/wz_client.go delete mode 100644 pkg/client/netease/live_person_test.go delete mode 100644 pkg/client/shengwang_client_test.go delete mode 100644 pkg/client/tencent_test.go delete mode 100644 pkg/common/netease/ImClient_test.go delete mode 100644 pkg/common/pinyin/pinyin_test.go delete mode 100644 pkg/helper/AliAudio_test.go delete mode 100644 pkg/partner/Apple/AppleClient_test.go diff --git a/README.md b/README.md index 1be9954..86c2a77 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,7 @@ - req:请求体定义,前缀为模块名 - res:响应体定义,前缀为模块名 - tools:通用工具封装 + +``` +git config --global url."git@gitea.ddegame.cn:".insteadOf "https://gitea.ddegame.cn/" +``` diff --git a/pkg/authmeta/rbac.go b/pkg/authmeta/rbac.go index 6316d7a..20a41d8 100644 --- a/pkg/authmeta/rbac.go +++ b/pkg/authmeta/rbac.go @@ -1,7 +1,5 @@ package authmeta -// 定义通用 - type TenantItem struct { Name string Type string diff --git a/pkg/cache/redis_client.go b/pkg/cache/redis_client.go index a2aa0d1..5737354 100644 --- a/pkg/cache/redis_client.go +++ b/pkg/cache/redis_client.go @@ -1,8 +1,8 @@ package cache import ( - logs "servicebase/pkg/log" "context" + logs "servicebase/pkg/log" redis "github.com/redis/go-redis/v9" "github.com/spf13/viper" diff --git a/pkg/cache/redis_lock.go b/pkg/cache/redis_lock.go index f1ec722..95c9a82 100644 --- a/pkg/cache/redis_lock.go +++ b/pkg/cache/redis_lock.go @@ -1,8 +1,8 @@ package cache import ( - "servicebase/pkg/log" "errors" + "servicebase/pkg/log" "time" ) @@ -10,7 +10,7 @@ func Lock(key string) (e error) { var success bool TryMax := 6 redisClient := GetCommonRedisInstance().RedisClient - for i := 0; i < TryMax; i++ { + for range TryMax { success, e = redisClient.SetNX(Ctx(), key, time.Now(), time.Millisecond*1000*3).Result() if e != nil { log.Info("Lock GetCommonRedisInstance error: " + e.Error()) @@ -46,7 +46,7 @@ func RedisLockGetTime(key string, duration time.Duration) (e error) { func RedisLockGet(key string) (e error) { redisClient := GetCommonRedisInstance().RedisClient success := false - for i := 0; i < TryMax; i++ { + for range TryMax { success, e = redisClient.SetNX(Ctx(), key, time.Now(), LockTimeout).Result() if nil != e { return diff --git a/pkg/cache/user/user.go b/pkg/cache/user/user.go index 10263f9..fbb5a92 100644 --- a/pkg/cache/user/user.go +++ b/pkg/cache/user/user.go @@ -1,9 +1,9 @@ package cache_user import ( + "fmt" "servicebase/pkg/cache" "servicebase/pkg/tools" - "fmt" "strings" "time" @@ -14,11 +14,9 @@ import ( const key = "user:models" const keyToken = "user:token" -// 用户当前所在的房间ID + userid = chatroomid const ACCESSTOKEN_KEY_PREV = "ACCESSTOKEN_" const ACCESSTOKEN_EXPIRE_DURATION = time.Hour * 24 * 180 -// 通过token获取userId func IdByToken(token string) (userId string) { if len(token) == 0 { return diff --git a/pkg/client/configs/mail-template-reset.html b/pkg/client/configs/mail-template-reset.html deleted file mode 100644 index e3385e8..0000000 --- a/pkg/client/configs/mail-template-reset.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - {{.Title}} - - - -

Hello!

-

This is a password reset email.

- {{.Url}} - - - \ No newline at end of file diff --git a/pkg/client/game/wz/wz_client.go b/pkg/client/game/wz/wz_client.go deleted file mode 100644 index 71cfab6..0000000 --- a/pkg/client/game/wz/wz_client.go +++ /dev/null @@ -1,225 +0,0 @@ -package client_game_wz - -import ( - "encoding/json" - "errors" - "fmt" - "net/http" - "servicebase/pkg/utils" - - "github.com/anxpp/common-utils/logg" - "github.com/anxpp/common-utils/str" -) - -const WZYD_TOKEN = "SZN62jr4" -const WZYD_UID = "1702857155" - -func RoleInfo(targetUid string) (targetRole map[string]interface{}, e error) { - if len(targetUid) == 0 { - e = errors.New("参数不足") - return - } - apiUrl := "https://kohcamp.qq.com/game/koh/profile" - token := WZYD_TOKEN // 登录王者营地的token - uid := WZYD_UID // 营地ID - headerMap := make(map[string]string, 0) - headerMap["Content-Type"] = "application/json" - headerMap["userId"] = uid - headerMap["cCurrentGameId"] = "20001" - headerMap["Accept-Language"] = "zh-Hans-CN;q=1, en-CN;q=0.9" - headerMap["token"] = token - - paraMap := make(map[string]string, 4) - paraMap["CampPreloadHTTPHandledIdentifier"] = "2" - paraMap["targetUserId"] = targetUid - - resStr, err2 := utils.HttpDo(http.MethodPost, apiUrl, headerMap, str.ToJsonString(paraMap)) - - if err2 != nil { - logg.Info("调用王者营地数据查询失败", err2.Error()) - e = fmt.Errorf("调用王者营地数据查询失败: %v", err2.Error()) - return - } - - logg.Info(resStr) - - resMap := make(map[string]interface{}, 0) - json.Unmarshal([]byte(resStr), &resMap) - - if resMap["returnCode"].(float64) != 0 { - e = fmt.Errorf("调用王者营地数据查询失败2: %v", resMap["returnMsg"]) - return - } - - // 获取成功 - data := resMap["data"].(map[string]interface{}) - // 默认角色ID - targetRoleId := data["targetRoleId"].(string) - - //角色列表 - roleList := data["roleList"].([]interface{}) - - // 匹配默认角色 - for _, item := range roleList { - m := item.(map[string]interface{}) - if m["roleId"].(string) == targetRoleId { - targetRole = m - } - } - if targetRole == nil { - e = errors.New("未找到角色信息") - return - } - - // 其他数据 - head := data["head"].(map[string]interface{}) - mods := head["mods"].([]interface{}) - //targetRole["mods"] = mods - - for _, item := range mods { - mod := item.(map[string]interface{}) - modId := mod["modId"].(float64) - if modId == 401 { - // 总场次 - targetRole["totalPlayCount"] = mod["content"].(string) - } else if modId == 408 { - // MVP - targetRole["mvpCount"] = mod["content"].(string) - } else if modId == 409 { - // 胜率 - targetRole["winRate"] = mod["content"].(string) - } else if modId == 201 { - // 英雄数 - targetRole["heroCount"] = mod["content"].(string) - } else if modId == 202 { - // 皮肤数 - targetRole["skinCount"] = mod["content"].(string) - } else if modId == 702 { - // 巅峰赛 - targetRole["topScore"] = mod["content"].(string) - } else if modId == 304 { - // 战力 - targetRole["battleScore"] = mod["content"].(string) - } - } - return -} - -func RoleSkinList(roleId string) (result map[string][]interface{}, e error) { - apiUrl := "https://kohcamp.qq.com/game/itempage/skinlist" - token := WZYD_TOKEN // 登录王者营地的token - uid := WZYD_UID // 营地ID - - if len(roleId) == 0 { - e = errors.New("参数不足") - return - } - headerMap := make(map[string]string, 0) - headerMap["Content-Type"] = "application/json" - headerMap["userId"] = uid - headerMap["cCurrentGameId"] = "20001" - headerMap["Accept-Language"] = "zh-Hans-CN;q=1, en-CN;q=0.9" - headerMap["token"] = token - - paraMap := make(map[string]string, 4) - paraMap["roleId"] = roleId - - resStr, err2 := utils.HttpDo(http.MethodPost, apiUrl, headerMap, str.ToJsonString(paraMap)) - - if err2 != nil { - logg.Info("调用王者营地数据查询失败", err2.Error()) - e = fmt.Errorf("调用王者营地数据查询失败:%v", err2) - return - } - - resMap := make(map[string]interface{}, 0) - json.Unmarshal([]byte(resStr), &resMap) - - if _, ok := resMap["returnCode"]; ok { - e = fmt.Errorf("调用王者营地数据查询失败2: %v", resMap["returnMsg"]) - return - } - - //全部皮肤 - allSkin := resMap["allSkinConf"].([]interface{}) - // 用户的皮肤 - userSkinList := resMap["skinData"].([]interface{}) - - resultList := []interface{}{} - - rongyaoList := []interface{}{} // 荣耀典藏 - xiandingList := []interface{}{} // 限定 - shishiList := []interface{}{} // 史诗级 - chuanshuoList := []interface{}{} // 传说 - wushuangList := []interface{}{} //无双 - - for _, item := range userSkinList { - skinMap := item.(map[string]interface{}) - userSkinId := skinMap["skinId"].(float64) - - mySkin := getSkinModel(allSkin, userSkinId) - mySkin["acquireTime"] = skinMap["acquireTime"].(string) - - // 去掉隐藏的皮肤 - if mySkin["isHidden"].(float64) == 1 { - continue - } - - // 去掉原皮 - if int64(userSkinId)%100 == 0 { - continue - } - - // 等级处理 - classTypeName := mySkin["classTypeName"].([]interface{}) - - nameList := []string{} - for _, name := range classTypeName { - nameList = append(nameList, name.(string)) - } - - str := fmt.Sprintf("%s(%s)", mySkin["skinName"].(string), mySkin["heroName"].(string)) - - if utils.IsInStringList("荣耀典藏", nameList) { - rongyaoList = append(rongyaoList, str) - } - if utils.IsInStringList("限定", nameList) { - xiandingList = append(xiandingList, str) - } - if utils.IsInStringList("史诗品质", nameList) { - shishiList = append(shishiList, str) - } - if utils.IsInStringList("传说品质", nameList) { - chuanshuoList = append(chuanshuoList, str) - } - if utils.IsInStringList("无双", nameList) { - wushuangList = append(wushuangList, str) - } - - resultList = append(resultList, mySkin) - } - - logg.Info("皮肤数量", len(resultList)) - - result = make(map[string][]interface{}, 0) - // result["totalCount"] = len(resultList) - result["allSkin"] = resultList - result["荣耀典藏"] = rongyaoList - result["限定"] = xiandingList - result["史诗品质"] = shishiList - result["传说品质"] = chuanshuoList - result["无双"] = wushuangList - return -} - -func getSkinModel(allSkin []interface{}, userSkinId float64) (result map[string]interface{}) { - for _, item := range allSkin { - skin := item.(map[string]interface{}) - skinId := skin["skinId"].(float64) - if skinId == userSkinId { - result = skin - break - } - } - return -} diff --git a/pkg/client/netease/captcha.go b/pkg/client/netease/captcha.go index 0ebee50..53a215a 100644 --- a/pkg/client/netease/captcha.go +++ b/pkg/client/netease/captcha.go @@ -1,18 +1,14 @@ package Netease import ( - "servicebase/pkg/log" "encoding/json" + "servicebase/pkg/log" "github.com/pkg/errors" "github.com/spf13/viper" captcha "github.com/yidun/yidun-golang-sdk/yidun/service/captcha" ) -var ( - CaptchaId = "28a052c000324d2e992e9e184291c92d" -) - // CaptchaSecondVerify 验证码二次校验请求 func CaptchaSecondVerify(captchaId, validate string) (bool, error) { request := captcha.NewCaptchaVerifyRequest() diff --git a/pkg/client/netease/live_person_test.go b/pkg/client/netease/live_person_test.go deleted file mode 100644 index 4f7c105..0000000 --- a/pkg/client/netease/live_person_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package Netease - -import ( - "servicebase/pkg/common/HyTools" - "servicebase/pkg/log" - "servicebase/pkg/partner/qiniu" - "context" - "github.com/spf13/viper" - "io" - "net/http" - "testing" -) - -func TestApplyH5LivePerson(t *testing.T) { - log.Init() - rst, err := H5ApplyLivePerson(context.Background(), &ApplyInfoReq{ - Name: "xxx", // 姓名 - CardNo: "xxxxxxx", // 身份证号码,x需要变成大写X - RedirectUrl: "https://www.baidu.com", - CallBackUrl: "", - DataId: "", - CallbackValidate: "", - EncryptType: "", - }) - if err != nil { - t.Error(err) - } - println(rst.AuthToken) - println(rst.AuthUrl) -} - -func TestH5ReCheckLivePersonToken(t *testing.T) { - log.Init() - _, err := H5ReCheckLivePersonToken(context.Background(), "6ZgHU-x9XsRVF8aS7PIFppBho28QEUAR") - if err != nil { - t.Error(err) - } -} - -func TestB(t *testing.T) { - log.Init() - - // key: CwGN8XGmbEZr7qqJl-y-QodcUYREz8ph_glVKCqp - // secret: KbZKt8WwQcZ6II0tygMLsO3KWpm50aMz737VaMV0 - viper.Set("qiniu.key", "CwGN8XGmbEZr7qqJl-y-QodcUYREz8ph_glVKCqp") - - viper.Set("qiniu.secret", "KbZKt8WwQcZ6II0tygMLsO3KWpm50aMz737VaMV0") - - viper.Set("qiniu.bucket.photo", "ddphoto") - - key := func() string { - resp, err := http.Get("xxx") - if err != nil { - log.ErrorF("获取人脸核身正面照图片错误:%+v", err) - return "" - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - log.ErrorF("获取人脸核身正面照图片错误 http code为%d", resp.StatusCode) - return "" - } - imageData, err := io.ReadAll(resp.Body) - if err != nil { - log.ErrorF("") - return "" - } - - key := "upload/" + HyTools.GetUUID() + ".jpg" - //上传文件 - newKey := qiniu.UploadFile(context.Background(), viper.GetString("qiniu.bucket.photo"), imageData, key) - if len(newKey) == 0 { - log.ErrorF("获取人脸核身正面照图片上传到七牛oss失败") - return "" - } - return key - }() - println(key) -} diff --git a/pkg/client/shengwang_client_test.go b/pkg/client/shengwang_client_test.go deleted file mode 100644 index 13cf6b9..0000000 --- a/pkg/client/shengwang_client_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package client - -import ( - "fmt" - "testing" -) - -func TestGenerateShenWangToken(t *testing.T) { - gotToken, err := GenerateShenWangToken("65945666", "9956050") - fmt.Printf("%+v %+v\n", gotToken, err) -} diff --git a/pkg/client/sms_client.go b/pkg/client/sms_client.go index 9050550..14c5313 100644 --- a/pkg/client/sms_client.go +++ b/pkg/client/sms_client.go @@ -14,22 +14,11 @@ import ( "github.com/spf13/viper" ) -// CreateAliSmsClient -/** - * 使用AK&SK初始化账号Client - * @param accessKeyId - * @param accessKeySecret - * @return Client - * @throws Exception - */ func CreateAliSmsClient(accessKeyId *string, accessKeySecret *string) (_result *dysmsapi20170525.Client, _err error) { config := &openapi.Config{ - // 必填,您的 AccessKey ID - AccessKeyId: accessKeyId, - // 必填,您的 AccessKey Secret + AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, } - // Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi config.Endpoint = tea.String("dysmsapi.aliyuncs.com") _result = &dysmsapi20170525.Client{} _result, _err = dysmsapi20170525.NewClient(config) @@ -71,8 +60,6 @@ func SendMobileMsg01(mobile, signName, tempCode, content string) (_result *dysms ID = viper.GetString("aliyun.sms.accessKeyId") Secret = viper.GetString("aliyun.sms.accessKeySecret") ) - // 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 - // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例使用环境变量获取 AccessKey 的方式进行调用,仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378661.html client, _err := CreateAliSmsClient(tea.String(ID), tea.String(Secret)) if _err != nil { return nil, _err @@ -90,7 +77,6 @@ func SendMobileMsg01(mobile, signName, tempCode, content string) (_result *dysms _e = r } }() - // 复制代码运行请自行打印 API 的返回值 _result, _err = client.SendSmsWithOptions(sendSmsRequest, &util.RuntimeOptions{}) if _err != nil { return nil, _err @@ -116,9 +102,6 @@ func SendMobileMsg01(mobile, signName, tempCode, content string) (_result *dysms } func SendVerifyCodeUsaAndCanada(mobile, content string, fn func(_result *dysmsapi20170525.SendSmsResponse, success bool)) (_result *dysmsapi20170525.SendSmsResponse, e error) { - // if !helper.IsMobile(mobile) { - // return nil, errors.New("手机号有误!") - // } sign, code := getSignAndCode() log.InfoF("SendVerifyCodeUsaAndCanada get sms sign and code: %s %s", sign, code) _result, e = SendMobileMsgUsaAndCanada(mobile, sign, code, content) @@ -129,9 +112,6 @@ func SendVerifyCodeUsaAndCanada(mobile, content string, fn func(_result *dysmsap } func SendVerifyCodeGlobalOther(mobile, content string, fn func(_result *dysmsapi20170525.SendSmsResponse, success bool)) (_result *dysmsapi20170525.SendSmsResponse, e error) { - // if !helper.IsMobile(mobile) { - // return nil, errors.New("手机号有误!") - // } sign, code := getSignAndCode() log.InfoF("SendVerifyCodeUsaAndCanada get sms sign and code: %s %s", sign, code) _result, e = SendMobileMsgGlobalOther(mobile, sign, code, content) @@ -141,14 +121,11 @@ func SendVerifyCodeGlobalOther(mobile, content string, fn func(_result *dysmsapi return } -// SendMobileMsgUsaAndCanada 美国/加拿大地区短信发送 func SendMobileMsgUsaAndCanada(mobile, signName, tempCode, content string) (_result *dysmsapi20170525.SendSmsResponse, _err error) { var ( ID = viper.GetString("aliyun.sms.accessKeyId") Secret = viper.GetString("aliyun.sms.accessKeySecret") ) - // 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 - // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例使用环境变量获取 AccessKey 的方式进行调用,仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378661.html client, _err := CreateAliSmsClient(tea.String(ID), tea.String(Secret)) if _err != nil { return nil, _err @@ -166,7 +143,6 @@ func SendMobileMsgUsaAndCanada(mobile, signName, tempCode, content string) (_res _e = r } }() - // 复制代码运行请自行打印 API 的返回值 _result, _err = client.SendSmsWithOptions(sendSmsRequest, &util.RuntimeOptions{}) if _err != nil { return nil, _err @@ -191,20 +167,11 @@ func SendMobileMsgUsaAndCanada(mobile, signName, tempCode, content string) (_res return res, _err } -// SendMobileMsgGlobalOther 全球其他国家 func SendMobileMsgGlobalOther(mobile, signName, tempCode, content string) (_result *dysmsapi20170525.SendSmsResponse, _err error) { var ( - // ID AccessKey ID - // LTAI5tRfkJnr6Y6NU2T6jWoB - // - // AccessKey Secret - // BcaMWgXkwdxdJXFnCwRQbEl3Q3Xtxl - // TODO: 替换为您的AccessKey ID和AccessKey Secret ID = viper.GetString("aliyun.sms.accessKeyId") Secret = viper.GetString("aliyun.sms.accessKeySecret") ) - // 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 - // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例使用环境变量获取 AccessKey 的方式进行调用,仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378661.html client, _err := CreateAliSmsClient(tea.String(ID), tea.String(Secret)) if _err != nil { return nil, _err @@ -238,7 +205,6 @@ func SendMobileMsgGlobalOther(mobile, signName, tempCode, content string) (_resu } else { e.Message = tea.String(tryErr.Error()) } - // 如有需要,请打印 error _, _err = util.AssertAsString(e.Message) if _err != nil { return nil, _err @@ -266,8 +232,6 @@ func SendMobileMsgHKMacauAndTW(mobile, signName, tempCode, content string) (_res ID = viper.GetString("aliyun.sms.accessKeyId") Secret = viper.GetString("aliyun.sms.accessKeySecret") ) - // 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 - // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例使用环境变量获取 AccessKey 的方式进行调用,仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378661.html client, _err := CreateAliSmsClient(tea.String(ID), tea.String(Secret)) if _err != nil { return nil, _err diff --git a/pkg/client/tencent.go b/pkg/client/tencent.go index 8c19e3c..10045e9 100644 --- a/pkg/client/tencent.go +++ b/pkg/client/tencent.go @@ -145,7 +145,7 @@ func _SendSms() { /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号] * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号*/ - request.PhoneNumberSet = common.StringPtrs([]string{"+8615215229221"}) + request.PhoneNumberSet = common.StringPtrs([]string{"+8615615156"}) /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */ request.SessionContext = common.StringPtr("") @@ -190,8 +190,6 @@ func _PullStatus() { * 以免泄露密钥对危及您的财产安全。 * SecretId、SecretKey 查询: https://console.cloud.tencent.com/cam/capi */ credential := common.NewCredential( - // os.Getenv("TENCENTCLOUD_SECRET_ID"), - // os.Getenv("TENCENTCLOUD_SECRET_KEY"), viper.GetString("tencent.secretId"), viper.GetString("tencent.secretKey"), ) @@ -235,26 +233,21 @@ func _PullStatus() { request.SmsSdkAppId = common.StringPtr(viper.GetString("tencent.sdkAppId")) /* 拉取最大条数,最多100条 */ request.Limit = common.Uint64Ptr(10) - PhoneNumber := "+8615215229221" + PhoneNumber := "+8645456151141" request.PhoneNumber = &PhoneNumber beginTime := uint64(time.Now().Unix()) - (60 * 60) request.BeginTime = &beginTime Offset := uint64(0) request.Offset = &Offset - // 通过client对象调用想要访问的接口,需要传入请求对象 response, err := client.PullSmsSendStatusByPhoneNumber(request) - // 处理异常 if _, ok := err.(*errors.TencentCloudSDKError); ok { fmt.Printf("An API error has returned: %s", err) return } - // 非SDK异常,直接失败。实际代码中可以加入其他的处理。 if err != nil { panic(err) } b, _ := json.Marshal(response.Response) - // 打印返回的json字符串 fmt.Printf("%s", b) - // {"PullSmsSendStatusSet":[{"UserReceiveTime":1695299239,"CountryCode":"86","SubscriberNumber":"15215229221","PhoneNumber":"+8615215229221","SerialNo":"4012:319315169316952992330592922","ReportStatus":"SUCCESS","Description":"DELIVRD","SessionContext":""}],"RequestId":"40476317-2cf4-4c48-bf30-2b33ac14a8b7"} } diff --git a/pkg/client/tencent_test.go b/pkg/client/tencent_test.go deleted file mode 100644 index cbd7b35..0000000 --- a/pkg/client/tencent_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package client - -import ( - "testing" - - sms "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111" -) - -func TestSendSms(t *testing.T) { - tests := []struct { - name string - }{ - { - name: "test01", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - _SendSms() - }) - } -} - -func TestPullStatus(t *testing.T) { - tests := []struct { - name string - }{ - { - name: "test01", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - _PullStatus() - }) - } -} - -func TestSmsSendByTemplate(t *testing.T) { - type args struct { - templateID string - mobile string - param []string - } - tests := []struct { - name string - args args - want *sms.SendSmsResponseParams - wantErr bool - }{ - { - name: "01", - args: args{ - templateID: "2319145", - mobile: "", - param: []string{"6666"}, - }, - want: &sms.SendSmsResponseParams{}, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - _, err := _SmsSendByTemplate(tt.args.templateID, tt.args.mobile, tt.args.param) - if (err != nil) != tt.wantErr { - t.Errorf("SmsSendByTemplate() error = %v, wantErr %v", err, tt.wantErr) - return - } - // if !reflect.DeepEqual(got, tt.want) { - // t.Errorf("SmsSendByTemplate() = %v, want %v", got, tt.want) - // } - }) - } -} diff --git a/pkg/common/CmdTools/AliyunCloudClient.go b/pkg/common/CmdTools/AliyunCloudClient.go index e169003..1045284 100644 --- a/pkg/common/CmdTools/AliyunCloudClient.go +++ b/pkg/common/CmdTools/AliyunCloudClient.go @@ -7,9 +7,9 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/services/slb" ) -// LTAI5tCB8SmJcwfO -// dX4kgF4VcblsbCVdKvtCGCmvNbLkZK -// ./AliyunCloudClient -t b -o update -key LTAI5tCB8SmJcwfO -sec dX4kgF4VcblsbCVdKvtCGCmvNbLkZK -reg cn-hangzhou -lb "[{"ServerId":"ServerId","Weight":"0"}] +// LTAI5tCB8SmJcwfO1 +// dX4kgF4VcblsbCVdKvtCGCmvNbLkZK1 +// ./AliyunCloudClient -t b -o update -key LTAI5tCB8SmJcwfO1 -sec dX4kgF4VcblsbCVdKvtCGCmvNbLkZK1 -reg cn-hangzhou -lb "[{"ServerId":"ServerId","Weight":"0"}] func main() { var target string flag.StringVar(&target, "t", "b", "target: b=backendServer") diff --git a/pkg/common/CmdTools/ExcelTool.go b/pkg/common/CmdTools/ExcelTool.go index 2fdaccd..d90ad2c 100644 --- a/pkg/common/CmdTools/ExcelTool.go +++ b/pkg/common/CmdTools/ExcelTool.go @@ -9,7 +9,7 @@ import ( ) func main02() { - data := ReadSheet("./CmdTools/星钻VIP体系.xlsx", 0) + data := ReadSheet("./CmdTools/1.xlsx", 0) fmt.Println(json.Marshal(data)) for index, item := range data { if index > 0 { diff --git a/pkg/common/CmdTools/TencentCloudClient.go b/pkg/common/CmdTools/TencentCloudClient.go index 69a5eb8..45d1d7a 100644 --- a/pkg/common/CmdTools/TencentCloudClient.go +++ b/pkg/common/CmdTools/TencentCloudClient.go @@ -10,8 +10,8 @@ import ( "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" ) -// ./TencentCloudClient -t b -o add -key AKIDSoxxjI5tukPr9ECsQmwthKhroaCZlldI -sec b1FG2b3JMrESVLxjJdhYDgx12qPiplXB -reg ap-shanghai -params "{\"LoadBalancerId\":\"lb-jip7505r\",\"Targets\":[{\"InstanceId\":\"ins-n2i7x483\",\"Weight\":20}]}" -// ./TencentCloudClient -t b -o remove -key AKIDSoxxjI5tukPr9ECsQmwthKhroaCZlldI -sec b1FG2b3JMrESVLxjJdhYDgx12qPiplXB -reg ap-shanghai -params "{\"LoadBalancerId\":\"lb-jip7505r\",\"InstanceIds\":[\"ins-n2i7x483\"]}" +// ./TencentCloudClient -t b -o add -key AKIDSoxxjI5tukPr9ECsQmwthKhroaCZlldI1 -sec b1FG2b3JMrESVLxjJdhYDgx12qPiplXB1 -reg ap-shanghai -params "{\"LoadBalancerId\":\"lb-jip7505r\",\"Targets\":[{\"InstanceId\":\"ins-n2i7x483\",\"Weight\":20}]}" +// ./TencentCloudClient -t b -o remove -key AKIDSoxxjI5tukPr9ECsQmwthKhroaCZlldI1 -sec b1FG2b3JMrESVLxjJdhYDgx12qPiplXB1 -reg ap-shanghai -params "{\"LoadBalancerId\":\"lb-jip7505r\",\"InstanceIds\":[\"ins-n2i7x483\"]}" func main03() { var target string diff --git a/pkg/common/ConstVar.go b/pkg/common/ConstVar.go index cb60524..1bcd0dc 100644 --- a/pkg/common/ConstVar.go +++ b/pkg/common/ConstVar.go @@ -14,7 +14,6 @@ const ( // API_V_NUM = "1" //API密钥 - // API_SECRECT = "x63363eacf804b4394a120aea240fd9a" //图片域名 @@ -23,8 +22,6 @@ const ( MEDIA_URL_PREV = "https://media-qiniu-app.ddegame.cn/" //====== 三方key ======= - //NETEASE_IM_APPKEY = "a0671ecde01ef03928ccfd460c62d203" - //NETEASE_IM_SECRET = "eb88916031ca" //用户认证申请状态 USER_CERTIFY_STATUS_INIT = "1" //已提交 diff --git a/pkg/common/app_const.go b/pkg/common/app_const.go index 3f7573d..f1415b8 100644 --- a/pkg/common/app_const.go +++ b/pkg/common/app_const.go @@ -1267,9 +1267,6 @@ const ( ICON_TYPE_VIP = "VIP" ICON_TYPE_NOBILITY = "NOBILITY" ICON_TYPE_MEDAL = "MEDAL" - - H5ROOM_API_SECRET = "H5ROOM_API_SECRET" //H5客户端key - INNER_API_SECRET_TRADE = "INNER_API_SECRET_TRADE_kasdhfih" //trade客户端key ) const ( diff --git a/pkg/common/netease/ImClient.go b/pkg/common/netease/ImClient.go index 28ed0a7..0bf274f 100644 --- a/pkg/common/netease/ImClient.go +++ b/pkg/common/netease/ImClient.go @@ -99,7 +99,6 @@ func (client *ImClient) CreateImUser(userId, nickName, avatar string) error { logs.Info("YunXin_SignUp_Fail_AccID_%s:"+err.Error(), userId) return err } else { - // {"code":200,"info":{"token":"123456","accid":"b8af4bebe2064435974ba2340d852055","name":"b8af4bebe2064435974ba2340d852055"}} var resDTO CreateImRes json.Unmarshal([]byte(res), &resDTO) if resDTO.Code != 200 { @@ -128,8 +127,6 @@ func (client *ImClient) GetImUserInfo(userId string) error { byteData, _ := json.Marshal(accids) sb.Append("accids=" + string(byteData)) res, err := HyTools.HttpDo(httpMethod, url, header, sb.ToString()) - // #查询云信用户信息结果:{"desc":"b8af4bebe2064435974ba2340d852055not register","code":414}# - // {"code":200,"uinfos":[{"icon":"https://xzphoto.meetalk.tech/upload/6bba4098-6ea8-4758-8193-19abed540c0b.0","accid":"2251bae8a0514e6892f0374f5dd260d4","name":"弦乐","gender":0}]} logs.Info("#" + "查询云信用户信息结果:" + res + "#") var body map[string]interface{} if errJson := json.Unmarshal([]byte(res), &body); errJson != nil { @@ -219,7 +216,6 @@ func (client *ImClient) CreateChatroom(ownerUserId string, roomName string) (cha logs.Info(common.LOG_QUOTE_STRING + "云信创建聊天室请求失败:" + err.Error() + common.LOG_QUOTE_STRING) return } - // {"valid":true,"ext":"","creator":"1b94b5e7af8a45ed9fda27d28165d4c9","name":"32452345","muted":false,"roomid":11142139973,"queuelevel":0} logs.Info(common.LOG_QUOTE_STRING + "云信创建聊天室结果:" + res + common.LOG_QUOTE_STRING) var createRes CreateChatroomResponse err1 := json.Unmarshal([]byte(res), &createRes) diff --git a/pkg/common/netease/ImClient_test.go b/pkg/common/netease/ImClient_test.go deleted file mode 100644 index e9f7f58..0000000 --- a/pkg/common/netease/ImClient_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package Netease - -import ( - "context" - "testing" -) - -// 测试获取IM用户信息 -func TestImClient_GetImUserInfo(t *testing.T) { - type fields struct { - AppKey string - AppSecret string - } - type args struct { - userId string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "test", - fields: fields{ - AppKey: "543b1a440b940b170fccdf494839efc01", - AppSecret: "41134093938f1", - }, - args: args{ - // 2251bae8a0514e6892f0374f5dd260d4 - // b8af4bebe2064435974ba2340d852055 - userId: "fcda23bc00e641f5ae17492503b566ed", - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - client := &ImClient{ - AppKey: tt.fields.AppKey, - AppSecret: tt.fields.AppSecret, - } - if err := client.GetImUserInfo(tt.args.userId); (err != nil) != tt.wantErr { - t.Errorf("GetImUserInfo() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -// 测试注册IM用户 -func TestImClient_CreateImUser(t *testing.T) { - type fields struct { - AppKey string - AppSecret string - } - type args struct { - userId string - nickname string - avatar string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "test", - fields: fields{ - AppKey: "543b1a440b940b170fccdf494839efc01", - AppSecret: "41134093938f1", - }, - args: args{ - // 2251bae8a0514e6892f0374f5dd260d4 - // b8af4bebe2064435974ba2340d852055 - userId: "fcda23bc00e641f5ae17492503b566ed", - nickname: "杏", - avatar: "https://photo-app.ddegame.cn/upload/19986a27-3bae-49f7-9643-cd18cda87557.jpg", - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - client := &ImClient{ - AppKey: tt.fields.AppKey, - AppSecret: tt.fields.AppSecret, - } - if err := client.CreateImUser(tt.args.userId, tt.args.nickname, tt.args.avatar); (err != nil) != tt.wantErr { - t.Errorf("GetImUserInfo() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -// 测试注册IM用户 -func TestImClient_CreateImUserOne(t *testing.T) { - client := &ImClient{ - AppKey: "543b1a440b940b170fccdf494839efc01", - AppSecret: "41134093938f1", - } - client.CreateImUser("fcda23bc00e641f5ae17492503b566ed", "杏", "https://photo-app.ddegame.cn/upload/19986a27-3bae-49f7-9643-cd18cda87557.jpg") -} - -func TestImClient_CreateChatGroup(t *testing.T) { - client := &ImClient{ - AppKey: "543b1a440b940b170fccdf494839efc01", - AppSecret: "41134093938f1", - } - groupId, err := client.CreateChatGroup(context.Background(), "e1fbefbbd77a402e8c2101a0ebe15f5d", "测试群", []string{"e1fbefbbd77a402e8c2101a0ebe15f5d"}) - if err != nil { - t.Error(err) - } - println(groupId) -} - -func init() { - // viper.SetConfigName("dev.yaml") - // viper.AddConfigPath("../../../configs/admin/") - // viper.SetConfigType("yaml") - // _ = viper.ReadInConfig() - // log.Init() - // datasource.InitMySQlMaster() -} diff --git a/pkg/common/pinyin/pinyin_test.go b/pkg/common/pinyin/pinyin_test.go deleted file mode 100644 index d2e71f0..0000000 --- a/pkg/common/pinyin/pinyin_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package pinyin - -import "testing" - -func TestTo_Py(t *testing.T) { - LoadingPYFile("./pinyin.txt") - s, _ := PY("3425另264325一4个44平444台") - println(s) -} diff --git a/pkg/constant/p_vars.go b/pkg/constant/p_vars.go index 36c403c..32fb56c 100644 --- a/pkg/constant/p_vars.go +++ b/pkg/constant/p_vars.go @@ -2,7 +2,6 @@ package constant const ( PhotoDomainUrl = "https://photo-app.ddegame.cn/" - API_SECRET = "c9ca017f078a4cd1ba5ccb9d02d4869a" HTTP_METHOD_POST = "POST" LOG_QUOTE_STRING = "#" diff --git a/pkg/helper/AliAudio_test.go b/pkg/helper/AliAudio_test.go deleted file mode 100644 index 74efda9..0000000 --- a/pkg/helper/AliAudio_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package helper - -import ( - "fmt" - "testing" -) - -func TestTransAudioToText(t *testing.T) { - gotResult, err := TransAudioToText("https://check.dongdongdianjing.com/videos/20250606/d69960523fe2756076f1f8d7c37fa742.mp4") - fmt.Sprintf("%+v %+v", gotResult, err) -} diff --git a/pkg/helper/Helper.go b/pkg/helper/Helper.go index 22b14ab..a5b0bc9 100644 --- a/pkg/helper/Helper.go +++ b/pkg/helper/Helper.go @@ -60,7 +60,6 @@ func getCommonHeaderMap() map[string]string { headerMap["TimeStamp"] = strconv.Itoa(time.Now().Second()) headerMap["BundleId"] = "meetalkH5" headerMap["OsVersion"] = "10.01" - headerMap["INNER-TOKEN"] = "b028c52286c95de48a1c773d7ed02d04" return headerMap } diff --git a/pkg/partner/Apple/AppleClient_test.go b/pkg/partner/Apple/AppleClient_test.go deleted file mode 100644 index 21a0cdf..0000000 --- a/pkg/partner/Apple/AppleClient_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package Apple - -import ( - "encoding/json" - "fmt" - "github.com/anxpp/beego/logs" - "github.com/dgrijalva/jwt-go" - "testing" -) - -func TestAppleClient_VerifyAppleAuthCode(t *testing.T) { - result := `{"access_token":"a43aca909b09c47e7ab17cf65f2f87d5a.0.mrwxs.NGHQpX4Dp1mHUeGiC7UF7A","token_type":"Bearer","expires_in":3600,"refresh_token":"r472107c8150844c0995604692008d3c5.0.mrwxs.WE3wQnwhQpVVX77-U6169A","id_token":"eyJraWQiOiI4NkQ4OEtmIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiY24ubWVldGFsay5lbmVuIiwiZXhwIjoxNTk4MTA1NDE2LCJpYXQiOjE1OTgxMDQ4MTYsInN1YiI6IjAwMTY3Mi43NTQyNGFiMGRjYWM0YTM2YTkxMmI5NDNmMzg5MmQ4ZC4xMDUzIiwiYXRfaGFzaCI6IlUwVUM5QTdnRWc4cnFfOHVORWxocVEiLCJlbWFpbCI6IjgzNDA3NzA2NUBxcS5jb20iLCJlbWFpbF92ZXJpZmllZCI6InRydWUiLCJhdXRoX3RpbWUiOjE1OTgxMDQ4MTMsIm5vbmNlX3N1cHBvcnRlZCI6dHJ1ZX0.G1GwHu5qWW1Hj8-E2BObM3BIwi0ntDeoX0ymHR2EufgXxWcBI7rePadO2vGqJIRFpzsoN7ixRT1-ChpvUT7X37izDqCMHRTsBgEEKqh15gvgB-siYfssBmojcJx4W_DcKx24-4Z_mi4_BejPU6_kstJrlOPzh33dOPiUZJcY0pAWpynaTPFR3WkdbLd7RB9N-s5Z9jY2VF2SQLA8kkTcdRZQsfagErGcawJK6zttkR8EwK3D0wo_cfXoJ9Q49fayzAwkyhqfMrAWZZVwzDDtdNq4dmXfnPxNG1pootRF4PZE1IkJKteN0262xp4XZEBuWsMBeUwwjHlpu4gr77Re9w"}` - - var resultDTO ResJwt - e := json.Unmarshal([]byte(result), &resultDTO) - if e != nil { - logs.Error("JSON:" + e.Error()) - return - } - secret := NewAppleClient().GenerateClientSecret() - token, jwtError := jwt.ParseWithClaims(resultDTO.IdToken, &Claims{}, func(token *jwt.Token) (interface{}, error) { - // Don't forget to validate the alg is what you expect: - if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { - return nil, fmt.Errorf("Unexpected signing method: %v ", token.Header["alg"]) - } - return []byte(secret), nil - }) - logs.Info(jwtError) - logs.Info(token.Valid) - logs.Info(token.SigningString()) - logs.Info(token.Claims.(*Claims).Sub) -} diff --git a/pkg/partner/submail/submail_client.go b/pkg/partner/submail/submail_client.go index 23a8943..50f1c64 100644 --- a/pkg/partner/submail/submail_client.go +++ b/pkg/partner/submail/submail_client.go @@ -8,18 +8,6 @@ import ( "github.com/spf13/viper" ) -const ( -// submailUrl = "https://api.mysubmail.com/message/xsend.json" -// submailAppId = "105610" -// submialAppKey = "6fec871bd91b4184cec9a6840bc55a31" -// submailSignType = "normal" - -// // 国际短信 -// internationalUrl = "https://api-v4.mysubmail.com/internationalsms/xsend" -// internationalAppId = "62587" -// internationalAppKey = "7b1e063c06d45b29a2490e61363981c4" -) - type SubmailClient struct { ToMobile string TplId string diff --git a/pkg/utils/p_tools.go b/pkg/utils/p_tools.go index c544df4..06f30c5 100644 --- a/pkg/utils/p_tools.go +++ b/pkg/utils/p_tools.go @@ -17,10 +17,7 @@ func IsWhiteIp(ip string) (result bool) { result = false - whiteList := []string{ - "120.53.99.84", - "175.11.144.242", - } + whiteList := []string{} result = IsInStringList(ip, whiteList)