// 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 ( userPlatformFieldNames = builder.RawFieldNames(&UserPlatform{}) userPlatformRows = strings.Join(userPlatformFieldNames, ",") userPlatformRowsExpectAutoSet = strings.Join(stringx.Remove(userPlatformFieldNames, "`create_time`", "`update_time`"), ",") userPlatformRowsWithPlaceHolder = strings.Join(stringx.Remove(userPlatformFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" ) type ( userPlatformModel interface { gormx.TxModel Insert(ctx context.Context, tx *gorm.DB, data *UserPlatform) error FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserPlatform, error) FindOneByPlatformPUid(ctx context.Context, tx *gorm.DB, platform string, pUid string) (*UserPlatform, error) Update(ctx context.Context, tx *gorm.DB, data *UserPlatform) error Delete(ctx context.Context, tx *gorm.DB, id int64) error } defaultUserPlatformModel struct { gormx.GormConn table string } UserPlatform struct { Id int64 `gorm:"column:id;primaryKey"` // 主键 UserId int64 `gorm:"column:user_id"` // 用户ID Platform string `gorm:"column:platform"` // 平台类型 POpenid string `gorm:"column:p_openid"` // 平台用户openid PUid string `gorm:"column:p_uid"` // 平台用户uid PUname string `gorm:"column:p_uname"` // 平台用户名 PInfo string `gorm:"column:p_info"` // 平台用户原始信息(json) PAvatar string `gorm:"column:p_avatar"` // 平台用户头像地址 CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间 UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间 } ) var UserPlatformTableName = "`user_platform`" func newUserPlatformModel(conn *gorm.DB) *defaultUserPlatformModel { return &defaultUserPlatformModel{ GormConn: gormx.NewConn(conn), table: UserPlatformTableName, } } func (m *defaultUserPlatformModel) Insert(ctx context.Context, tx *gorm.DB, data *UserPlatform) error { err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error return err } func (m *defaultUserPlatformModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserPlatform, error) { var resp UserPlatform err := gormx.WithTx(ctx, m.DB, tx).Model(&UserPlatform{}).Where("`id` = ?", id).Take(&resp).Error err = gormx.WrapSelectErr(err) if err != nil { return nil, err } return &resp, nil } func (m *defaultUserPlatformModel) FindOneByPlatformPUid(ctx context.Context, tx *gorm.DB, platform string, pUid string) (*UserPlatform, error) { var resp UserPlatform err := gormx.WithTx(ctx, m.DB, tx).Model(&UserPlatform{}).Where("`platform` = ? and `p_uid` = ?", platform, pUid).Take(&resp).Error err = gormx.WrapSelectErr(err) if err != nil { return nil, err } return &resp, nil } func (m *defaultUserPlatformModel) Update(ctx context.Context, tx *gorm.DB, data *UserPlatform) error { result := gormx.WithTx(ctx, m.DB, tx).Save(data) return gormx.WrapUpdateErr(result.Error, result.RowsAffected) } func (m *defaultUserPlatformModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error { err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserPlatform{}, id).Error return err } func (m *defaultUserPlatformModel) tableName() string { return m.table } func (UserPlatform) TableName() string { return UserPlatformTableName }