增加提取castile到游戏内的列表接口
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user