Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
64da2e66c7
@ -153,8 +153,10 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE
|
|||||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var flag bool
|
||||||
for _, v := range req.Format.Friendformat {
|
for _, v := range req.Format.Friendformat {
|
||||||
if v != "" {
|
if v != "" {
|
||||||
|
flag = true
|
||||||
// this.ModuleBuried.SendToRtask(session, comm.Rtype108, 1)
|
// this.ModuleBuried.SendToRtask(session, comm.Rtype108, 1)
|
||||||
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype108, 1))
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype108, 1))
|
||||||
break
|
break
|
||||||
@ -164,7 +166,7 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE
|
|||||||
if record, errdata = this.modelBattle.createpve(session, conn, pb.BattleType_pve, req); errdata != nil {
|
if record, errdata = this.modelBattle.createpve(session, conn, pb.BattleType_pve, req); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if req.Format.Friendformat != nil {
|
if flag {
|
||||||
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype12, 1))
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype12, 1))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -298,8 +300,10 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
|
|||||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var flag bool
|
||||||
for _, v := range req.Format.Friendformat {
|
for _, v := range req.Format.Friendformat {
|
||||||
if v != "" {
|
if v != "" {
|
||||||
|
flag = true
|
||||||
// this.ModuleBuried.SendToRtask(session, comm.Rtype108, 1)
|
// this.ModuleBuried.SendToRtask(session, comm.Rtype108, 1)
|
||||||
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype108, 1))
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype108, 1))
|
||||||
break
|
break
|
||||||
@ -309,7 +313,7 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
|
|||||||
if record, errdata = this.modelBattle.createlpve(session, conn, pb.BattleType_lpev, req); errdata != nil {
|
if record, errdata = this.modelBattle.createlpve(session, conn, pb.BattleType_lpev, req); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if req.Format.Friendformat != nil {
|
if flag {
|
||||||
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype12, 1))
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype12, 1))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -129,6 +129,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (err
|
|||||||
if this.module.modelUser.isLoginFirst(lastLoginTime) {
|
if this.module.modelUser.isLoginFirst(lastLoginTime) {
|
||||||
this.module.ModuleHero.NoLoginDay(user.Uid, int32(utils.DiffDays(lastLoginTime, configure.Now().Unix())))
|
this.module.ModuleHero.NoLoginDay(user.Uid, int32(utils.DiffDays(lastLoginTime, configure.Now().Unix())))
|
||||||
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype8, 1))
|
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype8, 1))
|
||||||
|
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype9, 1))
|
||||||
this.module.modelExpand.updateLoginDay(user.Uid, lastLoginTime)
|
this.module.modelExpand.updateLoginDay(user.Uid, lastLoginTime)
|
||||||
// 清理点赞
|
// 清理点赞
|
||||||
this.module.ModuleFriend.ResetFriend(user.Uid)
|
this.module.ModuleFriend.ResetFriend(user.Uid)
|
||||||
|
@ -536,10 +536,12 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
change.Ps += add
|
||||||
|
} else {
|
||||||
|
if change.Ps+add > ggd.PsUl {
|
||||||
|
change.Ps = ggd.PsUl
|
||||||
} else {
|
} else {
|
||||||
change.Ps += add
|
change.Ps += add
|
||||||
if change.Ps > ggd.PsUl {
|
|
||||||
change.Ps = ggd.PsUl
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
57
modules/version/api.go
Normal file
57
modules/version/api.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/core/cbase"
|
||||||
|
"go_dreamfactory/lego/sys/gin"
|
||||||
|
"go_dreamfactory/lego/sys/gin/engine"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
web api 服务组件
|
||||||
|
*/
|
||||||
|
type Api_Comp struct {
|
||||||
|
cbase.ModuleCompBase
|
||||||
|
options *Options //模块参数
|
||||||
|
module *Version //当前模块对象
|
||||||
|
gin gin.ISys //gin 框架 web的热门框架
|
||||||
|
}
|
||||||
|
|
||||||
|
// 组件初始化接口 启动web服务 并注册api
|
||||||
|
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.ModuleCompBase.Init(service, module, comp, options)
|
||||||
|
this.options = options.(*Options)
|
||||||
|
this.module = module.(*Version)
|
||||||
|
if this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.suitableMethods() //发射注册api
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Api_Comp) suitableMethods() {
|
||||||
|
typ := reflect.TypeOf(this)
|
||||||
|
vof := reflect.ValueOf(this)
|
||||||
|
for m := 0; m < typ.NumMethod(); m++ {
|
||||||
|
method := typ.Method(m)
|
||||||
|
mname := method.Name
|
||||||
|
mtype := method.Type
|
||||||
|
if method.PkgPath != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if mtype.NumIn() != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
context := mtype.In(1)
|
||||||
|
if context.String() != "*engine.Context" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if mtype.NumOut() != 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
this.gin.POST(strings.ToLower(mname), vof.MethodByName(mname).Interface().(func(*engine.Context)))
|
||||||
|
this.gin.GET(strings.ToLower(mname), vof.MethodByName(mname).Interface().(func(*engine.Context)))
|
||||||
|
}
|
||||||
|
}
|
47
modules/version/module.go
Normal file
47
modules/version/module.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/lego/base"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/core/cbase"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
模块名:web
|
||||||
|
描述:提供管理员相关的http接口
|
||||||
|
开发:李伟
|
||||||
|
*/
|
||||||
|
func NewModule() core.IModule {
|
||||||
|
m := new(Version)
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
type Version struct {
|
||||||
|
cbase.ModuleBase
|
||||||
|
options *Options
|
||||||
|
service base.IRPCXService
|
||||||
|
api_comp *Api_Comp //提供weba pi服务的组件
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模块名
|
||||||
|
func (this *Version) GetType() core.M_Modules {
|
||||||
|
return "version"
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模块自定义参数
|
||||||
|
func (this *Version) NewOptions() (options core.IModuleOptions) {
|
||||||
|
return new(Options)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Version) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
|
this.service = service.(base.IRPCXService)
|
||||||
|
this.options = options.(*Options)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Version) OnInstallComp() {
|
||||||
|
this.ModuleBase.OnInstallComp()
|
||||||
|
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
||||||
|
|
||||||
|
}
|
25
modules/version/options.go
Normal file
25
modules/version/options.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/lego/utils/mapstructure"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Options struct {
|
||||||
|
modules.Options
|
||||||
|
WebDir string
|
||||||
|
Port int
|
||||||
|
Key string
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
|
||||||
|
if settings != nil {
|
||||||
|
if err = this.Options.LoadConfig(settings); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = mapstructure.Decode(settings, this)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
59
services/version/main.go
Normal file
59
services/version/main.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"go_dreamfactory/modules/version"
|
||||||
|
"go_dreamfactory/services"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
|
|
||||||
|
"go_dreamfactory/lego"
|
||||||
|
"go_dreamfactory/lego/base/rpcx"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
服务类型:mainte
|
||||||
|
服务描述:数据库维护以及GM后台接口 服务
|
||||||
|
*/
|
||||||
|
var (
|
||||||
|
conf = flag.String("conf", "./conf/version.yaml", "获取需要启动的服务配置文件") //启动服务的Id
|
||||||
|
)
|
||||||
|
|
||||||
|
/*服务启动的入口函数*/
|
||||||
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
s := NewService(
|
||||||
|
rpcx.SetConfPath(*conf),
|
||||||
|
rpcx.SetVersion("1.0.0.0"),
|
||||||
|
)
|
||||||
|
s.OnInstallComp( //装备组件
|
||||||
|
//services.NewGateRouteComp(), //此服务需要接受用户的消息 需要装备网关组件
|
||||||
|
)
|
||||||
|
lego.Run(s, //运行模块
|
||||||
|
version.NewModule(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewService(ops ...rpcx.Option) core.IService {
|
||||||
|
s := new(Service)
|
||||||
|
s.Configure(ops...)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
// worker 的服务对象定义
|
||||||
|
type Service struct {
|
||||||
|
services.ServiceBase
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化worker需要的一些系统工具
|
||||||
|
func (this *Service) InitSys() {
|
||||||
|
this.ServiceBase.InitSys()
|
||||||
|
//存储系统
|
||||||
|
if err := db.OnInit(this.GetSettings().Sys["db"]); err != nil {
|
||||||
|
panic(fmt.Sprintf("init sys.db err: %s", err.Error()))
|
||||||
|
} else {
|
||||||
|
log.Infof("init sys.db success!")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user