上传道具出售接口
This commit is contained in:
parent
3db2d0dc46
commit
fe776970a9
20
bin/stup.sh
20
bin/stup.sh
@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
start(){
|
start(){
|
||||||
echo "starting..."
|
echo "starting..."
|
||||||
nohup $CMD > /dev/null 2>&1 &
|
nohup $CMD > /dev/null 2>&1 &
|
||||||
# nohup $CMD >output.log 2>&1 &
|
# nohup $CMD >output.log 2>&1 &
|
||||||
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
||||||
then
|
then
|
||||||
echo "start failed, please check the log!"
|
echo "start failed, please check the log!"
|
||||||
exit $?
|
exit $?
|
||||||
else
|
else
|
||||||
echo $! > $SERVICE.pid
|
echo $! > $SERVICE.pid
|
||||||
echo "start success"
|
echo "start success"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
stop(){
|
stop(){
|
||||||
echo "stopping..."
|
echo "stopping..."
|
||||||
|
@ -30,16 +30,16 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
|
|||||||
if code == pb.ErrorCode_Success {
|
if code == pb.ErrorCode_Success {
|
||||||
go func() { //异步处理修改数据
|
go func() { //异步处理修改数据
|
||||||
if len(modifys) > 0 {
|
if len(modifys) > 0 {
|
||||||
this.module.modelItems.Pack_UpdateUserPack(session.GetUserId(), modifys...)
|
this.module.modelItems.UpdateUserPack(session.GetUserId(), modifys...)
|
||||||
}
|
}
|
||||||
if len(dels) > 0 {
|
if len(dels) > 0 {
|
||||||
this.module.modelItems.Pack_DeleteUserPack(session.GetUserId(), dels...)
|
this.module.modelItems.DeleteUserPack(session.GetUserId(), dels...)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if items, err = this.module.modelItems.Pack_QueryUserPack(session.GetUserId()); err != nil {
|
if items, err = this.module.modelItems.QueryUserPack(session.GetUserId()); err != nil {
|
||||||
this.module.Errorf("QueryUserPackReq err:%v", err)
|
this.module.Errorf("QueryUserPackReq err:%v", err)
|
||||||
code = pb.ErrorCode_CacheReadError
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
|
@ -3,20 +3,57 @@ package items
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) SellItemCheck(session comm.IUserSession, req *pb.ItemsSellItemReq) (code pb.ErrorCode) {
|
func (this *apiComp) SellItemCheck(session comm.IUserSession, req *pb.ItemsSellItemReq) (code pb.ErrorCode) {
|
||||||
|
if req.GridId != "" || req.Amount <= 0 {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//出售道具
|
//出售道具
|
||||||
func (this *apiComp) SellItem(session comm.IUserSession, req *pb.ItemsSellItemReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) SellItem(session comm.IUserSession, req *pb.ItemsSellItemReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
defer func() {
|
var (
|
||||||
session.SendMsg(string(this.module.GetType()), "sellitem", &pb.ItemsSellItemResp{})
|
err error
|
||||||
}()
|
item *pb.DB_UserItemData
|
||||||
|
itemcf *cfg.Game_itemData
|
||||||
|
)
|
||||||
|
if code = this.SellItemCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if item, err = this.module.modelItems.QueryUserPackByGridId(session.GetUserId(), req.GridId); err != nil {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if itemcf, err = this.module.configure.GetItemConfigure(item.ItemId); err != nil {
|
||||||
|
code = pb.ErrorCode_ConfigurationException
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.Amount < item.Amount {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
this.module.Errorf("SellItemCheck over all amount:[%d:%d]", req.Amount, item.Amount)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if code = this.module.DispenseRes(session.GetUserId(), itemcf.Sale, true); code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
item.Amount = item.Amount - req.Amount
|
||||||
|
if item.Amount == 0 {
|
||||||
|
if err = this.module.modelItems.DelUserPack(session.GetUserId(), item.GridId); err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err = this.module.modelItems.UpdateUserPack(session.GetUserId(), item); err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.module.GetType()), "sellitem", &pb.ItemsSellItemResp{Item: item})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func (this *ModelItemsComp) Init(service core.IService, module core.IModule, com
|
|||||||
}
|
}
|
||||||
|
|
||||||
///查询用户背包数据
|
///查询用户背包数据
|
||||||
func (this *ModelItemsComp) Pack_QueryUserPack(uId string) (itmes []*pb.DB_UserItemData, err error) {
|
func (this *ModelItemsComp) QueryUserPack(uId string) (itmes []*pb.DB_UserItemData, err error) {
|
||||||
itmes = make([]*pb.DB_UserItemData, 0)
|
itmes = make([]*pb.DB_UserItemData, 0)
|
||||||
if err = this.GetList(uId, &itmes); err != nil {
|
if err = this.GetList(uId, &itmes); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
@ -41,7 +41,7 @@ func (this *ModelItemsComp) Pack_QueryUserPack(uId string) (itmes []*pb.DB_UserI
|
|||||||
}
|
}
|
||||||
|
|
||||||
///查询用户指定格子的物品数据
|
///查询用户指定格子的物品数据
|
||||||
func (this *ModelItemsComp) Pack_QueryUserPackByGridId(uId string, grid string) (itme *pb.DB_UserItemData, err error) {
|
func (this *ModelItemsComp) QueryUserPackByGridId(uId string, grid string) (itme *pb.DB_UserItemData, err error) {
|
||||||
itme = &pb.DB_UserItemData{}
|
itme = &pb.DB_UserItemData{}
|
||||||
if err = this.GetListObj(uId, grid, itme); err != nil {
|
if err = this.GetListObj(uId, grid, itme); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
@ -50,7 +50,7 @@ func (this *ModelItemsComp) Pack_QueryUserPackByGridId(uId string, grid string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新用户的背包信息
|
//更新用户的背包信息
|
||||||
func (this *ModelItemsComp) Pack_AddUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) {
|
func (this *ModelItemsComp) AddUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) {
|
||||||
for _, v := range itmes {
|
for _, v := range itmes {
|
||||||
this.AddList(uId, v.GridId, v)
|
this.AddList(uId, v.GridId, v)
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ func (this *ModelItemsComp) Pack_AddUserPack(uId string, itmes ...*pb.DB_UserIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新用户的背包信息
|
//更新用户的背包信息
|
||||||
func (this *ModelItemsComp) Pack_DelUserPack(uId string, ids ...string) (err error) {
|
func (this *ModelItemsComp) DelUserPack(uId string, ids ...string) (err error) {
|
||||||
if err = this.DelListlds(uId, ids...); err != nil {
|
if err = this.DelListlds(uId, ids...); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ func (this *ModelItemsComp) Pack_DelUserPack(uId string, ids ...string) (err err
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新用户的背包信息
|
//更新用户的背包信息
|
||||||
func (this *ModelItemsComp) Pack_UpdateUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) {
|
func (this *ModelItemsComp) UpdateUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) {
|
||||||
for _, v := range itmes {
|
for _, v := range itmes {
|
||||||
this.ChangeList(uId, v.GridId, map[string]interface{}{
|
this.ChangeList(uId, v.GridId, map[string]interface{}{
|
||||||
"amount": v.Amount,
|
"amount": v.Amount,
|
||||||
@ -76,7 +76,7 @@ func (this *ModelItemsComp) Pack_UpdateUserPack(uId string, itmes ...*pb.DB_User
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新用户的背包信息
|
//更新用户的背包信息
|
||||||
func (this *ModelItemsComp) Pack_DeleteUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) {
|
func (this *ModelItemsComp) DeleteUserPack(uId string, itmes ...*pb.DB_UserItemData) (err error) {
|
||||||
gridIds := make([]string, len(itmes))
|
gridIds := make([]string, len(itmes))
|
||||||
for i, v := range itmes {
|
for i, v := range itmes {
|
||||||
gridIds[i] = v.GridId
|
gridIds[i] = v.GridId
|
||||||
@ -89,12 +89,12 @@ func (this *ModelItemsComp) Pack_DeleteUserPack(uId string, itmes ...*pb.DB_User
|
|||||||
}
|
}
|
||||||
|
|
||||||
//查询用户背包物品数量
|
//查询用户背包物品数量
|
||||||
func (this *ModelItemsComp) Pack_QueryUserPackItemsAmount(uId string, itemid ...int32) (result map[int32]uint32) {
|
func (this *ModelItemsComp) QueryUserPackItemsAmount(uId string, itemid ...int32) (result map[int32]uint32) {
|
||||||
var (
|
var (
|
||||||
itmes []*pb.DB_UserItemData
|
itmes []*pb.DB_UserItemData
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if itmes, err = this.Pack_QueryUserPack(uId); err != nil {
|
if itmes, err = this.QueryUserPack(uId); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ func (this *ModelItemsComp) Pack_QueryUserPackItemsAmount(uId string, itemid ...
|
|||||||
}
|
}
|
||||||
|
|
||||||
///添加或则减少物品到用户背包
|
///添加或则减少物品到用户背包
|
||||||
func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, addnum int32) (change []*pb.DB_UserItemData, err error) {
|
func (this *ModelItemsComp) AddItemToUserPack(uId string, itemId int32, addnum int32) (change []*pb.DB_UserItemData, err error) {
|
||||||
var (
|
var (
|
||||||
itmes []*pb.DB_UserItemData
|
itmes []*pb.DB_UserItemData
|
||||||
add []*pb.DB_UserItemData
|
add []*pb.DB_UserItemData
|
||||||
@ -121,12 +121,12 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
|
|||||||
if addnum == 0 {
|
if addnum == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if itmes, err = this.Pack_QueryUserPack(uId); err != nil {
|
if itmes, err = this.QueryUserPack(uId); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
change = make([]*pb.DB_UserItemData, len(itmes))
|
change = make([]*pb.DB_UserItemData, len(itmes))
|
||||||
add, update, del, leftnum = this.pack_addItemToUserPack(uId, itmes, itemId, addnum)
|
add, update, del, leftnum = this.addItemToUserPack(uId, itmes, itemId, addnum)
|
||||||
if leftnum < 0 {
|
if leftnum < 0 {
|
||||||
err = ItemNotEnoughError
|
err = ItemNotEnoughError
|
||||||
return
|
return
|
||||||
@ -135,21 +135,21 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(add) > 0 {
|
if len(add) > 0 {
|
||||||
if err = this.Pack_AddUserPack(uId, add...); err != nil {
|
if err = this.AddUserPack(uId, add...); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
change = append(change, add...)
|
change = append(change, add...)
|
||||||
}
|
}
|
||||||
if len(del) > 0 {
|
if len(del) > 0 {
|
||||||
if err = this.Pack_DeleteUserPack(uId, del...); err != nil {
|
if err = this.DeleteUserPack(uId, del...); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
change = append(change, del...)
|
change = append(change, del...)
|
||||||
}
|
}
|
||||||
if len(update) > 0 {
|
if len(update) > 0 {
|
||||||
if err = this.Pack_UpdateUserPack(uId, update...); err != nil {
|
if err = this.UpdateUserPack(uId, update...); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ func (this *ModelItemsComp) Pack_AddItemToUserPack(uId string, itemId int32, add
|
|||||||
}
|
}
|
||||||
|
|
||||||
///添加或则减少多个物品到用户背包
|
///添加或则减少多个物品到用户背包
|
||||||
func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]int32) (change []*pb.DB_UserItemData, err error) {
|
func (this *ModelItemsComp) AddItemsToUserPack(uId string, items map[int32]int32) (change []*pb.DB_UserItemData, err error) {
|
||||||
var (
|
var (
|
||||||
itmes []*pb.DB_UserItemData
|
itmes []*pb.DB_UserItemData
|
||||||
add []*pb.DB_UserItemData
|
add []*pb.DB_UserItemData
|
||||||
@ -167,13 +167,13 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
|
|||||||
update []*pb.DB_UserItemData
|
update []*pb.DB_UserItemData
|
||||||
leftnum int64
|
leftnum int64
|
||||||
)
|
)
|
||||||
if itmes, err = this.Pack_QueryUserPack(uId); err != nil {
|
if itmes, err = this.QueryUserPack(uId); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
change = make([]*pb.DB_UserItemData, len(itmes))
|
change = make([]*pb.DB_UserItemData, len(itmes))
|
||||||
for k, v := range items {
|
for k, v := range items {
|
||||||
add, update, del, leftnum = this.pack_addItemToUserPack(uId, itmes, k, v)
|
add, update, del, leftnum = this.addItemToUserPack(uId, itmes, k, v)
|
||||||
if leftnum < 0 {
|
if leftnum < 0 {
|
||||||
err = ItemNotEnoughError
|
err = ItemNotEnoughError
|
||||||
return
|
return
|
||||||
@ -182,21 +182,21 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(add) > 0 {
|
if len(add) > 0 {
|
||||||
if err = this.Pack_AddUserPack(uId, add...); err != nil {
|
if err = this.AddUserPack(uId, add...); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
change = append(change, add...)
|
change = append(change, add...)
|
||||||
}
|
}
|
||||||
if len(del) > 0 {
|
if len(del) > 0 {
|
||||||
if err = this.Pack_DeleteUserPack(uId, del...); err != nil {
|
if err = this.DeleteUserPack(uId, del...); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
change = append(change, del...)
|
change = append(change, del...)
|
||||||
}
|
}
|
||||||
if len(update) > 0 {
|
if len(update) > 0 {
|
||||||
if err = this.Pack_UpdateUserPack(uId, update...); err != nil {
|
if err = this.UpdateUserPack(uId, update...); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ func (this *ModelItemsComp) Pack_AddItemsToUserPack(uId string, items map[int32]
|
|||||||
}
|
}
|
||||||
|
|
||||||
///修改指定格子的物品数量
|
///修改指定格子的物品数量
|
||||||
func (this *ModelItemsComp) Pack_AddItemToUserPackByGrid(uId string, gridid string, itemId int32, addnum int32) (err error) {
|
func (this *ModelItemsComp) AddItemToUserPackByGrid(uId string, gridid string, itemId int32, addnum int32) (err error) {
|
||||||
var (
|
var (
|
||||||
conf *cfg.Game_itemData
|
conf *cfg.Game_itemData
|
||||||
itme *pb.DB_UserItemData
|
itme *pb.DB_UserItemData
|
||||||
@ -223,7 +223,7 @@ func (this *ModelItemsComp) Pack_AddItemToUserPackByGrid(uId string, gridid stri
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if itme, err = this.Pack_QueryUserPackByGridId(uId, gridid); err != nil {
|
if itme, err = this.QueryUserPackByGridId(uId, gridid); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -241,14 +241,14 @@ func (this *ModelItemsComp) Pack_AddItemToUserPackByGrid(uId string, gridid stri
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
itme.Amount = uint32(num)
|
itme.Amount = uint32(num)
|
||||||
this.Pack_UpdateUserPack(uId, itme)
|
this.UpdateUserPack(uId, itme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
///添加移除物品到用户背包
|
///添加移除物品到用户背包
|
||||||
func (this *ModelItemsComp) pack_addItemToUserPack(uid string, items []*pb.DB_UserItemData, itemId int32, addnum int32) (add, update, del []*pb.DB_UserItemData, leftnum int64) {
|
func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserItemData, itemId int32, addnum int32) (add, update, del []*pb.DB_UserItemData, leftnum int64) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
conf *cfg.Game_itemData
|
conf *cfg.Game_itemData
|
||||||
|
@ -49,7 +49,7 @@ func (this *Items) OnInstallComp() {
|
|||||||
func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid int32) (amount uint32) {
|
func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid int32) (amount uint32) {
|
||||||
defer this.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount)
|
defer this.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount)
|
||||||
amount = 0
|
amount = 0
|
||||||
if result := this.modelItems.Pack_QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 {
|
if result := this.modelItems.QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 {
|
||||||
return result[itemid]
|
return result[itemid]
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -57,7 +57,7 @@ func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, it
|
|||||||
|
|
||||||
///查询用户背包多个物品数量
|
///查询用户背包多个物品数量
|
||||||
func (this *Items) QueryItemsAmount(source *comm.ModuleCallSource, uId string, itemid ...int32) (result map[int32]uint32) {
|
func (this *Items) QueryItemsAmount(source *comm.ModuleCallSource, uId string, itemid ...int32) (result map[int32]uint32) {
|
||||||
result = this.modelItems.Pack_QueryUserPackItemsAmount(uId, itemid...)
|
result = this.modelItems.QueryUserPackItemsAmount(uId, itemid...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, ad
|
|||||||
change []*pb.DB_UserItemData
|
change []*pb.DB_UserItemData
|
||||||
)
|
)
|
||||||
defer this.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil)
|
defer this.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil)
|
||||||
if change, err = this.modelItems.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil {
|
if change, err = this.modelItems.AddItemToUserPack(uId, itemid, addnum); err != nil {
|
||||||
this.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err)
|
this.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err)
|
||||||
if err == ItemNotEnoughError {
|
if err == ItemNotEnoughError {
|
||||||
code = pb.ErrorCode_ItemsNoEnough
|
code = pb.ErrorCode_ItemsNoEnough
|
||||||
@ -94,7 +94,7 @@ func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map
|
|||||||
)
|
)
|
||||||
|
|
||||||
defer this.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil)
|
defer this.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil)
|
||||||
if change, err = this.modelItems.Pack_AddItemsToUserPack(uId, items); err != nil {
|
if change, err = this.modelItems.AddItemsToUserPack(uId, items); err != nil {
|
||||||
this.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err)
|
this.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err)
|
||||||
if err == ItemNotEnoughError {
|
if err == ItemNotEnoughError {
|
||||||
code = pb.ErrorCode_ItemsNoEnough
|
code = pb.ErrorCode_ItemsNoEnough
|
||||||
|
@ -171,8 +171,7 @@ type ItemsUseItemReq struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
GridId string `protobuf:"bytes,1,opt,name=GridId,proto3" json:"GridId"` //格子Id
|
GridId string `protobuf:"bytes,1,opt,name=GridId,proto3" json:"GridId"` //格子Id
|
||||||
ItemId int32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId"` //物品Id
|
Amount uint32 `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount"` //使用数量
|
||||||
Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount"` //使用数量
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ItemsUseItemReq) Reset() {
|
func (x *ItemsUseItemReq) Reset() {
|
||||||
@ -214,13 +213,6 @@ func (x *ItemsUseItemReq) GetGridId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ItemsUseItemReq) GetItemId() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.ItemId
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ItemsUseItemReq) GetAmount() uint32 {
|
func (x *ItemsUseItemReq) GetAmount() uint32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Amount
|
return x.Amount
|
||||||
@ -336,6 +328,8 @@ type ItemsSellItemResp struct {
|
|||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Item *DB_UserItemData `protobuf:"bytes,1,opt,name=Item,proto3" json:"Item"` //变化物品
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ItemsSellItemResp) Reset() {
|
func (x *ItemsSellItemResp) Reset() {
|
||||||
@ -370,6 +364,13 @@ func (*ItemsSellItemResp) Descriptor() ([]byte, []int) {
|
|||||||
return file_items_items_msg_proto_rawDescGZIP(), []int{6}
|
return file_items_items_msg_proto_rawDescGZIP(), []int{6}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *ItemsSellItemResp) GetItem() *DB_UserItemData {
|
||||||
|
if x != nil {
|
||||||
|
return x.Item
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var File_items_items_msg_proto protoreflect.FileDescriptor
|
var File_items_items_msg_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_items_items_msg_proto_rawDesc = []byte{
|
var file_items_items_msg_proto_rawDesc = []byte{
|
||||||
@ -385,22 +386,23 @@ var file_items_items_msg_proto_rawDesc = []byte{
|
|||||||
0x64, 0x73, 0x22, 0x39, 0x0a, 0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67,
|
0x64, 0x73, 0x22, 0x39, 0x0a, 0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67,
|
||||||
0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x26, 0x0a, 0x05, 0x47, 0x72, 0x69, 0x64, 0x73, 0x18, 0x01,
|
0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x26, 0x0a, 0x05, 0x47, 0x72, 0x69, 0x64, 0x73, 0x18, 0x01,
|
||||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x74,
|
0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x74,
|
||||||
0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x47, 0x72, 0x69, 0x64, 0x73, 0x22, 0x59, 0x0a,
|
0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x47, 0x72, 0x69, 0x64, 0x73, 0x22, 0x41, 0x0a,
|
||||||
0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71,
|
0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71,
|
||||||
0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d,
|
0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75,
|
||||||
0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64,
|
0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
|
||||||
0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d,
|
0x22, 0x12, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d,
|
||||||
0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x12, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d,
|
0x52, 0x65, 0x73, 0x70, 0x22, 0x5a, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c,
|
||||||
0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x22, 0x5a, 0x0a, 0x10,
|
0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64,
|
||||||
0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71,
|
0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64,
|
||||||
0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
|
||||||
0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d,
|
0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75,
|
||||||
0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64,
|
0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
|
||||||
0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d,
|
0x22, 0x39, 0x0a, 0x11, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65,
|
||||||
0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x49, 0x74, 0x65, 0x6d,
|
0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20,
|
||||||
0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a,
|
0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x74, 0x65,
|
||||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||||
|
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -429,11 +431,12 @@ var file_items_items_msg_proto_goTypes = []interface{}{
|
|||||||
var file_items_items_msg_proto_depIdxs = []int32{
|
var file_items_items_msg_proto_depIdxs = []int32{
|
||||||
7, // 0: ItemsGetlistResp.Grids:type_name -> DB_UserItemData
|
7, // 0: ItemsGetlistResp.Grids:type_name -> DB_UserItemData
|
||||||
7, // 1: ItemsChangePush.Grids:type_name -> DB_UserItemData
|
7, // 1: ItemsChangePush.Grids:type_name -> DB_UserItemData
|
||||||
2, // [2:2] is the sub-list for method output_type
|
7, // 2: ItemsSellItemResp.Item:type_name -> DB_UserItemData
|
||||||
2, // [2:2] is the sub-list for method input_type
|
3, // [3:3] is the sub-list for method output_type
|
||||||
2, // [2:2] is the sub-list for extension type_name
|
3, // [3:3] is the sub-list for method input_type
|
||||||
2, // [2:2] is the sub-list for extension extendee
|
3, // [3:3] is the sub-list for extension type_name
|
||||||
0, // [0:2] is the sub-list for field type_name
|
3, // [3:3] is the sub-list for extension extendee
|
||||||
|
0, // [0:3] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_items_items_msg_proto_init() }
|
func init() { file_items_items_msg_proto_init() }
|
||||||
|
@ -20,8 +20,7 @@ message ItemsChangePush {
|
|||||||
//使用物品请求
|
//使用物品请求
|
||||||
message ItemsUseItemReq {
|
message ItemsUseItemReq {
|
||||||
string GridId = 1; //格子Id
|
string GridId = 1; //格子Id
|
||||||
int32 ItemId = 2; //物品Id
|
uint32 Amount = 2; //使用数量
|
||||||
uint32 Amount = 3; //使用数量
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用物品请求 回应
|
//使用物品请求 回应
|
||||||
@ -38,5 +37,5 @@ message ItemsSellItemReq {
|
|||||||
|
|
||||||
//出售道具请求 回应
|
//出售道具请求 回应
|
||||||
message ItemsSellItemResp {
|
message ItemsSellItemResp {
|
||||||
|
DB_UserItemData Item = 1; //变化物品
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user