feat(app): update

This commit is contained in:
Yangtao
2025-11-18 18:33:22 +08:00
parent 6e56cab848
commit 7c0ad28e96
27 changed files with 20 additions and 673 deletions

View File

@ -14,3 +14,7 @@
- req请求体定义前缀为模块名 - req请求体定义前缀为模块名
- res响应体定义前缀为模块名 - res响应体定义前缀为模块名
- tools通用工具封装 - tools通用工具封装
```
git config --global url."git@gitea.ddegame.cn:".insteadOf "https://gitea.ddegame.cn/"
```

View File

@ -1,7 +1,5 @@
package authmeta package authmeta
// 定义通用
type TenantItem struct { type TenantItem struct {
Name string Name string
Type string Type string

View File

@ -1,8 +1,8 @@
package cache package cache
import ( import (
logs "servicebase/pkg/log"
"context" "context"
logs "servicebase/pkg/log"
redis "github.com/redis/go-redis/v9" redis "github.com/redis/go-redis/v9"
"github.com/spf13/viper" "github.com/spf13/viper"

View File

@ -1,8 +1,8 @@
package cache package cache
import ( import (
"servicebase/pkg/log"
"errors" "errors"
"servicebase/pkg/log"
"time" "time"
) )
@ -10,7 +10,7 @@ func Lock(key string) (e error) {
var success bool var success bool
TryMax := 6 TryMax := 6
redisClient := GetCommonRedisInstance().RedisClient 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() success, e = redisClient.SetNX(Ctx(), key, time.Now(), time.Millisecond*1000*3).Result()
if e != nil { if e != nil {
log.Info("Lock GetCommonRedisInstance error: " + e.Error()) 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) { func RedisLockGet(key string) (e error) {
redisClient := GetCommonRedisInstance().RedisClient redisClient := GetCommonRedisInstance().RedisClient
success := false success := false
for i := 0; i < TryMax; i++ { for range TryMax {
success, e = redisClient.SetNX(Ctx(), key, time.Now(), LockTimeout).Result() success, e = redisClient.SetNX(Ctx(), key, time.Now(), LockTimeout).Result()
if nil != e { if nil != e {
return return

View File

@ -1,9 +1,9 @@
package cache_user package cache_user
import ( import (
"fmt"
"servicebase/pkg/cache" "servicebase/pkg/cache"
"servicebase/pkg/tools" "servicebase/pkg/tools"
"fmt"
"strings" "strings"
"time" "time"
@ -14,11 +14,9 @@ import (
const key = "user:models" const key = "user:models"
const keyToken = "user:token" const keyToken = "user:token"
// 用户当前所在的房间ID + userid = chatroomid
const ACCESSTOKEN_KEY_PREV = "ACCESSTOKEN_" const ACCESSTOKEN_KEY_PREV = "ACCESSTOKEN_"
const ACCESSTOKEN_EXPIRE_DURATION = time.Hour * 24 * 180 const ACCESSTOKEN_EXPIRE_DURATION = time.Hour * 24 * 180
// 通过token获取userId
func IdByToken(token string) (userId string) { func IdByToken(token string) (userId string) {
if len(token) == 0 { if len(token) == 0 {
return return

View File

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{{.Title}}</title>
</head>
<body>
<p>Hello!</p>
<p>This is a password reset email.</p>
<a href="{{.Url}}">{{.Url}}</a>
</body>
</html>

View File

@ -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
}

View File

@ -1,18 +1,14 @@
package Netease package Netease
import ( import (
"servicebase/pkg/log"
"encoding/json" "encoding/json"
"servicebase/pkg/log"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/viper" "github.com/spf13/viper"
captcha "github.com/yidun/yidun-golang-sdk/yidun/service/captcha" captcha "github.com/yidun/yidun-golang-sdk/yidun/service/captcha"
) )
var (
CaptchaId = "28a052c000324d2e992e9e184291c92d"
)
// CaptchaSecondVerify 验证码二次校验请求 // CaptchaSecondVerify 验证码二次校验请求
func CaptchaSecondVerify(captchaId, validate string) (bool, error) { func CaptchaSecondVerify(captchaId, validate string) (bool, error) {
request := captcha.NewCaptchaVerifyRequest() request := captcha.NewCaptchaVerifyRequest()

View File

@ -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)
}

View File

@ -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)
}

View File

@ -14,22 +14,11 @@ import (
"github.com/spf13/viper" "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) { func CreateAliSmsClient(accessKeyId *string, accessKeySecret *string) (_result *dysmsapi20170525.Client, _err error) {
config := &openapi.Config{ config := &openapi.Config{
// 必填,您的 AccessKey ID
AccessKeyId: accessKeyId, AccessKeyId: accessKeyId,
// 必填,您的 AccessKey Secret
AccessKeySecret: accessKeySecret, AccessKeySecret: accessKeySecret,
} }
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
config.Endpoint = tea.String("dysmsapi.aliyuncs.com") config.Endpoint = tea.String("dysmsapi.aliyuncs.com")
_result = &dysmsapi20170525.Client{} _result = &dysmsapi20170525.Client{}
_result, _err = dysmsapi20170525.NewClient(config) _result, _err = dysmsapi20170525.NewClient(config)
@ -71,8 +60,6 @@ func SendMobileMsg01(mobile, signName, tempCode, content string) (_result *dysms
ID = viper.GetString("aliyun.sms.accessKeyId") ID = viper.GetString("aliyun.sms.accessKeyId")
Secret = viper.GetString("aliyun.sms.accessKeySecret") 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)) client, _err := CreateAliSmsClient(tea.String(ID), tea.String(Secret))
if _err != nil { if _err != nil {
return nil, _err return nil, _err
@ -90,7 +77,6 @@ func SendMobileMsg01(mobile, signName, tempCode, content string) (_result *dysms
_e = r _e = r
} }
}() }()
// 复制代码运行请自行打印 API 的返回值
_result, _err = client.SendSmsWithOptions(sendSmsRequest, &util.RuntimeOptions{}) _result, _err = client.SendSmsWithOptions(sendSmsRequest, &util.RuntimeOptions{})
if _err != nil { if _err != nil {
return nil, _err 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) { 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() sign, code := getSignAndCode()
log.InfoF("SendVerifyCodeUsaAndCanada get sms sign and code: %s %s", sign, code) log.InfoF("SendVerifyCodeUsaAndCanada get sms sign and code: %s %s", sign, code)
_result, e = SendMobileMsgUsaAndCanada(mobile, sign, code, content) _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) { 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() sign, code := getSignAndCode()
log.InfoF("SendVerifyCodeUsaAndCanada get sms sign and code: %s %s", sign, code) log.InfoF("SendVerifyCodeUsaAndCanada get sms sign and code: %s %s", sign, code)
_result, e = SendMobileMsgGlobalOther(mobile, sign, code, content) _result, e = SendMobileMsgGlobalOther(mobile, sign, code, content)
@ -141,14 +121,11 @@ func SendVerifyCodeGlobalOther(mobile, content string, fn func(_result *dysmsapi
return return
} }
// SendMobileMsgUsaAndCanada 美国/加拿大地区短信发送
func SendMobileMsgUsaAndCanada(mobile, signName, tempCode, content string) (_result *dysmsapi20170525.SendSmsResponse, _err error) { func SendMobileMsgUsaAndCanada(mobile, signName, tempCode, content string) (_result *dysmsapi20170525.SendSmsResponse, _err error) {
var ( var (
ID = viper.GetString("aliyun.sms.accessKeyId") ID = viper.GetString("aliyun.sms.accessKeyId")
Secret = viper.GetString("aliyun.sms.accessKeySecret") 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)) client, _err := CreateAliSmsClient(tea.String(ID), tea.String(Secret))
if _err != nil { if _err != nil {
return nil, _err return nil, _err
@ -166,7 +143,6 @@ func SendMobileMsgUsaAndCanada(mobile, signName, tempCode, content string) (_res
_e = r _e = r
} }
}() }()
// 复制代码运行请自行打印 API 的返回值
_result, _err = client.SendSmsWithOptions(sendSmsRequest, &util.RuntimeOptions{}) _result, _err = client.SendSmsWithOptions(sendSmsRequest, &util.RuntimeOptions{})
if _err != nil { if _err != nil {
return nil, _err return nil, _err
@ -191,20 +167,11 @@ func SendMobileMsgUsaAndCanada(mobile, signName, tempCode, content string) (_res
return res, _err return res, _err
} }
// SendMobileMsgGlobalOther 全球其他国家
func SendMobileMsgGlobalOther(mobile, signName, tempCode, content string) (_result *dysmsapi20170525.SendSmsResponse, _err error) { func SendMobileMsgGlobalOther(mobile, signName, tempCode, content string) (_result *dysmsapi20170525.SendSmsResponse, _err error) {
var ( var (
// ID AccessKey ID
// LTAI5tRfkJnr6Y6NU2T6jWoB
//
// AccessKey Secret
// BcaMWgXkwdxdJXFnCwRQbEl3Q3Xtxl
// TODO: 替换为您的AccessKey ID和AccessKey Secret
ID = viper.GetString("aliyun.sms.accessKeyId") ID = viper.GetString("aliyun.sms.accessKeyId")
Secret = viper.GetString("aliyun.sms.accessKeySecret") 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)) client, _err := CreateAliSmsClient(tea.String(ID), tea.String(Secret))
if _err != nil { if _err != nil {
return nil, _err return nil, _err
@ -238,7 +205,6 @@ func SendMobileMsgGlobalOther(mobile, signName, tempCode, content string) (_resu
} else { } else {
e.Message = tea.String(tryErr.Error()) e.Message = tea.String(tryErr.Error())
} }
// 如有需要,请打印 error
_, _err = util.AssertAsString(e.Message) _, _err = util.AssertAsString(e.Message)
if _err != nil { if _err != nil {
return nil, _err return nil, _err
@ -266,8 +232,6 @@ func SendMobileMsgHKMacauAndTW(mobile, signName, tempCode, content string) (_res
ID = viper.GetString("aliyun.sms.accessKeyId") ID = viper.GetString("aliyun.sms.accessKeyId")
Secret = viper.GetString("aliyun.sms.accessKeySecret") 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)) client, _err := CreateAliSmsClient(tea.String(ID), tea.String(Secret))
if _err != nil { if _err != nil {
return nil, _err return nil, _err

View File

@ -145,7 +145,7 @@ func _SendSms() {
/* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号] /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]
* 示例如:+8613711112222 其中前面有一个+号 86为国家码13711112222为手机号最多不要超过200个手机号*/ * 示例如:+8613711112222 其中前面有一个+号 86为国家码13711112222为手机号最多不要超过200个手机号*/
request.PhoneNumberSet = common.StringPtrs([]string{"+8615215229221"}) request.PhoneNumberSet = common.StringPtrs([]string{"+8615615156"})
/* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息server 会原样返回 */ /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息server 会原样返回 */
request.SessionContext = common.StringPtr("") request.SessionContext = common.StringPtr("")
@ -190,8 +190,6 @@ func _PullStatus() {
* 以免泄露密钥对危及您的财产安全。 * 以免泄露密钥对危及您的财产安全。
* SecretId、SecretKey 查询: https://console.cloud.tencent.com/cam/capi */ * SecretId、SecretKey 查询: https://console.cloud.tencent.com/cam/capi */
credential := common.NewCredential( credential := common.NewCredential(
// os.Getenv("TENCENTCLOUD_SECRET_ID"),
// os.Getenv("TENCENTCLOUD_SECRET_KEY"),
viper.GetString("tencent.secretId"), viper.GetString("tencent.secretId"),
viper.GetString("tencent.secretKey"), viper.GetString("tencent.secretKey"),
) )
@ -235,26 +233,21 @@ func _PullStatus() {
request.SmsSdkAppId = common.StringPtr(viper.GetString("tencent.sdkAppId")) request.SmsSdkAppId = common.StringPtr(viper.GetString("tencent.sdkAppId"))
/* 拉取最大条数最多100条 */ /* 拉取最大条数最多100条 */
request.Limit = common.Uint64Ptr(10) request.Limit = common.Uint64Ptr(10)
PhoneNumber := "+8615215229221" PhoneNumber := "+8645456151141"
request.PhoneNumber = &PhoneNumber request.PhoneNumber = &PhoneNumber
beginTime := uint64(time.Now().Unix()) - (60 * 60) beginTime := uint64(time.Now().Unix()) - (60 * 60)
request.BeginTime = &beginTime request.BeginTime = &beginTime
Offset := uint64(0) Offset := uint64(0)
request.Offset = &Offset request.Offset = &Offset
// 通过client对象调用想要访问的接口需要传入请求对象
response, err := client.PullSmsSendStatusByPhoneNumber(request) response, err := client.PullSmsSendStatusByPhoneNumber(request)
// 处理异常
if _, ok := err.(*errors.TencentCloudSDKError); ok { if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err) fmt.Printf("An API error has returned: %s", err)
return return
} }
// 非SDK异常直接失败。实际代码中可以加入其他的处理。
if err != nil { if err != nil {
panic(err) panic(err)
} }
b, _ := json.Marshal(response.Response) b, _ := json.Marshal(response.Response)
// 打印返回的json字符串
fmt.Printf("%s", b) 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"}
} }

View File

@ -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)
// }
})
}
}

View File

@ -7,9 +7,9 @@ import (
"github.com/aliyun/alibaba-cloud-sdk-go/services/slb" "github.com/aliyun/alibaba-cloud-sdk-go/services/slb"
) )
// LTAI5tCB8SmJcwfO // LTAI5tCB8SmJcwfO1
// dX4kgF4VcblsbCVdKvtCGCmvNbLkZK // dX4kgF4VcblsbCVdKvtCGCmvNbLkZK1
// ./AliyunCloudClient -t b -o update -key LTAI5tCB8SmJcwfO -sec dX4kgF4VcblsbCVdKvtCGCmvNbLkZK -reg cn-hangzhou -lb "[{"ServerId":"ServerId","Weight":"0"}] // ./AliyunCloudClient -t b -o update -key LTAI5tCB8SmJcwfO1 -sec dX4kgF4VcblsbCVdKvtCGCmvNbLkZK1 -reg cn-hangzhou -lb "[{"ServerId":"ServerId","Weight":"0"}]
func main() { func main() {
var target string var target string
flag.StringVar(&target, "t", "b", "target: b=backendServer") flag.StringVar(&target, "t", "b", "target: b=backendServer")

View File

@ -9,7 +9,7 @@ import (
) )
func main02() { func main02() {
data := ReadSheet("./CmdTools/星钻VIP体系.xlsx", 0) data := ReadSheet("./CmdTools/1.xlsx", 0)
fmt.Println(json.Marshal(data)) fmt.Println(json.Marshal(data))
for index, item := range data { for index, item := range data {
if index > 0 { if index > 0 {

View File

@ -10,8 +10,8 @@ import (
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" "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 add -key AKIDSoxxjI5tukPr9ECsQmwthKhroaCZlldI1 -sec b1FG2b3JMrESVLxjJdhYDgx12qPiplXB1 -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 remove -key AKIDSoxxjI5tukPr9ECsQmwthKhroaCZlldI1 -sec b1FG2b3JMrESVLxjJdhYDgx12qPiplXB1 -reg ap-shanghai -params "{\"LoadBalancerId\":\"lb-jip7505r\",\"InstanceIds\":[\"ins-n2i7x483\"]}"
func main03() { func main03() {
var target string var target string

View File

@ -14,7 +14,6 @@ const (
// API_V_NUM = "1" // API_V_NUM = "1"
//API密钥 //API密钥
// API_SECRECT = "x63363eacf804b4394a120aea240fd9a"
//图片域名 //图片域名
@ -23,8 +22,6 @@ const (
MEDIA_URL_PREV = "https://media-qiniu-app.ddegame.cn/" MEDIA_URL_PREV = "https://media-qiniu-app.ddegame.cn/"
//====== 三方key ======= //====== 三方key =======
//NETEASE_IM_APPKEY = "a0671ecde01ef03928ccfd460c62d203"
//NETEASE_IM_SECRET = "eb88916031ca"
//用户认证申请状态 //用户认证申请状态
USER_CERTIFY_STATUS_INIT = "1" //已提交 USER_CERTIFY_STATUS_INIT = "1" //已提交

View File

@ -1267,9 +1267,6 @@ const (
ICON_TYPE_VIP = "VIP" ICON_TYPE_VIP = "VIP"
ICON_TYPE_NOBILITY = "NOBILITY" ICON_TYPE_NOBILITY = "NOBILITY"
ICON_TYPE_MEDAL = "MEDAL" ICON_TYPE_MEDAL = "MEDAL"
H5ROOM_API_SECRET = "H5ROOM_API_SECRET" //H5客户端key
INNER_API_SECRET_TRADE = "INNER_API_SECRET_TRADE_kasdhfih" //trade客户端key
) )
const ( const (

View File

@ -99,7 +99,6 @@ func (client *ImClient) CreateImUser(userId, nickName, avatar string) error {
logs.Info("YunXin_SignUp_Fail_AccID_%s:"+err.Error(), userId) logs.Info("YunXin_SignUp_Fail_AccID_%s:"+err.Error(), userId)
return err return err
} else { } else {
// {"code":200,"info":{"token":"123456","accid":"b8af4bebe2064435974ba2340d852055","name":"b8af4bebe2064435974ba2340d852055"}}
var resDTO CreateImRes var resDTO CreateImRes
json.Unmarshal([]byte(res), &resDTO) json.Unmarshal([]byte(res), &resDTO)
if resDTO.Code != 200 { if resDTO.Code != 200 {
@ -128,8 +127,6 @@ func (client *ImClient) GetImUserInfo(userId string) error {
byteData, _ := json.Marshal(accids) byteData, _ := json.Marshal(accids)
sb.Append("accids=" + string(byteData)) sb.Append("accids=" + string(byteData))
res, err := HyTools.HttpDo(httpMethod, url, header, sb.ToString()) 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 + "#") logs.Info("#" + "查询云信用户信息结果:" + res + "#")
var body map[string]interface{} var body map[string]interface{}
if errJson := json.Unmarshal([]byte(res), &body); errJson != nil { 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) logs.Info(common.LOG_QUOTE_STRING + "云信创建聊天室请求失败:" + err.Error() + common.LOG_QUOTE_STRING)
return 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) logs.Info(common.LOG_QUOTE_STRING + "云信创建聊天室结果:" + res + common.LOG_QUOTE_STRING)
var createRes CreateChatroomResponse var createRes CreateChatroomResponse
err1 := json.Unmarshal([]byte(res), &createRes) err1 := json.Unmarshal([]byte(res), &createRes)

View File

@ -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()
}

View File

@ -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)
}

View File

@ -2,7 +2,6 @@ package constant
const ( const (
PhotoDomainUrl = "https://photo-app.ddegame.cn/" PhotoDomainUrl = "https://photo-app.ddegame.cn/"
API_SECRET = "c9ca017f078a4cd1ba5ccb9d02d4869a"
HTTP_METHOD_POST = "POST" HTTP_METHOD_POST = "POST"
LOG_QUOTE_STRING = "#" LOG_QUOTE_STRING = "#"

View File

@ -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)
}

View File

@ -60,7 +60,6 @@ func getCommonHeaderMap() map[string]string {
headerMap["TimeStamp"] = strconv.Itoa(time.Now().Second()) headerMap["TimeStamp"] = strconv.Itoa(time.Now().Second())
headerMap["BundleId"] = "meetalkH5" headerMap["BundleId"] = "meetalkH5"
headerMap["OsVersion"] = "10.01" headerMap["OsVersion"] = "10.01"
headerMap["INNER-TOKEN"] = "b028c52286c95de48a1c773d7ed02d04"
return headerMap return headerMap
} }

View File

@ -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)
}

View File

@ -8,18 +8,6 @@ import (
"github.com/spf13/viper" "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 { type SubmailClient struct {
ToMobile string ToMobile string
TplId string TplId string

View File

@ -17,10 +17,7 @@ func IsWhiteIp(ip string) (result bool) {
result = false result = false
whiteList := []string{ whiteList := []string{}
"120.53.99.84",
"175.11.144.242",
}
result = IsInStringList(ip, whiteList) result = IsInStringList(ip, whiteList)