增加提取castile到游戏的数据库表,定义API接口等;
This commit is contained in:
92
internal/model/nh_castile_token_log_model_gen.go
Normal file
92
internal/model/nh_castile_token_log_model_gen.go
Normal file
@@ -0,0 +1,92 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// versions:
|
||||
// goctl version: 1.7.3
|
||||
|
||||
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 (
|
||||
nhCastileTokenLogFieldNames = builder.RawFieldNames(&NhCastileTokenLog{})
|
||||
nhCastileTokenLogRows = strings.Join(nhCastileTokenLogFieldNames, ",")
|
||||
nhCastileTokenLogRowsExpectAutoSet = strings.Join(stringx.Remove(nhCastileTokenLogFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
nhCastileTokenLogRowsWithPlaceHolder = strings.Join(stringx.Remove(nhCastileTokenLogFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
nhCastileTokenLogModel interface {
|
||||
Insert(ctx context.Context, data *NhCastileTokenLog) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id uint) (*NhCastileTokenLog, error)
|
||||
Update(ctx context.Context, data *NhCastileTokenLog) error
|
||||
Delete(ctx context.Context, id uint) error
|
||||
}
|
||||
|
||||
defaultNhCastileTokenLogModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
NhCastileTokenLog struct {
|
||||
Id uint `db:"id"`
|
||||
Uid uint `db:"uid"` // 用户id
|
||||
RoleId uint64 `db:"role_id"` // 角色id
|
||||
Amount uint `db:"amount"` // 提取的数量
|
||||
CallbackStatus int8 `db:"callback_status"` // 下发通知状态:0未通知,1已通知,2通知异常
|
||||
Action uint8 `db:"action"` // 操作类型:1=提取到游戏
|
||||
CreatedAt time.Time `db:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `db:"updated_at"` // 修改时间
|
||||
}
|
||||
)
|
||||
|
||||
func newNhCastileTokenLogModel(conn sqlx.SqlConn) *defaultNhCastileTokenLogModel {
|
||||
return &defaultNhCastileTokenLogModel{
|
||||
conn: conn,
|
||||
table: "`nh_castile_token_log`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenLogModel) 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 *defaultNhCastileTokenLogModel) FindOne(ctx context.Context, id uint) (*NhCastileTokenLog, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhCastileTokenLogRows, m.table)
|
||||
var resp NhCastileTokenLog
|
||||
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 *defaultNhCastileTokenLogModel) Insert(ctx context.Context, data *NhCastileTokenLog) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?)", m.table, nhCastileTokenLogRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Uid, data.RoleId, data.Amount, data.CallbackStatus, data.Action)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenLogModel) Update(ctx context.Context, data *NhCastileTokenLog) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhCastileTokenLogRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.Uid, data.RoleId, data.Amount, data.CallbackStatus, data.Action, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenLogModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
Reference in New Issue
Block a user