1
This commit is contained in:
parent
70edc57d8f
commit
d0b839bb0e
@ -5,9 +5,8 @@ import (
|
|||||||
"f5"
|
"f5"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
"main/common"
|
"main/common"
|
||||||
"main/model"
|
"main/service"
|
||||||
"main/vo"
|
"main/vo"
|
||||||
"main/mt"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,34 +18,19 @@ func (this *BuffApi) List(c *gin.Context) {
|
|||||||
if s == nil {
|
if s == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user := new(model.User)
|
err, buffs := service.Buff.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.Buff `json:"data"`
|
||||||
}{}
|
}{}
|
||||||
nowTime := f5.GetApp().GetRealSeconds()
|
for _, m := range buffs {
|
||||||
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
v := new(vo.Buff)
|
||||||
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/buff.go
Normal file
18
server/wheelserver/vo/buff.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package vo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"q5"
|
||||||
|
"main/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Buff struct {
|
||||||
|
BuffUniId string `json:"buff_uniid"`
|
||||||
|
BuffId int32 `json:"buff_id"`
|
||||||
|
DurationTime int32 `json:"duration_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Buff) FromModel(m *model.Buff) {
|
||||||
|
this.BuffUniId = q5.ToString(m.Idx)
|
||||||
|
this.BuffId = m.BuffId
|
||||||
|
//this.ItemNum = m.
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user