实现获取用户角色列表接口
This commit is contained in:
@ -12,4 +12,5 @@ const (
|
||||
const (
|
||||
GetNonLoginTaskList = "GetNonloginTaskList"
|
||||
GetTaskList = "GetTaskList"
|
||||
QueryUserRoleList = "QueryUserRoleList"
|
||||
)
|
||||
|
||||
17
internal/controller/user/user_v1_get_user_game_role_list.go
Normal file
17
internal/controller/user/user_v1_get_user_game_role_list.go
Normal file
@ -0,0 +1,17 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/user/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) GetUserGameRoleList(ctx context.Context, req *v1.GetUserGameRoleListReq) (res *v1.GetUserGameRoleListRes, err error) {
|
||||
out, err := service.User().GetUserGameRole(ctx, &model.GetUserGameRoleIn{BindType: req.BindType, GameId: req.GameId, PopenId: req.PopenId, Area: req.Area})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.GetUserGameRoleListRes{List: out.RoleList}, nil
|
||||
}
|
||||
@ -299,3 +299,17 @@ func (s *sUser) DelUser(ctx context.Context, in *model.DelUserIn) (out *model.De
|
||||
|
||||
return &model.DeleteOut{Success: true}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) GetUserGameRole(ctx context.Context, in *model.GetUserGameRoleIn) (out *model.GetUserGameRoleOut, err error) {
|
||||
activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{ServiceName: consts.QueryUserRoleList, PopenId: in.PopenId, BindType: in.BindType, UserRoleParam: model.UserRoleParam{Gid: in.GameId, Area: in.Area}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result, ok := activity.(*[]model.UserRole)
|
||||
if !ok {
|
||||
return nil, ecode.Fail.Sub("获取用户游戏角色失败")
|
||||
}
|
||||
return &model.GetUserGameRoleOut{
|
||||
RoleList: *result,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -58,9 +58,21 @@ type TaskParam struct {
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
type QQNetbarActivityIn struct {
|
||||
ServiceName string // 服务名称
|
||||
TaskParam TaskParam // 参数体
|
||||
PopenId string
|
||||
BindType int
|
||||
type UserRoleParam struct {
|
||||
Area int `json:"area,omitempty"` // 可选参数
|
||||
Gid int `json:"gid"`
|
||||
}
|
||||
type UserRole struct {
|
||||
RoleName string `json:"role_name"`
|
||||
RoleIdx string `json:"roleIdx"`
|
||||
}
|
||||
type UserRoleListResponse struct {
|
||||
RoleList []UserRole `json:"role_list"`
|
||||
}
|
||||
type QQNetbarActivityIn struct {
|
||||
ServiceName string // 服务名称
|
||||
TaskParam TaskParam // 参数体
|
||||
UserRoleParam UserRoleParam
|
||||
PopenId string
|
||||
BindType int
|
||||
}
|
||||
|
||||
@ -183,3 +183,12 @@ type DelUserIn struct {
|
||||
type DelUserOut struct {
|
||||
Success bool
|
||||
}
|
||||
type GetUserGameRoleIn struct {
|
||||
PopenId string
|
||||
GameId int
|
||||
BindType int
|
||||
Area int
|
||||
}
|
||||
type GetUserGameRoleOut struct {
|
||||
RoleList []UserRole
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ type (
|
||||
UnBoundUrl(ctx context.Context, in *model.UserBoundUrlIn) (out *model.UserUnBoundUrlOut, err error)
|
||||
BoundInfo(ctx context.Context, in *model.UserBoundInfoIn) (out *model.UserBoundInfoOut, err error)
|
||||
DelUser(ctx context.Context, in *model.DelUserIn) (out *model.DeleteOut, err error)
|
||||
GetUserGameRole(ctx context.Context, in *model.GetUserGameRoleIn) (out *model.GetUserGameRoleOut, err error)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user