调整微信登录二维码请求限制,修改商户注册接口
This commit is contained in:
@ -27,7 +27,7 @@ type MerchantLoginRes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MerchantCodeReq struct {
|
type MerchantCodeReq struct {
|
||||||
g.Meta `path:"/merchant/code" method:"get" tags:"Merchant" summary:"(商户门店后台)商户获取短信验证码"`
|
g.Meta `path:"/merchant/code" method:"post" tags:"Merchant" summary:"(商户门店后台)商户获取短信验证码"`
|
||||||
Phone string `json:"phone" v:"required" dc:"手机号"`
|
Phone string `json:"phone" v:"required" dc:"手机号"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ type RankingRes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NonLoginTaskListReq struct {
|
type NonLoginTaskListReq struct {
|
||||||
g.Meta `path:"/task/getNonLoginTaskList" method:"get" tags:"Task" summary:"(PC)网吧未登录任务列表"`
|
g.Meta `path:"/task/getNonLoginTaskList" method:"get" tags:"Task" summary:"(PC)网吧未登录、已登录未绑定任务列表"`
|
||||||
NetBarAccount string `json:"netBarAccount" v:"required#网关账号不能为空" dc:"网关账号"`
|
NetBarAccount string `json:"netBarAccount" v:"required#网关账号不能为空" dc:"网关账号"`
|
||||||
Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
||||||
Num int `json:"num" v:"required#不能为空" dc:""`
|
Num int `json:"num" v:"required#不能为空" dc:""`
|
||||||
@ -35,7 +35,7 @@ type NonLoginTaskListRes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetLoginTaskListReq struct {
|
type GetLoginTaskListReq struct {
|
||||||
g.Meta `path:"/task/getLoginTaskList" method:"get" tags:"Task" summary:"(PC)网吧已登录任务列表"`
|
g.Meta `path:"/task/getLoginTaskList" method:"get" tags:"Task" summary:"(PC)网吧已登录已绑定任务列表"`
|
||||||
NetBarAccount string `json:"netBarAccount" v:"required#网关账号不能为空" dc:"网关账号"`
|
NetBarAccount string `json:"netBarAccount" v:"required#网关账号不能为空" dc:"网关账号"`
|
||||||
Num int `json:"num" v:"required#不能为空" dc:""`
|
Num int `json:"num" v:"required#不能为空" dc:""`
|
||||||
Pageidx string `json:"pageidx" dc:"分页索引"`
|
Pageidx string `json:"pageidx" dc:"分页索引"`
|
||||||
|
|||||||
@ -19,24 +19,24 @@ import (
|
|||||||
|
|
||||||
func (c *ControllerV1) WeChatLogin(ctx context.Context, req *v1.WeChatLoginReq) (res *v1.WeChatLoginRes, err error) {
|
func (c *ControllerV1) WeChatLogin(ctx context.Context, req *v1.WeChatLoginReq) (res *v1.WeChatLoginRes, err error) {
|
||||||
glog.Infof(ctx, "收到微信登录请求,SceneId: %s", req.SceneId)
|
glog.Infof(ctx, "收到微信登录请求,SceneId: %s", req.SceneId)
|
||||||
loginLimitKey := fmt.Sprintf(consts.WeChatLoginLimit, req.SceneId)
|
//loginLimitKey := fmt.Sprintf(consts.WeChatLoginLimit, req.SceneId)
|
||||||
|
//
|
||||||
// 检查登录限制
|
//// 检查登录限制
|
||||||
va, err := g.Redis().Get(ctx, loginLimitKey)
|
//va, err := g.Redis().Get(ctx, loginLimitKey)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
glog.Errorf(ctx, "Redis 获取登录限制失败: %v", err)
|
// glog.Errorf(ctx, "Redis 获取登录限制失败: %v", err)
|
||||||
return nil, ecode.Fail.Sub("获取登录限制失败")
|
// return nil, ecode.Fail.Sub("获取登录限制失败")
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
if !va.IsEmpty() {
|
//if !va.IsEmpty() {
|
||||||
glog.Warningf(ctx, "SceneId %s 登录请求过于频繁", req.SceneId)
|
// glog.Warningf(ctx, "SceneId %s 登录请求过于频繁", req.SceneId)
|
||||||
return nil, ecode.InvalidOperation.Sub("请勿重复请求登录二维码")
|
// return nil, ecode.InvalidOperation.Sub("请勿重复请求登录二维码")
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
if err = g.Redis().SetEX(ctx, loginLimitKey, 1, 60); err != nil {
|
//if err = g.Redis().SetEX(ctx, loginLimitKey, 1, 60); err != nil {
|
||||||
glog.Errorf(ctx, "Redis 设置登录限制失败: %v", err)
|
// glog.Errorf(ctx, "Redis 设置登录限制失败: %v", err)
|
||||||
return nil, ecode.Fail.Sub("登录频率限制设置失败")
|
// return nil, ecode.Fail.Sub("登录频率限制设置失败")
|
||||||
}
|
//}
|
||||||
|
|
||||||
client := wechat.GetWeChatClient()
|
client := wechat.GetWeChatClient()
|
||||||
ticket, err := client.GetTicket(fmt.Sprintf("%s", req.SceneId))
|
ticket, err := client.GetTicket(fmt.Sprintf("%s", req.SceneId))
|
||||||
|
|||||||
Reference in New Issue
Block a user