package repository

import (
	"context"

	"backend/pkg/member/domain/entity"
	"backend/pkg/member/domain/member"

	"go.mongodb.org/mongo-driver/v2/mongo"
)

type UserRepository interface {
	BaseUserRepository
	UpdateUserDetailsByUID(ctx context.Context, data *UpdateUserInfoRequest) error
	UpdateStatus(ctx context.Context, uid string, status int32) error
	FindOneByUID(ctx context.Context, uid string) (*entity.User, error)
	FindOneByNickName(ctx context.Context, nickName string) (*entity.User, error)
	ListMembers(ctx context.Context, params *UserQueryParams) ([]*entity.User, int64, error)
	UpdateEmailVerifyStatus(ctx context.Context, uid, email string) error
	UpdatePhoneVerifyStatus(ctx context.Context, uid, phone string) error
	UserIndexUP
}

type UserIndexUP interface {
	Index20241226001UP(ctx context.Context) (*mongo.Cursor, error)
}

type BaseUserRepository interface {
	Insert(ctx context.Context, data *entity.User) error
	FindOne(ctx context.Context, id string) (*entity.User, error)
	Update(ctx context.Context, data *entity.User) (*mongo.UpdateResult, error)
	Delete(ctx context.Context, id string) (int64, error)
}

type UserQueryParams struct {
	AlarmCategory   *member.AlarmType
	UserStatus      *member.Status
	CreateStartTime *int64
	CreateEndTime   *int64
	PageSize        int64
	PageIndex       int64
}

type UpdateUserInfoRequest struct {
	UID               string            `json:"uid"`                          // 用戶 UID
	AvatarURL         *string           `json:"avatar_url,omitempty"`         // 頭像 URL（可選）
	FullName          *string           `json:"full_name,omitempty"`          // 用戶全名
	Nickname          *string           `json:"nickname,omitempty"`           // 暱稱（可選）
	GenderCode        *int8             `json:"gender_code,omitempty"`        // 性別代碼
	Birthdate         *int64            `json:"birthdate,omitempty"`          // 生日 (格式: 19930417)
	Address           *string           `json:"address,omitempty"`            // 地址
	AlarmCategory     *member.AlarmType `json:"alarm_category,omitempty"`     // 警報類型
	UserStatus        *member.Status    `json:"user_status,omitempty"`        // 用戶狀態
	PreferredLanguage *string           `json:"preferred_language,omitempty"` // 使用語言
	Currency          *string           `json:"currency,omitempty"`           // 使用幣種
}
