Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
51f729dcd6
@ -77,9 +77,10 @@ var (
|
|||||||
},
|
},
|
||||||
rsp: &pb.FriendBlackAddResp{},
|
rsp: &pb.FriendBlackAddResp{},
|
||||||
// enabled: true,
|
// 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 {
|
if r, ok := rsp.(*pb.FriendBlackAddResp); ok {
|
||||||
handle(&TestCase{
|
tc := &TestCase{
|
||||||
desc: "删除黑名单",
|
desc: "删除黑名单",
|
||||||
mainType: string(comm.ModuleFriend),
|
mainType: string(comm.ModuleFriend),
|
||||||
subType: friend.FriendSubTypeDelBlack,
|
subType: friend.FriendSubTypeDelBlack,
|
||||||
@ -88,8 +89,11 @@ var (
|
|||||||
},
|
},
|
||||||
rsp: &pb.FriendDelBlackResp{},
|
rsp: &pb.FriendDelBlackResp{},
|
||||||
enabled: true,
|
enabled: true,
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
tcs = append(tcs, tc)
|
||||||
|
robot.AddTestCases(tcs)
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
desc: "删除黑名单",
|
desc: "删除黑名单",
|
||||||
@ -104,6 +108,5 @@ var (
|
|||||||
|
|
||||||
//声明加入到构建器并发起请求
|
//声明加入到构建器并发起请求
|
||||||
func (r *Robot) RunFriend() {
|
func (r *Robot) RunFriend() {
|
||||||
r.addBuilders(friendBuilders)
|
r.AddTestCases(friendBuilders)
|
||||||
r.batchHandleReq()
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,31 @@ var (
|
|||||||
fmt.Printf("%d- %v\n", (i + 1), v)
|
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: "英雄详情",
|
desc: "英雄详情",
|
||||||
mainType: string(comm.ModuleHero),
|
mainType: string(comm.ModuleHero),
|
||||||
@ -72,6 +96,5 @@ var (
|
|||||||
|
|
||||||
//声明加入到构建器并发起请求
|
//声明加入到构建器并发起请求
|
||||||
func (r *Robot) RunHero() {
|
func (r *Robot) RunHero() {
|
||||||
r.addBuilders(heroBuilders)
|
r.AddTestCases(heroBuilders)
|
||||||
r.batchHandleReq()
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ func (r *Robot) AccountLogin() {
|
|||||||
log.Printf("区服:[%d] 账号:[%s] login...", r.opts.ServerId, r.opts.Account)
|
log.Printf("区服:[%d] 账号:[%s] login...", r.opts.ServerId, r.opts.Account)
|
||||||
builders := []*TestCase{
|
builders := []*TestCase{
|
||||||
{
|
{
|
||||||
|
id: "login",
|
||||||
|
desc: "登录",
|
||||||
mainType: string(comm.ModuleUser),
|
mainType: string(comm.ModuleUser),
|
||||||
subType: user.UserSubTypeLogin,
|
subType: user.UserSubTypeLogin,
|
||||||
req: &pb.UserLoginReq{
|
req: &pb.UserLoginReq{
|
||||||
@ -47,10 +49,11 @@ func (r *Robot) AccountLogin() {
|
|||||||
},
|
},
|
||||||
rsp: &pb.UserLoginResp{},
|
rsp: &pb.UserLoginResp{},
|
||||||
enabled: true,
|
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 {
|
if _, ok := rsp.(*pb.UserLoginResp); ok {
|
||||||
nick := randomdata.SillyName()
|
nick := randomdata.SillyName()
|
||||||
handle(&TestCase{
|
tc := &TestCase{
|
||||||
desc: "创角",
|
desc: "创角",
|
||||||
mainType: string(comm.ModuleUser),
|
mainType: string(comm.ModuleUser),
|
||||||
subType: user.UserSubTypeCreate,
|
subType: user.UserSubTypeCreate,
|
||||||
@ -58,12 +61,14 @@ func (r *Robot) AccountLogin() {
|
|||||||
NickName: nick,
|
NickName: nick,
|
||||||
},
|
},
|
||||||
rsp: &pb.UserCreateResp{},
|
rsp: &pb.UserCreateResp{},
|
||||||
enabled: true,
|
// enabled: true,
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
tcs = append(tcs, tc)
|
||||||
|
r.AddTestCases(tcs)
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
r.addBuilders(builders)
|
r.AddTestCases(builders)
|
||||||
r.batchHandleReq()
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
var notify_builders = []*TestCase{
|
var notify_builders = []*TestCase{
|
||||||
{
|
{
|
||||||
//create
|
//create
|
||||||
|
desc: "全局通知",
|
||||||
mainType: comm.MainTypeNotify,
|
mainType: comm.MainTypeNotify,
|
||||||
subType: comm.SubTypeErrorNotify,
|
subType: comm.SubTypeErrorNotify,
|
||||||
rsp: &pb.NotifyErrorNotifyPush{},
|
rsp: &pb.NotifyErrorNotifyPush{},
|
||||||
|
@ -19,6 +19,5 @@ var pack_builders = []*TestCase{
|
|||||||
|
|
||||||
//声明加入到构建器并发起请求
|
//声明加入到构建器并发起请求
|
||||||
func (r *Robot) RunPack() {
|
func (r *Robot) RunPack() {
|
||||||
r.addBuilders(pack_builders)
|
r.AddTestCases(pack_builders)
|
||||||
r.batchHandleReq()
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,10 +22,10 @@ type Robot struct {
|
|||||||
ws *websocket.Conn
|
ws *websocket.Conn
|
||||||
opts *Options
|
opts *Options
|
||||||
user *pb.DBUser
|
user *pb.DBUser
|
||||||
builders []*TestCase //测试用例
|
builderMap map[string]*TestCase
|
||||||
|
// linkCase *LinkCase
|
||||||
linkCase *LinkCase //测试用例链,适应于用例跑批
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
ch chan string //uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRobot(opts *Options) *Robot {
|
func NewRobot(opts *Options) *Robot {
|
||||||
@ -35,7 +36,8 @@ func NewRobot(opts *Options) *Robot {
|
|||||||
r := &Robot{
|
r := &Robot{
|
||||||
ws: ws,
|
ws: ws,
|
||||||
opts: opts,
|
opts: opts,
|
||||||
linkCase: NewLinkCase(),
|
builderMap: make(map[string]*TestCase),
|
||||||
|
ch: make(chan string, 10),
|
||||||
}
|
}
|
||||||
|
|
||||||
return r
|
return r
|
||||||
@ -69,33 +71,45 @@ func (r *Robot) Run() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// select {}
|
|
||||||
r.wg.Wait()
|
r.wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
type TestCase struct {
|
type TestCase struct {
|
||||||
desc string
|
id string //uuid
|
||||||
mainType string
|
desc string //用例描述
|
||||||
subType string
|
mainType string //协议类型 L1
|
||||||
req proto.Message
|
subType string //协议类型 L2
|
||||||
rsp proto.Message
|
req proto.Message //请求类型
|
||||||
enabled bool
|
rsp proto.Message //响应类型
|
||||||
start time.Time
|
enabled bool //是否启用
|
||||||
requested bool //请求标识 true已发
|
start time.Time //启用时间
|
||||||
|
requested bool //是否已请求 //请求标识 true已发
|
||||||
print func(rsp proto.Message) //定义打印
|
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) {
|
func (r *Robot) addBuilders(builders []*TestCase) {
|
||||||
for _, b := range builders {
|
for _, b := range builders {
|
||||||
if b.enabled {
|
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()
|
b.start = time.Now()
|
||||||
head := &pb.UserMessage{MainType: b.mainType, SubType: b.subType}
|
head := &pb.UserMessage{MainType: b.mainType, SubType: b.subType}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), b.req)
|
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), b.req)
|
||||||
@ -103,56 +117,56 @@ func (r *Robot) handleReq(b *TestCase) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
b.requested = true
|
||||||
|
r.ch <- b.id
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//执行请求
|
//执行请求
|
||||||
func (r *Robot) batchHandleReq() {
|
func (r *Robot) AddTestCases(tcs []*TestCase) {
|
||||||
for _, b := range r.builders {
|
r.addBuilders(tcs)
|
||||||
if b.req != nil && !b.requested {
|
r.handleReq()
|
||||||
r.wg.Add(1)
|
|
||||||
time.Sleep(time.Second * 1)
|
|
||||||
r.handleReq(b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//执行响应
|
//执行响应
|
||||||
func (r *Robot) batchhandleRsp(msg *pb.UserMessage) {
|
func (r *Robot) batchhandleRsp(msg *pb.UserMessage) {
|
||||||
for i, b := range r.builders {
|
uuid := <-r.ch
|
||||||
if b.enabled && (msg.MainType == b.mainType &&
|
if v, ok := r.builderMap[uuid]; ok {
|
||||||
msg.SubType == b.subType) {
|
if v.enabled &&
|
||||||
if !comm.ProtoUnmarshal(msg, b.rsp) {
|
(msg.MainType == v.mainType &&
|
||||||
|
msg.SubType == v.subType) &&
|
||||||
|
v.requested {
|
||||||
|
if !comm.ProtoUnmarshal(msg, v.rsp) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if b.print == nil {
|
if v.print == nil {
|
||||||
printReply(msg, b)
|
printReply(msg, v)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("===== %s [%s.%s] =====\n", b.desc, msg.MainType, msg.SubType)
|
fmt.Println()
|
||||||
b.print(b.rsp)
|
fmt.Printf("===== %s [%s.%s]=====\n", v.desc, msg.MainType, msg.SubType)
|
||||||
|
v.print(v.rsp)
|
||||||
fmt.Println("==============================")
|
fmt.Println("==============================")
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.next != nil {
|
if v.next != nil {
|
||||||
b.next(b.rsp, r.handleReq)
|
v.next(r, v.rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if msg.MainType == "user" && msg.SubType == "login" {
|
if msg.MainType == "user" && msg.SubType == "login" {
|
||||||
r.loginCallback(b.rsp)
|
r.loginCallback(v.rsp)
|
||||||
} else {
|
} else {
|
||||||
if b.requested {
|
delete(r.builderMap, v.id)
|
||||||
r.builders = append(r.builders[:i], r.builders[i+1:]...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.wg.Done()
|
r.wg.Done()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//登录回调
|
//登录回调
|
||||||
func (r *Robot) loginCallback(rsp proto.Message) {
|
func (r *Robot) loginCallback(rsp proto.Message) {
|
||||||
r.builders = append(r.builders[:0], r.builders[1:]...)
|
delete(r.builderMap, "login")
|
||||||
lr := rsp.(*pb.UserLoginResp)
|
lr := rsp.(*pb.UserLoginResp)
|
||||||
if lr.Data != nil {
|
if lr.Data != nil {
|
||||||
r.user = lr.Data
|
r.user = lr.Data
|
||||||
@ -235,8 +249,7 @@ func (r *Robot) AccountRegister(account string, sid int32) {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
r.addBuilders(user_builders)
|
r.AddTestCases(user_builders)
|
||||||
r.batchHandleReq()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,5 @@ var (
|
|||||||
|
|
||||||
//声明加入到构建器并发起请求
|
//声明加入到构建器并发起请求
|
||||||
func (r *Robot) RunStory() {
|
func (r *Robot) RunStory() {
|
||||||
r.addBuilders(storyBuilders)
|
r.AddTestCases(storyBuilders)
|
||||||
r.batchHandleReq()
|
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,5 @@ var (
|
|||||||
|
|
||||||
//声明加入到构建器并发起请求
|
//声明加入到构建器并发起请求
|
||||||
func (r *Robot) RunTask() {
|
func (r *Robot) RunTask() {
|
||||||
r.addBuilders(taskBuilders)
|
r.AddTestCases(taskBuilders)
|
||||||
r.batchHandleReq()
|
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,5 @@ var user_builders = []*TestCase{
|
|||||||
|
|
||||||
//声明加入到构建器并发起请求
|
//声明加入到构建器并发起请求
|
||||||
func (r *Robot) RunUser() {
|
func (r *Robot) RunUser() {
|
||||||
r.addBuilders(user_builders)
|
r.AddTestCases(user_builders)
|
||||||
r.batchHandleReq()
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package hero
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"strconv"
|
"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)
|
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
log.Errorf("update hero skill failed:%v", err1)
|
this.module.Errorf("update hero skill failed:%v", err1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else { // 加属性
|
} else { // 加属性
|
||||||
@ -91,7 +90,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
|||||||
|
|
||||||
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
this.module.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero})
|
||||||
return
|
return
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package hero
|
package hero
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
@ -28,15 +29,17 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code
|
|||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
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)
|
hero := this.module.modelHero.getOneHero(session.GetUserId(), req.HeroId)
|
||||||
if hero == nil {
|
if hero == nil {
|
||||||
code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp.Base = hero
|
rsp.Base = hero
|
||||||
|
|
||||||
|
fmt.Printf("[ %v ] \n", hero)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package hero
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"strconv"
|
"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) // 修改英雄信息
|
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("update hero skill failed:%v", err1)
|
this.module.Errorf("update hero skill failed:%v", err1)
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -124,7 +123,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
|||||||
}
|
}
|
||||||
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
this.module.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero})
|
||||||
return
|
return
|
||||||
|
@ -2,7 +2,6 @@ package hero
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"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) // 修改英雄信息
|
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("update hero skill failed:%v", err1)
|
this.module.Errorf("update hero skill failed:%v", err1)
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err1 != nil {
|
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})
|
session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum})
|
||||||
return
|
return
|
||||||
|
@ -2,7 +2,6 @@ package hero
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"math"
|
"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) // 修改英雄信息
|
err1 := this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
log.Errorf("update hero skill failed:%v", err1)
|
this.module.Errorf("update hero skill failed:%v", err1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 计算属性
|
// 计算属性
|
||||||
@ -69,7 +68,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR
|
|||||||
|
|
||||||
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
this.module.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero})
|
||||||
return
|
return
|
||||||
|
@ -3,7 +3,6 @@ package hero
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"math/big"
|
"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) // 修改英雄信息
|
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("update hero skill failed:%v", err1)
|
this.module.Errorf("update hero skill failed:%v", err1)
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -132,7 +131,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
|||||||
}
|
}
|
||||||
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
this.module.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero})
|
||||||
|
@ -2,7 +2,6 @@ package hero
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
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) // 减少金币
|
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), "gold", -target.Gold) // 减少金币
|
||||||
if code != pb.ErrorCode_Success {
|
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
|
code = pb.ErrorCode_GoldNoEnough
|
||||||
return
|
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)
|
code = this.module.DelCard(session.GetUserId(), v.CostCardObj, v.Amount)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_DBError
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package hero
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
@ -122,7 +121,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
|||||||
return
|
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) // 加经验
|
code = this.module.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
|
||||||
if code != pb.ErrorCode_Success {
|
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)
|
err1 := this.module.modelHero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_HeroNoEnough
|
code = pb.ErrorCode_HeroNoEnough
|
||||||
log.Errorf("delete err failed err:%T!", err1)
|
this.module.Errorf("delete err failed err:%T!", err1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
this.module.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
|
||||||
|
@ -87,7 +87,7 @@ func TestPropertyCompute(t *testing.T) {
|
|||||||
|
|
||||||
func TestHeroList(t *testing.T) {
|
func TestHeroList(t *testing.T) {
|
||||||
heroes := module.modelHero.getHeroList("u1")
|
heroes := module.modelHero.getHeroList("u1")
|
||||||
fmt.Printf("%v", heroes,)
|
fmt.Printf("%v", heroes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestModify(t *testing.T) {
|
func TestModify(t *testing.T) {
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"math"
|
"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 {
|
func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero {
|
||||||
heroCfg := this.moduleHero.configure.GetHero(heroCfgId)
|
heroCfg := this.moduleHero.configure.GetHero(heroCfgId)
|
||||||
if heroCfg == nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
objId := primitive.NewObjectID().Hex()
|
objId := primitive.NewObjectID().Hex()
|
||||||
@ -90,7 +89,7 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) {
|
|||||||
hero := this.initHero(uid, heroCfgId)
|
hero := this.initHero(uid, heroCfgId)
|
||||||
if hero != nil {
|
if hero != nil {
|
||||||
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
|
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
|
||||||
log.Errorf("%v", err)
|
this.moduleHero.Errorf("%v", err)
|
||||||
return
|
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) {
|
func (this *ModelHero) consumeOneHeroCard(uid, heroId string, count int32) (err error) {
|
||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < int(count); i++ {
|
||||||
if err := this.moduleHero.modelHero.DelListlds(uid, heroId); err != nil {
|
if err := this.moduleHero.modelHero.DelListlds(uid, heroId); err != nil {
|
||||||
log.Errorf("%v", err)
|
this.moduleHero.Errorf("%v", err)
|
||||||
break
|
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 {
|
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)
|
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],
|
comm.Def: hero.Property[comm.Def],
|
||||||
}
|
}
|
||||||
if err := this.modifyHeroData(uid, heroId, update); err != nil {
|
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],
|
comm.DefPro: hero.AddProperty[comm.DefPro],
|
||||||
}
|
}
|
||||||
if err := this.modifyHeroData(uid, heroId, update); err != nil {
|
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 {
|
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
|
||||||
}
|
}
|
||||||
return session.SendMsg("push", "property", &pb.HeroProperty{Property: m})
|
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)
|
err1 := this.modifyHeroData(session.GetUserId(), hero.Id, _heroMap)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_DBError
|
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)
|
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) // 推送属性变化
|
err1 = this.PushHeroProperty(session, hero.Id) // 推送属性变化
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_Unknown
|
code = pb.ErrorCode_Unknown
|
||||||
log.Errorf("PushHeroProperty err!")
|
this.moduleHero.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package mail
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"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 {
|
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
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package mail
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
@ -25,7 +24,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.MailGetListReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if mailinfo, err = this.module.modelMail.Mail_QueryUserMail(session.GetUserId()); err != nil {
|
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
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"go_dreamfactory/lego/core"
|
"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)
|
err := this.modelMail.Mail_InsertUserMail(mail)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("create mail failed")
|
this.ModuleBase.Errorf("create mail failed")
|
||||||
}
|
}
|
||||||
// 通知玩家
|
// 通知玩家
|
||||||
var _cache = &pb.CacheUser{}
|
var _cache = &pb.CacheUser{}
|
||||||
|
@ -2,7 +2,6 @@ package story
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
@ -13,12 +12,12 @@ const ( //Redis
|
|||||||
|
|
||||||
type ModelStory struct {
|
type ModelStory struct {
|
||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
moduleStory *Story
|
module *Story
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelStory) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
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)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.moduleStory = module.(*Story)
|
this.module = module.(*Story)
|
||||||
this.TableName = string(TableStory)
|
this.TableName = string(TableStory)
|
||||||
return
|
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 {
|
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) {
|
func (this *ModelStory) addNewChapter(uId string, data map[string]interface{}) (err error) {
|
||||||
|
|
||||||
if err = this.AddLists(uId, data); err != nil {
|
if err = this.AddLists(uId, data); err != nil {
|
||||||
log.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -114,6 +114,9 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32) (code pb
|
|||||||
update[comm.ResDiamond] = user.Diamond + add
|
update[comm.ResDiamond] = user.Diamond + add
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(update) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
if err := this.modelUser.updateUserAttr(uid, update); err != nil {
|
if err := this.modelUser.updateUserAttr(uid, update); err != nil {
|
||||||
log.Errorf("AddAttributeValue err:%v", err)
|
log.Errorf("AddAttributeValue err:%v", err)
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
|
Loading…
Reference in New Issue
Block a user