Files
novatask/internal/model/nh_stake_home_point_config_model.go
2025-04-03 16:17:20 +08:00

46 lines
1.4 KiB
Go
Executable File

package model
import (
"context"
"errors"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ NhStakeHomePointConfigModel = (*customNhStakeHomePointConfigModel)(nil)
type (
// NhStakeHomePointConfigModel is an interface to be customized, add more methods here,
// and implement the added methods in customNhStakeHomePointConfigModel.
NhStakeHomePointConfigModel interface {
nhStakeHomePointConfigModel
withSession(session sqlx.Session) NhStakeHomePointConfigModel
All(ctx context.Context) ([]*NhStakeHomePointConfig, error)
}
customNhStakeHomePointConfigModel struct {
*defaultNhStakeHomePointConfigModel
}
)
func (m *customNhStakeHomePointConfigModel) All(ctx context.Context) ([]*NhStakeHomePointConfig, error) {
query := fmt.Sprintf("select %s from %s", nhStakeHomePointConfigRows, m.table)
var resp []*NhStakeHomePointConfig
err := m.conn.QueryRowsCtx(ctx, &resp, query)
if err != nil && !errors.Is(err, sqlx.ErrNotFound) {
return nil, err
}
return resp, nil
}
// NewNhStakeHomePointConfigModel returns a model for the database table.
func NewNhStakeHomePointConfigModel(conn sqlx.SqlConn) NhStakeHomePointConfigModel {
return &customNhStakeHomePointConfigModel{
defaultNhStakeHomePointConfigModel: newNhStakeHomePointConfigModel(conn),
}
}
func (m *customNhStakeHomePointConfigModel) withSession(session sqlx.Session) NhStakeHomePointConfigModel {
return NewNhStakeHomePointConfigModel(sqlx.NewSqlConnFromSession(session))
}