增加详细羁绊数据推送,加一些错误日志

This commit is contained in:
meixiongfeng 2022-10-14 14:06:56 +08:00
parent 6d4a95f461
commit caf1b0cdc9
3 changed files with 33 additions and 16 deletions

View File

@ -175,7 +175,7 @@ type (
ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息
QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息
//QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息
AddHeroFetterData(uid string, heroConfId ...string) (code pb.ErrorCode) // 创建一条羁绊信息
AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息
}
//月子秘境
IMoonFantasy interface {

View File

@ -103,9 +103,9 @@ func (this *Library) GetHeroFetterList(uid string) []*pb.DBHeroFetter {
}
// 创建一条英雄羁绊信息
func (this *Library) createHeroFetter(uid string, heroConfId string) (code pb.ErrorCode) {
func (this *Library) createHeroFetter(uid string, heroConfId string) (obj *pb.DBHeroFetter, code pb.ErrorCode) {
this.modelFetter.getHeroFetterList(uid)
obj := &pb.DBHeroFetter{
obj = &pb.DBHeroFetter{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
Heroid: heroConfId,
@ -141,7 +141,11 @@ func (this *Library) AddHeroFetterData(uid string, heroConfId string) (code pb.E
_data := this.QueryOneHeroFetter(uid, heroConfId)
this.Debugf("%v", _data)
if _data == nil {
this.createHeroFetter(uid, heroConfId)
objFetter, c := this.createHeroFetter(uid, heroConfId)
if c != pb.ErrorCode_Success {
code = c
this.Errorf("createHeroFetter failed:%v,uid:%s,heroid:%s", code, uid, heroConfId)
}
_conf := this.configure.GetLibraryHero(heroConfId)
if _conf != nil {
szFid := _conf.Fid
@ -149,9 +153,10 @@ func (this *Library) AddHeroFetterData(uid string, heroConfId string) (code pb.E
// 查询是否存在这个羁绊对象
obj := this.GetLibraryListByFid(uid, fid)
if obj == nil { // 没有羁绊信息
this.createHeroFetter(uid, heroConfId)
code, obj = this.CreateLibrary(uid, fid, heroConfId)
if code != pb.ErrorCode_Success {
this.Errorf("CreateLibrary failed: %v,uid:%s,fid:%d", code, uid, fid)
}
} else { // 羁绊信息中没有这个heroid 也需要加进来
for k, v := range obj.Hero {
if v == 0 && k == heroConfId {
@ -174,8 +179,9 @@ func (this *Library) AddHeroFetterData(uid string, heroConfId string) (code pb.E
}
rsp.Data = append(rsp.Data, obj)
}
this.SendMsgToUser(string(this.GetType()), LibraryChangePush, rsp, uid)
}
rsp.Fetter = append(rsp.Fetter, objFetter)
this.SendMsgToUser(string(this.GetType()), LibraryChangePush, rsp, uid)
}
return

View File

@ -610,7 +610,8 @@ type LibraryChangePush struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []*DBLibrary `protobuf:"bytes,1,rep,name=data,proto3" json:"data"`
Data []*DBLibrary `protobuf:"bytes,1,rep,name=data,proto3" json:"data"`
Fetter []*DBHeroFetter `protobuf:"bytes,2,rep,name=fetter,proto3" json:"fetter"` // 羁绊详细信息
}
func (x *LibraryChangePush) Reset() {
@ -652,6 +653,13 @@ func (x *LibraryChangePush) GetData() []*DBLibrary {
return nil
}
func (x *LibraryChangePush) GetFetter() []*DBHeroFetter {
if x != nil {
return x.Fetter
}
return nil
}
var File_library_library_msg_proto protoreflect.FileDescriptor
var file_library_library_msg_proto_rawDesc = []byte{
@ -707,11 +715,13 @@ var file_library_library_msg_proto_rawDesc = []byte{
0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x65, 0x74, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73,
0x70, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0a, 0x2e, 0x44, 0x42, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74,
0x61, 0x22, 0x33, 0x0a, 0x11, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x43, 0x68, 0x61, 0x6e,
0x61, 0x22, 0x5a, 0x0a, 0x11, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x43, 0x68, 0x61, 0x6e,
0x67, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79,
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x25, 0x0a, 0x06, 0x66, 0x65, 0x74, 0x74, 0x65, 0x72,
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x46,
0x65, 0x74, 0x74, 0x65, 0x72, 0x52, 0x06, 0x66, 0x65, 0x74, 0x74, 0x65, 0x72, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -754,11 +764,12 @@ var file_library_library_msg_proto_depIdxs = []int32{
15, // 5: LibraryUseGiftResp.data:type_name -> DBHeroFetter
14, // 6: LibraryActivationFetterResp.data:type_name -> DBLibrary
14, // 7: LibraryChangePush.data:type_name -> DBLibrary
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
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
15, // 8: LibraryChangePush.fetter:type_name -> DBHeroFetter
9, // [9:9] is the sub-list for method output_type
9, // [9:9] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name
9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
}
func init() { file_library_library_msg_proto_init() }