feat: 积分质押功能
This commit is contained in:
45
internal/model/nh_stake_home_point_config_model.go
Executable file
45
internal/model/nh_stake_home_point_config_model.go
Executable file
@@ -0,0 +1,45 @@
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user