接口补充,通过特权类型获取特权对应功能增加的数量
This commit is contained in:
parent
93b049704e
commit
b39cef8fa0
@ -290,6 +290,8 @@ type (
|
||||
AddVipData(session IUserSession, oldVip, newVip int32)
|
||||
// 查询所有特权 key 对应comm.PrivilegeType1类型
|
||||
CheckAllPrivilege(session IUserSession) map[int32]*pb.PrivilegeList
|
||||
// 通过特权类型获取特权对应的增加数量
|
||||
GetCountByPrivilegeId(uid string, pId int32) (count int32)
|
||||
}
|
||||
//武馆
|
||||
IMartialhall interface {
|
||||
|
@ -3,8 +3,11 @@ package privilege
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -15,7 +18,9 @@ const (
|
||||
///背包配置管理组件
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Privilege
|
||||
module *Privilege
|
||||
hlock sync.RWMutex
|
||||
_privilegeMap map[int32]map[int32]int32
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
@ -24,6 +29,25 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
this.module = module.(*Privilege)
|
||||
this.LoadConfigure(game_privilegecard, cfg.NewGamePrivilegeCard)
|
||||
this.LoadConfigure(game_privilege, cfg.NewGamePrivilege)
|
||||
this._privilegeMap = make(map[int32]map[int32]int32, 0)
|
||||
configure.RegisterConfigure(game_privilege, cfg.NewGamePrivilege, func() {
|
||||
if v, err := this.GetConfigure(game_privilege); err == nil {
|
||||
if configure, ok := v.(*cfg.GamePrivilege); ok {
|
||||
this.hlock.Lock()
|
||||
defer this.hlock.Unlock()
|
||||
for k, v := range configure.GetDataMap() {
|
||||
if v1, ok := this._privilegeMap[v.PrivilegeType]; ok {
|
||||
v1[k] = v.PrivilegeParameter
|
||||
} else {
|
||||
this._privilegeMap[v.PrivilegeType] = make(map[int32]int32)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Errorf("get game_pagoda conf err:%v", err)
|
||||
return
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
@ -59,3 +83,11 @@ func (this *configureComp) GetPrivilegeData(id int32) (result *cfg.GamePrivilege
|
||||
this.module.Errorf("GetPrivilegeData err, id:%d", id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *configureComp) GetPrivilegeByType(iType int32) (result map[int32]int32) {
|
||||
result = make(map[int32]int32)
|
||||
if v, ok := this._privilegeMap[iType]; ok {
|
||||
result = v
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -401,3 +401,18 @@ func (this *Privilege) SendDailyPrivilegeMail(session comm.IUserSession, cId []i
|
||||
this.mail.SendMailByCid(session, comm.VipDaily, res)
|
||||
}
|
||||
}
|
||||
func (this *Privilege) GetCountByPrivilegeId(uid string, pId int32) (count int32) {
|
||||
vip, err := this.modelVip.getVipList(uid)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if v, ok := vip.Privilege[pId]; ok {
|
||||
data := this.configure.GetPrivilegeByType(pId)
|
||||
for _, v1 := range v.PrivilegeID {
|
||||
if c, ok1 := data[v1]; ok1 {
|
||||
count += c
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user