批量空投
This commit is contained in:
98
internal/model/nh_airdrop_log_model_gen.go
Executable file
98
internal/model/nh_airdrop_log_model_gen.go
Executable file
@@ -0,0 +1,98 @@
|
||||
// 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 (
|
||||
nhAirdropLogFieldNames = builder.RawFieldNames(&NhAirdropLog{})
|
||||
nhAirdropLogRows = strings.Join(nhAirdropLogFieldNames, ",")
|
||||
nhAirdropLogRowsExpectAutoSet = strings.Join(stringx.Remove(nhAirdropLogFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
nhAirdropLogRowsWithPlaceHolder = strings.Join(stringx.Remove(nhAirdropLogFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
nhAirdropLogModel interface {
|
||||
Insert(ctx context.Context, data *NhAirdropLog) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id uint) (*NhAirdropLog, error)
|
||||
Update(ctx context.Context, data *NhAirdropLog) error
|
||||
Delete(ctx context.Context, id uint) error
|
||||
}
|
||||
|
||||
defaultNhAirdropLogModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
NhAirdropLog struct {
|
||||
Id uint `db:"id"`
|
||||
Address string `db:"address"` // 用户钱包地址
|
||||
Amount decimal.Decimal `db:"amount"` // 空投数量
|
||||
Status string `db:"status"` // 状态
|
||||
TxHash string `db:"tx_hash"` // 交易hash
|
||||
SubmitAt sql.NullTime `db:"submit_at"` // 提交时间
|
||||
BatchDate sql.NullTime `db:"batch_date"` // 批次-日期
|
||||
BatchNum uint `db:"batch_num"` // 批次-数量
|
||||
AdminId uint `db:"admin_id"` // 管理员ID
|
||||
IsDel int8 `db:"is_del"` // 是否已删除:0否,1是
|
||||
CreatedAt time.Time `db:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `db:"updated_at"` // 修改时间
|
||||
}
|
||||
)
|
||||
|
||||
func newNhAirdropLogModel(conn sqlx.SqlConn) *defaultNhAirdropLogModel {
|
||||
return &defaultNhAirdropLogModel{
|
||||
conn: conn,
|
||||
table: "`nh_airdrop_log`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhAirdropLogModel) 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 *defaultNhAirdropLogModel) FindOne(ctx context.Context, id uint) (*NhAirdropLog, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhAirdropLogRows, m.table)
|
||||
var resp NhAirdropLog
|
||||
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 *defaultNhAirdropLogModel) Insert(ctx context.Context, data *NhAirdropLog) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, nhAirdropLogRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Address, data.Amount, data.Status, data.TxHash, data.SubmitAt, data.BatchDate, data.BatchNum, data.AdminId, data.IsDel)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultNhAirdropLogModel) Update(ctx context.Context, data *NhAirdropLog) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhAirdropLogRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.Address, data.Amount, data.Status, data.TxHash, data.SubmitAt, data.BatchDate, data.BatchNum, data.AdminId, data.IsDel, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultNhAirdropLogModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
Reference in New Issue
Block a user