This commit is contained in:
liwei1dao 2022-07-13 16:50:39 +08:00
commit 51f729dcd6
24 changed files with 163 additions and 125 deletions

View File

@ -77,9 +77,10 @@ var (
},
rsp: &pb.FriendBlackAddResp{},
// enabled: true,
next: func(rsp proto.Message, handle func(nextCase *TestCase)) {
next: func(robot *Robot, rsp proto.Message) {
tcs := []*TestCase{}
if r, ok := rsp.(*pb.FriendBlackAddResp); ok {
handle(&TestCase{
tc := &TestCase{
desc: "删除黑名单",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeDelBlack,
@ -88,8 +89,11 @@ var (
},
rsp: &pb.FriendDelBlackResp{},
enabled: true,
})
}
tcs = append(tcs, tc)
robot.AddTestCases(tcs)
}
},
}, {
desc: "删除黑名单",
@ -104,6 +108,5 @@ var (
//声明加入到构建器并发起请求
func (r *Robot) RunFriend() {
r.addBuilders(friendBuilders)
r.batchHandleReq()
r.AddTestCases(friendBuilders)
}

View File

@ -24,7 +24,31 @@ var (
fmt.Printf("%d- %v\n", (i + 1), v)
}
},
// enabled: true,
enabled: true,
next: func(robot *Robot, rsp proto.Message) {
tcs := []*TestCase{}
if r, ok := rsp.(*pb.HeroListResp); ok {
for _, v := range r.List {
tc := &TestCase{
desc: "英雄详情",
mainType: string(comm.ModuleHero),
subType: hero.HeroSubTypeInfo,
req: &pb.HeroInfoReq{
HeroId: v.Id,
},
rsp: &pb.HeroInfoResp{},
enabled: true,
print: func(rsp proto.Message) {
r := rsp.(*pb.HeroInfoResp)
fmt.Printf("%v\n", r)
},
}
tcs = append(tcs, tc)
}
robot.AddTestCases(tcs)
}
},
}, {
desc: "英雄详情",
mainType: string(comm.ModuleHero),
@ -72,6 +96,5 @@ var (
//声明加入到构建器并发起请求
func (r *Robot) RunHero() {
r.addBuilders(heroBuilders)
r.batchHandleReq()
r.AddTestCases(heroBuilders)
}

View File

@ -39,6 +39,8 @@ func (r *Robot) AccountLogin() {
log.Printf("区服:[%d] 账号:[%s] login...", r.opts.ServerId, r.opts.Account)
builders := []*TestCase{
{
id: "login",
desc: "登录",
mainType: string(comm.ModuleUser),
subType: user.UserSubTypeLogin,
req: &pb.UserLoginReq{
@ -47,10 +49,11 @@ func (r *Robot) AccountLogin() {
},
rsp: &pb.UserLoginResp{},
enabled: true,
next: func(rsp proto.Message, handle func(nextCase *TestCase)) {
next: func(r *Robot, rsp proto.Message) {
tcs := []*TestCase{}
if _, ok := rsp.(*pb.UserLoginResp); ok {
nick := randomdata.SillyName()
handle(&TestCase{
tc := &TestCase{
desc: "创角",
mainType: string(comm.ModuleUser),
subType: user.UserSubTypeCreate,
@ -58,12 +61,14 @@ func (r *Robot) AccountLogin() {
NickName: nick,
},
rsp: &pb.UserCreateResp{},
enabled: true,
})
// enabled: true,
}
tcs = append(tcs, tc)
r.AddTestCases(tcs)
}
},
},
}
r.addBuilders(builders)
r.batchHandleReq()
r.AddTestCases(builders)
}

View File

@ -8,6 +8,7 @@ import (
var notify_builders = []*TestCase{
{
//create
desc: "全局通知",
mainType: comm.MainTypeNotify,
subType: comm.SubTypeErrorNotify,
rsp: &pb.NotifyErrorNotifyPush{},

View File

@ -19,6 +19,5 @@ var pack_builders = []*TestCase{
//声明加入到构建器并发起请求
func (r *Robot) RunPack() {
r.addBuilders(pack_builders)
r.batchHandleReq()
r.AddTestCases(pack_builders)
}

View File

@ -14,6 +14,7 @@ import (
"github.com/gorilla/websocket"
jsoniter "github.com/json-iterator/go"
uuid "github.com/satori/go.uuid"
"google.golang.org/protobuf/proto"
)
@ -21,10 +22,10 @@ type Robot struct {
ws *websocket.Conn
opts *Options
user *pb.DBUser
builders []*TestCase //测试用例
linkCase *LinkCase //测试用例链,适应于用例跑批
builderMap map[string]*TestCase
// linkCase *LinkCase
wg sync.WaitGroup
ch chan string //uuid
}
func NewRobot(opts *Options) *Robot {
@ -35,7 +36,8 @@ func NewRobot(opts *Options) *Robot {
r := &Robot{
ws: ws,
opts: opts,
linkCase: NewLinkCase(),
builderMap: make(map[string]*TestCase),
ch: make(chan string, 10),
}
return r
@ -69,33 +71,45 @@ func (r *Robot) Run() {
}
}()
// select {}
r.wg.Wait()
}
type TestCase struct {
desc string
mainType string
subType string
req proto.Message
rsp proto.Message
enabled bool
start time.Time
requested bool //请求标识 true已发
id string //uuid
desc string //用例描述
mainType string //协议类型 L1
subType string //协议类型 L2
req proto.Message //请求类型
rsp proto.Message //响应类型
enabled bool //是否启用
start time.Time //启用时间
requested bool //是否已请求 //请求标识 true已发
print func(rsp proto.Message) //定义打印
next func(rsp proto.Message, handle func(nextCase *TestCase))
next func(robot *Robot, rsp proto.Message) //处理下一层用例请求
}
//添加测试用用例
func (r *Robot) addBuilders(builders []*TestCase) {
for _, b := range builders {
if b.enabled {
r.builders = append(r.builders, b)
if b.id == "" {
uuid := uuid.NewV4().String()
b.id = uuid
r.builderMap[uuid] = b
} else {
r.builderMap[b.id] = b
}
}
}
}
func (r *Robot) handleReq(b *TestCase) {
b.requested = true
//处理用例,发送请求
func (r *Robot) handleReq() {
for _, b := range r.builderMap {
if b.enabled && b.req != nil && !b.requested {
r.wg.Add(1)
time.Sleep(time.Second * 1)
b.start = time.Now()
head := &pb.UserMessage{MainType: b.mainType, SubType: b.subType}
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), b.req)
@ -103,56 +117,56 @@ func (r *Robot) handleReq(b *TestCase) {
if err != nil {
log.Fatal(err)
}
b.requested = true
r.ch <- b.id
}
}
}
//执行请求
func (r *Robot) batchHandleReq() {
for _, b := range r.builders {
if b.req != nil && !b.requested {
r.wg.Add(1)
time.Sleep(time.Second * 1)
r.handleReq(b)
}
}
func (r *Robot) AddTestCases(tcs []*TestCase) {
r.addBuilders(tcs)
r.handleReq()
}
//执行响应
func (r *Robot) batchhandleRsp(msg *pb.UserMessage) {
for i, b := range r.builders {
if b.enabled && (msg.MainType == b.mainType &&
msg.SubType == b.subType) {
if !comm.ProtoUnmarshal(msg, b.rsp) {
uuid := <-r.ch
if v, ok := r.builderMap[uuid]; ok {
if v.enabled &&
(msg.MainType == v.mainType &&
msg.SubType == v.subType) &&
v.requested {
if !comm.ProtoUnmarshal(msg, v.rsp) {
return
}
if b.print == nil {
printReply(msg, b)
if v.print == nil {
printReply(msg, v)
} else {
fmt.Printf("===== %s [%s.%s] =====\n", b.desc, msg.MainType, msg.SubType)
b.print(b.rsp)
fmt.Println()
fmt.Printf("===== %s [%s.%s]=====\n", v.desc, msg.MainType, msg.SubType)
v.print(v.rsp)
fmt.Println("==============================")
}
if b.next != nil {
b.next(b.rsp, r.handleReq)
if v.next != nil {
v.next(r, v.rsp)
}
if msg.MainType == "user" && msg.SubType == "login" {
r.loginCallback(b.rsp)
r.loginCallback(v.rsp)
} else {
if b.requested {
r.builders = append(r.builders[:i], r.builders[i+1:]...)
}
delete(r.builderMap, v.id)
}
r.wg.Done()
}
}
}
//登录回调
func (r *Robot) loginCallback(rsp proto.Message) {
r.builders = append(r.builders[:0], r.builders[1:]...)
delete(r.builderMap, "login")
lr := rsp.(*pb.UserLoginResp)
if lr.Data != nil {
r.user = lr.Data
@ -235,8 +249,7 @@ func (r *Robot) AccountRegister(account string, sid int32) {
enabled: true,
},
}
r.addBuilders(user_builders)
r.batchHandleReq()
r.AddTestCases(user_builders)
}
}

View File

@ -40,6 +40,5 @@ var (
//声明加入到构建器并发起请求
func (r *Robot) RunStory() {
r.addBuilders(storyBuilders)
r.batchHandleReq()
r.AddTestCases(storyBuilders)
}

View File

@ -62,6 +62,5 @@ var (
//声明加入到构建器并发起请求
func (r *Robot) RunTask() {
r.addBuilders(taskBuilders)
r.batchHandleReq()
r.AddTestCases(taskBuilders)
}

View File

@ -36,6 +36,5 @@ var user_builders = []*TestCase{
//声明加入到构建器并发起请求
func (r *Robot) RunUser() {
r.addBuilders(user_builders)
r.batchHandleReq()
r.AddTestCases(user_builders)
}

View File

@ -2,7 +2,6 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"strconv"
@ -77,7 +76,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap)
if err1 != nil {
code = pb.ErrorCode_DBError
log.Errorf("update hero skill failed:%v", err1)
this.module.Errorf("update hero skill failed:%v", err1)
return
}
} else { // 加属性
@ -91,7 +90,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
log.Errorf("PushHeroProperty err!")
this.module.Errorf("PushHeroProperty err!")
}
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero})
return

View File

@ -1,6 +1,7 @@
package hero
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
@ -28,15 +29,17 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code
code = pb.ErrorCode_SystemError
return
}
utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), HeroSubTypeList, req, rsp)
utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), HeroSubTypeInfo, req, rsp)
}()
hero := this.module.modelHero.getOneHero(session.GetUserId(), req.HeroId)
if hero == nil {
code = pb.ErrorCode_HeroNoExist
return
}
rsp.Base = hero
fmt.Printf("[ %v ] \n", hero)
return
}

View File

@ -2,7 +2,6 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"strconv"
@ -105,7 +104,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
}
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil {
log.Errorf("update hero skill failed:%v", err1)
this.module.Errorf("update hero skill failed:%v", err1)
code = pb.ErrorCode_DBError
return
}
@ -124,7 +123,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
}
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
log.Errorf("PushHeroProperty err!")
this.module.Errorf("PushHeroProperty err!")
}
session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero})
return

View File

@ -2,7 +2,6 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
@ -76,13 +75,13 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil {
log.Errorf("update hero skill failed:%v", err1)
this.module.Errorf("update hero skill failed:%v", err1)
code = pb.ErrorCode_DBError
return
}
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
log.Errorf("PushHeroProperty err!")
this.module.Errorf("PushHeroProperty err!")
}
session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum})
return

View File

@ -2,7 +2,6 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"math"
@ -46,7 +45,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR
err1 := this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil {
code = pb.ErrorCode_DBError
log.Errorf("update hero skill failed:%v", err1)
this.module.Errorf("update hero skill failed:%v", err1)
return
}
// 计算属性
@ -69,7 +68,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
log.Errorf("PushHeroProperty err!")
this.module.Errorf("PushHeroProperty err!")
}
session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero})
return

View File

@ -3,7 +3,6 @@ package hero
import (
"crypto/rand"
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"math/big"
@ -120,7 +119,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
}
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil {
log.Errorf("update hero skill failed:%v", err1)
this.module.Errorf("update hero skill failed:%v", err1)
code = pb.ErrorCode_DBError
return
}
@ -132,7 +131,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
}
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
log.Errorf("PushHeroProperty err!")
this.module.Errorf("PushHeroProperty err!")
}
session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero})

View File

@ -2,7 +2,6 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
@ -116,7 +115,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
// 消耗道具
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), "gold", -target.Gold) // 减少金币
if code != pb.ErrorCode_Success {
log.Errorf("cost gold failed ,count = %d", target.Gold)
this.module.Errorf("cost gold failed ,count = %d", target.Gold)
code = pb.ErrorCode_GoldNoEnough
return
}
@ -125,7 +124,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
code = this.module.DelCard(session.GetUserId(), v.CostCardObj, v.Amount)
if code != pb.ErrorCode_Success {
code = pb.ErrorCode_DBError
log.Errorf("del hero err card:%s,count = %d", v.CostCardObj, v.Amount)
this.module.Errorf("del hero err card:%s,count = %d", v.CostCardObj, v.Amount)
return
}
}

View File

@ -2,7 +2,6 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
@ -122,7 +121,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
return
}
log.Debugf("升级后当前等级: %d,经验: %d,需要消耗的金币: %d,增加的经验: %d", curLv, curExp, costRes["gold"], addExp)
this.module.Debugf("升级后当前等级: %d,经验: %d,需要消耗的金币: %d,增加的经验: %d", curLv, curExp, costRes["gold"], addExp)
// 执行升级逻辑
code = this.module.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
if code != pb.ErrorCode_Success {
@ -140,13 +139,13 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
err1 := this.module.modelHero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount)
if err1 != nil {
code = pb.ErrorCode_HeroNoEnough
log.Errorf("delete err failed err:%T!", err1)
this.module.Errorf("delete err failed err:%T!", err1)
return
}
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
log.Errorf("PushHeroProperty err!")
this.module.Errorf("PushHeroProperty err!")
}
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})

View File

@ -87,7 +87,7 @@ func TestPropertyCompute(t *testing.T) {
func TestHeroList(t *testing.T) {
heroes := module.modelHero.getHeroList("u1")
fmt.Printf("%v", heroes,)
fmt.Printf("%v", heroes)
}
func TestModify(t *testing.T) {

View File

@ -4,7 +4,6 @@ import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"math"
@ -35,7 +34,7 @@ func (this *ModelHero) Init(service core.IService, module core.IModule, comp cor
func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero {
heroCfg := this.moduleHero.configure.GetHero(heroCfgId)
if heroCfg == nil {
log.Errorf("%v hero not found from config %v", heroCfgId)
this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId)
return nil
}
objId := primitive.NewObjectID().Hex()
@ -90,7 +89,7 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) {
hero := this.initHero(uid, heroCfgId)
if hero != nil {
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
log.Errorf("%v", err)
this.moduleHero.Errorf("%v", err)
return
}
}
@ -151,7 +150,7 @@ func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero {
func (this *ModelHero) consumeOneHeroCard(uid, heroId string, count int32) (err error) {
for i := 0; i < int(count); i++ {
if err := this.moduleHero.modelHero.DelListlds(uid, heroId); err != nil {
log.Errorf("%v", err)
this.moduleHero.Errorf("%v", err)
break
}
}
@ -160,6 +159,9 @@ func (this *ModelHero) consumeOneHeroCard(uid, heroId string, count int32) (err
//更新英雄数据
func (this *ModelHero) modifyHeroData(uid, heroId string, data map[string]interface{}) error {
if len(data) == 0 {
return fmt.Errorf("params len is 0")
}
return this.moduleHero.modelHero.ChangeList(uid, heroId, data)
}
@ -197,7 +199,7 @@ func (this *ModelHero) mergeMainProperty(uid, heroId string, data map[string]int
comm.Def: hero.Property[comm.Def],
}
if err := this.modifyHeroData(uid, heroId, update); err != nil {
log.Errorf("mergeMainProperty err %v", err)
this.moduleHero.Errorf("mergeMainProperty err %v", err)
}
}
@ -216,7 +218,7 @@ func (this *ModelHero) mergeAddProperty(uid, heroId string, data map[string]int3
comm.DefPro: hero.AddProperty[comm.DefPro],
}
if err := this.modifyHeroData(uid, heroId, update); err != nil {
log.Errorf("mergeAddProperty err %v", err)
this.moduleHero.Errorf("mergeAddProperty err %v", err)
}
}
@ -288,7 +290,7 @@ func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string
}
if err = this.ChangeList(session.GetUserId(), heroId, update); err != nil {
log.Errorf("PushHeroProperty err:%v", err)
this.moduleHero.Errorf("PushHeroProperty err:%v", err)
return
}
return session.SendMsg("push", "property", &pb.HeroProperty{Property: m})
@ -304,7 +306,7 @@ func (this *ModelHero) HeroStarUp(session comm.IUserSession, hero *pb.DBHero) (c
err1 := this.modifyHeroData(session.GetUserId(), hero.Id, _heroMap)
if err1 != nil {
code = pb.ErrorCode_DBError
log.Errorf("update hero skill failed:%v", err1)
this.moduleHero.Errorf("update hero skill failed:%v", err1)
}
// 计算属性
data := make(map[string]int32, 0)
@ -324,7 +326,7 @@ func (this *ModelHero) HeroStarUp(session comm.IUserSession, hero *pb.DBHero) (c
err1 = this.PushHeroProperty(session, hero.Id) // 推送属性变化
if err1 != nil {
code = pb.ErrorCode_Unknown
log.Errorf("PushHeroProperty err!")
this.moduleHero.Errorf("PushHeroProperty err!")
}
return
}

View File

@ -2,7 +2,6 @@ package mail
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
@ -36,7 +35,7 @@ func (this *apiComp) DelMail(session comm.IUserSession, req *pb.MailDelMailReq)
}
if mailinfo, err = this.module.modelMail.Mail_QueryUserMail(session.GetUserId()); err != nil {
log.Errorf("QueryUserMailResp err:%v", err)
this.module.Errorf("QueryUserMailResp err:%v", err)
code = pb.ErrorCode_CacheReadError
return
}

View File

@ -2,7 +2,6 @@ package mail
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
@ -25,7 +24,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.MailGetListReq)
return
}
if mailinfo, err = this.module.modelMail.Mail_QueryUserMail(session.GetUserId()); err != nil {
log.Errorf("Mail_GetList_Resp err:%v", err)
this.module.Errorf("Mail_GetList_Resp err:%v", err)
code = pb.ErrorCode_CacheReadError
return
}

View File

@ -6,7 +6,6 @@ import (
"go_dreamfactory/pb"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
)
/*
@ -53,7 +52,7 @@ func (this *Mail) CreateNewMail(uId string, mail *pb.DBMailData) bool {
}
err := this.modelMail.Mail_InsertUserMail(mail)
if err != nil {
log.Error("create mail failed")
this.ModuleBase.Errorf("create mail failed")
}
// 通知玩家
var _cache = &pb.CacheUser{}

View File

@ -2,7 +2,6 @@ package story
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
)
@ -13,12 +12,12 @@ const ( //Redis
type ModelStory struct {
modules.MCompModel
moduleStory *Story
module *Story
}
func (this *ModelStory) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.moduleStory = module.(*Story)
this.module = module.(*Story)
this.TableName = string(TableStory)
return
}
@ -32,14 +31,14 @@ func (this *ModelStory) getStoryList(uid string) (storys []*pb.DBStory, err erro
// 修改章节信息
func (this *ModelStory) modifyStoryData(uid string, objid string, data map[string]interface{}) error {
return this.moduleStory.modelStory.ChangeList(uid, objid, data)
return this.module.modelStory.ChangeList(uid, objid, data)
}
// 增加新的章节数据
func (this *ModelStory) addNewChapter(uId string, data map[string]interface{}) (err error) {
if err = this.AddLists(uId, data); err != nil {
log.Errorf("err:%v", err)
this.module.Errorf("err:%v", err)
return
}
return nil

View File

@ -114,6 +114,9 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb
update[comm.ResDiamond] = user.Diamond + add
}
if len(update) == 0 {
return
}
if err := this.modelUser.updateUserAttr(uid, update); err != nil {
log.Errorf("AddAttributeValue err:%v", err)
code = pb.ErrorCode_DBError