|
|
|
|
// 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 (
|
|
|
|
|
userNobilityFieldNames = builder.RawFieldNames(&UserNobility{})
|
|
|
|
|
userNobilityRows = strings.Join(userNobilityFieldNames, ",")
|
|
|
|
|
userNobilityRowsExpectAutoSet = strings.Join(stringx.Remove(userNobilityFieldNames, "`create_time`", "`update_time`"), ",")
|
|
|
|
|
userNobilityRowsWithPlaceHolder = strings.Join(stringx.Remove(userNobilityFieldNames, "`user_id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
userNobilityModel interface {
|
|
|
|
|
gormx.TxModel
|
|
|
|
|
Insert(ctx context.Context, tx *gorm.DB, data *UserNobility) error
|
|
|
|
|
FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*UserNobility, error)
|
|
|
|
|
Update(ctx context.Context, tx *gorm.DB, data *UserNobility) error
|
|
|
|
|
Delete(ctx context.Context, tx *gorm.DB, userId int64) error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defaultUserNobilityModel struct {
|
|
|
|
|
gormx.GormConn
|
|
|
|
|
table string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UserNobility struct {
|
|
|
|
|
UserId int64 `gorm:"column:user_id;primaryKey"` // 用户ID
|
|
|
|
|
NobilityLevel int64 `gorm:"column:nobility_level"` // 贵族等级,0表示非贵族
|
|
|
|
|
Forever BitBool `gorm:"column:forever"` // 是否永久贵族
|
|
|
|
|
StartTime time.Time `gorm:"column:start_time;default:null"` // 开始时间
|
|
|
|
|
EndTime time.Time `gorm:"column:end_time;default:null"` // 结束时间
|
|
|
|
|
CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间
|
|
|
|
|
UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var UserNobilityTableName = "`user_nobility`"
|
|
|
|
|
|
|
|
|
|
func newUserNobilityModel(conn *gorm.DB) *defaultUserNobilityModel {
|
|
|
|
|
return &defaultUserNobilityModel{
|
|
|
|
|
GormConn: gormx.NewConn(conn),
|
|
|
|
|
table: UserNobilityTableName,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *defaultUserNobilityModel) Insert(ctx context.Context, tx *gorm.DB, data *UserNobility) error {
|
|
|
|
|
err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *defaultUserNobilityModel) FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*UserNobility, error) {
|
|
|
|
|
var resp UserNobility
|
|
|
|
|
err := gormx.WithTx(ctx, m.DB, tx).Model(&UserNobility{}).Where("`user_id` = ?", userId).Take(&resp).Error
|
|
|
|
|
err = gormx.WrapSelectErr(err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return &resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *defaultUserNobilityModel) Update(ctx context.Context, tx *gorm.DB, data *UserNobility) error {
|
|
|
|
|
|
|
|
|
|
result := gormx.WithTx(ctx, m.DB, tx).Save(data)
|
|
|
|
|
return gormx.WrapUpdateErr(result.Error, result.RowsAffected)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *defaultUserNobilityModel) Delete(ctx context.Context, tx *gorm.DB, userId int64) error {
|
|
|
|
|
err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserNobility{}, userId).Error
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *defaultUserNobilityModel) tableName() string {
|
|
|
|
|
return m.table
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (UserNobility) TableName() string {
|
|
|
|
|
return UserNobilityTableName
|
|
|
|
|
}
|