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.

94 lines
3.0 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
"strings"
"time"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stringx"
3 years ago
"gorm.io/gorm"
3 years ago
)
var (
userPlatformFieldNames = builder.RawFieldNames(&UserPlatform{})
userPlatformRows = strings.Join(userPlatformFieldNames, ",")
userPlatformRowsExpectAutoSet = strings.Join(stringx.Remove(userPlatformFieldNames, "`create_time`", "`update_time`"), ",")
3 years ago
userPlatformRowsWithPlaceHolder = strings.Join(stringx.Remove(userPlatformFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
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"` // 平台用户头像地址
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: "`user_platform`",
}
}
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 {
model := newUserPlatformModel(nil)
3 years ago
return model.tableName()
}