feat: 积分质押功能

This commit is contained in:
2025-04-03 16:17:20 +08:00
parent 229f1d181b
commit 8119bcefdc
40 changed files with 2552 additions and 108 deletions

View File

@@ -0,0 +1,92 @@
// 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"
)
var (
nhGameServerNotifyFieldNames = builder.RawFieldNames(&NhGameServerNotify{})
nhGameServerNotifyRows = strings.Join(nhGameServerNotifyFieldNames, ",")
nhGameServerNotifyRowsExpectAutoSet = strings.Join(stringx.Remove(nhGameServerNotifyFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
nhGameServerNotifyRowsWithPlaceHolder = strings.Join(stringx.Remove(nhGameServerNotifyFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)
type (
nhGameServerNotifyModel interface {
Insert(ctx context.Context, data *NhGameServerNotify) (sql.Result, error)
FindOne(ctx context.Context, id uint) (*NhGameServerNotify, error)
Update(ctx context.Context, data *NhGameServerNotify) error
Delete(ctx context.Context, id uint) error
}
defaultNhGameServerNotifyModel struct {
conn sqlx.SqlConn
table string
}
NhGameServerNotify struct {
Id uint `db:"id"`
RoleId uint64 `db:"role_id"` // 角色id
Action string `db:"action"` // 事件类型
Data sql.NullString `db:"data"` // 事件数据
Status int8 `db:"status"` // 状态1=待处理2=处理中, 3=处理失败, 4=处理成功
RetryTimes int `db:"retry_times"` // 重试次数
CreatedAt time.Time `db:"created_at"` // 创建时间
UpdatedAt time.Time `db:"updated_at"` // 修改时间
}
)
func newNhGameServerNotifyModel(conn sqlx.SqlConn) *defaultNhGameServerNotifyModel {
return &defaultNhGameServerNotifyModel{
conn: conn,
table: "`nh_game_server_notify`",
}
}
func (m *defaultNhGameServerNotifyModel) 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 *defaultNhGameServerNotifyModel) FindOne(ctx context.Context, id uint) (*NhGameServerNotify, error) {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhGameServerNotifyRows, m.table)
var resp NhGameServerNotify
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 *defaultNhGameServerNotifyModel) Insert(ctx context.Context, data *NhGameServerNotify) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?)", m.table, nhGameServerNotifyRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.RoleId, data.Action, data.Data, data.Status, data.RetryTimes)
return ret, err
}
func (m *defaultNhGameServerNotifyModel) Update(ctx context.Context, data *NhGameServerNotify) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhGameServerNotifyRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, data.RoleId, data.Action, data.Data, data.Status, data.RetryTimes, data.Id)
return err
}
func (m *defaultNhGameServerNotifyModel) tableName() string {
return m.table
}