package module

import (
	"fmt"

	"gitlab.alibaba-inc.com/pai_biz_arch/pairec/context"
)

type UID string

type UserDao interface {
	// ListItemsByUid(uid UID, context *context.RecommendContext) []*Item
	// ListTagsByUid(uid UID, context *context.RecommendContext) []*Tag
	// WriteItemCacheByUid(uid UID, items []*Item)
	// GetItemCacheByUid(uid UID) []*Item
	GetUserById(id UID, context *context.RecommendContext) *User
	GetUserFeatures(user *User, context *context.RecommendContext)
}

func NewUserDao(name string) UserDao {
	dao, ok := userDaoAdapters[name]
	if !ok {
		panic(fmt.Sprintf("UserDao:name:%s not found", name))
	}
	return dao
}

var userDaoAdapters = make(map[string]UserDao)

func RegisterUserDao(name string, u UserDao) {
	if u == nil {
		panic("UserDao:UserDao is nil, name:" + name)
	}
	userDaoAdapters[name] = u
}
