等级推送
This commit is contained in:
parent
ef6f6efa69
commit
4b2873db8e
@ -24,7 +24,7 @@ var (
|
||||
fmt.Printf("%d- %v\n", (i + 1), v)
|
||||
}
|
||||
},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
next: func(robot *Robot, rsp proto.Message) {
|
||||
tcs := []*TestCase{}
|
||||
if _, ok := rsp.(*pb.HeroListResp); ok {
|
||||
@ -33,13 +33,16 @@ var (
|
||||
mainType: string(comm.ModuleHero),
|
||||
subType: hero.StrengthenUplv,
|
||||
req: &pb.HeroStrengthenUplvReq{
|
||||
HeroObjID: "62dabaacd8c5789e2cc8b95e",
|
||||
ExpCards: map[string]int32{
|
||||
"62dabac1d8c5789e2cc8b9d3": 1,
|
||||
HeroObjID: "62de35b92f462b70c1105aa8",
|
||||
ExpCards: []*pb.MapStringInt32{
|
||||
{
|
||||
Key: "62de35b92f462b70c1105ab8",
|
||||
Value: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
rsp: &pb.HeroStrengthenUplvResp{},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
}
|
||||
tcs = append(tcs, tc)
|
||||
}
|
||||
@ -97,8 +100,11 @@ var (
|
||||
subType: hero.StrengthenUplv,
|
||||
req: &pb.HeroStrengthenUplvReq{
|
||||
HeroObjID: heroId,
|
||||
ExpCards: map[string]int32{
|
||||
"62da19017944b60fd473df61": 1,
|
||||
ExpCards: []*pb.MapStringInt32{
|
||||
{
|
||||
Key: "62da19017944b60fd473df61",
|
||||
Value: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
rsp: &pb.HeroStrengthenUplvResp{},
|
||||
|
@ -40,7 +40,7 @@ var (
|
||||
subType: task.TaskSubTypeReceive,
|
||||
req: &pb.TaskReceiveReq{
|
||||
TaskTag: int32(comm.TASK_DAILY),
|
||||
Id: "62dab21d9efd6536b1cc1bb9",
|
||||
Id: "62de35b92f462b70c1105ac5",
|
||||
},
|
||||
rsp: &pb.TaskReceiveResp{},
|
||||
// enabled: true,
|
||||
|
@ -11,15 +11,14 @@ import (
|
||||
//申明测试接口及请求和响应参数
|
||||
var user_builders = []*TestCase{
|
||||
{
|
||||
//create
|
||||
desc: "创角",
|
||||
desc: "修改名称",
|
||||
mainType: string(comm.ModuleUser),
|
||||
subType: user.UserSubTypeCreate,
|
||||
req: &pb.UserCreateReq{ //设置请求参数
|
||||
NickName: "乐谷70616",
|
||||
subType: user.UserSubTypeModifyName,
|
||||
req: &pb.UserModifynameReq{ //设置请求参数
|
||||
Name: "uuuuuu",
|
||||
},
|
||||
rsp: &pb.UserCreateResp{},
|
||||
// enabled: true,
|
||||
rsp: &pb.UserModifynameResp{},
|
||||
enabled: true,
|
||||
}, {
|
||||
desc: "添加资源",
|
||||
mainType: string(comm.ModuleUser),
|
||||
|
@ -492,7 +492,7 @@ func (this *MCompModel) DelListlds(uid string, ids ...string) (err error) {
|
||||
func (this *MCompModel) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
|
||||
result = &pb.DBUserExpand{}
|
||||
key := fmt.Sprintf("userexpand:%s", uid)
|
||||
if err = this.Redis.HGetAll(key, result); err != nil && err != redis.RedisNil {
|
||||
if err = this.Redis.HGetAll(key, result); err != nil {
|
||||
return
|
||||
}
|
||||
if err == redis.RedisNil {
|
||||
|
@ -120,8 +120,12 @@ func (this *ModelTaskActive) receiveHandle(uid, id string, conf *cfg.Game_active
|
||||
}
|
||||
|
||||
//清空任务
|
||||
func (this *ModelTaskActive) clearTask(uid string) {
|
||||
data := this.getActiveList(uid)
|
||||
func (this *ModelTaskActive) clearTask(uid string, taskTag ...comm.TaskTag) {
|
||||
if len(taskTag) == 0 {
|
||||
log.Errorf("least one param for taskTag")
|
||||
return
|
||||
}
|
||||
data := this.getActiveListByTag(uid, taskTag[0])
|
||||
for _, v := range data {
|
||||
if err := this.moduleTask.modelTaskActive.DelListlds(uid, v.Id); err != nil {
|
||||
log.Errorf("uid: %v err:%v", uid, err)
|
||||
|
@ -142,8 +142,12 @@ func (this *ModelTask) modifyUserTask(uid string, taskId string, data map[string
|
||||
}
|
||||
|
||||
//清空任务
|
||||
func (this *ModelTask) clearTask(uid string) {
|
||||
taskList := this.getTaskList(uid)
|
||||
func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
|
||||
if len(taskTag) == 0 {
|
||||
log.Errorf("least one param for taskTag")
|
||||
return
|
||||
}
|
||||
taskList := this.getTaskListByTag(uid, taskTag[0])
|
||||
for _, v := range taskList {
|
||||
if err := this.moduleTask.modelTask.DelListlds(uid, v.Id); err != nil {
|
||||
log.Errorf("uid: %v err:%v", uid, err)
|
||||
|
@ -56,9 +56,9 @@ func (this *ModuleTask) InitTaskAll(uid string) {
|
||||
}
|
||||
|
||||
//重置任务
|
||||
func (this *ModuleTask) ResetTask(uid string) {
|
||||
this.modelTask.clearTask(uid)
|
||||
this.modelTaskActive.clearTask(uid)
|
||||
func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) {
|
||||
this.modelTask.clearTask(uid, taskTag)
|
||||
this.modelTaskActive.clearTask(uid, taskTag)
|
||||
this.InitTaskAll(uid)
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ const (
|
||||
UserSubTypeVeriCode = "vericode" //验证码
|
||||
UserSubTypeInitData = "initdata" //初始化用户
|
||||
UserGetTujianResp = "gettujian" //获取图鉴信息
|
||||
UserSubTypeLvChangedPush = "lvChangedPush" //等级变化推送
|
||||
UserSubTypeModifyName = "modifyname" //修改名称
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
|
@ -4,12 +4,13 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (this *apiComp) ModifynameCheck(session comm.IUserSession, req *pb.UserModifynameReq) (code pb.ErrorCode) {
|
||||
if req.Name == "" || len(req.Name) > 6 {
|
||||
if strings.TrimSpace(req.Name) == "" || len(strings.TrimSpace(req.Name)) > 6 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
@ -20,13 +21,14 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
|
||||
return
|
||||
}
|
||||
|
||||
name := strings.TrimSpace(req.Name)
|
||||
//验证名称
|
||||
if this.module.modelUser.NickNameIsExist(req.Name) {
|
||||
if !this.module.modelUser.NickNameIsExist(name) {
|
||||
code = pb.ErrorCode_NameExist
|
||||
return
|
||||
}
|
||||
|
||||
expand, err := this.module.modelUser.GetUserExpand(session.GetSessionId())
|
||||
expand, err := this.module.modelUser.GetUserExpand(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
@ -56,7 +58,7 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
|
||||
}
|
||||
|
||||
// 修改名称
|
||||
if code = this.module.modelUser.modifyName(session.GetUserId(), req.Name); code != pb.ErrorCode_Success {
|
||||
if code = this.module.modelUser.modifyName(session.GetUserId(), name); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -158,6 +158,9 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{
|
||||
"lv": ul.lv,
|
||||
}
|
||||
this.moduleUser.modelUser.Change(ul.session.GetUserId(), update)
|
||||
ul.session.SendMsg(string(this.moduleUser.GetType()),
|
||||
UserSubTypeLvChangedPush,
|
||||
&pb.UserChangedPush{Uid: ul.session.GetUserId(), Exp: ul.exp, Lv: ul.lv})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -93,10 +93,13 @@ message UserModifynameResp {
|
||||
uint32 count = 2; //剩余修改次数
|
||||
}
|
||||
|
||||
message UserGetTujianReq{
|
||||
// 图鉴
|
||||
message UserGetTujianReq {}
|
||||
message UserGetTujianResp { repeated string heroids = 1; }
|
||||
|
||||
}
|
||||
|
||||
message UserGetTujianResp{
|
||||
repeated string heroids = 1;
|
||||
//玩家等级经验变化推送
|
||||
message UserChangedPush {
|
||||
string uid = 1;
|
||||
int32 exp = 2;
|
||||
int32 lv = 3;
|
||||
}
|
@ -1083,6 +1083,7 @@ func (x *UserModifynameResp) GetCount() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// 图鉴
|
||||
type UserGetTujianReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -1168,6 +1169,70 @@ func (x *UserGetTujianResp) GetHeroids() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
//玩家等级经验变化推送
|
||||
type UserChangedPush struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"`
|
||||
Exp int32 `protobuf:"varint,2,opt,name=exp,proto3" json:"exp"`
|
||||
Lv int32 `protobuf:"varint,3,opt,name=lv,proto3" json:"lv"`
|
||||
}
|
||||
|
||||
func (x *UserChangedPush) Reset() {
|
||||
*x = UserChangedPush{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_user_msg_proto_msgTypes[24]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UserChangedPush) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UserChangedPush) ProtoMessage() {}
|
||||
|
||||
func (x *UserChangedPush) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_user_msg_proto_msgTypes[24]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UserChangedPush.ProtoReflect.Descriptor instead.
|
||||
func (*UserChangedPush) Descriptor() ([]byte, []int) {
|
||||
return file_user_user_msg_proto_rawDescGZIP(), []int{24}
|
||||
}
|
||||
|
||||
func (x *UserChangedPush) GetUid() string {
|
||||
if x != nil {
|
||||
return x.Uid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserChangedPush) GetExp() int32 {
|
||||
if x != nil {
|
||||
return x.Exp
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UserChangedPush) GetLv() int32 {
|
||||
if x != nil {
|
||||
return x.Lv
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_user_user_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_user_user_msg_proto_rawDesc = []byte{
|
||||
@ -1247,7 +1312,12 @@ var file_user_user_msg_proto_rawDesc = []byte{
|
||||
0x71, 0x22, 0x2d, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x47, 0x65, 0x74, 0x54, 0x75, 0x6a, 0x69,
|
||||
0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64,
|
||||
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x73,
|
||||
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x22, 0x45, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x50,
|
||||
0x75, 0x73, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -1262,7 +1332,7 @@ func file_user_user_msg_proto_rawDescGZIP() []byte {
|
||||
return file_user_user_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 24)
|
||||
var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 25)
|
||||
var file_user_user_msg_proto_goTypes = []interface{}{
|
||||
(*UserLoginReq)(nil), // 0: UserLoginReq
|
||||
(*UserLoginResp)(nil), // 1: UserLoginResp
|
||||
@ -1288,22 +1358,23 @@ var file_user_user_msg_proto_goTypes = []interface{}{
|
||||
(*UserModifynameResp)(nil), // 21: UserModifynameResp
|
||||
(*UserGetTujianReq)(nil), // 22: UserGetTujianReq
|
||||
(*UserGetTujianResp)(nil), // 23: UserGetTujianResp
|
||||
(*DBUser)(nil), // 24: DBUser
|
||||
(*DBUserExpand)(nil), // 25: DBUserExpand
|
||||
(ErrorCode)(0), // 26: ErrorCode
|
||||
(*CacheUser)(nil), // 27: CacheUser
|
||||
(*UserAssets)(nil), // 28: UserAssets
|
||||
(*DBUserSetting)(nil), // 29: DBUserSetting
|
||||
(*UserChangedPush)(nil), // 24: UserChangedPush
|
||||
(*DBUser)(nil), // 25: DBUser
|
||||
(*DBUserExpand)(nil), // 26: DBUserExpand
|
||||
(ErrorCode)(0), // 27: ErrorCode
|
||||
(*CacheUser)(nil), // 28: CacheUser
|
||||
(*UserAssets)(nil), // 29: UserAssets
|
||||
(*DBUserSetting)(nil), // 30: DBUserSetting
|
||||
}
|
||||
var file_user_user_msg_proto_depIdxs = []int32{
|
||||
24, // 0: UserLoginResp.data:type_name -> DBUser
|
||||
25, // 1: UserLoginResp.ex:type_name -> DBUserExpand
|
||||
26, // 2: UserRegisterResp.Code:type_name -> ErrorCode
|
||||
27, // 3: UserLoadResp.data:type_name -> CacheUser
|
||||
28, // 4: UserAddResReq.res:type_name -> UserAssets
|
||||
28, // 5: UserAddResResp.res:type_name -> UserAssets
|
||||
29, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting
|
||||
29, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting
|
||||
25, // 0: UserLoginResp.data:type_name -> DBUser
|
||||
26, // 1: UserLoginResp.ex:type_name -> DBUserExpand
|
||||
27, // 2: UserRegisterResp.Code:type_name -> ErrorCode
|
||||
28, // 3: UserLoadResp.data:type_name -> CacheUser
|
||||
29, // 4: UserAddResReq.res:type_name -> UserAssets
|
||||
29, // 5: UserAddResResp.res:type_name -> UserAssets
|
||||
30, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting
|
||||
30, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting
|
||||
8, // [8:8] is the sub-list for method output_type
|
||||
8, // [8:8] is the sub-list for method input_type
|
||||
8, // [8:8] is the sub-list for extension type_name
|
||||
@ -1609,6 +1680,18 @@ func file_user_user_msg_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_user_msg_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserChangedPush); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -1616,7 +1699,7 @@ func file_user_user_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_user_user_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 24,
|
||||
NumMessages: 25,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user