|
|
|
// Code generated by goctl. DO NOT EDIT!
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"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, "`id`", "`create_time`", "`update_time`"), ",")
|
|
|
|
userPlatformRowsWithPlaceHolder = strings.Join(stringx.Remove(userPlatformFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
userPlatformModel interface {
|
|
|
|
Insert(ctx context.Context, data *UserPlatform) error
|
|
|
|
FindOne(ctx context.Context, id int64) (*UserPlatform, error)
|
|
|
|
Update(ctx context.Context, data *UserPlatform) error
|
|
|
|
Delete(ctx context.Context, id int64) error
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultUserPlatformModel struct {
|
|
|
|
conn *gorm.DB
|
|
|
|
table string
|
|
|
|
}
|
|
|
|
|
|
|
|
UserPlatform struct {
|
|
|
|
Id int64 `gorm:"column:id"` // 主键
|
|
|
|
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"` // 创建时间
|
|
|
|
UpdateTime time.Time `gorm:"column:update_time"` // 更新时间
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func newUserPlatformModel(conn *gorm.DB) *defaultUserPlatformModel {
|
|
|
|
return &defaultUserPlatformModel{
|
|
|
|
conn: conn,
|
|
|
|
table: "`user_platform`",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultUserPlatformModel) Insert(ctx context.Context, data *UserPlatform) error {
|
|
|
|
err := m.conn.WithContext(ctx).Save(&data).Error
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultUserPlatformModel) FindOne(ctx context.Context, id int64) (*UserPlatform, error) {
|
|
|
|
var resp UserPlatform
|
|
|
|
err := m.conn.WithContext(ctx).Model(&UserPlatform{}).Where("`id` = ?", id).Take(&resp).Error
|
|
|
|
switch err {
|
|
|
|
case nil:
|
|
|
|
return &resp, nil
|
|
|
|
case gormc.ErrNotFound:
|
|
|
|
return nil, ErrNotFound
|
|
|
|
default:
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultUserPlatformModel) Update(ctx context.Context, data *UserPlatform) error {
|
|
|
|
err := m.conn.WithContext(ctx).Save(data).Error
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultUserPlatformModel) Delete(ctx context.Context, id int64) error {
|
|
|
|
err := m.conn.WithContext(ctx).Delete(&UserPlatform{}, id).Error
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultUserPlatformModel) tableName() string {
|
|
|
|
return m.table
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UserPlatform) TableName() string {
|
|
|
|
model := defaultUserPlatformModel{}
|
|
|
|
return model.tableName()
|
|
|
|
}
|