1
This commit is contained in:
parent
ce71769b2d
commit
d62d5a7ee9
74
server/wheelserver/api/v1/bag/bag.go
Normal file
74
server/wheelserver/api/v1/bag/bag.go
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package bag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"q5"
|
||||||
|
"f5"
|
||||||
|
"main/constant"
|
||||||
|
"main/common"
|
||||||
|
"main/model"
|
||||||
|
"main/vo"
|
||||||
|
"main/mt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BagApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *BagApi) List(c *gin.Context) {
|
||||||
|
s := c.MustGet(constant.SESSION_KEY).(common.Session)
|
||||||
|
if s == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
user := new(model.User)
|
||||||
|
rspObj := struct {
|
||||||
|
vo.BaseVo
|
||||||
|
UserInfo vo.User `json:"user_info"`
|
||||||
|
}{}
|
||||||
|
nowTime := f5.GetApp().GetRealSeconds()
|
||||||
|
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
} else if !found {
|
||||||
|
user.AccountId = s.GetAccountId()
|
||||||
|
user.Avatar = ""
|
||||||
|
user.NickName = s.GetNickName()
|
||||||
|
user.Score = 0
|
||||||
|
user.Dice = mt.Table.Global.GetDailyDiceNum()
|
||||||
|
user.LastPresentDiceTime = q5.ToInt32(nowTime)
|
||||||
|
user.CreateTime = q5.ToInt32(nowTime)
|
||||||
|
user.ModifyTime = q5.ToInt32(nowTime)
|
||||||
|
if user.Create() != nil {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f5.GetMsgQueue().FireEvent(constant.MSG_CREATE_USER, q5.Args{user})
|
||||||
|
}
|
||||||
|
if user.NickName != s.GetNickName() {
|
||||||
|
user.UpdateName()
|
||||||
|
}
|
||||||
|
f5.GetMsgQueue().FireEvent(constant.MSG_LOGIN, q5.Args{user})
|
||||||
|
rspObj.UserInfo.FromModel(user)
|
||||||
|
c.JSON(200, rspObj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *BagApi) UseItem(c *gin.Context) {
|
||||||
|
s := c.MustGet(constant.SESSION_KEY).(common.Session)
|
||||||
|
if s == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
user := new(model.User)
|
||||||
|
rspObj := struct {
|
||||||
|
vo.BaseVo
|
||||||
|
UserInfo vo.User `json:"user_info"`
|
||||||
|
}{}
|
||||||
|
nowTime := f5.GetApp().GetRealSeconds()
|
||||||
|
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
} else if !found {
|
||||||
|
f5.RspErr(c, 1, "server internal error")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rspObj.UserInfo.FromModel(user)
|
||||||
|
c.JSON(200, rspObj)
|
||||||
|
}
|
5
server/wheelserver/api/v1/bag/enter.go
Normal file
5
server/wheelserver/api/v1/bag/enter.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package bag
|
||||||
|
|
||||||
|
type ApiGroup struct {
|
||||||
|
BagApi
|
||||||
|
}
|
52
server/wheelserver/api/v1/buff/buff.go
Normal file
52
server/wheelserver/api/v1/buff/buff.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package buff
|
||||||
|
|
||||||
|
import (
|
||||||
|
"q5"
|
||||||
|
"f5"
|
||||||
|
"main/constant"
|
||||||
|
"main/common"
|
||||||
|
"main/model"
|
||||||
|
"main/vo"
|
||||||
|
"main/mt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BuffApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *BuffApi) List(c *gin.Context) {
|
||||||
|
s := c.MustGet(constant.SESSION_KEY).(common.Session)
|
||||||
|
if s == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
user := new(model.User)
|
||||||
|
rspObj := struct {
|
||||||
|
vo.BaseVo
|
||||||
|
UserInfo vo.User `json:"user_info"`
|
||||||
|
}{}
|
||||||
|
nowTime := f5.GetApp().GetRealSeconds()
|
||||||
|
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
} else if !found {
|
||||||
|
user.AccountId = s.GetAccountId()
|
||||||
|
user.Avatar = ""
|
||||||
|
user.NickName = s.GetNickName()
|
||||||
|
user.Score = 0
|
||||||
|
user.Dice = mt.Table.Global.GetDailyDiceNum()
|
||||||
|
user.LastPresentDiceTime = q5.ToInt32(nowTime)
|
||||||
|
user.CreateTime = q5.ToInt32(nowTime)
|
||||||
|
user.ModifyTime = q5.ToInt32(nowTime)
|
||||||
|
if user.Create() != nil {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f5.GetMsgQueue().FireEvent(constant.MSG_CREATE_USER, q5.Args{user})
|
||||||
|
}
|
||||||
|
if user.NickName != s.GetNickName() {
|
||||||
|
user.UpdateName()
|
||||||
|
}
|
||||||
|
f5.GetMsgQueue().FireEvent(constant.MSG_LOGIN, q5.Args{user})
|
||||||
|
rspObj.UserInfo.FromModel(user)
|
||||||
|
c.JSON(200, rspObj)
|
||||||
|
}
|
5
server/wheelserver/api/v1/buff/enter.go
Normal file
5
server/wheelserver/api/v1/buff/enter.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package buff
|
||||||
|
|
||||||
|
type ApiGroup struct {
|
||||||
|
BuffApi
|
||||||
|
}
|
@ -8,6 +8,9 @@ import (
|
|||||||
"main/api/v1/mission"
|
"main/api/v1/mission"
|
||||||
"main/api/v1/shop"
|
"main/api/v1/shop"
|
||||||
"main/api/v1/user"
|
"main/api/v1/user"
|
||||||
|
"main/api/v1/buff"
|
||||||
|
"main/api/v1/bag"
|
||||||
|
"main/api/v1/gm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApiGroup struct {
|
type ApiGroup struct {
|
||||||
@ -18,6 +21,9 @@ type ApiGroup struct {
|
|||||||
MissionApiGroup mission.ApiGroup
|
MissionApiGroup mission.ApiGroup
|
||||||
ShopApiGroup shop.ApiGroup
|
ShopApiGroup shop.ApiGroup
|
||||||
UserApiGroup user.ApiGroup
|
UserApiGroup user.ApiGroup
|
||||||
|
BuffApiGroup buff.ApiGroup
|
||||||
|
BagApiGroup bag.ApiGroup
|
||||||
|
GmApiGroup gm.ApiGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
var ApiGroupApp = new(ApiGroup)
|
var ApiGroupApp = new(ApiGroup)
|
||||||
|
5
server/wheelserver/api/v1/gm/enter.go
Normal file
5
server/wheelserver/api/v1/gm/enter.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package gm
|
||||||
|
|
||||||
|
type ApiGroup struct {
|
||||||
|
GmApi
|
||||||
|
}
|
52
server/wheelserver/api/v1/gm/gm.go
Normal file
52
server/wheelserver/api/v1/gm/gm.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package gm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"q5"
|
||||||
|
"f5"
|
||||||
|
"main/constant"
|
||||||
|
"main/common"
|
||||||
|
"main/model"
|
||||||
|
"main/vo"
|
||||||
|
"main/mt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GmApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *GmApi) ExecCmd(c *gin.Context) {
|
||||||
|
s := c.MustGet(constant.SESSION_KEY).(common.Session)
|
||||||
|
if s == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
user := new(model.User)
|
||||||
|
rspObj := struct {
|
||||||
|
vo.BaseVo
|
||||||
|
UserInfo vo.User `json:"user_info"`
|
||||||
|
}{}
|
||||||
|
nowTime := f5.GetApp().GetRealSeconds()
|
||||||
|
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
} else if !found {
|
||||||
|
user.AccountId = s.GetAccountId()
|
||||||
|
user.Avatar = ""
|
||||||
|
user.NickName = s.GetNickName()
|
||||||
|
user.Score = 0
|
||||||
|
user.Dice = mt.Table.Global.GetDailyDiceNum()
|
||||||
|
user.LastPresentDiceTime = q5.ToInt32(nowTime)
|
||||||
|
user.CreateTime = q5.ToInt32(nowTime)
|
||||||
|
user.ModifyTime = q5.ToInt32(nowTime)
|
||||||
|
if user.Create() != nil {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f5.GetMsgQueue().FireEvent(constant.MSG_CREATE_USER, q5.Args{user})
|
||||||
|
}
|
||||||
|
if user.NickName != s.GetNickName() {
|
||||||
|
user.UpdateName()
|
||||||
|
}
|
||||||
|
f5.GetMsgQueue().FireEvent(constant.MSG_LOGIN, q5.Args{user})
|
||||||
|
rspObj.UserInfo.FromModel(user)
|
||||||
|
c.JSON(200, rspObj)
|
||||||
|
}
|
19
server/wheelserver/router/bag/bag.go
Normal file
19
server/wheelserver/router/bag/bag.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package bag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"main/middleware"
|
||||||
|
"main/api/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BagRouter struct{}
|
||||||
|
|
||||||
|
func (this *BagRouter) InitRouter() {
|
||||||
|
api := v1.ApiGroupApp.BagApiGroup
|
||||||
|
f5.GetApp().GetGinEngine().GET("/api/v1/bag/list",
|
||||||
|
middleware.JwtAuth,
|
||||||
|
api.BagApi.List)
|
||||||
|
f5.GetApp().GetGinEngine().POST("/api/v1/bag/use_item",
|
||||||
|
middleware.JwtAuth,
|
||||||
|
api.BagApi.UserItem)
|
||||||
|
}
|
5
server/wheelserver/router/bag/enter.go
Normal file
5
server/wheelserver/router/bag/enter.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package bag
|
||||||
|
|
||||||
|
type RouterGroup struct {
|
||||||
|
BagRouter
|
||||||
|
}
|
16
server/wheelserver/router/buff/buff.go
Normal file
16
server/wheelserver/router/buff/buff.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package buff
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"main/middleware"
|
||||||
|
"main/api/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BuffRouter struct{}
|
||||||
|
|
||||||
|
func (this *BuffRouter) InitRouter() {
|
||||||
|
api := v1.ApiGroupApp.BuffApiGroup
|
||||||
|
f5.GetApp().GetGinEngine().GET("/api/v1/buff/list",
|
||||||
|
middleware.JwtAuth,
|
||||||
|
api.BuffApi.List)
|
||||||
|
}
|
5
server/wheelserver/router/buff/enter.go
Normal file
5
server/wheelserver/router/buff/enter.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package buff
|
||||||
|
|
||||||
|
type RouterGroup struct {
|
||||||
|
BuffRouter
|
||||||
|
}
|
5
server/wheelserver/router/gm/enter.go
Normal file
5
server/wheelserver/router/gm/enter.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package gm
|
||||||
|
|
||||||
|
type RouterGroup struct {
|
||||||
|
GmRouter
|
||||||
|
}
|
16
server/wheelserver/router/gm/gm.go
Normal file
16
server/wheelserver/router/gm/gm.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"main/middleware"
|
||||||
|
"main/api/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BagRouter struct{}
|
||||||
|
|
||||||
|
func (this *BagRouter) InitRouter() {
|
||||||
|
api := v1.ApiGroupApp.BagApiGroup
|
||||||
|
f5.GetApp().GetGinEngine().POST("/api/v1/gm/exec_cmd",
|
||||||
|
middleware.JwtAuth,
|
||||||
|
api.BagApi.ExecCmd)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user