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.

88 lines
2.7 KiB
Go

3 years ago
// Code generated by goctl. DO NOT EDIT!
package model
import (
"context"
3 years ago
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
3 years ago
"time"
3 years ago
"gorm.io/gorm"
3 years ago
)
const (
TableNameUserPlatform = "`user_platform`"
3 years ago
)
type (
userPlatformModel interface {
3 years ago
Insert(ctx context.Context, data *UserPlatform) error
3 years ago
FindOne(ctx context.Context, id int64) (*UserPlatform, error)
Update(ctx context.Context, data *UserPlatform) error
Delete(ctx context.Context, id int64) error
}
defaultUserPlatformModel struct {
3 years ago
conn *gorm.DB
3 years ago
table string
}
UserPlatform struct {
Id int64 `gorm:"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"` // 平台用户头像地址
PNobilityLevel int32 `gorm:"p_nobility_level"` // 平台贵族等级 根据平台不同等级有所不同,代码逻辑判断 0代表不是贵族
CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间
UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间
3 years ago
}
)
3 years ago
func newUserPlatformModel(conn *gorm.DB) *defaultUserPlatformModel {
3 years ago
return &defaultUserPlatformModel{
conn: conn,
table: TableNameUserPlatform,
3 years ago
}
}
3 years ago
func (m *defaultUserPlatformModel) Insert(ctx context.Context, data *UserPlatform) error {
err := m.conn.WithContext(ctx).Create(data).Error
3 years ago
return err
3 years ago
}
func (m *defaultUserPlatformModel) FindOne(ctx context.Context, id int64) (*UserPlatform, error) {
var resp UserPlatform
3 years ago
err := m.conn.WithContext(ctx).Model(&UserPlatform{}).Where("`id` = ?", id).Take(&resp).Error
3 years ago
switch err {
case nil:
return &resp, nil
3 years ago
case gormc.ErrNotFound:
3 years ago
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultUserPlatformModel) Update(ctx context.Context, data *UserPlatform) error {
3 years ago
err := m.conn.WithContext(ctx).Save(data).Error
3 years ago
return err
}
func (m *defaultUserPlatformModel) Delete(ctx context.Context, id int64) error {
3 years ago
err := m.conn.WithContext(ctx).Delete(&UserPlatform{}, id).Error
3 years ago
return err
}
func (m *defaultUserPlatformModel) tableName() string {
return m.table
}
3 years ago
func (UserPlatform) TableName() string {
return TableNameUserPlatform
3 years ago
}