This commit is contained in:
2025-08-03 18:46:53 +08:00
parent 7b433e703a
commit 6c5016912e
14 changed files with 124 additions and 37 deletions

View File

@@ -89,7 +89,7 @@ func (r *GormWalletRepository) CreateBatch(ctx context.Context, wallets []entiti
func (r *GormWalletRepository) GetByIDs(ctx context.Context, ids []string) ([]entities.Wallet, error) {
var wallets []entities.Wallet
err := r.GetDB(ctx).Where("id IN ?", ids).Find(&wallets).Error
err := r.GetDB(ctx).Where("id IN ?", ids).Order("created_at DESC").Find(&wallets).Error
return wallets, err
}
@@ -120,6 +120,9 @@ func (r *GormWalletRepository) List(ctx context.Context, options interfaces.List
order += " ASC"
}
query = query.Order(order)
} else {
// 默认按创建时间倒序
query = query.Order("created_at DESC")
}
if options.Page > 0 && options.PageSize > 0 {
offset := (options.Page - 1) * options.PageSize