// 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 ( userCheckInFieldNames = builder.RawFieldNames(&UserCheckIn{}) userCheckInRows = strings.Join(userCheckInFieldNames, ",") userCheckInRowsExpectAutoSet = strings.Join(stringx.Remove(userCheckInFieldNames, "`create_time`", "`update_time`"), ",") userCheckInRowsWithPlaceHolder = strings.Join(stringx.Remove(userCheckInFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" ) type ( userCheckInModel interface { gormx.TxModel Insert(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserCheckIn, error) Update(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error Delete(ctx context.Context, tx *gorm.DB, id int64) error } defaultUserCheckInModel struct { gormx.GormConn table string } UserCheckIn struct { Id int64 `gorm:"column:id;primaryKey"` // ID UserId int64 `gorm:"column:user_id"` // 用户ID CheckInTime time.Time `gorm:"column:check_in_time;default:null"` // 签到时间 } ) var UserCheckInTableName = "`user_check_in`" func newUserCheckInModel(conn *gorm.DB) *defaultUserCheckInModel { return &defaultUserCheckInModel{ GormConn: gormx.NewConn(conn), table: UserCheckInTableName, } } func (m *defaultUserCheckInModel) Insert(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error { err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error return err } func (m *defaultUserCheckInModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserCheckIn, error) { var resp UserCheckIn err := gormx.WithTx(ctx, m.DB, tx).Model(&UserCheckIn{}).Where("`id` = ?", id).Take(&resp).Error err = gormx.WrapSelectErr(err) if err != nil { return nil, err } return &resp, nil } func (m *defaultUserCheckInModel) Update(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error { result := gormx.WithTx(ctx, m.DB, tx).Save(data) return gormx.WrapUpdateErr(result.Error, result.RowsAffected) } func (m *defaultUserCheckInModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error { err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserCheckIn{}, id).Error return err } func (m *defaultUserCheckInModel) tableName() string { return m.table } func (UserCheckIn) TableName() string { return UserCheckInTableName }