package giftrecord

import (
	"strings"

	"hyapp-admin-server/internal/modules/shared"
)

const (
	sceneRoom   = "room"
	sceneDirect = "direct"
)

type listQuery struct {
	Page         int
	PageSize     int
	Scene        string
	SenderFilter shared.UserIdentityFilter
	StartAtMS    int64
	EndAtMS      int64
}

func normalizeListQuery(query listQuery) listQuery {
	if query.Page < 1 {
		query.Page = 1
	}
	if query.PageSize < 1 {
		query.PageSize = 30
	}
	if query.PageSize > 100 {
		query.PageSize = 100
	}
	query.SenderFilter.UserID = strings.TrimSpace(query.SenderFilter.UserID)
	query.SenderFilter.DisplayUserID = strings.TrimSpace(query.SenderFilter.DisplayUserID)
	query.SenderFilter.Username = strings.TrimSpace(query.SenderFilter.Username)
	return query
}

func listOffset(query listQuery) int {
	return (query.Page - 1) * query.PageSize
}
