上传背包相关接口优化
This commit is contained in:
parent
b9672e0682
commit
8ca83cb6ab
@ -11,6 +11,7 @@ type (
|
|||||||
}
|
}
|
||||||
//背包模块对外接口定义 提供给其他模块使用的
|
//背包模块对外接口定义 提供给其他模块使用的
|
||||||
IPack interface {
|
IPack interface {
|
||||||
|
AddItemToUserPack(uId string, itemid, addnum int32) (err error)
|
||||||
///添加多个物品到背包 (可以加物品和减物品)
|
///添加多个物品到背包 (可以加物品和减物品)
|
||||||
AddItemsToUserPack(uId string, items map[int32]int32) (err error)
|
AddItemsToUserPack(uId string, items map[int32]int32) (err error)
|
||||||
}
|
}
|
||||||
|
@ -6,20 +6,37 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/cache"
|
"go_dreamfactory/sys/cache"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *Api_Comp) getlist_check(ctx context.Context, session comm.IUserSession, req *pb.GetlistReq) (code pb.ErrorCode) {
|
||||||
|
if !session.IsLogin() {
|
||||||
|
code = pb.ErrorCode_NoLogin
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
///获取用户道具
|
///获取用户道具
|
||||||
func (this *Api_Comp) Getlist(ctx context.Context, session comm.IUserSession, req *pb.GetlistReq) (err error) {
|
func (this *Api_Comp) Getlist(ctx context.Context, session comm.IUserSession, req *pb.GetlistReq) (err error) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
pack *pb.DB_UserPackData
|
pack *pb.DB_UserPackData
|
||||||
|
nt int64
|
||||||
|
tempgrids []*pb.DB_GridData
|
||||||
grids []*pb.DB_GridData
|
grids []*pb.DB_GridData
|
||||||
|
modifys []*pb.DB_GridData
|
||||||
)
|
)
|
||||||
defer func() {
|
defer func() {
|
||||||
session.SendMsg(string(this.module.GetType()), GetlistResp, code, &pb.GetlistResp{Grids: grids})
|
session.SendMsg(string(this.module.GetType()), GetlistResp, code, &pb.GetlistResp{Grids: grids})
|
||||||
|
if code == pb.ErrorCode_Success {
|
||||||
|
go func() { //异步处理修改数据
|
||||||
|
cache.Defsys.Pack_UpdateGridToUserPack(session.GetUserId(), modifys...)
|
||||||
}()
|
}()
|
||||||
if !session.IsLogin() {
|
}
|
||||||
code = pb.ErrorCode_NoLogin
|
}()
|
||||||
|
if code = this.getlist_check(ctx, session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if pack, err = cache.Defsys.Pack_QueryUserPack(session.GetUserId()); err != nil {
|
if pack, err = cache.Defsys.Pack_QueryUserPack(session.GetUserId()); err != nil {
|
||||||
@ -27,7 +44,21 @@ func (this *Api_Comp) Getlist(ctx context.Context, session comm.IUserSession, re
|
|||||||
code = pb.ErrorCode_CacheReadError
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
grids = this.module.configure_comp.GetPackItemByType(pack, req.IType)
|
tempgrids = this.module.configure_comp.GetPackItemByType(pack, req.IType)
|
||||||
|
modifys = make([]*pb.DB_GridData, 0, len(tempgrids))
|
||||||
|
grids = make([]*pb.DB_GridData, 0, len(grids))
|
||||||
|
nt = time.Now().Unix()
|
||||||
|
for _, v := range tempgrids {
|
||||||
|
if v.ETime > 0 && v.ETime < nt { //已经过期
|
||||||
|
modifys = append(modifys, &pb.DB_GridData{GridId: v.GridId, IsEmpty: true})
|
||||||
|
} else {
|
||||||
|
grids = append(grids, v)
|
||||||
|
if v.IsNewItem {
|
||||||
|
v.IsNewItem = false
|
||||||
|
modifys = append(modifys, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,15 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *Api_Comp) sellItem_check(ctx context.Context, session comm.IUserSession, req *pb.SellItemReq) (code pb.ErrorCode) {
|
||||||
|
if !session.IsLogin() {
|
||||||
|
code = pb.ErrorCode_NoLogin
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//出售道具
|
//出售道具
|
||||||
func (this *Api_Comp) SellItem(ctx context.Context, session comm.IUserSession, req *pb.SellItemReq) (err error) {
|
func (this *Api_Comp) SellItem(ctx context.Context, session comm.IUserSession, req *pb.SellItemReq) (err error) {
|
||||||
var (
|
var (
|
||||||
@ -14,8 +23,7 @@ func (this *Api_Comp) SellItem(ctx context.Context, session comm.IUserSession, r
|
|||||||
defer func() {
|
defer func() {
|
||||||
session.SendMsg(string(this.module.GetType()), SellItemResp, code, &pb.SellItemResp{})
|
session.SendMsg(string(this.module.GetType()), SellItemResp, code, &pb.SellItemResp{})
|
||||||
}()
|
}()
|
||||||
if !session.IsLogin() {
|
if code = this.sellItem_check(ctx, session, req); code != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_NoLogin
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -6,6 +6,15 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *Api_Comp) useitem_check(ctx context.Context, session comm.IUserSession, req *pb.UseItemReq) (code pb.ErrorCode) {
|
||||||
|
if !session.IsLogin() {
|
||||||
|
code = pb.ErrorCode_NoLogin
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//使用道具
|
//使用道具
|
||||||
func (this *Api_Comp) Useitem(ctx context.Context, session comm.IUserSession, req *pb.UseItemReq) (err error) {
|
func (this *Api_Comp) Useitem(ctx context.Context, session comm.IUserSession, req *pb.UseItemReq) (err error) {
|
||||||
var (
|
var (
|
||||||
@ -14,8 +23,7 @@ func (this *Api_Comp) Useitem(ctx context.Context, session comm.IUserSession, re
|
|||||||
defer func() {
|
defer func() {
|
||||||
session.SendMsg(string(this.module.GetType()), UseItemResp, code, &pb.UseItemResp{})
|
session.SendMsg(string(this.module.GetType()), UseItemResp, code, &pb.UseItemResp{})
|
||||||
}()
|
}()
|
||||||
if !session.IsLogin() {
|
if code = this.useitem_check(ctx, session, req); code != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_NoLogin
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -60,6 +60,7 @@ func (this *Configure_Comp) GetPackItemByType(pack *pb.DB_UserPackData, usetype
|
|||||||
} else {
|
} else {
|
||||||
table = v.(*cfg.Game_item)
|
table = v.(*cfg.Game_item)
|
||||||
for _, v := range pack.Pack {
|
for _, v := range pack.Pack {
|
||||||
|
if !v.IsEmpty {
|
||||||
if item, ok = table.GetDataMap()[id]; ok {
|
if item, ok = table.GetDataMap()[id]; ok {
|
||||||
if item.Usetype == usetype {
|
if item.Usetype == usetype {
|
||||||
result = append(result, v)
|
result = append(result, v)
|
||||||
@ -69,5 +70,6 @@ func (this *Configure_Comp) GetPackItemByType(pack *pb.DB_UserPackData, usetype
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,21 @@ func (this *Pack) OnInstallComp() {
|
|||||||
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//IPack-------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
///添加单个物品到背包 (可以加物品和减物品)
|
||||||
|
func (this *Pack) AddItemToUserPack(uId string, itemid, addnum int32) (err error) {
|
||||||
|
defer log.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil)
|
||||||
|
if err = cache.Defsys.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil {
|
||||||
|
log.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
///添加多个物品到背包 (可以加物品和减物品)
|
///添加多个物品到背包 (可以加物品和减物品)
|
||||||
func (this *Pack) AddItemsToUserPack(uId string, items map[int32]int32) (err error) {
|
func (this *Pack) AddItemsToUserPack(uId string, items map[int32]int32) (err error) {
|
||||||
|
defer log.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil)
|
||||||
if err = cache.Defsys.Pack_AddItemsToUserPack(uId, items); err != nil {
|
if err = cache.Defsys.Pack_AddItemsToUserPack(uId, items); err != nil {
|
||||||
log.Errorf("AddItemsToUserPack err:%v", err)
|
log.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@ type DB_GridData struct {
|
|||||||
IsEmpty bool `protobuf:"varint,2,opt,name=IsEmpty,proto3" json:"IsEmpty,omitempty"` //是否是空格子
|
IsEmpty bool `protobuf:"varint,2,opt,name=IsEmpty,proto3" json:"IsEmpty,omitempty"` //是否是空格子
|
||||||
ItemId int32 `protobuf:"varint,3,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //存放物品的Id
|
ItemId int32 `protobuf:"varint,3,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //存放物品的Id
|
||||||
Amount uint32 `protobuf:"varint,4,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量
|
Amount uint32 `protobuf:"varint,4,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量
|
||||||
IsNewItem bool `protobuf:"varint,5,opt,name=IsNewItem,proto3" json:"IsNewItem,omitempty"` //是否是新的
|
CTime int64 `protobuf:"varint,5,opt,name=CTime,proto3" json:"CTime,omitempty"` //物品获取时间
|
||||||
|
ETime int64 `protobuf:"varint,6,opt,name=ETime,proto3" json:"ETime,omitempty"` //物品过期时间
|
||||||
|
IsNewItem bool `protobuf:"varint,7,opt,name=IsNewItem,proto3" json:"IsNewItem,omitempty"` //是否是新的
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_GridData) Reset() {
|
func (x *DB_GridData) Reset() {
|
||||||
@ -93,6 +95,20 @@ func (x *DB_GridData) GetAmount() uint32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *DB_GridData) GetCTime() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.CTime
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DB_GridData) GetETime() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.ETime
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func (x *DB_GridData) GetIsNewItem() bool {
|
func (x *DB_GridData) GetIsNewItem() bool {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.IsNewItem
|
return x.IsNewItem
|
||||||
@ -160,22 +176,24 @@ var File_pack_pack_db_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_pack_pack_db_proto_rawDesc = []byte{
|
var file_pack_pack_db_proto_rawDesc = []byte{
|
||||||
0x0a, 0x12, 0x70, 0x61, 0x63, 0x6b, 0x2f, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70,
|
0x0a, 0x12, 0x70, 0x61, 0x63, 0x6b, 0x2f, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x47, 0x72, 0x69, 0x64,
|
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb9, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x47, 0x72, 0x69, 0x64,
|
||||||
0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01,
|
0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01,
|
||||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07,
|
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07,
|
||||||
0x49, 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x49,
|
0x49, 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x49,
|
||||||
0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64,
|
0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64,
|
||||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16,
|
0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16,
|
||||||
0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06,
|
0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06,
|
||||||
0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x49,
|
0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x54, 0x69, 0x6d, 0x65, 0x18,
|
||||||
0x74, 0x65, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x49, 0x73, 0x4e, 0x65, 0x77,
|
0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x43, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05,
|
||||||
0x49, 0x74, 0x65, 0x6d, 0x22, 0x4b, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50,
|
0x45, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x45, 0x54, 0x69,
|
||||||
0x61, 0x63, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49,
|
0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x18,
|
||||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12,
|
0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d,
|
||||||
0x20, 0x0a, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e,
|
0x22, 0x4b, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x44,
|
||||||
0x44, 0x42, 0x5f, 0x47, 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63,
|
0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20,
|
||||||
0x6b, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x50,
|
||||||
0x33,
|
0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x47,
|
||||||
|
0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x42, 0x06, 0x5a,
|
||||||
|
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -219,7 +219,7 @@ func (*UseItemResp) Descriptor() ([]byte, []int) {
|
|||||||
return file_pack_pack_msg_proto_rawDescGZIP(), []int{3}
|
return file_pack_pack_msg_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
//出售道具请求
|
//出售道具请求sailitem
|
||||||
type SellItemReq struct {
|
type SellItemReq struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
@ -8,7 +8,9 @@ message DB_GridData {
|
|||||||
bool IsEmpty = 2; //是否是空格子
|
bool IsEmpty = 2; //是否是空格子
|
||||||
int32 ItemId = 3; //存放物品的Id
|
int32 ItemId = 3; //存放物品的Id
|
||||||
uint32 Amount = 4; //存放物品的数量
|
uint32 Amount = 4; //存放物品的数量
|
||||||
bool IsNewItem = 5; //是否是新的
|
int64 CTime = 5; //物品获取时间
|
||||||
|
int64 ETime = 6; //物品过期时间
|
||||||
|
bool IsNewItem = 7; //是否是新的
|
||||||
}
|
}
|
||||||
|
|
||||||
//用户背包
|
//用户背包
|
||||||
|
@ -4,12 +4,12 @@ import "pack/pack_db.proto";
|
|||||||
|
|
||||||
//查询用户背包请求
|
//查询用户背包请求
|
||||||
message GetlistReq {
|
message GetlistReq {
|
||||||
int32 IType = 1;
|
int32 IType = 1; //道具类型
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询用户背包请求 回应
|
//查询用户背包请求 回应
|
||||||
message GetlistResp {
|
message GetlistResp {
|
||||||
repeated DB_GridData Grids = 1;
|
repeated DB_GridData Grids = 1; //用户背包列表
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用物品请求
|
//使用物品请求
|
||||||
|
24
sys/cache/pack.go
vendored
24
sys/cache/pack.go
vendored
@ -17,6 +17,7 @@ const ( //Redis
|
|||||||
const (
|
const (
|
||||||
GridCapMaxNum = 99 //单个格子的最大容量
|
GridCapMaxNum = 99 //单个格子的最大容量
|
||||||
GridMaxNUm = 200 //背包格子数量上限
|
GridMaxNUm = 200 //背包格子数量上限
|
||||||
|
Pack_Expiration = -1 //背包缓存数据过期时间
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -35,6 +36,8 @@ type IPack interface {
|
|||||||
Pack_AddItemsToUserPack(uId string, items map[int32]int32) (err error)
|
Pack_AddItemsToUserPack(uId string, items map[int32]int32) (err error)
|
||||||
//修改用户背包格子的标识
|
//修改用户背包格子的标识
|
||||||
Pack_ModifyPackGridIsNewItem(uId string, grids []int32) (err error)
|
Pack_ModifyPackGridIsNewItem(uId string, grids []int32) (err error)
|
||||||
|
//更新用户背包格子信息
|
||||||
|
Pack_UpdateGridToUserPack(uId string, grids ...*pb.DB_GridData) (err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
///查询用户背包数据
|
///查询用户背包数据
|
||||||
@ -46,7 +49,7 @@ func (this *Cache) Pack_QueryUserPack(uId string) (pack *pb.DB_UserPackData, err
|
|||||||
return
|
return
|
||||||
} else if err == redis.RedisNil {
|
} else if err == redis.RedisNil {
|
||||||
if pack, err = db.Defsys.Pack_QueryUserPack(uId); err == nil {
|
if pack, err = db.Defsys.Pack_QueryUserPack(uId); err == nil {
|
||||||
this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, -1)
|
this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, Pack_Expiration)
|
||||||
} else if err == mgo.MongodbNil {
|
} else if err == mgo.MongodbNil {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
@ -76,7 +79,7 @@ func (this *Cache) Pack_AddItemToUserPack(uId string, itemId int32, addnum int32
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if pack, err = db.Defsys.Pack_UpdateGridToUserPack(uId, modifys...); err == nil {
|
if pack, err = db.Defsys.Pack_UpdateGridToUserPack(uId, modifys...); err == nil {
|
||||||
this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, -1)
|
this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, Pack_Expiration)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -116,7 +119,7 @@ func (this *Cache) Pack_AddItemsToUserPack(uId string, items map[int32]int32) (e
|
|||||||
}
|
}
|
||||||
|
|
||||||
if pack, err = db.Defsys.Pack_UpdateGridToUserPack(uId, modifys...); err == nil {
|
if pack, err = db.Defsys.Pack_UpdateGridToUserPack(uId, modifys...); err == nil {
|
||||||
this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, -1)
|
this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, Pack_Expiration)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -159,7 +162,7 @@ func (this *Cache) Pack_AddItemToUserPackByGrid(uId string, gridid int32, itemId
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if pack, err = db.Defsys.Pack_UpdateGridToUserPack(uId, grid); err == nil {
|
if pack, err = db.Defsys.Pack_UpdateGridToUserPack(uId, grid); err == nil {
|
||||||
this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, -1)
|
this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, Pack_Expiration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,7 +175,18 @@ func (this *Cache) Pack_ModifyPackGridIsNewItem(uId string, grids []int32) (err
|
|||||||
pack *pb.DB_UserPackData
|
pack *pb.DB_UserPackData
|
||||||
)
|
)
|
||||||
if pack, err = db.Defsys.Pack_ModifyPackGridIsNewItem(uId, grids); err == nil {
|
if pack, err = db.Defsys.Pack_ModifyPackGridIsNewItem(uId, grids); err == nil {
|
||||||
err = this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, -1)
|
err = this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, Pack_Expiration)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
///修改目标格子的新获取标识
|
||||||
|
func (this *Cache) Pack_UpdateGridToUserPack(uId string, grids ...*pb.DB_GridData) (err error) {
|
||||||
|
var (
|
||||||
|
pack *pb.DB_UserPackData
|
||||||
|
)
|
||||||
|
if pack, err = db.Defsys.Pack_UpdateGridToUserPack(uId, grids...); err == nil {
|
||||||
|
err = this.redis.Set(fmt.Sprintf(Redis_PackCache, uId), pack, Pack_Expiration)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user