Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
0210e6d4d3
@ -52,6 +52,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
//this.module.Debug("StrengthenUplv", log.Field{Key: "hero", Value: _hero})
|
||||
// 只有英雄卡才能升级
|
||||
if _hero.CardType != comm.CardTypeHero {
|
||||
code = pb.ErrorCode_HeroTypeErr
|
||||
|
@ -545,10 +545,12 @@ func (this *ModelHero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhe
|
||||
hero.Exp = curExp
|
||||
hero.IsOverlying = false
|
||||
hero.SameCount = 1
|
||||
|
||||
this.moduleHero.Debugf("add hero exp :%v", hero)
|
||||
if err := this.ChangeList(uid, hero.Id, update); err != nil {
|
||||
this.moduleHero.Errorf("add hero exp failed ChangeList %v", err)
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -283,10 +283,14 @@ func (this *Hero) AddHeroExp(session comm.IUserSession, heroObjID string, exp in
|
||||
newhero *pb.DBHero
|
||||
_changeHero []*pb.DBHero // 变化的英雄
|
||||
)
|
||||
if heroObjID == "" {
|
||||
return
|
||||
}
|
||||
_hero, code = this.GetHeroByObjID(session.GetUserId(), heroObjID)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
//this.Debug("AddHeroExp", log.Field{Key: "hero", Value: _hero})
|
||||
newhero, code = this.modelHero.AddCardExp(session.GetUserId(), _hero, exp)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
|
@ -151,6 +151,7 @@ func (this *DBModel) UpdateModelLogs(table string, uID string, where bson.M, tar
|
||||
|
||||
//添加新的数据
|
||||
func (this *DBModel) Add(uid string, data interface{}, opt ...DBOption) (err error) {
|
||||
//defer log.Debug("DBModel Add", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "data", Value: data})
|
||||
if err = this.Redis.HMSet(this.ukey(uid), data); err != nil {
|
||||
return
|
||||
}
|
||||
@ -167,6 +168,7 @@ func (this *DBModel) Add(uid string, data interface{}, opt ...DBOption) (err err
|
||||
|
||||
//添加新的数据到列表
|
||||
func (this *DBModel) AddList(uid string, id string, data interface{}, opt ...DBOption) (err error) {
|
||||
//defer log.Debug("DBModel AddList", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "_id", Value: id}, log.Field{Key: "data", Value: data})
|
||||
key := this.ukeylist(uid, id)
|
||||
if err = this.Redis.HMSet(key, data); err != nil {
|
||||
return
|
||||
@ -187,6 +189,7 @@ func (this *DBModel) AddList(uid string, id string, data interface{}, opt ...DBO
|
||||
|
||||
//添加新的多个数据到列表 data map[string]type
|
||||
func (this *DBModel) AddLists(uid string, data interface{}, opt ...DBOption) (err error) {
|
||||
//defer log.Debug("DBModel AddLists", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "data", Value: data})
|
||||
vof := reflect.ValueOf(data)
|
||||
if !vof.IsValid() {
|
||||
return fmt.Errorf("Model_Comp: AddLists(nil)")
|
||||
@ -229,6 +232,7 @@ func (this *DBModel) AddLists(uid string, data interface{}, opt ...DBOption) (er
|
||||
|
||||
//添加队列
|
||||
func (this *DBModel) AddQueues(key string, uplimit int64, data interface{}) (outkey []string, err error) {
|
||||
//defer log.Debug("DBModel AddQueues", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "key", Value: key}, log.Field{Key: "data", Value: data})
|
||||
vof := reflect.ValueOf(data)
|
||||
if !vof.IsValid() {
|
||||
err = fmt.Errorf("Model_Comp: AddLists(nil)")
|
||||
@ -268,6 +272,7 @@ func (this *DBModel) AddQueues(key string, uplimit int64, data interface{}) (out
|
||||
|
||||
//修改数据多个字段 uid 作为主键
|
||||
func (this *DBModel) Change(uid string, data map[string]interface{}, opt ...DBOption) (err error) {
|
||||
//defer log.Debug("DBModel Change", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "data", Value: data})
|
||||
if err = this.Redis.HMSet(this.ukey(uid), data); err != nil {
|
||||
return
|
||||
}
|
||||
@ -284,7 +289,9 @@ func (this *DBModel) Change(uid string, data map[string]interface{}, opt ...DBOp
|
||||
|
||||
//修改数据多个字段 uid 作为主键
|
||||
func (this *DBModel) ChangeList(uid string, _id string, data map[string]interface{}, opt ...DBOption) (err error) {
|
||||
//defer log.Debug("DBModel ChangeList", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "_id", Value: _id}, log.Field{Key: "data", Value: data})
|
||||
if err = this.Redis.HMSet(this.ukeylist(uid, _id), data); err != nil {
|
||||
log.Error("DBModel ChangeList", log.Field{Key: "err", Value: err})
|
||||
return
|
||||
}
|
||||
|
||||
@ -301,6 +308,7 @@ func (this *DBModel) ChangeList(uid string, _id string, data map[string]interfac
|
||||
|
||||
//读取全部数据
|
||||
func (this *DBModel) Get(uid string, data interface{}, opt ...DBOption) (err error) {
|
||||
//defer log.Debug("DBModel Get", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "data", Value: data})
|
||||
if err = this.Redis.HGetAll(this.ukey(uid), data); err != nil && err != lgredis.RedisNil {
|
||||
return
|
||||
}
|
||||
@ -320,6 +328,7 @@ func (this *DBModel) Get(uid string, data interface{}, opt ...DBOption) (err err
|
||||
|
||||
//获取列表数据 注意 data 必须是 切片的指针 *[]type
|
||||
func (this *DBModel) GetList(uid string, data interface{}) (err error) {
|
||||
//defer log.Debug("DBModel GetList", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "data", Value: data})
|
||||
var (
|
||||
dtype reflect2.Type
|
||||
dkind reflect.Kind
|
||||
@ -435,6 +444,7 @@ func (this *DBModel) GetList(uid string, data interface{}) (err error) {
|
||||
|
||||
//获取队列数据
|
||||
func (this *DBModel) GetQueues(key string, count int, data interface{}) (err error) {
|
||||
//defer log.Debug("DBModel GetQueues", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "key", Value: key}, log.Field{Key: "data", Value: data})
|
||||
var (
|
||||
dtype reflect2.Type
|
||||
dkind reflect.Kind
|
||||
@ -505,6 +515,7 @@ func (this *DBModel) GetQueues(key string, count int, data interface{}) (err err
|
||||
|
||||
//读取单个数据中 多个字段数据
|
||||
func (this *DBModel) GetFields(uid string, data interface{}, fields ...string) (err error) {
|
||||
//defer log.Debug("DBModel GetFields", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "data", Value: data})
|
||||
if err = this.Redis.HMGet(this.ukey(uid), data, fields...); err != nil && err != lgredis.RedisNil {
|
||||
return
|
||||
}
|
||||
@ -524,6 +535,7 @@ func (this *DBModel) GetFields(uid string, data interface{}, fields ...string) (
|
||||
|
||||
//读取List列表中单个数据中 多个字段数据
|
||||
func (this *DBModel) GetListFields(uid string, id string, data interface{}, fields ...string) (err error) {
|
||||
//defer log.Debug("DBModel GetListFields", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "id", Value: id}, log.Field{Key: "data", Value: data})
|
||||
var (
|
||||
c *mongo.Cursor
|
||||
keys map[string]string
|
||||
@ -578,6 +590,7 @@ func (this *DBModel) GetListFields(uid string, id string, data interface{}, fiel
|
||||
|
||||
//读取列表数据中单个数据
|
||||
func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err error) {
|
||||
//defer log.Debug("DBModel GetListObj", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "id", Value: id}, log.Field{Key: "data", Value: data})
|
||||
var (
|
||||
c *mongo.Cursor
|
||||
keys map[string]string
|
||||
@ -642,6 +655,7 @@ func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err er
|
||||
|
||||
//读取列表数据中单个数据
|
||||
func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (err error) {
|
||||
//defer log.Debug("DBModel GetListObjs", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "ids", Value: ids}, log.Field{Key: "data", Value: data})
|
||||
var (
|
||||
dtype reflect2.Type
|
||||
dkind reflect.Kind
|
||||
@ -754,6 +768,7 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er
|
||||
|
||||
//删除用户数据
|
||||
func (this *DBModel) Del(uid string, opt ...DBOption) (err error) {
|
||||
//defer log.Debug("DBModel Del", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid})
|
||||
err = this.Redis.Delete(this.ukey(uid))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -767,6 +782,7 @@ func (this *DBModel) Del(uid string, opt ...DBOption) (err error) {
|
||||
|
||||
//删除多条数据
|
||||
func (this *DBModel) DelListlds(uid string, ids ...string) (err error) {
|
||||
//defer log.Debug("DBModel DelListlds", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "ids", Value: ids})
|
||||
listkey := this.ukey(uid)
|
||||
pipe := this.Redis.RedisPipe(context.TODO())
|
||||
for _, v := range ids {
|
||||
@ -782,6 +798,7 @@ func (this *DBModel) DelListlds(uid string, ids ...string) (err error) {
|
||||
|
||||
//批量删除数据
|
||||
func (this *DBModel) BatchDelLists(uid string) (err error) {
|
||||
//defer log.Debug("DBModel BatchDelLists", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid})
|
||||
var keys map[string]string
|
||||
pipe := this.Redis.RedisPipe(context.TODO())
|
||||
if keys, err = this.Redis.HGetAllToMapString(this.ukey(uid)); err == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user