互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.8 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const UserPrizeTableName = TableNamePrefix + "user_prize"
  7. type UserPrize struct {
  8. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  9. UserId int64 `json:"user_id" xorm:"not null comment('用户表id') INT(11)"`
  10. ActivityId int64 `json:"activity_id" xorm:"not null comment('互动表id') INT(11)"`
  11. RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id') INT(11)"`
  12. ActivityName string `json:"activity_name" xorm:"not null default('') comment('互动名字') VARCHAR(128)"`
  13. PrizeName string `json:"prize_name" xorm:"not null default('') comment('奖品名字') VARCHAR(128)"`
  14. PrizeImg string `json:"prize_img" xorm:"not null default('') comment('奖品图片') VARCHAR(255)"`
  15. PrizeType int `json:"prize_type" xorm:"not null default(0) comment('订单来源1普通抽奖2订单抽奖3订单送礼4直播下单') INT(11)"`
  16. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
  17. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  18. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  19. }
  20. func (t *UserPrize) TableName() string {
  21. return UserPrizeTableName
  22. }
  23. func (t *UserPrize) SoftDeleteById(id int64) (int64, error) {
  24. t.IsDelete = true
  25. return core.GetXormAuto().Where("id=?", id).Cols("is_delete").Update(t)
  26. }
  27. func (t *UserPrize) Add() (int64, error) {
  28. return core.GetXormAuto().InsertOne(t)
  29. }
  30. func (t *UserPrize) Update(fields ...string) error {
  31. _, err := core.GetXormAuto().Where("is_delete=0 and id = ? and user_id =?", t.Id, t.UserId).Cols(fields...).Update(t)
  32. return err
  33. }