修改用户未登录,登录查询游戏任务功能
This commit is contained in:
@ -22,13 +22,11 @@ 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:"网关账号"`
|
||||||
//Page int `json:"page" v:"required#分页索引不能为空" dc:"分页索引"`
|
Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
||||||
//Size int `json:"size" v:"required#分页大小不能为空" dc:"分页大小"`
|
Num int `json:"num" v:"required#不能为空" dc:""`
|
||||||
Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
Pageidx string `json:"pageidx" dc:"分页索引"`
|
||||||
Num int `json:"num" v:"required#不能为空" dc:""`
|
Source string `json:"source" v:"required#不能为空" dc:""`
|
||||||
Pageidx string `json:"pageidx" dc:"分页索引"`
|
BrandId string `json:"brandId" dc:"品牌id(可选)"`
|
||||||
Source string `json:"source" v:"required#不能为空" dc:""`
|
|
||||||
BrandId string `json:"brandId" dc:"品牌id(可选)"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type NonLoginTaskListRes struct {
|
type NonLoginTaskListRes struct {
|
||||||
@ -40,12 +38,11 @@ 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:"网关账号"`
|
||||||
//Page int `json:"page" v:"required#分页索引不能为空" dc:"分页索引"`
|
//Num int `json:"num" v:"required#不能为空" dc:""`
|
||||||
//Size int `json:"size" v:"required#分页大小不能为空" dc:"分页大小"`
|
//Pageidx string `json:"pageidx" dc:"分页索引"`
|
||||||
Num int `json:"num" v:"required#不能为空" dc:""`
|
Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
||||||
Pageidx string `json:"pageidx" dc:"分页索引"`
|
//BrandId string `json:"brandId" dc:"品牌id(可选)"`
|
||||||
Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
|
PopenId string `json:"popenId" v:"required#popenId不能为空" dc:"用户详情接口返回的 wxPopenId 或者是 qqPopenId"`
|
||||||
BrandId string `json:"brandId" dc:"品牌id(可选)"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetLoginTaskListRes struct {
|
type GetLoginTaskListRes struct {
|
||||||
|
|||||||
@ -10,11 +10,9 @@ import (
|
|||||||
|
|
||||||
func (c *ControllerV1) GetLoginTaskList(ctx context.Context, req *v1.GetLoginTaskListReq) (res *v1.GetLoginTaskListRes, err error) {
|
func (c *ControllerV1) GetLoginTaskList(ctx context.Context, req *v1.GetLoginTaskListReq) (res *v1.GetLoginTaskListRes, err error) {
|
||||||
out, err := service.Task().GetLoginTaskList(ctx, &model.GetLoginTaskListIn{
|
out, err := service.Task().GetLoginTaskList(ctx, &model.GetLoginTaskListIn{
|
||||||
NetBarAccount: req.NetBarAccount,
|
|
||||||
Num: req.Num,
|
|
||||||
Pageidx: req.Pageidx,
|
|
||||||
Gid: req.Gid,
|
Gid: req.Gid,
|
||||||
BrandId: req.BrandId,
|
NetBarAccount: req.NetBarAccount,
|
||||||
|
POpenId: req.PopenId,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -157,7 +157,7 @@ func (s *sTask) GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskList
|
|||||||
// 调用外部接口
|
// 调用外部接口
|
||||||
data, err := tencent.GetLoginTaskList(ctx, in)
|
data, err := tencent.GetLoginTaskList(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("调用接口异常")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 任务列表数据处理
|
// TODO 任务列表数据处理
|
||||||
|
|||||||
@ -18,14 +18,18 @@ type GetNonLoginTaskListOut struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetLoginTaskListIn struct {
|
type GetLoginTaskListIn struct {
|
||||||
NetBarAccount string `json:"netBarAccount"` //网关账号
|
NetBarAccount string `json:"netbar_account"` //网关账号
|
||||||
//Page int `json:"page"` // 分页索引
|
Gid int `json:"gid"` // 游戏唯一id
|
||||||
//Size int `json:"size"` // 分页大小
|
POpenId string `json:"POpenId"` //POpenId
|
||||||
Pageidx string `json:"pageidx"` // 分页索引
|
}
|
||||||
Num int `json:"num"` //
|
|
||||||
Gid int `json:"gid"` // 游戏唯一id
|
// 获取腾讯游戏任务列表已登录入参
|
||||||
Source string `json:"source"` // 不能为空
|
type GetTenCentLoginTaskListIn struct {
|
||||||
BrandId string `json:"brandId"` // 品牌id(可选)
|
NetBarAccount string `json:"netbar_account"` //网关账号
|
||||||
|
Pageidx string `json:"pageidx"` // 分页索引
|
||||||
|
Num int `json:"num"` //
|
||||||
|
Gid int `json:"gid"` // 游戏唯一id
|
||||||
|
BrandId string `json:"brand_id"` // 品牌id(可选)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetLoginTaskListOut struct {
|
type GetLoginTaskListOut struct {
|
||||||
|
|||||||
@ -73,6 +73,9 @@ func init() {
|
|||||||
//enforcer.AddPolicy("user", "/x/feedback/*", "DELETE", "删除反馈信息")*
|
//enforcer.AddPolicy("user", "/x/feedback/*", "DELETE", "删除反馈信息")*
|
||||||
enforcer.AddPolicy("user", "/x/feedback/*", "GET", "查询反馈详情")
|
enforcer.AddPolicy("user", "/x/feedback/*", "GET", "查询反馈详情")
|
||||||
|
|
||||||
|
// 任务
|
||||||
|
enforcer.AddPolicy("user", "/x/task/getLoginTaskList", "GET", "获取任务列表(已登录)")
|
||||||
|
|
||||||
}
|
}
|
||||||
// 门店
|
// 门店
|
||||||
{
|
{
|
||||||
@ -84,9 +87,6 @@ func init() {
|
|||||||
enforcer.AddPolicy("store", "/x/rewardType", "PUT", "更新奖励类型")
|
enforcer.AddPolicy("store", "/x/rewardType", "PUT", "更新奖励类型")
|
||||||
enforcer.AddPolicy("store", "/x/rewardType/*", "DELETE", "删除奖励类型")
|
enforcer.AddPolicy("store", "/x/rewardType/*", "DELETE", "删除奖励类型")
|
||||||
|
|
||||||
// 任务
|
|
||||||
enforcer.AddPolicy("user", "/x/task/getNonLoginTaskList", "GET", "获取任务列表(已登录)")
|
|
||||||
|
|
||||||
// 门店角色
|
// 门店角色
|
||||||
enforcer.AddPolicy("store", "/x/store/role", "GET", "获取门店角色列表")
|
enforcer.AddPolicy("store", "/x/store/role", "GET", "获取门店角色列表")
|
||||||
enforcer.AddPolicy("store", "/x/store/role", "POST", "添加门店角色")
|
enforcer.AddPolicy("store", "/x/store/role", "POST", "添加门店角色")
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
"golang.org/x/net/context/ctxhttp"
|
"golang.org/x/net/context/ctxhttp"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -15,35 +17,6 @@ import (
|
|||||||
// GetNonLoginTaskList 获取下发到指定网吧的任务列表(未登录)
|
// GetNonLoginTaskList 获取下发到指定网吧的任务列表(未登录)
|
||||||
func GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTaskListIn) (data interface{}, err error) {
|
func GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTaskListIn) (data interface{}, err error) {
|
||||||
|
|
||||||
//client := &http.Client{}
|
|
||||||
//// 请求参数
|
|
||||||
//jsonStr, err := json.Marshal(in)
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("参数序列化失败")
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//req, err := http.NewRequest("POST", consts.TestAddr+"GetNonloginTaskList", bytes.NewBuffer(jsonStr))
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("创建请求失败")
|
|
||||||
//}
|
|
||||||
//req.Header.Set("Content-Type", "application/json")
|
|
||||||
//
|
|
||||||
//resp, err := client.Do(req)
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("请求失败")
|
|
||||||
//}
|
|
||||||
//defer resp.Body.Close()
|
|
||||||
//
|
|
||||||
//body, err := io.ReadAll(resp.Body) // 推荐用法
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("读取响应失败")
|
|
||||||
//}
|
|
||||||
//err = json.Unmarshal(body, &data)
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("解析响应失败")
|
|
||||||
//}
|
|
||||||
//return data, err
|
|
||||||
|
|
||||||
// 请求参数
|
// 请求参数
|
||||||
jsonStr, err := json.Marshal(in)
|
jsonStr, err := json.Marshal(in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -70,41 +43,36 @@ func GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTaskListIn) (
|
|||||||
|
|
||||||
// GetLoginTaskList 获取下发到指定网吧的任务列表(已登录)
|
// GetLoginTaskList 获取下发到指定网吧的任务列表(已登录)
|
||||||
func GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskListIn) (data interface{}, err error) {
|
func GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskListIn) (data interface{}, err error) {
|
||||||
|
value, err := g.Redis().Get(ctx, fmt.Sprintf(consts.GameLifeUserKey, in.POpenId))
|
||||||
|
|
||||||
//client := &http.Client{}
|
if value.IsEmpty() {
|
||||||
//// 请求参数
|
return nil, ecode.Fail.Sub("从redis获取值异常")
|
||||||
//jsonStr, err := json.Marshal(in)
|
}
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("参数序列化失败")
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//req, err := http.NewRequest("POST", consts.TestAddr+"GetTaskList", bytes.NewBuffer(jsonStr))
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("创建请求失败")
|
|
||||||
//}
|
|
||||||
//req.Header.Set("Content-Type", "application/json")
|
|
||||||
////req.Header.Set("Authorization", "Bearer 你的Token")
|
|
||||||
//
|
|
||||||
//resp, err := client.Do(req)
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("请求失败")
|
|
||||||
//}
|
|
||||||
//defer resp.Body.Close()
|
|
||||||
//
|
|
||||||
//body, err := io.ReadAll(resp.Body) // 推荐用法
|
|
||||||
//if err != nil {
|
|
||||||
// return nil, ecode.Fail.Sub("读取响应失败")
|
|
||||||
//}
|
|
||||||
//fmt.Println("响应内容:", string(body))
|
|
||||||
//return nil, err
|
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("从redis读取数据失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
var cache model.UserGamelifeCache
|
||||||
|
err = json.Unmarshal(value.Bytes(), &cache)
|
||||||
|
if err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("获取用户信息失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
req := &model.GetTenCentLoginTaskListIn{
|
||||||
|
Gid: in.Gid,
|
||||||
|
NetBarAccount: in.NetBarAccount,
|
||||||
|
Num: 10,
|
||||||
|
Pageidx: "",
|
||||||
|
BrandId: "",
|
||||||
|
}
|
||||||
// 请求参数
|
// 请求参数
|
||||||
jsonStr, err := json.Marshal(in)
|
jsonStr, err := json.Marshal(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("参数序列化失败")
|
return nil, ecode.Fail.Sub("参数序列化失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := ctxhttp.Post(ctx, http.DefaultClient, consts.TestAddr+"GetTaskList", "application/json", bytes.NewBuffer(jsonStr))
|
resp, err := ctxhttp.Post(ctx, http.DefaultClient, consts.TestAddr+"GetTaskList"+"?"+cache.Params, "application/json", bytes.NewBuffer(jsonStr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("请求失败")
|
return nil, ecode.Fail.Sub("请求失败")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user