Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34f70342f4 | ||
|
|
069f74b60f | ||
|
|
854c355456 | ||
|
|
252e5953f3 | ||
|
|
34fbd24365 | ||
|
|
451be79b39 | ||
| 7097afb18c | |||
|
|
7f363e9428 | ||
|
|
fac72b7014 |
@ -54,3 +54,10 @@ func (c *Client) Auth(req *AuthReq) (resp *AuthResp, err error) {
|
|||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearPaySwitchCache 清切支付名单判定缓存(内网无签名接口,按 user_name + game_id 即时清 asdk 判定缓存)
|
||||||
|
func (c *Client) ClearPaySwitchCache(req *ClearPaySwitchCacheReq) (resp *ClearPaySwitchCacheResp, err error) {
|
||||||
|
resp = CreateClearPaySwitchCacheResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
42
services/asdk/pay_switch.go
Normal file
42
services/asdk/pay_switch.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package asdk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ClearPaySwitchCacheReq
|
||||||
|
// 清切支付名单判定缓存请求(内网无签名接口,按 user_name + game_id 即时清 asdk 判定缓存)
|
||||||
|
type ClearPaySwitchCacheReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClearPaySwitchCacheResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data struct{} `json:"data"`
|
||||||
|
TraceId string `json:"trace_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateClearPaySwitchCacheReq 构造清缓存请求(user_name + game_id)
|
||||||
|
func CreateClearPaySwitchCacheReq(userName string, gameId int64) *ClearPaySwitchCacheReq {
|
||||||
|
req := &ClearPaySwitchCacheReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/vip/clear_pay_switch_cache")
|
||||||
|
req.Method = requests.POST
|
||||||
|
req.FormParams = map[string]string{
|
||||||
|
"user_name": userName,
|
||||||
|
"game_id": strconv.FormatInt(gameId, 10),
|
||||||
|
}
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateClearPaySwitchCacheResp() *ClearPaySwitchCacheResp {
|
||||||
|
return &ClearPaySwitchCacheResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,7 +14,7 @@ import (
|
|||||||
// 说明:切片为空表示不限定该条件;标量字符串为空时不参与筛选
|
// 说明:切片为空表示不限定该条件;标量字符串为空时不参与筛选
|
||||||
type GetUserLoginLogParam struct {
|
type GetUserLoginLogParam struct {
|
||||||
Uid string `json:"uid"`
|
Uid string `json:"uid"`
|
||||||
EventTime string `json:"event_time"` // 形如 "2026-06"
|
EventTime []string `json:"event_time"` // 区间 [开始, 结束]
|
||||||
GameSign string `json:"game_sign"`
|
GameSign string `json:"game_sign"`
|
||||||
ServerGroupId []string `json:"server_group_id"`
|
ServerGroupId []string `json:"server_group_id"`
|
||||||
GameId string `json:"game_id"`
|
GameId string `json:"game_id"`
|
||||||
@ -31,7 +31,7 @@ type GetUserLoginLogParam struct {
|
|||||||
type GetUserLoginLogRequest struct {
|
type GetUserLoginLogRequest struct {
|
||||||
*requests.JsonRequest
|
*requests.JsonRequest
|
||||||
Uid string `position:"Json" field:"uid"`
|
Uid string `position:"Json" field:"uid"`
|
||||||
EventTime string `position:"Json" field:"event_time"`
|
EventTime []string `position:"Json" field:"event_time"`
|
||||||
GameSign string `position:"Json" field:"game_sign"`
|
GameSign string `position:"Json" field:"game_sign"`
|
||||||
ServerGroupId []string `position:"Json" field:"server_group_id"`
|
ServerGroupId []string `position:"Json" field:"server_group_id"`
|
||||||
GameId string `position:"Json" field:"game_id"`
|
GameId string `position:"Json" field:"game_id"`
|
||||||
@ -50,7 +50,7 @@ type GetUserLoginLogRequest struct {
|
|||||||
// - 标量字符串用 omitempty:空串时不出现在 JSON 中,避免被 DMS 当成真实筛选条件。
|
// - 标量字符串用 omitempty:空串时不出现在 JSON 中,避免被 DMS 当成真实筛选条件。
|
||||||
type getUserLoginLogBody struct {
|
type getUserLoginLogBody struct {
|
||||||
Uid string `json:"uid,omitempty"`
|
Uid string `json:"uid,omitempty"`
|
||||||
EventTime string `json:"event_time,omitempty"`
|
EventTime []string `json:"event_time"`
|
||||||
GameSign string `json:"game_sign,omitempty"`
|
GameSign string `json:"game_sign,omitempty"`
|
||||||
ServerGroupId []string `json:"server_group_id"`
|
ServerGroupId []string `json:"server_group_id"`
|
||||||
GameId string `json:"game_id,omitempty"`
|
GameId string `json:"game_id,omitempty"`
|
||||||
@ -67,7 +67,7 @@ type getUserLoginLogBody struct {
|
|||||||
func (request *GetUserLoginLogRequest) GetBodyReader() io.Reader {
|
func (request *GetUserLoginLogRequest) GetBodyReader() io.Reader {
|
||||||
body := getUserLoginLogBody{
|
body := getUserLoginLogBody{
|
||||||
Uid: request.Uid,
|
Uid: request.Uid,
|
||||||
EventTime: request.EventTime,
|
EventTime: emptyStrSlice(request.EventTime),
|
||||||
GameSign: request.GameSign,
|
GameSign: request.GameSign,
|
||||||
ServerGroupId: emptyStrSlice(request.ServerGroupId),
|
ServerGroupId: emptyStrSlice(request.ServerGroupId),
|
||||||
GameId: request.GameId,
|
GameId: request.GameId,
|
||||||
|
|||||||
@ -205,3 +205,10 @@ func (c *Client) GetRole(req *GetRoleReq) (response *GetRoleResp, err error) {
|
|||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPaySwitchUser 微信小游戏切支付名单中转查询(按 user_name + game_id 读 db_center 名单,返回 status + risk_level)
|
||||||
|
func (c *Client) GetPaySwitchUser(req *GetPaySwitchUserReq) (resp *GetPaySwitchUserResp, err error) {
|
||||||
|
resp = CreateGetPaySwitchUserResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
45
services/game/pay_switch.go
Normal file
45
services/game/pay_switch.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetPaySwitchUserReq
|
||||||
|
// 微信小游戏切支付名单中转查询请求(按 user_name + game_id 读 db_center.wd_pay_switch_user)
|
||||||
|
type GetPaySwitchUserReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
UserName string `position:"Body" field:"user_name"` // 账号
|
||||||
|
GameId int64 `position:"Body" field:"game_id"` // 子游戏ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPaySwitchUserRespData 中转返回的名单状态
|
||||||
|
type GetPaySwitchUserRespData struct {
|
||||||
|
Status int64 `json:"status"` // 切支付开关 1开启 0关闭
|
||||||
|
RiskLevel int64 `json:"risk_level"` // 风险档位 1高 2中 3低;0未设置/关闭
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPaySwitchUserResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data GetPaySwitchUserRespData `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetPaySwitchUserReq(userName string, gameId int64) *GetPaySwitchUserReq {
|
||||||
|
req := &GetPaySwitchUserReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.UserName = userName
|
||||||
|
req.GameId = gameId
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/pay/switchUser")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetPaySwitchUserResp() *GetPaySwitchUserResp {
|
||||||
|
resp := &GetPaySwitchUserResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return resp
|
||||||
|
}
|
||||||
@ -1,9 +1,10 @@
|
|||||||
package passport
|
package passport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -84,6 +85,20 @@ func (c *Client) EditPhone(param EditPhoneRequestParam) (response string, err er
|
|||||||
return editPhoneResponse.GetHttpContentString(), nil
|
return editPhoneResponse.GetHttpContentString(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EditPassword
|
||||||
|
// 修改/清除用户手机号(phone 传空字符串即清除),成功返回 "ok"
|
||||||
|
func (c *Client) EditPassword(param EditPasswordRequestParam) (response string, err error) {
|
||||||
|
editPasswordRequest := CreateEditPasswordRequest(param)
|
||||||
|
editPasswordResponse := CreateEditPasswordResponse()
|
||||||
|
err = c.DoAction(editPasswordRequest, editPasswordResponse)
|
||||||
|
if err != nil && strings.Contains(err.Error(), "json Unmarshal:") {
|
||||||
|
return editPasswordResponse.GetHttpContentString(), nil
|
||||||
|
} else if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return editPasswordResponse.GetHttpContentString(), nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetUserGameSign
|
// GetUserGameSign
|
||||||
// 获取用户登录过的游戏大类
|
// 获取用户登录过的游戏大类
|
||||||
func (c *Client) GetUserGameSign(req *GetUserGameSignRequest) (response *GetUserGameSignResponse, err error) {
|
func (c *Client) GetUserGameSign(req *GetUserGameSignRequest) (response *GetUserGameSignResponse, err error) {
|
||||||
|
|||||||
@ -274,3 +274,24 @@ func TestGetUserLogin(t *testing.T) {
|
|||||||
fmt.Printf("raw: %s\n", resp.GetHttpContentString())
|
fmt.Printf("raw: %s\n", resp.GetHttpContentString())
|
||||||
fmt.Printf("data: %+v\n, %d", resp.Data, len(resp.Data))
|
fmt.Printf("data: %+v\n, %d", resp.Data, len(resp.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 测试修改密码
|
||||||
|
func TestEditPassword(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := EditPasswordRequestParam{
|
||||||
|
UserName: "huangqzcs",
|
||||||
|
Newpwd: "123456789",
|
||||||
|
}
|
||||||
|
resp, err := client.EditPassword(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("edit phone result: %s", resp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -181,3 +181,48 @@ func CreateEditPhoneResponse() (response *EditPhoneResponse) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EditPasswordRequestParam
|
||||||
|
// 修改密码相关
|
||||||
|
type EditPasswordRequestParam struct {
|
||||||
|
UserName string `position:"Body" field:"user_name"`
|
||||||
|
Newpwd string `position:"Body" field:"newpwd"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EditPasswordResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
type EditPasswordRequest struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
UserName string `position:"Body" field:"user_name"`
|
||||||
|
Newpwd string `position:"Body" field:"newpwd"`
|
||||||
|
Action string `position:"Body" field:"action"`
|
||||||
|
Flag string `position:"Body" field:"flag"`
|
||||||
|
Time string `position:"Body" field:"time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEditPasswordRequest 修改用户密码
|
||||||
|
func CreateEditPasswordRequest(param EditPasswordRequestParam) (req *EditPasswordRequest) {
|
||||||
|
ts := time.Now().Unix()
|
||||||
|
sign := weeDongGetSign(ts)
|
||||||
|
|
||||||
|
req = &EditPasswordRequest{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
Action: "edit_pwd",
|
||||||
|
Flag: sign,
|
||||||
|
Time: fmt.Sprintf("%v", ts),
|
||||||
|
UserName: param.UserName,
|
||||||
|
Newpwd: utils.Md5(param.Newpwd),
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/weedong.php")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateEditPasswordResponse() (response *EditPasswordResponse) {
|
||||||
|
response = &EditPasswordResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ const (
|
|||||||
ReplaceKeyUrl ReplaceKey = "${url}" // 链接
|
ReplaceKeyUrl ReplaceKey = "${url}" // 链接
|
||||||
ReplaceKeyUserName ReplaceKey = "${userName}" // 用户名
|
ReplaceKeyUserName ReplaceKey = "${userName}" // 用户名
|
||||||
ReplaceKeyDateTime ReplaceKey = "${dateTime}" // 年月日时分秒
|
ReplaceKeyDateTime ReplaceKey = "${dateTime}" // 年月日时分秒
|
||||||
|
ReplaceKeyPassWord ReplaceKey = "${passWord}" // 密码
|
||||||
)
|
)
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
@ -54,6 +55,7 @@ const (
|
|||||||
TemplateTypeKFOrderAdditional SmsType = "kf_order_additional" // 客服工单完成
|
TemplateTypeKFOrderAdditional SmsType = "kf_order_additional" // 客服工单完成
|
||||||
TemplateTypeCancelTip SmsType = "cancel_tip" // 提交账号注销申请
|
TemplateTypeCancelTip SmsType = "cancel_tip" // 提交账号注销申请
|
||||||
TemplateTypeReverseCancel SmsType = "reverse_cancel" // 终止账号注销申请
|
TemplateTypeReverseCancel SmsType = "reverse_cancel" // 终止账号注销申请
|
||||||
|
TemplateTypeResetPassword SmsType = "reset_password" // 重置密码
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendSmsParam struct {
|
type SendSmsParam struct {
|
||||||
|
|||||||
@ -53,3 +53,13 @@ func (c *Client) CreateRemoveBanRuleCacheReq(req *RemoveBanRuleCacheReq) (resp *
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateCheckBatchReq 批量检查用户是否被封禁
|
||||||
|
func (c *Client) CreateCheckBatchReq(req *CheckBatchReq) (resp *CheckBatchResp, err error) {
|
||||||
|
resp = CreateCheckBatchResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@ -158,3 +158,47 @@ func CreateRemoveBanRuleCacheResp() *RemoveBanRuleCacheResp {
|
|||||||
BaseResponse: &responses.BaseResponse{},
|
BaseResponse: &responses.BaseResponse{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckBatchReq
|
||||||
|
// 批量检查用户是否被封禁(只读,按身份维度匹配现行封禁规则)
|
||||||
|
type CheckBatchReq struct {
|
||||||
|
*requests.JsonRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type CheckBatchReqParam struct {
|
||||||
|
UserNames []string `json:"user_names"` // 要检查的用户名列表
|
||||||
|
}
|
||||||
|
|
||||||
|
type CheckBatchItem struct {
|
||||||
|
UserName string `json:"user_name"` // 用户名
|
||||||
|
Ban bool `json:"ban"` // 是否被封禁
|
||||||
|
BanRuleId int64 `json:"ban_rule_id"` // 命中的封禁规则id(未命中为0)
|
||||||
|
BanEndTime string `json:"ban_end_time"` // 封禁结束时间(未命中为空)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CheckBatchResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data struct {
|
||||||
|
List []CheckBatchItem `json:"list"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateCheckBatchReq(param CheckBatchReqParam) *CheckBatchReq {
|
||||||
|
req := &CheckBatchReq{
|
||||||
|
&requests.JsonRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/api/user_ban/check_batch")
|
||||||
|
req.Method = requests.POST
|
||||||
|
|
||||||
|
marshal, _ := json.Marshal(param)
|
||||||
|
_ = json.Unmarshal(marshal, &req.JsonParams)
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateCheckBatchResp() *CheckBatchResp {
|
||||||
|
return &CheckBatchResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
42
services/web/client.go
Normal file
42
services/web/client.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package web
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2020-01-01"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HOST 官网 web 服务域名(带 ".",SDK 不会再追加 .gaore.com)
|
||||||
|
var HOST = requests.Host{
|
||||||
|
Default: "web.gaore.com",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForceOut 清除玩家官网 web 登录 session,返回远端原始响应
|
||||||
|
// 对齐老综合后台 GaoreSDK web->force_out
|
||||||
|
func (c *Client) ForceOut(userName string, ts int64) (response string, err error) {
|
||||||
|
req := CreateForceOutReq(userName, ts)
|
||||||
|
resp := CreateForceOutResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
if err != nil && strings.Contains(err.Error(), "json Unmarshal:") {
|
||||||
|
// 远端返回非 JSON(如纯文本),直接取原始响应
|
||||||
|
return resp.GetHttpContentString(), nil
|
||||||
|
} else if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return resp.GetHttpContentString(), nil
|
||||||
|
}
|
||||||
44
services/web/force_out.go
Normal file
44
services/web/force_out.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package web
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// forceOutSignKey 老综合后台业务层计算 sign 用的固定盐
|
||||||
|
const forceOutSignKey = "user_session_20220505"
|
||||||
|
|
||||||
|
type ForceOutReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type ForceOutResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateForceOutReq 创建官网强制下线请求
|
||||||
|
// POST web.gaore.com/web/users/force_out,sign=md5(user_name+time+"user_session_20220505")
|
||||||
|
func CreateForceOutReq(userName string, ts int64) *ForceOutReq {
|
||||||
|
sign := utils.Md5(fmt.Sprintf("%s%d%s", userName, ts, forceOutSignKey))
|
||||||
|
|
||||||
|
req := &ForceOutReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/web/users/force_out")
|
||||||
|
req.FormParams = map[string]string{
|
||||||
|
"user_name": userName,
|
||||||
|
"time": fmt.Sprintf("%d", ts),
|
||||||
|
"sign": sign,
|
||||||
|
}
|
||||||
|
req.Method = requests.POST
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateForceOutResp() *ForceOutResp {
|
||||||
|
return &ForceOutResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,8 @@
|
|||||||
package www
|
package www
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
)
|
)
|
||||||
@ -25,6 +27,13 @@ type Client struct {
|
|||||||
sdk.Client
|
sdk.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewClient 无凭证客户端(用于自带签名的表单接口,如 refreshUserSessionId)
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = &Client{}
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
||||||
client = &Client{}
|
client = &Client{}
|
||||||
err = client.InitWithAccessKey(accesskey, secrect, source)
|
err = client.InitWithAccessKey(accesskey, secrect, source)
|
||||||
@ -42,3 +51,17 @@ func (c *Client) GetUserInfo(req *GetPwdRequest) (response *GetPwdResponse, err
|
|||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RefreshUserSessionID 刷新用户 session(清 www 登录态),返回远端原始响应
|
||||||
|
func (c *Client) RefreshUserSessionID(uname string) (response string, err error) {
|
||||||
|
req := CreateRefreshUserSessionIDReq(uname)
|
||||||
|
resp := CreateRefreshUserSessionIDResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
if err != nil && strings.Contains(err.Error(), "json Unmarshal:") {
|
||||||
|
// 远端返回非 JSON(如纯文本),直接取原始响应
|
||||||
|
return resp.GetHttpContentString(), nil
|
||||||
|
} else if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return resp.GetHttpContentString(), nil
|
||||||
|
}
|
||||||
|
|||||||
55
services/www/refresh_session.go
Normal file
55
services/www/refresh_session.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package www
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 对齐老综合后台 GaoreSDK www->refreshUserSessionId 的固定 appid=20 验签
|
||||||
|
const (
|
||||||
|
refreshSessionAppID = "20"
|
||||||
|
refreshSessionAppKey = "yWpx3hWQHFhSnTCj#20#6KuRKuaAjLJ5sYRy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// refreshSessionHost 老 PHP SDK 打的是 apisdk.gaore.com,与本包默认 HOST(apisdk.9ooo.cn) 不同,
|
||||||
|
// 此处显式固定到 apisdk.gaore.com,与老综合后台 1:1 对齐。
|
||||||
|
var refreshSessionHost = requests.Host{Default: "apisdk.gaore.com"}
|
||||||
|
|
||||||
|
type RefreshUserSessionIDReq struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type RefreshUserSessionIDResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRefreshUserSessionIDReq 刷新用户 www session(使官网/9ooo 登录态失效)
|
||||||
|
// POST /user/sdk_passport.php,sign=md5(appkey+time)
|
||||||
|
func CreateRefreshUserSessionIDReq(uname string) *RefreshUserSessionIDReq {
|
||||||
|
ts := time.Now().Unix()
|
||||||
|
sign := utils.Md5(refreshSessionAppKey + fmt.Sprintf("%d", ts))
|
||||||
|
|
||||||
|
req := &RefreshUserSessionIDReq{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(refreshSessionHost, VERSION, "/user/sdk_passport.php")
|
||||||
|
req.FormParams = map[string]string{
|
||||||
|
"appid": refreshSessionAppID,
|
||||||
|
"time": fmt.Sprintf("%d", ts),
|
||||||
|
"do": "refreshUserSessionId",
|
||||||
|
"uname": uname,
|
||||||
|
"sign": sign,
|
||||||
|
}
|
||||||
|
req.Method = requests.POST
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateRefreshUserSessionIDResp() *RefreshUserSessionIDResp {
|
||||||
|
return &RefreshUserSessionIDResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user