1
This commit is contained in:
parent
d5915aa8c6
commit
e1ecb6d690
@ -47,3 +47,37 @@ func (this *UserApi) Login(c *gin.Context) {
|
|||||||
rspObj.UserInfo.FromModel(user)
|
rspObj.UserInfo.FromModel(user)
|
||||||
c.JSON(200, rspObj)
|
c.JSON(200, rspObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *UserApi) Info(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})
|
||||||
|
}
|
||||||
|
f5.GetMsgQueue().FireEvent(constant.MSG_LOGIN, q5.Args{user})
|
||||||
|
rspObj.UserInfo.FromModel(user)
|
||||||
|
c.JSON(200, rspObj)
|
||||||
|
}
|
||||||
|
@ -13,4 +13,7 @@ func (this *UserRouter) InitRouter() {
|
|||||||
f5.GetApp().GetGinEngine().POST("/api/v1/user/login",
|
f5.GetApp().GetGinEngine().POST("/api/v1/user/login",
|
||||||
middleware.JwtAuth,
|
middleware.JwtAuth,
|
||||||
api.UserApi.Login)
|
api.UserApi.Login)
|
||||||
|
f5.GetApp().GetGinEngine().POST("/api/v1/user/info",
|
||||||
|
middleware.JwtAuth,
|
||||||
|
api.UserApi.Info)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user