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.
100 lines
3.2 KiB
Go
100 lines
3.2 KiB
Go
2 years ago
|
// 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 (
|
||
|
userEliteFieldNames = builder.RawFieldNames(&UserElite{})
|
||
|
userEliteRows = strings.Join(userEliteFieldNames, ",")
|
||
|
userEliteRowsExpectAutoSet = strings.Join(stringx.Remove(userEliteFieldNames, "`create_time`", "`update_time`"), ",")
|
||
|
userEliteRowsWithPlaceHolder = strings.Join(stringx.Remove(userEliteFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||
|
)
|
||
|
|
||
|
type (
|
||
|
userEliteModel interface {
|
||
|
gormx.TxModel
|
||
|
Insert(ctx context.Context, tx *gorm.DB, data *UserElite) error
|
||
|
FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserElite, error)
|
||
|
FindOneByUserIdEliteId(ctx context.Context, tx *gorm.DB, userId int64, eliteId int64) (*UserElite, error)
|
||
|
Update(ctx context.Context, tx *gorm.DB, data *UserElite) error
|
||
|
Delete(ctx context.Context, tx *gorm.DB, id int64) error
|
||
|
}
|
||
|
|
||
|
defaultUserEliteModel struct {
|
||
|
gormx.GormConn
|
||
|
table string
|
||
|
}
|
||
|
|
||
|
UserElite struct {
|
||
|
Id int64 `gorm:"column:id;primaryKey"` // 主键ID
|
||
|
UserId int64 `gorm:"column:user_id"` // 用户ID
|
||
|
EliteId int64 `gorm:"column:elite_id"` // 精英单位ID
|
||
|
Forever BitBool `gorm:"forever"` // 永久
|
||
|
StartTime time.Time `gorm:"column:start_time;default:null"` // 开始时间
|
||
|
EndTime time.Time `gorm:"column:end_time;default:null"` // 结束时间
|
||
|
}
|
||
|
)
|
||
|
|
||
|
var UserEliteTableName = "`user_elite`"
|
||
|
|
||
|
func newUserEliteModel(conn *gorm.DB) *defaultUserEliteModel {
|
||
|
return &defaultUserEliteModel{
|
||
|
GormConn: gormx.NewConn(conn),
|
||
|
table: UserEliteTableName,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (m *defaultUserEliteModel) Insert(ctx context.Context, tx *gorm.DB, data *UserElite) error {
|
||
|
err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (m *defaultUserEliteModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserElite, error) {
|
||
|
var resp UserElite
|
||
|
err := gormx.WithTx(ctx, m.DB, tx).Model(&UserElite{}).Where("`id` = ?", id).Take(&resp).Error
|
||
|
if err = gormx.WrapSelectErr(err); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &resp, nil
|
||
|
}
|
||
|
|
||
|
func (m *defaultUserEliteModel) FindOneByUserIdEliteId(ctx context.Context, tx *gorm.DB, userId int64, eliteId int64) (*UserElite, error) {
|
||
|
var resp UserElite
|
||
|
err := gormx.WithTx(ctx, m.DB, tx).Model(&UserElite{}).Where("`user_id` = ? and `elite_id` = ?", userId, eliteId).Take(&resp).Error
|
||
|
if err = gormx.WrapSelectErr(err); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &resp, nil
|
||
|
}
|
||
|
|
||
|
func (m *defaultUserEliteModel) Update(ctx context.Context, tx *gorm.DB, data *UserElite) error {
|
||
|
|
||
|
result := gormx.WithTx(ctx, m.DB, tx).Save(data)
|
||
|
return gormx.WrapUpdateErr(result.Error, result.RowsAffected)
|
||
|
|
||
|
}
|
||
|
|
||
|
func (m *defaultUserEliteModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
|
||
|
err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserElite{}, id).Error
|
||
|
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (m *defaultUserEliteModel) tableName() string {
|
||
|
return m.table
|
||
|
}
|
||
|
|
||
|
func (UserElite) TableName() string {
|
||
|
return UserEliteTableName
|
||
|
}
|