先锋赛季账号汇总数据接口
This commit is contained in:
29
internal/model/nh_pioneer_rewards_model.go
Executable file
29
internal/model/nh_pioneer_rewards_model.go
Executable file
@@ -0,0 +1,29 @@
|
||||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ NhPioneerRewardsModel = (*customNhPioneerRewardsModel)(nil)
|
||||
|
||||
type (
|
||||
// NhPioneerRewardsModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customNhPioneerRewardsModel.
|
||||
NhPioneerRewardsModel interface {
|
||||
nhPioneerRewardsModel
|
||||
withSession(session sqlx.Session) NhPioneerRewardsModel
|
||||
}
|
||||
|
||||
customNhPioneerRewardsModel struct {
|
||||
*defaultNhPioneerRewardsModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewNhPioneerRewardsModel returns a model for the database table.
|
||||
func NewNhPioneerRewardsModel(conn sqlx.SqlConn) NhPioneerRewardsModel {
|
||||
return &customNhPioneerRewardsModel{
|
||||
defaultNhPioneerRewardsModel: newNhPioneerRewardsModel(conn),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhPioneerRewardsModel) withSession(session sqlx.Session) NhPioneerRewardsModel {
|
||||
return NewNhPioneerRewardsModel(sqlx.NewSqlConnFromSession(session))
|
||||
}
|
||||
110
internal/model/nh_pioneer_rewards_model_gen.go
Executable file
110
internal/model/nh_pioneer_rewards_model_gen.go
Executable file
@@ -0,0 +1,110 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// versions:
|
||||
// goctl version: 1.7.6
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
var (
|
||||
nhPioneerRewardsFieldNames = builder.RawFieldNames(&NhPioneerRewards{})
|
||||
nhPioneerRewardsRows = strings.Join(nhPioneerRewardsFieldNames, ",")
|
||||
nhPioneerRewardsRowsExpectAutoSet = strings.Join(stringx.Remove(nhPioneerRewardsFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
nhPioneerRewardsRowsWithPlaceHolder = strings.Join(stringx.Remove(nhPioneerRewardsFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
nhPioneerRewardsModel interface {
|
||||
Insert(ctx context.Context, data *NhPioneerRewards) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id uint) (*NhPioneerRewards, error)
|
||||
FindOneByEmail(ctx context.Context, email string) (*NhPioneerRewards, error)
|
||||
Update(ctx context.Context, data *NhPioneerRewards) error
|
||||
Delete(ctx context.Context, id uint) error
|
||||
}
|
||||
|
||||
defaultNhPioneerRewardsModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
NhPioneerRewards struct {
|
||||
Id uint `db:"id"`
|
||||
Email string `db:"email"`
|
||||
Amount1 uint `db:"amount1"` // 游戏代币
|
||||
Amount2 uint `db:"amount2"` // 挖矿代币
|
||||
Amount3 decimal.Decimal `db:"amount3"` // NFT加成
|
||||
Amount4 uint `db:"amount4"` // 大使额外代币
|
||||
Amount5 uint `db:"amount5"` // 总代币
|
||||
CreatedAt time.Time `db:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `db:"updated_at"` // 修改时间
|
||||
}
|
||||
)
|
||||
|
||||
func newNhPioneerRewardsModel(conn sqlx.SqlConn) *defaultNhPioneerRewardsModel {
|
||||
return &defaultNhPioneerRewardsModel{
|
||||
conn: conn,
|
||||
table: "`nh_pioneer_rewards`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhPioneerRewardsModel) 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 *defaultNhPioneerRewardsModel) FindOne(ctx context.Context, id uint) (*NhPioneerRewards, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhPioneerRewardsRows, m.table)
|
||||
var resp NhPioneerRewards
|
||||
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 *defaultNhPioneerRewardsModel) FindOneByEmail(ctx context.Context, email string) (*NhPioneerRewards, error) {
|
||||
var resp NhPioneerRewards
|
||||
query := fmt.Sprintf("select %s from %s where `email` = ? limit 1", nhPioneerRewardsRows, m.table)
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, email)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlx.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhPioneerRewardsModel) Insert(ctx context.Context, data *NhPioneerRewards) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?)", m.table, nhPioneerRewardsRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Email, data.Amount1, data.Amount2, data.Amount3, data.Amount4, data.Amount5)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultNhPioneerRewardsModel) Update(ctx context.Context, newData *NhPioneerRewards) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhPioneerRewardsRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, newData.Email, newData.Amount1, newData.Amount2, newData.Amount3, newData.Amount4, newData.Amount5, newData.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultNhPioneerRewardsModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
Reference in New Issue
Block a user