1
This commit is contained in:
parent
3f5dee6f82
commit
c3d4fdc784
@ -7,7 +7,7 @@ import (
|
|||||||
"main/common"
|
"main/common"
|
||||||
"main/model"
|
"main/model"
|
||||||
"main/vo"
|
"main/vo"
|
||||||
"main/mt"
|
"main/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,35 +19,20 @@ func (this *BagApi) List(c *gin.Context) {
|
|||||||
if s == nil {
|
if s == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user := new(model.User)
|
err, items := service.Bag.List(s.GetAccountId())
|
||||||
|
if err != nil {
|
||||||
|
f5.RspErr(c, 500, "server internal error")
|
||||||
|
return
|
||||||
|
}
|
||||||
rspObj := struct {
|
rspObj := struct {
|
||||||
vo.BaseVo
|
vo.BaseVo
|
||||||
UserInfo vo.User `json:"user_info"`
|
Data []*vo.BagItem `json:"data"`
|
||||||
}{}
|
}{}
|
||||||
nowTime := f5.GetApp().GetRealSeconds()
|
for _, m := range items {
|
||||||
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
v := new(vo.BagItem)
|
||||||
f5.RspErr(c, 500, "server internal error")
|
v.FromModel(m)
|
||||||
return
|
q5.AppendSlice(&rspObj.Data, v)
|
||||||
} 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)
|
c.JSON(200, rspObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
server/wheelserver/vo/bagitem.go
Normal file
18
server/wheelserver/vo/bagitem.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package vo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"q5"
|
||||||
|
"main/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BagItem struct {
|
||||||
|
ItemUniId string `json:"item_uniid"`
|
||||||
|
ItemId int32 `json:"item_id"`
|
||||||
|
ItemNum int32 `json:"item_num"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *BagItem) FromModel(m *model.Bag) {
|
||||||
|
this.ItemUniId = q5.ToString(m.Idx)
|
||||||
|
this.ItemId = m.ItemId
|
||||||
|
this.ItemNum = m.ItemNum
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user