1
This commit is contained in:
parent
abfd76128f
commit
87f923d42f
@ -19,6 +19,17 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
reqJson := struct {
|
||||
ForwardPoint int32 `json:"forward_point"`
|
||||
}{}
|
||||
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||
f5.RspErr(c, 401, "params parse error")
|
||||
return
|
||||
}
|
||||
if reqJson.ForwardPoint < 0 || reqJson.ForwardPoint > 6 {
|
||||
f5.RspErr(c, 401, "forward_point param error")
|
||||
return
|
||||
}
|
||||
user := new(model.User)
|
||||
nowTime := f5.GetApp().GetRealSeconds()
|
||||
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
||||
@ -56,7 +67,6 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
|
||||
}{}
|
||||
rspObj.Point = int32(1 + rand.Intn(6))
|
||||
rspObj.GetOrCreateAward().AddItem(constant.VIRTUAL_ITEM_SCORE, score)
|
||||
rspObj.GetOrCreateSideEffect().User = new(vo.User)
|
||||
rspObj.GetOrCreateSideEffect().User.FromModel(user)
|
||||
rspObj.GetOrCreateSideEffect().GetOrCreateUser().FromModel(user)
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
@ -35,6 +35,14 @@ func (this *User) TableName() string {
|
||||
return "t_user"
|
||||
}
|
||||
|
||||
func (this *User) UpdateFields(fields []string) error {
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Model(this).Select(
|
||||
fields).Updates(this); result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *User) Find(accountId string, nowTime int64) (error, bool) {
|
||||
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Table(this.TableName()).Take(
|
||||
this, "account_id = ?", accountId); result.Error != nil &&
|
||||
|
@ -59,3 +59,10 @@ func (this *BaseVo) GetOrCreateSideEffect() *SideEffect {
|
||||
}
|
||||
return this.SideEffect
|
||||
}
|
||||
|
||||
func (this *SideEffect) GetOrCreateUser() *User {
|
||||
if this.User == nil {
|
||||
this.User = new(User)
|
||||
}
|
||||
return this.User
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user