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

95 lines
3.1 KiB
Go

// Code generated by goctl. DO NOT EDIT!
package model
import (
"context"
"strings"
"time"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stringx"
"gorm.io/gorm"
)
var (
userGiftFieldNames = builder.RawFieldNames(&UserGift{})
userGiftRows = strings.Join(userGiftFieldNames, ",")
userGiftRowsExpectAutoSet = strings.Join(stringx.Remove(userGiftFieldNames, "`create_time`", "`update_time`"), ",")
userGiftRowsWithPlaceHolder = strings.Join(stringx.Remove(userGiftFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
type (
userGiftModel interface {
gormx.TxModel
Insert(ctx context.Context, tx *gorm.DB, data *UserGift) error
FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserGift, error)
Update(ctx context.Context, tx *gorm.DB, data *UserGift) error
Delete(ctx context.Context, tx *gorm.DB, id int64) error
}
defaultUserGiftModel struct {
gormx.GormConn
table string
}
UserGift struct {
Id int64 `gorm:"column:id;primaryKey"` // 主键ID
UserId int64 `gorm:"column:user_id"` // 用户ID
Platform string `gorm:"column:platform"` // 直播平台使用varchar兼容更多平台
RoomId string `gorm:"column:room_id"` // 直播间ID使用varchar兼容更多平台
GiftId string `gorm:"column:gift_id"` // 礼物ID使用varchar兼容更多平台
GiftName string `gorm:"column:gift_name"` // 礼物名称
Price int64 `gorm:"column:price"` // 价值(收费礼物,平台货币)
FreePrice int64 `gorm:"column:free_price"` // 价值(免费)
Num int64 `gorm:"column:num"` // 单次送礼数量
CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间
}
)
var UserGiftTableName = "`user_gift`"
func newUserGiftModel(conn *gorm.DB) *defaultUserGiftModel {
return &defaultUserGiftModel{
GormConn: gormx.NewConn(conn),
table: UserGiftTableName,
}
}
func (m *defaultUserGiftModel) Insert(ctx context.Context, tx *gorm.DB, data *UserGift) error {
err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err
}
func (m *defaultUserGiftModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserGift, error) {
var resp UserGift
err := gormx.WithTx(ctx, m.DB, tx).Model(&UserGift{}).Where("`id` = ?", id).Take(&resp).Error
err = gormx.WrapSelectErr(err)
if err != nil {
return nil, err
}
return &resp, nil
}
func (m *defaultUserGiftModel) Update(ctx context.Context, tx *gorm.DB, data *UserGift) error {
result := gormx.WithTx(ctx, m.DB, tx).Save(data)
return gormx.WrapUpdateErr(result.Error, result.RowsAffected)
}
func (m *defaultUserGiftModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserGift{}, id).Error
return err
}
func (m *defaultUserGiftModel) tableName() string {
return m.table
}
func (UserGift) TableName() string {
return UserGiftTableName
}