上传公会boos代码
This commit is contained in:
parent
2e214bf274
commit
d7d67fbcb6
@ -12,6 +12,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@ -280,3 +281,62 @@ func (this *ModelUniongve) infochangepush(unionid string, info *pb.DBGuildGve) {
|
|||||||
Info: info,
|
Info: info,
|
||||||
}, users...)
|
}, users...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新埋点数据到db中
|
||||||
|
func (this *ModelUniongve) guildgveModel() (model *guildgveModel, err error) {
|
||||||
|
var (
|
||||||
|
conn *db.DBConn
|
||||||
|
m *db.DBModel
|
||||||
|
)
|
||||||
|
if db.IsCross() {
|
||||||
|
model = &guildgveModel{module: this.module, model: this.DBModel}
|
||||||
|
} else {
|
||||||
|
if conn, err = db.Cross(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m = db.NewDBModel(this.TableName, conn)
|
||||||
|
model = &guildgveModel{module: this.module, model: m}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 埋点专属模型 会封装特殊的数据转换接口
|
||||||
|
type guildgveModel struct {
|
||||||
|
module *GuildGve
|
||||||
|
model *db.DBModel
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分布式锁
|
||||||
|
func (this *guildgveModel) userlock(id string) (result *redis.RedisMutex, err error) {
|
||||||
|
return this.model.Redis.NewRedisMutex(fmt.Sprintf("lockuniongve:%s", id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户全部的埋点数据
|
||||||
|
func (this *guildgveModel) getGuildGve(guildid string) (results *pb.DBGuildGve, err error) {
|
||||||
|
|
||||||
|
results = &pb.DBGuildGve{
|
||||||
|
Boos: make([]*pb.DBGuildGveBoss, 0),
|
||||||
|
}
|
||||||
|
if err = this.model.GetByID(guildid, results); err != nil {
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *guildgveModel) updateGuildGve(data *pb.DBGuildGve) (err error) {
|
||||||
|
if err = this.model.ChangeById(data.Guildid, map[string]interface{}{
|
||||||
|
"fire": data.Fire,
|
||||||
|
"notice": data.Notice,
|
||||||
|
"currstage": data.Currstage,
|
||||||
|
"rtime": data.Rtime,
|
||||||
|
"kills": data.Kills,
|
||||||
|
"lastkilltime": data.Lastkilltime,
|
||||||
|
"rank": data.Rank,
|
||||||
|
"boos": data.Boos,
|
||||||
|
}); err != nil {
|
||||||
|
this.module.Error("更新用户任务数据 错误!", log.Field{Key: "err", Value: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -119,20 +119,25 @@ func (this *GuildGve) ModifyBooslv(session comm.IUserSession, lv int32) (errdata
|
|||||||
members []*pb.SociatyMemberInfo
|
members []*pb.SociatyMemberInfo
|
||||||
users []string = make([]string, 0)
|
users []string = make([]string, 0)
|
||||||
conf *cfg.GameGuildBossData
|
conf *cfg.GameGuildBossData
|
||||||
|
model *guildgveModel
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if sociaty = this.ModuleSociaty.GetSociaty(session.GetUserId()); sociaty != nil {
|
if sociaty = this.ModuleSociaty.GetSociaty(session.GetUserId()); sociaty == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
lock, _ := this.modelGuildGve.userlock(sociaty.Id)
|
if model, err = this.modelGuildGve.guildgveModel(); err != nil {
|
||||||
|
this.Error("guildgveModel err!", log.Field{Key: "Unionid", Value: sociaty.Id}, log.Field{Key: "err", Value: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
lock, _ := model.userlock(sociaty.Id)
|
||||||
err = lock.Lock()
|
err = lock.Lock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Error("公会战分布式锁 err!", log.Field{Key: "Unionid", Value: sociaty.Id}, log.Field{Key: "err", Value: err.Error()})
|
this.Error("公会战分布式锁 err!", log.Field{Key: "Unionid", Value: sociaty.Id}, log.Field{Key: "err", Value: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
if info, err = this.modelGuildGve.getGuildGve(sociaty.Id); err != nil {
|
if info, err = model.getGuildGve(sociaty.Id); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
@ -150,7 +155,7 @@ func (this *GuildGve) ModifyBooslv(session comm.IUserSession, lv int32) (errdata
|
|||||||
v.Hp = conf.Hp
|
v.Hp = conf.Hp
|
||||||
v.Record = make([]*pb.DBGveRecord, 0)
|
v.Record = make([]*pb.DBGveRecord, 0)
|
||||||
}
|
}
|
||||||
if err = this.modelGuildGve.updateGuildGve(info); err != nil {
|
if err = model.updateGuildGve(info); err != nil {
|
||||||
this.Errorln(err)
|
this.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
@ -169,9 +170,24 @@ func (this *ModelSociaty) findByName(name string) *pb.DBSociaty {
|
|||||||
// 获取公会
|
// 获取公会
|
||||||
func (this *ModelSociaty) getSociaty(sociatyId string) (sociaty *pb.DBSociaty, err error) {
|
func (this *ModelSociaty) getSociaty(sociatyId string) (sociaty *pb.DBSociaty, err error) {
|
||||||
sociaty = &pb.DBSociaty{}
|
sociaty = &pb.DBSociaty{}
|
||||||
if err = this.GetListObj(comm.RDS_EMPTY, sociatyId, sociaty); err != nil {
|
if db.IsCross() {
|
||||||
this.module.Error("获取工会信息 失败", log.Field{Key: "sociatyId", Value: sociatyId}, log.Field{Key: "err", Value: err.Error()})
|
if err = this.GetListObj(comm.RDS_EMPTY, sociatyId, sociaty); err != nil {
|
||||||
return
|
this.module.Error("获取工会信息 失败", log.Field{Key: "sociatyId", Value: sociatyId}, log.Field{Key: "err", Value: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var (
|
||||||
|
conn *db.DBConn
|
||||||
|
model *db.DBModel
|
||||||
|
)
|
||||||
|
if conn, err = db.Cross(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
model = db.NewDBModel(this.TableName, conn)
|
||||||
|
if err = model.GetListObj(comm.RDS_EMPTY, sociatyId, sociaty); err != nil {
|
||||||
|
this.module.Error("获取工会信息 失败", log.Field{Key: "sociatyId", Value: sociatyId}, log.Field{Key: "err", Value: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user