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

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

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"
)
// 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

View File

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

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