Files
novatask/internal/model/nh_promote_bind_model_gen.go
2025-01-08 16:02:11 +08:00

108 lines
3.9 KiB
Go
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Code generated by goctl. DO NOT EDIT.
// versions:
// goctl version: 1.7.3
package model
import (
"context"
"database/sql"
"fmt"
"strings"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
nhPromoteBindFieldNames = builder.RawFieldNames(&NhPromoteBind{})
nhPromoteBindRows = strings.Join(nhPromoteBindFieldNames, ",")
nhPromoteBindRowsExpectAutoSet = strings.Join(stringx.Remove(nhPromoteBindFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
nhPromoteBindRowsWithPlaceHolder = strings.Join(stringx.Remove(nhPromoteBindFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)
type (
nhPromoteBindModel interface {
Insert(ctx context.Context, data *NhPromoteBind) (sql.Result, error)
FindOne(ctx context.Context, id uint) (*NhPromoteBind, error)
FindOneByInvitedUid(ctx context.Context, invitedUid uint) (*NhPromoteBind, error)
Update(ctx context.Context, data *NhPromoteBind) error
Delete(ctx context.Context, id uint) error
}
defaultNhPromoteBindModel struct {
conn sqlx.SqlConn
table string
}
NhPromoteBind struct {
Id uint `db:"id"`
ShareUid uint `db:"share_uid"` // 分享者uid
InvitedUid uint `db:"invited_uid"` // 受邀者uid
CreateTime uint `db:"create_time"` // 创建时间
IsPushUser int8 `db:"is_push_user"` // 是否已推送用户信息
IsPushRole int8 `db:"is_push_role"` // 是否已推送绑定游戏账号
IsCreateRole int8 `db:"is_create_role"` // 是否已创建角色,0=否1=已创建
IsBindWallet int8 `db:"is_bind_wallet"` // 是否已绑定钱包,0=否1=已绑定
IsOpenSeason int8 `db:"is_open_season"` // 是否已开启赛季,0=否1=已开启
}
)
func newNhPromoteBindModel(conn sqlx.SqlConn) *defaultNhPromoteBindModel {
return &defaultNhPromoteBindModel{
conn: conn,
table: "`nh_promote_bind`",
}
}
func (m *defaultNhPromoteBindModel) Delete(ctx context.Context, id uint) error {
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, id)
return err
}
func (m *defaultNhPromoteBindModel) FindOne(ctx context.Context, id uint) (*NhPromoteBind, error) {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhPromoteBindRows, m.table)
var resp NhPromoteBind
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
switch err {
case nil:
return &resp, nil
case sqlx.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultNhPromoteBindModel) FindOneByInvitedUid(ctx context.Context, invitedUid uint) (*NhPromoteBind, error) {
var resp NhPromoteBind
query := fmt.Sprintf("select %s from %s where `invited_uid` = ? limit 1", nhPromoteBindRows, m.table)
err := m.conn.QueryRowCtx(ctx, &resp, query, invitedUid)
switch err {
case nil:
return &resp, nil
case sqlx.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultNhPromoteBindModel) Insert(ctx context.Context, data *NhPromoteBind) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, nhPromoteBindRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.ShareUid, data.InvitedUid, data.IsPushUser, data.IsPushRole, data.IsCreateRole, data.IsBindWallet, data.IsOpenSeason)
return ret, err
}
func (m *defaultNhPromoteBindModel) Update(ctx context.Context, newData *NhPromoteBind) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhPromoteBindRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, newData.ShareUid, newData.InvitedUid, newData.IsPushUser, newData.IsPushRole, newData.IsCreateRole, newData.IsBindWallet, newData.IsOpenSeason, newData.Id)
return err
}
func (m *defaultNhPromoteBindModel) tableName() string {
return m.table
}