增加提取castile到游戏内的列表接口
This commit is contained in:
@@ -12,7 +12,7 @@ service novatask {
|
||||
|
||||
@doc "获取提取castile到游戏的记录"
|
||||
@handler TransferCastileToGameList
|
||||
post /list (TransferCastileToGameListReq) returns (TransferCastileToGameResp)
|
||||
post /list (TransferCastileToGameListReq) returns (TransferCastileToGameListResp)
|
||||
}
|
||||
|
||||
type TransferCastileToGameReq {
|
||||
@@ -22,13 +22,16 @@ type TransferCastileToGameReq {
|
||||
|
||||
type TransferCastileToGameListReq {
|
||||
RoleID int64 `json:"role_id,optional"` // 角色id
|
||||
Page int `form:"page,range=[1:],optional,default=1"` // 页码
|
||||
Size int `form:"size,range=[10:100],optional,default=10"` // 每页数量
|
||||
}
|
||||
|
||||
type TransferCastileToGameResp {
|
||||
Id int `json:"id"` // id
|
||||
RoleID int64 `json:"role_id"` // 角色id
|
||||
Amount int64 `json:"amount"` // 数量
|
||||
Status int64 `json:"status"` // 状态
|
||||
Id int `json:"id"` // id
|
||||
RoleID int64 `json:"role_id"` // 角色id
|
||||
Amount int64 `json:"amount"` // 数量
|
||||
Status int64 `json:"status"` // 状态
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
}
|
||||
|
||||
type TransferCastileToGameListResp {
|
||||
|
||||
@@ -903,7 +903,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/TransferCastileToGameResp"
|
||||
"$ref": "#/definitions/TransferCastileToGameListResp"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -920,6 +920,9 @@
|
||||
"tags": [
|
||||
"transfercastile"
|
||||
],
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"apiKey": []
|
||||
@@ -1930,6 +1933,20 @@
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 角色id"
|
||||
},
|
||||
"page": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": "1",
|
||||
"description": " 页码"
|
||||
},
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": "10",
|
||||
"description": " 每页数量",
|
||||
"maximum": 100,
|
||||
"minimum": 10
|
||||
}
|
||||
},
|
||||
"title": "TransferCastileToGameListReq"
|
||||
@@ -1998,6 +2015,10 @@
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 状态"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"description": " 创建时间"
|
||||
}
|
||||
},
|
||||
"title": "TransferCastileToGameResp",
|
||||
@@ -2005,7 +2026,8 @@
|
||||
"id",
|
||||
"role_id",
|
||||
"amount",
|
||||
"status"
|
||||
"status",
|
||||
"created_at"
|
||||
]
|
||||
},
|
||||
"UnStakeNftReq": {
|
||||
|
||||
@@ -32,6 +32,10 @@ const (
|
||||
RewardCastile = 2 // 代币
|
||||
)
|
||||
|
||||
const (
|
||||
FORMATDATETIME = "2006-01-02 15:04:05" // 日期时间
|
||||
)
|
||||
|
||||
func GetAssetType(rewardType int8) AssetType {
|
||||
switch rewardType {
|
||||
case RewardTypePoints:
|
||||
|
||||
@@ -2,6 +2,9 @@ package transfercastile
|
||||
|
||||
import (
|
||||
"context"
|
||||
"nova_task/internal/consts"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"nova_task/internal/pkg/utils"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
@@ -24,8 +27,26 @@ func NewTransferCastileToGameListLogic(ctx context.Context, svcCtx *svc.ServiceC
|
||||
}
|
||||
}
|
||||
|
||||
func (l *TransferCastileToGameListLogic) TransferCastileToGameList(req *types.TransferCastileToGameListReq) (resp *types.TransferCastileToGameResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
func (l *TransferCastileToGameListLogic) TransferCastileToGameList(req *types.TransferCastileToGameListReq) (resp *types.TransferCastileToGameListResp, err error) {
|
||||
|
||||
return
|
||||
uid := utils.GetUidUint(l.ctx)
|
||||
ls, err := l.svcCtx.CastileTokenLogModel.List(l.ctx, uid, uint64(req.RoleID), req.Page, req.Size)
|
||||
if err != nil {
|
||||
l.Errorw("get castile log list failed", logx.Field("err", err), logx.Field("uid", uid))
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
var lss []types.TransferCastileToGameResp
|
||||
for _, ll := range ls {
|
||||
lss = append(lss, types.TransferCastileToGameResp{
|
||||
Id: int(ll.Id),
|
||||
RoleID: int64(ll.RoleId),
|
||||
Amount: int64(ll.Amount),
|
||||
Status: int64(ll.CallbackStatus),
|
||||
CreatedAt: ll.CreatedAt.Format(consts.FORMATDATETIME),
|
||||
})
|
||||
}
|
||||
return &types.TransferCastileToGameListResp{
|
||||
List: lss,
|
||||
Total: len(lss),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -138,9 +138,10 @@ func (l *TransferCastileToGameLogic) TransferCastileToGame(req *types.TransferCa
|
||||
}
|
||||
|
||||
return &types.TransferCastileToGameResp{
|
||||
Id: int(res.Id),
|
||||
RoleID: int64(res.RoleId),
|
||||
Amount: int64(res.Amount),
|
||||
Status: int64(res.CallbackStatus),
|
||||
Id: int(res.Id),
|
||||
RoleID: int64(res.RoleId),
|
||||
Amount: int64(res.Amount),
|
||||
Status: int64(res.CallbackStatus),
|
||||
CreatedAt: res.CreatedAt.Format(consts.FORMATDATETIME),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
@@ -15,6 +16,7 @@ type (
|
||||
nhCastileTokenLogModel
|
||||
WithSession(session sqlx.Session) NhCastileTokenLogModel
|
||||
UpdateStatus(ctx context.Context, status uint, id uint) error
|
||||
List(ctx context.Context, uid uint, roleId uint64, page, pageSize int) ([]*NhCastileTokenLog, error)
|
||||
}
|
||||
|
||||
customNhCastileTokenLogModel struct {
|
||||
@@ -38,3 +40,21 @@ func (m *customNhCastileTokenLogModel) UpdateStatus(ctx context.Context, status
|
||||
_, err := m.conn.ExecCtx(ctx, query, status, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *customNhCastileTokenLogModel) List(ctx context.Context, uid uint, roleId uint64, page, pageSize int) ([]*NhCastileTokenLog, error) {
|
||||
var query string
|
||||
var result []*NhCastileTokenLog
|
||||
var err error
|
||||
if roleId == 0 {
|
||||
query = fmt.Sprintf("select %s from %s where uid = ? order by id desc limit ?, ?", nhCastileTokenLogRows, m.table)
|
||||
err = m.conn.QueryRowsCtx(ctx, &result, query, uid, (page-1)*pageSize, pageSize)
|
||||
} else {
|
||||
query = fmt.Sprintf("select %s from %s where uid = ? and role_id = ? order by id desc limit ?, ?", nhCastileTokenLogRows, m.table)
|
||||
err = m.conn.QueryRowsCtx(ctx, &result, query, uid, roleId, (page-1)*pageSize, pageSize)
|
||||
}
|
||||
|
||||
if err != nil && !errors.Is(err, sqlx.ErrNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -241,7 +241,9 @@ type Task struct {
|
||||
}
|
||||
|
||||
type TransferCastileToGameListReq struct {
|
||||
RoleID int64 `json:"role_id,optional"` // 角色id
|
||||
RoleID int64 `json:"role_id,optional"` // 角色id
|
||||
Page int `form:"page,range=[1:],optional,default=1"` // 页码
|
||||
Size int `form:"size,range=[10:100],optional,default=10"` // 每页数量
|
||||
}
|
||||
|
||||
type TransferCastileToGameListResp struct {
|
||||
@@ -255,10 +257,11 @@ type TransferCastileToGameReq struct {
|
||||
}
|
||||
|
||||
type TransferCastileToGameResp struct {
|
||||
Id int `json:"id"` // id
|
||||
RoleID int64 `json:"role_id"` // 角色id
|
||||
Amount int64 `json:"amount"` // 数量
|
||||
Status int64 `json:"status"` // 状态
|
||||
Id int `json:"id"` // id
|
||||
RoleID int64 `json:"role_id"` // 角色id
|
||||
Amount int64 `json:"amount"` // 数量
|
||||
Status int64 `json:"status"` // 状态
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
}
|
||||
|
||||
type UnStakeNftReq struct {
|
||||
|
||||
Reference in New Issue
Block a user