// Code generated by goctl. DO NOT EDIT. package model import ( "context" "database/sql" "fmt" "strings" "github.com/zeromicro/go-zero/core/stores/builder" "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" ) var ( fsUserFieldNames = builder.RawFieldNames(&FsUser{}) fsUserRows = strings.Join(fsUserFieldNames, ",") fsUserRowsExpectAutoSet = strings.Join(stringx.Remove(fsUserFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",") fsUserRowsWithPlaceHolder = strings.Join(stringx.Remove(fsUserFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?" ) type ( fsUserModel interface { Insert(ctx context.Context, data *FsUser) (sql.Result, error) FindOne(ctx context.Context, id int64) (*FsUser, error) FindOneByEmail(ctx context.Context, email string) (*FsUser, error) FindOneByPasswordResetToken(ctx context.Context, passwordResetToken sql.NullString) (*FsUser, error) FindOneByUsername(ctx context.Context, username sql.NullString) (*FsUser, error) Update(ctx context.Context, data *FsUser) error Delete(ctx context.Context, id int64) error } defaultFsUserModel struct { conn sqlx.SqlConn table string } FsUser struct { Id int64 `db:"id"` // ID FaceId int64 `db:"face_id"` // facebook的userid Sub int64 `db:"sub"` // google的sub FirstName sql.NullString `db:"first_name"` // FirstName LastName sql.NullString `db:"last_name"` // LastName Username sql.NullString `db:"username"` // 用户名 Company sql.NullString `db:"company"` // 公司名称 Mobile sql.NullString `db:"mobile"` // 手机号码 AuthKey string `db:"auth_key"` PasswordHash string `db:"password_hash"` VerificationToken sql.NullString `db:"verification_token"` PasswordResetToken sql.NullString `db:"password_reset_token"` Email string `db:"email"` // 邮箱 Type int64 `db:"type"` // 1普通餐厅 2连锁餐厅 Status int64 `db:"status"` // 1正常 0不正常 IsDel int64 `db:"is_del"` // 是否删除 1删除 CreatedAt int64 `db:"created_at"` // 添加时间 UpdatedAt int64 `db:"updated_at"` // 更新时间 IsOrderStatusEmail int64 `db:"is_order_status_email"` // 订单状态改变时是否接收邮件 IsEmailAdvertisement int64 `db:"is_email_advertisement"` // 是否接收邮件广告 IsOrderStatusPhone int64 `db:"is_order_status_phone"` // 订单状态改变是是否接收电话 IsPhoneAdvertisement int64 `db:"is_phone_advertisement"` // 是否接收短信广告 IsOpenRender int64 `db:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭) IsThousandFace int64 `db:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在) IsLowRendering int64 `db:"is_low_rendering"` // 是否开启低渲染模型渲染 IsRemoveBg int64 `db:"is_remove_bg"` // 用户上传logo是否去除背景 } ) func newFsUserModel(conn sqlx.SqlConn) *defaultFsUserModel { return &defaultFsUserModel{ conn: conn, table: "`fs_user`", } } func (m *defaultFsUserModel) Delete(ctx context.Context, id int64) error { query := fmt.Sprintf("delete from %s where `id` = ?", m.table) _, err := m.conn.ExecCtx(ctx, query, id) return err } func (m *defaultFsUserModel) FindOne(ctx context.Context, id int64) (*FsUser, error) { query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsUserRows, m.table) var resp FsUser err := m.conn.QueryRowCtx(ctx, &resp, query, id) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: return nil, ErrNotFound default: return nil, err } } func (m *defaultFsUserModel) FindOneByEmail(ctx context.Context, email string) (*FsUser, error) { var resp FsUser query := fmt.Sprintf("select %s from %s where `email` = ? limit 1", fsUserRows, m.table) err := m.conn.QueryRowCtx(ctx, &resp, query, email) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: return nil, ErrNotFound default: return nil, err } } func (m *defaultFsUserModel) FindOneByPasswordResetToken(ctx context.Context, passwordResetToken sql.NullString) (*FsUser, error) { var resp FsUser query := fmt.Sprintf("select %s from %s where `password_reset_token` = ? limit 1", fsUserRows, m.table) err := m.conn.QueryRowCtx(ctx, &resp, query, passwordResetToken) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: return nil, ErrNotFound default: return nil, err } } func (m *defaultFsUserModel) FindOneByUsername(ctx context.Context, username sql.NullString) (*FsUser, error) { var resp FsUser query := fmt.Sprintf("select %s from %s where `username` = ? limit 1", fsUserRows, m.table) err := m.conn.QueryRowCtx(ctx, &resp, query, username) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: return nil, ErrNotFound default: return nil, err } } func (m *defaultFsUserModel) Insert(ctx context.Context, data *FsUser) (sql.Result, error) { query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsUserRowsExpectAutoSet) ret, err := m.conn.ExecCtx(ctx, query, data.FaceId, data.Sub, data.FirstName, data.LastName, data.Username, data.Company, data.Mobile, data.AuthKey, data.PasswordHash, data.VerificationToken, data.PasswordResetToken, data.Email, data.Type, data.Status, data.IsDel, data.IsOrderStatusEmail, data.IsEmailAdvertisement, data.IsOrderStatusPhone, data.IsPhoneAdvertisement, data.IsOpenRender, data.IsThousandFace, data.IsLowRendering, data.IsRemoveBg) return ret, err } func (m *defaultFsUserModel) Update(ctx context.Context, newData *FsUser) error { query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsUserRowsWithPlaceHolder) _, err := m.conn.ExecCtx(ctx, query, newData.FaceId, newData.Sub, newData.FirstName, newData.LastName, newData.Username, newData.Company, newData.Mobile, newData.AuthKey, newData.PasswordHash, newData.VerificationToken, newData.PasswordResetToken, newData.Email, newData.Type, newData.Status, newData.IsDel, newData.IsOrderStatusEmail, newData.IsEmailAdvertisement, newData.IsOrderStatusPhone, newData.IsPhoneAdvertisement, newData.IsOpenRender, newData.IsThousandFace, newData.IsLowRendering, newData.IsRemoveBg, newData.Id) return err } func (m *defaultFsUserModel) tableName() string { return m.table }