上传item 写入mgo日志异常bug修复

This commit is contained in:
liwei1dao 2022-07-26 20:12:32 +08:00
parent 158a66407c
commit 398783c256
3 changed files with 39 additions and 45 deletions

View File

@ -92,6 +92,7 @@ func (this *ServiceBase) Start() (err error) {
//运行模块 //运行模块
func (this *ServiceBase) Run(mod ...core.IModule) { func (this *ServiceBase) Run(mod ...core.IModule) {
go func() {
for _, v := range mod { //初始化模块对象 分配配置参数 for _, v := range mod { //初始化模块对象 分配配置参数
if sf, ok := this.service.GetSettings().Modules[string(v.GetType())]; ok { if sf, ok := this.service.GetSettings().Modules[string(v.GetType())]; ok {
this.modules[v.GetType()] = &defaultModule{ this.modules[v.GetType()] = &defaultModule{
@ -129,6 +130,7 @@ func (this *ServiceBase) Run(mod ...core.IModule) {
go v.run() go v.run()
} }
event.TriggerEvent(core.Event_ServiceStartEnd) //广播服务启动完毕事件 event.TriggerEvent(core.Event_ServiceStartEnd) //广播服务启动完毕事件
}()
//监听外部关闭服务信号 //监听外部关闭服务信号
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
//添加进程结束信号 //添加进程结束信号

View File

@ -26,16 +26,13 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
dels []*pb.DB_UserItemData dels []*pb.DB_UserItemData
) )
defer func() { defer func() {
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ItemsGetlistResp{Grids: items})
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
go func() { //异步处理修改数据
if len(modifys) > 0 { if len(modifys) > 0 {
this.module.modelItems.UpdateUserPack(session.GetUserId(), modifys...) this.module.modelItems.UpdateUserPack(session.GetUserId(), modifys...)
} }
if len(dels) > 0 { if len(dels) > 0 {
this.module.modelItems.DeleteUserPack(session.GetUserId(), dels...) this.module.modelItems.DeleteUserPack(session.GetUserId(), dels...)
} }
}()
} }
}() }()
@ -61,5 +58,6 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
} }
} }
} }
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ItemsGetlistResp{Grids: items})
return return
} }

View File

@ -1,7 +1,6 @@
package items package items
import ( import (
"errors"
"fmt" "fmt"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
@ -68,11 +67,6 @@ func (this *ModelItemsComp) DelUserPack(uId string, ids ...string) (err error) {
//更新用户的背包信息 //更新用户的背包信息
func (this *ModelItemsComp) UpdateUserPack(uid string, itmes ...*pb.DB_UserItemData) (err error) { func (this *ModelItemsComp) UpdateUserPack(uid string, itmes ...*pb.DB_UserItemData) (err error) {
if len(uid) == 0 {
err = errors.New("UpdateUserPack uid is nil")
this.module.Panicf("err:%v", err)
return
}
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,