// 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"` // 是否已推送绑定游戏账号 } ) 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) 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.Id) return err } func (m *defaultNhPromoteBindModel) tableName() string { return m.table }